Files
BMLFS/build-scripts/openssh.build
2023-12-30 01:02:43 -06:00

157 lines
6.0 KiB
Bash

#! /bin/bash
# OpenSSH
# Source: https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.5p1.tar.gz
#
# DEPS
# Required: NONE
# Recommended: NONE
# Optional: GDB(for tests), Linux-PAM, X Window System, MIT Kerberos V5,
# Optional: libedit, LibreSSL Portable, OpenSC, and libsectok
# LTO: LLVM works, untested with GCC+binutils
# If optimizing, use these flags
# Recommended to not use LTO
export CFLAGS="-march=native -mtune=native -pipe "
export CFLAGS+="-O3 -fno-lto -fstack-protector-strong -fzero-call-used-regs=used "
#export LDFLAGS="-Wl,-O2 -Wl,--as-needed "
sudo -S install -v -m700 -d /var/lib/sshd
sudo -S chown -v root:sys /var/lib/sshd
sudo -S groupadd -g 50 sshd
sudo -S useradd -c 'sshd PrivSep' \
-d /var/lib/sshd \
-g sshd \
-s /bin/false \
-u 50 sshd
autoreconf -fiv &&
# If OpenSSL was built:
export OPTARGS="--with-ssl-dir=/opt/openssl "
export OPTFLAGS="-I/opt/openssl/include -L/opt/openssl/lib "
export OPTLDF="-Wl,--rpath=/opt/openssl/lib "
LDFLAGS=$OPTLDF \
CFLAGS=$OPTFLAGS \
LIBS="-lutmps -lskarnet" \
ac_cv_header_sys_cdefs_h=false \
./configure --prefix=/usr \
--sysconfdir=/etc/ssh \
--with-privsep-path=/var/lib/sshd \
--with-pam --with-libedit \
--with-Werror \
--without-selinux \
--without-rpath \
--with-ssl-engine \
--enable-wtmpx \
--with-Werror=no $BT $OPTARGS --with-cflags --with-ldflags &&
read -p "Compile? " && make -j2 &&
read -p "Press Enter to install" &&
# if not using a package manager:
# make install
unset OPTARGS OPTFLAGS OPTLDF
# if using pkgtools from Slackware, then:
sudo -S make DESTDIR=$BUILD install &&
# If packing documentation and man pages in seperate package:
sudo mkdir -pv /BMAN/install
sudo mkdir -pv /BMAN/usr/share/man/man1
sudo install -v -m755 -d /BMAN/usr/share/doc/openssh-8.9p1
sudo install -v -m644 contrib/ssh-copy-id.1 \
/BMAN/usr/share/man/man1
sudo install -v -m644 INSTALL LICENCE OVERVIEW README* \
/BMAN/usr/share/doc/openssh-8.9p1
sudo -S mkdir -pv ${BUILD}/usr/bin &&
sudo -S install -v -m755 contrib/ssh-copy-id ${BUILD}/usr/bin &&
sudo -S sed -i ${BUILD}/etc/ssh/sshd_config \
-e 's|^#\(UsePAM\) no|\1 yes|g' \
-e 's|^#\(ChallengeResponseAuthentication\) yes|\1 no|g' \
-e 's|^#\(PrintMotd\) yes|\1 no|g' &&
read -p "Press Enter to create pakage description."
cd $BUILD && sudo mkdir -v install &&
cat > /tmp/slack-desc << "EOF"
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|' on
# the right side marks the last column you can put a character in. You must make
# exactly 11 lines for the formatting to be correct. It's also customary to
# leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
openssh: openssh (Secure Shell daemon and clients)
openssh:
openssh: ssh (Secure Shell) is a program for logging into a remote machine and
openssh: for executing commands on a remote machine. It is intended to replace
openssh: rlogin and rsh, and provide secure encrypted communications between
openssh: two untrusted hosts over an insecure network. sshd (SSH Daemon) is
openssh: the daemon program for ssh. OpenSSH is based on the last free version
openssh: of Tatu Ylonen's SSH, further enhanced and cleaned up by Aaron
openssh: Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt, and
openssh: Dug Song. It has a homepage at http://www.openssh.com/
openssh:
EOF
sudo mv /tmp/slack-desc install/ &&
cat > /tmp/doinst.sh << "EOF"
chown -v root:sys /var/lib/sshd &&
echo "Adding sshd user..."
groupadd -g 50 sshd &&
useradd -c 'sshd PrivSep' \
-d /var/lib/sshd \
-g sshd \
-s /bin/false \
-u 50 sshd
echo "Generating host keys.."
ssh-keygen -A
EOF
sudo -S cp -v /tmp/doinst.sh install/
# skip if not using PAM
sudo -S mkdir -v etc/pam.d
sudo -S sh -c "sed 's@d/login@d/sshd@g' /etc/pam.d/login > etc/pam.d/sshd" &&
sudo -S chmod 644 etc/pam.d/sshd &&
sudo -S sh -c 'echo "UsePAM yes" >> etc/ssh/sshd_config'
# If packing documentation and man pages in seperate package:
sudo cp -rv usr/share/man /BMAN/usr/share/
sudo rm -rf ust/share
read -p "Enter to build package" &&
sudo makepkg -l y -c n $PKGS/openssh-9.5p1-$PSUFFIX
cd /BMAN
cat > /tmp/slack-desc << "EOF"
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|' on
# the right side marks the last column you can put a character in. You must make
# exactly 11 lines for the formatting to be correct. It's also customary to
# leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
openssh-doc: Manuals for openssh (Secure Shell daemon and clients)
openssh-doc:
openssh-doc: ssh (Secure Shell) is a program for logging into a remote machine and
openssh-doc: for executing commands on a remote machine. It is intended to replace
openssh-doc: rlogin and rsh, and provide secure encrypted communications between
openssh-doc: two untrusted hosts over an insecure network. sshd (SSH Daemon) is
openssh-doc: the daemon program for ssh. OpenSSH is based on the last free version
openssh-doc: of Tatu Ylonen's SSH, further enhanced and cleaned up by Aaron
openssh-doc: Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt, and
openssh-doc: Dug Song. It has a homepage at http://www.openssh.com/
openssh-doc:
EOF
sudo mv /tmp/slack-desc install/
sudo makepkg -l y -c n $PKGS/openssh-doc-9.5p1-${PSUFFIX}
sudo rm -rf /BMAN/*
isudo rm -rf $BUILD/*