dropbear: Add back scp
[termux-packages] / packages / openssh / build.sh
CommitLineData
cff3a76b 1TERMUX_PKG_HOMEPAGE=https://www.openssh.com/
59f0d218 2TERMUX_PKG_DESCRIPTION="Secure shell for logging into a remote machine"
1ff10e5c 3TERMUX_PKG_VERSION=7.7p1
e18c260e 4TERMUX_PKG_REVISION=1
1ff10e5c 5TERMUX_PKG_SHA256=d73be7e684e99efcd024be15a30bffcbe41b012b2f7b3c9084aed621775e6b8f
bbfa4e7a 6TERMUX_PKG_SRCURL=https://fastly.cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${TERMUX_PKG_VERSION}.tar.gz
1ee955a1 7TERMUX_PKG_DEPENDS="libandroid-support, ldns, openssl, libedit, libutil"
e18c260e 8TERMUX_PKG_CONFLICTS="dropbear"
59f0d218 9# --disable-strip to prevent host "install" command to use "-s", which won't work for target binaries:
cff3a76b
FF
10TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
11--disable-etc-default-login
12--disable-lastlog
13--disable-libutil
14--disable-pututline
15--disable-pututxline
16--disable-strip
17--disable-utmp
18--disable-utmpx
19--disable-wtmp
20--disable-wtmpx
21--sysconfdir=$TERMUX_PREFIX/etc/ssh
22--with-cflags=-Dfd_mask=int
23--with-ldns
1ee955a1 24--with-libedit
da5a3586 25--with-mantype=man
cff3a76b
FF
26--without-ssh1
27--without-stackprotect
28--with-pid-dir=$TERMUX_PREFIX/var/run
29--with-privsep-path=$TERMUX_PREFIX/var/empty
7504becc 30--with-xauth=$TERMUX_PREFIX/bin/xauth
cff3a76b
FF
31ac_cv_func_endgrent=yes
32ac_cv_func_fmt_scaled=no
33ac_cv_func_getlastlogxbyname=no
34ac_cv_func_readpassphrase=no
35ac_cv_func_strnvis=no
36ac_cv_header_sys_un_h=yes
37ac_cv_search_getrrsetbyname=no
1ff10e5c 38ac_cv_func_bzero=yes
cff3a76b 39"
59f0d218
FF
40TERMUX_PKG_MAKE_INSTALL_TARGET="install-nokeys"
41TERMUX_PKG_RM_AFTER_INSTALL="bin/slogin share/man/man1/slogin.1"
42
7ce56385 43termux_step_pre_configure() {
cff3a76b
FF
44 autoreconf
45
7504becc
LP
46 ## Configure script require this variable to set
47 ## prefixed path to program 'passwd'
48 export PATH_PASSWD_PROG="${TERMUX_PREFIX}/bin/passwd"
49
c7ce60b7 50 CPPFLAGS+=" -DHAVE_ATTRIBUTE__SENTINEL__=1"
7ce56385
FF
51 LD=$CC # Needed to link the binaries
52 LDFLAGS+=" -llog" # liblog for android logging in syslog hack
53}
59f0d218 54
7b1f1bd3 55termux_step_post_configure() {
59f0d218
FF
56 # We need to remove this file before installing, since otherwise the
57 # install leaves it alone which means no updated timestamps.
58 rm -Rf $TERMUX_PREFIX/etc/moduli
59}
60
61termux_step_post_make_install () {
8773737e 62 # "PrintMotd no" is due to our login program already showing it.
62c37b97 63 # OpenSSH 7.0 disabled ssh-dss by default, keep it for a while in Termux:
8773737e
FF
64 echo -e "PrintMotd no\nPasswordAuthentication no\nPubkeyAcceptedKeyTypes +ssh-dss\nSubsystem sftp $TERMUX_PREFIX/libexec/sftp-server" > $TERMUX_PREFIX/etc/ssh/sshd_config
65 echo "PubkeyAcceptedKeyTypes +ssh-dss" > $TERMUX_PREFIX/etc/ssh/ssh_config
59f0d218
FF
66 cp $TERMUX_PKG_BUILDER_DIR/source-ssh-agent.sh $TERMUX_PREFIX/bin/source-ssh-agent
67 cp $TERMUX_PKG_BUILDER_DIR/ssh-with-agent.sh $TERMUX_PREFIX/bin/ssha
68
b0c457ae
FF
69 # Install ssh-copy-id:
70 cp $TERMUX_PKG_SRCDIR/contrib/ssh-copy-id.1 $TERMUX_PREFIX/share/man/man1/
71 cp $TERMUX_PKG_SRCDIR/contrib/ssh-copy-id $TERMUX_PREFIX/bin/
72 chmod +x $TERMUX_PREFIX/bin/ssh-copy-id
73
59f0d218
FF
74 mkdir -p $TERMUX_PREFIX/var/run
75 echo "OpenSSH needs this folder to put sshd.pid in" >> $TERMUX_PREFIX/var/run/README.openssh
76
77 mkdir -p $TERMUX_PREFIX/etc/ssh/
78 cp $TERMUX_PKG_SRCDIR/moduli $TERMUX_PREFIX/etc/ssh/moduli
79}
80
87566986
FF
81termux_step_post_massage () {
82 # Verify that we have man pages packaged (#1538).
83 local manpage
84 for manpage in ssh-keyscan.1 ssh-add.1 scp.1 ssh-agent.1 ssh.1; do
85 if [ ! -f share/man/man1/$manpage ]; then
86 termux_error_exit "Missing man page $manpage"
87 fi
88 done
89}
90
59f0d218 91termux_step_create_debscripts () {
aa605e89 92 echo "#!$TERMUX_PREFIX/bin/sh" > postinst
93 echo "mkdir -p \$HOME/.ssh" >> postinst
d8425dcd 94 echo "touch \$HOME/.ssh/authorized_keys" >> postinst
95 echo "chmod 700 \$HOME/.ssh" >> postinst
96 echo "chmod 600 \$HOME/.ssh/authorized_keys" >> postinst
59f0d218
FF
97 echo "" >> postinst
98 echo "for a in rsa dsa ecdsa ed25519; do" >> postinst
99 echo " KEYFILE=$TERMUX_PREFIX/etc/ssh/ssh_host_\${a}_key" >> postinst
100 echo " test ! -f \$KEYFILE && ssh-keygen -N '' -t \$a -f \$KEYFILE" >> postinst
101 echo "done" >> postinst
102 echo "exit 0" >> postinst
103 chmod 0755 postinst
104}