#!/bin/bash # Copyright (C) 2010-2011 Matias A. Fonzo, # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . set -e CWD=$(pwd) TMP=${TMP:-/tmp/sources} OUT=${OUT:-/tmp/packages} V=5.8p2 ARCH=${ARCH:-x86_64} B=1 # Flags for the compiler: DCFLAGS=${DCFLAGS:=-O2 -mtune=generic} PKG=${TMP}/package-openssh rm -rf $PKG mkdir -p $PKG $OUT cd $TMP rm -rf openssh-${V} echo "Uncompressing the tarball..." tar -xvf ${CWD}/openssh-${V}.tar.lz -C $TMP cd openssh-${V} # Set sane ownerships and permissions: chown -R 0:0 . find . \ \( -perm 2777 -o \ -perm 777 -o \ -perm 775 -o \ -perm 711 -o \ -perm 555 -o \ -perm 511 \ \) -exec chmod 755 {} + \ -o \ \( -perm 666 -o \ -perm 664 -o \ -perm 600 -o \ -perm 444 -o \ -perm 440 -o \ -perm 400 \ \) -exec chmod 644 {} + CFLAGS="$DCFLAGS" \ ./configure \ --prefix=/usr \ --mandir=/usr/man \ --sysconfdir=/etc/ssh \ --datadir=/usr/share/sshd \ --libexecdir=/usr/lib64/openssh \ --with-tcp-wrappers \ --with-md5-passwords \ --with-default-path='/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin' \ --with-privsep-path=/var/empty \ --with-privsep-user=sshd \ --disable-strip \ --build=${ARCH}-dragora-linux-gnu make make install DESTDIR=$PKG # Set permissions: install --directory --mode=0755 ${PKG}/var/empty find ${PKG}/usr/sbin -type f -exec chmod -v 750 '{}' \; # To handle config: mv ${PKG}/etc/ssh/ssh_config{,.new} mv ${PKG}/etc/ssh/sshd_config{,.new} # Add scripts from the contrib/ directory: install --mode=0755 contrib/ssh-copy-id ${PKG}/usr/bin cat contrib/ssh-copy-id.1 > ${PKG}/usr/man/man1/ssh-copy-id.1 # Strip binaries & libraries: ( cd $PKG find . -type f | xargs file | awk '/ELF/ && /executable/ || /shared object/' | \ cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null ) # Reconstructs these links: ( cd ${PKG}/usr ( cd bin rm -f slogin ln -s ssh slogin ) ( cd man/man1 rm -f slogin.1 ln -s ssh.1 slogin.1 ) ) # Install the OpenSSH daemon script: install --mode=0755 ${CWD}/config/sshd -D ${PKG}/etc/sv/sshd/run.new install -d ${PKG}/etc/runit/runsvdir/default ( cd ${PKG}/etc/runit/runsvdir/default ln -sf /etc/sv/sshd . ) # Compress and link manpages: ( cd ${PKG}/usr/man find . -type f -exec gzip -9N '{}' + find . -type l | while read file ; do ln -sf $(readlink $file).gz ${file}.gz rm $file done ) # Add the documentation: mkdir -p ${PKG}/usr/doc/openssh-${V} cp -a \ CREDITS ChangeLog LICENCE OVERVIEW PROTOCOL* README* TODO WARNING.RNG \ ${PKG}/usr/doc/openssh-${V} find ${PKG}/usr/doc/openssh-${V} -type f -exec chmod 644 '{}' \; # Copy the description files including the post install script: mkdir -p ${PKG}/{description,install} cp ${CWD}/description/?? ${PKG}/description zcat ${CWD}/post-install.gz > ${PKG}/install/post-install cd $PKG makepkg -l ${OUT}/openssh-${V}-${ARCH}-${B}.tlz