aboutsummaryrefslogtreecommitdiff
path: root/patches/openssh/openssh.SlackBuild
blob: fd4c7075a97fe35ef7a153cd7c566e8283b80b37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/bin/bash
# Copyright 2000 BSDi, Inc. Concord, CA, USA
# Copyright 2001, 2002, 2003, 2004  Slackware Linux, Inc. Concord, CA, USA
# Copyright 2006  Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Small changes by rhatto.
#

CWD="`pwd`"

if [ -f ~/.slackbuildrc ]; then
  source ~/.slackbuildrc
elif [ -f /etc/slackbuildrc ]; then
  source /etc/slackbuildrc
fi

PACKAGE="openssh"
VERSION=${VERSION:=4.4p1}
ARCH=${ARCH:=i486}
BUILD=${BUILD:=1rha}
SRC_DIR=${SRC:=$CWD}
TMP=${TMP:=/tmp}
REPOS=${REPOS:=$TMP}

if [ "$ARCH" == "x86_64" ]; then
  LIBDIR=/usr/lib64
else
  LIBDIR=/usr/lib
fi

RTOOL="wget"
PACKAGE_EXT="gz"
SRC="$PACKAGE-$VERSION.tar.$PACKAGE_EXT"
URL="ftp://ftp.openbsd.org.br/pub/OpenBSD/OpenSSH/portable/$SRC"

if [ "$PACKAGE_EXT" == "bz2" ]; then
  tarflag="j"
else
  tarflag="z"
fi

SRC_DIR="$SRC_DIR/$PACKAGE"
mkdir -p $SRC_DIR

if [ "$RTOOL" == "wget" ] && [ ! -f "$SRC_DIR/$SRC" ]; then
  rm -f $SRC_DIR/$SRC.asc
  wget "$URL" -O "$SRC_DIR/$SRC"
  wget "$URL.asc" -O "$SRC_DIR/$SRC.asc"
fi

gpg --import << EOGPG
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

mQGiBDqa5pwRBADJSEyXXsgXiyytN93prDPTPmrueRP9lQQfgaQvCvqK0bN0AF1Z
Vxxk9wlSXQp3+Qw5+qqsN5ovzsn39r9pqGslfCqQn9ACTmsn42+VCyW4hdwUGSBS
5myh65ZJ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CdFS6tPgPrfYV+iwq
2NB/BatePGg7Z6UALaULQ0m83DCEVLJNnjemEdIouShelikAAO7QDKMr7vAjH8n0
zwMpwRMXnvCM6zYlS9i1kOm8LVATk0WyihpQGSaTukdPjKlG7sKwMu20ssK9DGVp
PgulTZ7rHqXl4juY8LQ2j4dPNaPoKWG8JuBVCsyf2D6GNW97PfKQSkzFeZsbVB4S
RQrVTchgBSYoxRVW3fLk/yc3TC5Abh6Gpj4izawUiEYEGBECAAYFAjqa5tQACgkQ
zo7LA4b/nEgftgCdHIZUDVAWDRa5siSi8Aos+IiyAgAAn02wGOl1Wo/YJ+RY+c6K
N58TmAPE
=rCFY
-----END PGP PUBLIC KEY BLOCK-----
EOGPG

gpg --verify $SRC.asc $SRC || echo WARNING: Could not check signature or WRONG signature found.

if [ "$ARCH" = "i386" ]; then
  SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
elif [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
elif [ "$ARCH" = "s390" ]; then
  SLKCFLAGS="-O2"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
fi

# Clean target location:
TMP="$TMP/$PACKAGE"
PKG=$TMP/package-$PACKAGE
rm -rf $TMP
mkdir -p $PKG

# Prepare the framework and extract the package:
cd $TMP
rm -rf $PKG openssh-$VERSION
tar xvf$tarflag $SRC_DIR/$SRC
cd openssh-$VERSION
chown -R root.root .

# Compile package:
CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --sysconfdir=/etc/ssh \
  --libdir=$LIBDIR \
  --without-pam \
  --with-md5-passwords \
  --with-tcp-wrappers \
  --with-default-path=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin \
  --with-ipv4-default \
  --with-privsep-path=/var/empty \
  --with-privsep-user=sshd \
  $ARCH-slackware-linux

make || exit 32

# Install the package:
make install DESTDIR=$PKG

( cd $PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)

# Compress the installed manpages:
find $PKG/usr/man -type f -exec gzip -9 {} \;

# Relink the slogin(1) man page
( cd $PKG/usr/man/man1
  rm -f slogin.1
  ln -sf ssh.1.gz slogin.1.gz
)

# Install directory used with PrivilegeSeparation option:
mkdir -p $PKG/var/empty
chmod 755 $PKG/var/empty

# Install docs:
mkdir -p $PKG/usr/doc/openssh-$VERSION
cp -a \
  CREDITS ChangeLog INSTALL LICENCE OVERVIEW README README.privsep README.smartcard RFC.nroff TODO WARNING.RNG \
  $PKG/usr/doc/openssh-$VERSION
chmod 644 $PKG/usr/doc/openssh-$VERSION/*

# Install also 'ssh-copy-id' and its manpage from contrib:
( cd contrib
  cp -a ssh-copy-id $PKG/usr/bin/ssh-copy-id
  chown root.bin $PKG/usr/bin/ssh-copy-id
  chmod 755 $PKG/usr/bin/ssh-copy-id
  cat ssh-copy-id.1 | gzip -9c > $PKG/usr/man/man1/ssh-copy-id.1.gz
)

# Fix some ownerships per FSSTND:
chown -R root.bin $PKG/usr/bin $PKG/usr/sbin

( cd $PKG

  # Ditch the new host keys, since these have to be uniquely prepared on each machine:
  rm -f etc/ssh/ssh_host_dsa_key
  rm -f etc/ssh/ssh_host_dsa_key.pub
  rm -f etc/ssh/ssh_host_rsa_key
  rm -f etc/ssh/ssh_host_rsa_key.pub
  rm -f etc/ssh/ssh_host_key
  rm -f etc/ssh/ssh_host_key.pub

  # Set up the config script installation:
  mv etc/ssh/ssh_config etc/ssh/ssh_config.new
  mv etc/ssh/sshd_config etc/ssh/sshd_config.new

  # Add the init script:
  mkdir -p etc/rc.d
  cat $CWD/rc.sshd > etc/rc.d/rc.sshd
  chmod 755 etc/rc.d/rc.sshd

  # Copy runtime installation files:
  mkdir -p install
  zcat $CWD/doinst.sh.gz > install/doinst.sh
  cat $CWD/slack-desc > install/slack-desc
)

# Create the package itself:
cd $PKG
makepkg -l y -c n $REPOS/openssh-$VERSION-$ARCH-$BUILD.tgz

if [ "$CLEANUP" == "yes" ]; then
  rm -rf $TMP
fi