NAME="openssh"
DESC="Contains ssh clients and the sshd daemon"
VERSION="9.7p1"
FILES=(
  "https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-$VERSION.tar.gz"
  "ssha.service"
  "sshd.service"
  "sshdkeys.service"
)
HASHES=(
  "490426f766d82a2763fcacd8d83ea3d70798750c7bd2aff2e57dc5660f773ffd"
  "b37b1fd6dcfca467f701ec9eedde904b0ae34b1802b9b51e6dda70ad55291e6e"
  "b229f4257fdda31a803608ba39427c159dedaa839fd53e53b26e2b997a4cf2ec" 
  "e5305767b2d317183ad1c5022a5f6705bd9014a8b22495a000fd482713738611"
)
DEPENDS=()

PACKAGE() {
  tar xf $NAME-$VERSION.tar.gz
  cd $NAME-$VERSION

  ./configure --prefix=/usr                          \
            --sysconfdir=/etc/ssh                    \
            --with-privsep-path=/var/lib/sshd        \
            --with-default-path=/usr/bin             \
            --with-superuser-path=/usr/sbin:/usr/bin \
            --with-pid-dir=/run                      

  make && make DESTDIR=$ROOTDIR install 
 
  install -v -m755    contrib/ssh-copy-id $ROOTDIR/usr/bin    
  install -v -m644    contrib/ssh-copy-id.1 \
                    $ROOTDIR/usr/share/man/man1              
  install -v -m755 -d $ROOTDIR/usr/share/doc/openssh-$VERSION     
  install -v -m644    INSTALL LICENCE OVERVIEW README* \
                    $ROOTDIR/usr/share/doc/openssh-$VERSION 

  mkdir -p $ROOTDIR/usr/lib/systemd/system
  install -Dm644 $ROOTDIR/ssha.service -t $ROOTDIR/usr/lib/systemd/user/
  install -Dm644 $ROOTDIR/sshd.service -t $ROOTDIR/usr/lib/systemd/system/
  install -Dm644 $ROOTDIR/sshdkeys.service -t $ROOTDIR/usr/lib/systemd/system/

  cd .. && rm -rf $NAME-$VERSION
}

INSTALL(){
  install -v -g sys -m700 -d /var/lib/sshd
  groupadd -g 50 sshd
  useradd  -c 'sshd PrivSep'          -d /var/lib/sshd           -g sshd                    -s /bin/false              -u 50 sshd
}
