diff options
Diffstat (limited to 'contrib/solaris/buildpkg.sh')
-rwxr-xr-x | contrib/solaris/buildpkg.sh | 287 |
1 files changed, 251 insertions, 36 deletions
diff --git a/contrib/solaris/buildpkg.sh b/contrib/solaris/buildpkg.sh index 05abb2236..20f8544aa 100755 --- a/contrib/solaris/buildpkg.sh +++ b/contrib/solaris/buildpkg.sh | |||
@@ -1,52 +1,139 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # | 2 | # |
3 | # Fake Root Solaris Build System - Prototype | 3 | # Fake Root Solaris/SVR4/SVR5 Build System - Prototype |
4 | # | 4 | # |
5 | # The following code has been provide under Public Domain License. I really | 5 | # The following code has been provide under Public Domain License. I really |
6 | # don't care what you use it for. Just as long as you don't complain to me | 6 | # don't care what you use it for. Just as long as you don't complain to me |
7 | # nor my employer if you break it. - Ben Lindstrom (mouring@eviladmin.org) | 7 | # nor my employer if you break it. - Ben Lindstrom (mouring@eviladmin.org) |
8 | # | 8 | # |
9 | umask 022 | 9 | umask 022 |
10 | # | ||
11 | # Options for building the package | ||
12 | # You can create a config.local with your customized options | ||
13 | # | ||
14 | # uncommenting TEST_DIR and using configure--prefix=/var/tmp and | ||
15 | # PKGNAME=tOpenSSH should allow testing a package without interfering | ||
16 | # with a real OpenSSH package on a system. | ||
17 | #TEST_DIR=/var/tmp # leave commented out for production build | ||
10 | PKGNAME=OpenSSH | 18 | PKGNAME=OpenSSH |
19 | SYSVINIT_NAME=opensshd | ||
20 | MAKE=${MAKE:="make"} | ||
21 | # uncomment these next two as needed | ||
22 | #PERMIT_ROOT_LOGIN=no | ||
23 | #X11_FORWARDING=yes | ||
24 | # list of system directories we do NOT want to change owner/group/perms | ||
25 | # when installing our package | ||
26 | SYSTEM_DIR="/etc \ | ||
27 | /etc/init.d \ | ||
28 | /etc/rcS.d \ | ||
29 | /etc/rc0.d \ | ||
30 | /etc/rc1.d \ | ||
31 | /etc/rc2.d \ | ||
32 | /opt \ | ||
33 | /opt/bin \ | ||
34 | /usr \ | ||
35 | /usr/bin \ | ||
36 | /usr/lib \ | ||
37 | /usr/sbin \ | ||
38 | /usr/share \ | ||
39 | /usr/share/man \ | ||
40 | /usr/share/man/man1 \ | ||
41 | /usr/share/man/man8 \ | ||
42 | /usr/local \ | ||
43 | /usr/local/bin \ | ||
44 | /usr/local/etc \ | ||
45 | /usr/local/libexec \ | ||
46 | /usr/local/man \ | ||
47 | /usr/local/man/man1 \ | ||
48 | /usr/local/man/man8 \ | ||
49 | /usr/local/sbin \ | ||
50 | /usr/local/share \ | ||
51 | /var \ | ||
52 | /var/run \ | ||
53 | /var/tmp \ | ||
54 | /tmp" | ||
11 | 55 | ||
12 | ## Extract common info requires for the 'info' part of the package. | 56 | # We may need to buiild as root so we make sure PATH is set up |
13 | VERSION=`tail -1 ../../version.h | sed -e 's/.*_\([0-9]\)/\1/g' | sed 's/\"$//'` | 57 | # only set the path if it's not set already |
14 | ARCH=`uname -p` | 58 | [ -d /usr/local/bin ] && { |
59 | echo $PATH | grep ":/usr/local/bin" > /dev/null 2>&1 | ||
60 | [ $? -ne 0 ] && PATH=$PATH:/usr/local/bin | ||
61 | } | ||
62 | [ -d /usr/ccs/bin ] && { | ||
63 | echo $PATH | grep ":/usr/ccs/bin" > /dev/null 2>&1 | ||
64 | [ $? -ne 0 ] && PATH=$PATH:/usr/ccs/bin | ||
65 | } | ||
66 | export PATH | ||
67 | # | ||
68 | |||
69 | [ -f Makefile ] || { | ||
70 | echo "Please run this script from your build directory" | ||
71 | exit 1 | ||
72 | } | ||
73 | |||
74 | # we will look for config.local to override the above options | ||
75 | [ -s ./config.local ] && . ./config.local | ||
15 | 76 | ||
16 | ## Start by faking root install | 77 | ## Start by faking root install |
17 | echo "Faking root install..." | 78 | echo "Faking root install..." |
18 | START=`pwd` | 79 | START=`pwd` |
80 | OPENSSHD_IN=`dirname $0`/opensshd.in | ||
19 | FAKE_ROOT=$START/package | 81 | FAKE_ROOT=$START/package |
82 | [ -d $FAKE_ROOT ] && rm -fr $FAKE_ROOT | ||
20 | mkdir $FAKE_ROOT | 83 | mkdir $FAKE_ROOT |
21 | cd ../.. | 84 | ${MAKE} install-nokeys DESTDIR=$FAKE_ROOT |
22 | make install-nokeys DESTDIR=$FAKE_ROOT | 85 | if [ $? -gt 0 ] |
86 | then | ||
87 | echo "Fake root install failed, stopping." | ||
88 | exit 1 | ||
89 | fi | ||
23 | 90 | ||
24 | ## Fill in some details, like prefix and sysconfdir | 91 | ## Fill in some details, like prefix and sysconfdir |
25 | ETCDIR=`grep "^sysconfdir=" Makefile | sed 's/sysconfdir=//'` | 92 | for confvar in prefix exec_prefix bindir sbindir libexecdir datadir mandir sysconfdir piddir |
26 | PREFIX=`grep "^prefix=" Makefile | cut -d = -f 2` | 93 | do |
27 | PIDDIR=`grep "^piddir=" Makefile | cut -d = -f 2` | 94 | eval $confvar=`grep "^$confvar=" Makefile | cut -d = -f 2` |
28 | cd $FAKE_ROOT | 95 | done |
29 | 96 | ||
30 | ## Setup our run level stuff while we are at it. | 97 | ## Extract common info requires for the 'info' part of the package. |
31 | mkdir -p $FAKE_ROOT/etc/init.d | 98 | VERSION=`./ssh -V 2>&1 | sed -e 's/,.*//'` |
32 | mkdir -p $FAKE_ROOT/etc/rcS.d | ||
33 | mkdir -p $FAKE_ROOT/etc/rc0.d | ||
34 | mkdir -p $FAKE_ROOT/etc/rc1.d | ||
35 | mkdir -p $FAKE_ROOT/etc/rc2.d | ||
36 | 99 | ||
100 | UNAME_S=`uname -s` | ||
101 | case ${UNAME_S} in | ||
102 | SunOS) UNAME_S=Solaris | ||
103 | ARCH=`uname -p` | ||
104 | RCS_D=yes | ||
105 | DEF_MSG="(default: n)" | ||
106 | ;; | ||
107 | *) ARCH=`uname -m` ;; | ||
108 | esac | ||
109 | |||
110 | ## Setup our run level stuff while we are at it. | ||
111 | mkdir -p $FAKE_ROOT${TEST_DIR}/etc/init.d | ||
37 | 112 | ||
38 | ## setup our initscript correctly | 113 | ## setup our initscript correctly |
39 | sed -e "s#%%configDir%%#$ETCDIR#g" \ | 114 | sed -e "s#%%configDir%%#${sysconfdir}#g" \ |
40 | -e "s#%%openSSHDir%%#$PREFIX#g" \ | 115 | -e "s#%%openSSHDir%%#$prefix#g" \ |
41 | -e "s#%%pidDir%%#$PIDDIR#g" \ | 116 | -e "s#%%pidDir%%#${piddir}#g" \ |
42 | ../opensshd.in > $FAKE_ROOT/etc/init.d/opensshd | 117 | ${OPENSSHD_IN} > $FAKE_ROOT${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} |
43 | chmod 711 $FAKE_ROOT/etc/init.d/opensshd | 118 | chmod 744 $FAKE_ROOT${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} |
44 | 119 | ||
45 | ln -s ../init.d/opensshd $FAKE_ROOT/etc/rcS.d/K30opensshd | 120 | [ "${PERMIT_ROOT_LOGIN}" = no ] && \ |
46 | ln -s ../init.d/opensshd $FAKE_ROOT/etc/rc0.d/K30opensshd | 121 | perl -p -i -e "s/#PermitRootLogin yes/PermitRootLogin no/" \ |
47 | ln -s ../init.d/opensshd $FAKE_ROOT/etc/rc1.d/K30opensshd | 122 | $FAKE_ROOT/${sysconfdir}/sshd_config |
48 | ln -s ../init.d/opensshd $FAKE_ROOT/etc/rc2.d/S98opensshd | 123 | [ "${X11_FORWARDING}" = yes ] && \ |
124 | perl -p -i -e "s/#X11Forwarding no/X11Forwarding yes/" \ | ||
125 | $FAKE_ROOT/${sysconfdir}/sshd_config | ||
126 | # fix PrintMotd | ||
127 | perl -p -i -e "s/#PrintMotd yes/PrintMotd no/" \ | ||
128 | $FAKE_ROOT/${sysconfdir}/sshd_config | ||
49 | 129 | ||
130 | # We don't want to overwrite config files on multiple installs | ||
131 | mv $FAKE_ROOT/${sysconfdir}/ssh_config $FAKE_ROOT/${sysconfdir}/ssh_config.default | ||
132 | mv $FAKE_ROOT/${sysconfdir}/sshd_config $FAKE_ROOT/${sysconfdir}/sshd_config.default | ||
133 | [ -f $FAKE_ROOT/${sysconfdir}/ssh_prng_cmds ] && \ | ||
134 | mv $FAKE_ROOT/${sysconfdir}/ssh_prng_cmds $FAKE_ROOT/${sysconfdir}/ssh_prng_cmds.default | ||
135 | |||
136 | cd $FAKE_ROOT | ||
50 | 137 | ||
51 | ## Ok, this is outright wrong, but it will work. I'm tired of pkgmk | 138 | ## Ok, this is outright wrong, but it will work. I'm tired of pkgmk |
52 | ## whining. | 139 | ## whining. |
@@ -58,28 +145,156 @@ done | |||
58 | echo "Building pkginfo file..." | 145 | echo "Building pkginfo file..." |
59 | cat > pkginfo << _EOF | 146 | cat > pkginfo << _EOF |
60 | PKG=$PKGNAME | 147 | PKG=$PKGNAME |
61 | NAME=OpenSSH Portable for Solaris | 148 | NAME="OpenSSH Portable for ${UNAME_S}" |
62 | DESC="Secure Shell remote access utility; replaces telnet and rlogin/rsh." | 149 | DESC="Secure Shell remote access utility; replaces telnet and rlogin/rsh." |
63 | VENDOR="OpenSSH Portable Team - http://www.openssh.com/portable.html" | 150 | VENDOR="OpenSSH Portable Team - http://www.openssh.com/portable.html" |
64 | BASEDIR=$FAKE_ROOT | ||
65 | ARCH=$ARCH | 151 | ARCH=$ARCH |
66 | VERSION=$VERSION | 152 | VERSION=$VERSION |
67 | CATEGORY=Security | 153 | CATEGORY="Security,application" |
68 | BASEDIR=/ | 154 | BASEDIR=/ |
155 | CLASSES="none" | ||
156 | _EOF | ||
157 | |||
158 | ## Build preinstall file | ||
159 | echo "Building preinstall file..." | ||
160 | cat > preinstall << _EOF | ||
161 | #! /sbin/sh | ||
162 | # | ||
163 | [ "\${PRE_INS_STOP}" = "yes" ] && ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} stop | ||
164 | exit 0 | ||
165 | _EOF | ||
166 | |||
167 | ## Build postinstall file | ||
168 | echo "Building postinstall file..." | ||
169 | cat > postinstall << _EOF | ||
170 | #! /sbin/sh | ||
171 | # | ||
172 | [ -f ${sysconfdir}/ssh_config ] || \\ | ||
173 | cp -p ${sysconfdir}/ssh_config.default ${sysconfdir}/ssh_config | ||
174 | [ -f ${sysconfdir}/sshd_config ] || \\ | ||
175 | cp -p ${sysconfdir}/sshd_config.default ${sysconfdir}/sshd_config | ||
176 | [ -f ${sysconfdir}/ssh_prng_cmds.default ] && { | ||
177 | [ -f ${sysconfdir}/ssh_prng_cmds ] || \\ | ||
178 | cp -p ${sysconfdir}/ssh_prng_cmds.default ${sysconfdir}/ssh_prng_cmds | ||
179 | } | ||
180 | |||
181 | # make rc?.d dirs only if we are doing a test install | ||
182 | [ -n "${TEST_DIR}" ] && { | ||
183 | [ "$RCS_D" = yes ] && mkdir -p ${TEST_DIR}/etc/rcS.d | ||
184 | mkdir -p ${TEST_DIR}/etc/rc0.d | ||
185 | mkdir -p ${TEST_DIR}/etc/rc1.d | ||
186 | mkdir -p ${TEST_DIR}/etc/rc2.d | ||
187 | } | ||
188 | |||
189 | if [ "\${USE_SYM_LINKS}" = yes ] | ||
190 | then | ||
191 | [ "$RCS_D" = yes ] && \ | ||
192 | installf ${PKGNAME} $TEST_DIR/etc/rcS.d/K30${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s | ||
193 | installf ${PKGNAME} $TEST_DIR/etc/rc0.d/K30${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s | ||
194 | installf ${PKGNAME} $TEST_DIR/etc/rc1.d/K30${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s | ||
195 | installf ${PKGNAME} $TEST_DIR/etc/rc2.d/S98${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s | ||
196 | else | ||
197 | [ "$RCS_D" = yes ] && \ | ||
198 | installf ${PKGNAME} $TEST_DIR/etc/rcS.d/K30${SYSVINIT_NAME}=$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l | ||
199 | installf ${PKGNAME} $TEST_DIR/etc/rc0.d/K30${SYSVINIT_NAME}=$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l | ||
200 | installf ${PKGNAME} $TEST_DIR/etc/rc1.d/K30${SYSVINIT_NAME}=$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l | ||
201 | installf ${PKGNAME} $TEST_DIR/etc/rc2.d/S98${SYSVINIT_NAME}=$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l | ||
202 | fi | ||
203 | |||
204 | installf -f ${PKGNAME} | ||
205 | |||
206 | [ "\${POST_INS_START}" = "yes" ] && ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} start | ||
207 | exit 0 | ||
69 | _EOF | 208 | _EOF |
70 | 209 | ||
210 | ## Build preremove file | ||
211 | echo "Building preremove file..." | ||
212 | cat > preremove << _EOF | ||
213 | #! /sbin/sh | ||
214 | # | ||
215 | ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} stop | ||
216 | exit 0 | ||
217 | _EOF | ||
218 | |||
219 | ## Build request file | ||
220 | echo "Building request file..." | ||
221 | cat > request << _EOF | ||
222 | trap 'exit 3' 15 | ||
223 | USE_SYM_LINKS=no | ||
224 | PRE_INS_STOP=no | ||
225 | POST_INS_START=no | ||
226 | # Use symbolic links? | ||
227 | ans=\`ckyorn -d n \ | ||
228 | -p "Do you want symbolic links for the start/stop scripts? ${DEF_MSG}"\` || exit \$? | ||
229 | case \$ans in | ||
230 | [y,Y]*) USE_SYM_LINKS=yes ;; | ||
231 | esac | ||
232 | |||
233 | # determine if should restart the daemon | ||
234 | if [ -s ${piddir}/sshd.pid -a -f ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} ] | ||
235 | then | ||
236 | ans=\`ckyorn -d n \ | ||
237 | -p "Should the running sshd daemon be restarted? ${DEF_MSG}"\` || exit \$? | ||
238 | case \$ans in | ||
239 | [y,Y]*) PRE_INS_STOP=yes | ||
240 | POST_INS_START=yes | ||
241 | ;; | ||
242 | esac | ||
243 | |||
244 | else | ||
245 | |||
246 | # determine if we should start sshd | ||
247 | ans=\`ckyorn -d n \ | ||
248 | -p "Start the sshd daemon after installing this package? ${DEF_MSG}"\` || exit \$? | ||
249 | case \$ans in | ||
250 | [y,Y]*) POST_INS_START=yes ;; | ||
251 | esac | ||
252 | fi | ||
253 | |||
254 | # make parameters available to installation service, | ||
255 | # and so to any other packaging scripts | ||
256 | cat >\$1 <<! | ||
257 | USE_SYM_LINKS='\$USE_SYM_LINKS' | ||
258 | PRE_INS_STOP='\$PRE_INS_STOP' | ||
259 | POST_INS_START='\$POST_INS_START' | ||
260 | ! | ||
261 | exit 0 | ||
262 | |||
263 | _EOF | ||
264 | |||
265 | ## Build space file | ||
266 | echo "Building space file..." | ||
267 | cat > space << _EOF | ||
268 | # extra space required by start/stop links added by installf in postinstall | ||
269 | $TEST_DIR/etc/rc0.d/K30${SYSVINIT_NAME} 0 1 | ||
270 | $TEST_DIR/etc/rc1.d/K30${SYSVINIT_NAME} 0 1 | ||
271 | $TEST_DIR/etc/rc2.d/S98${SYSVINIT_NAME} 0 1 | ||
272 | _EOF | ||
273 | [ "$RCS_D" = yes ] && \ | ||
274 | echo "$TEST_DIR/etc/rcS.d/K30${SYSVINIT_NAME} 0 1" >> space | ||
275 | |||
71 | ## Next Build our prototype | 276 | ## Next Build our prototype |
72 | echo "Building prototype file..." | 277 | echo "Building prototype file..." |
73 | find . | egrep -v "prototype|pkginfo" | sort | pkgproto $PROTO_ARGS | \ | 278 | cat >mk-proto.awk << _EOF |
74 | awk ' | 279 | BEGIN { print "i pkginfo"; print "i preinstall"; \\ |
75 | BEGIN { print "i pkginfo" } | 280 | print "i postinstall"; print "i preremove"; \\ |
76 | { $5="root"; $6="sys"; } | 281 | print "i request"; print "i space"; \\ |
77 | { print; }' > prototype | 282 | split("$SYSTEM_DIR",sys_files); } |
283 | { | ||
284 | for (dir in sys_files) { if ( \$3 != sys_files[dir] ) | ||
285 | { \$5="root"; \$6="sys"; } | ||
286 | else | ||
287 | { \$4="?"; \$5="?"; \$6="?"; break;} | ||
288 | } } | ||
289 | { print; } | ||
290 | _EOF | ||
291 | find . | egrep -v "prototype|pkginfo|mk-proto.awk" | sort | \ | ||
292 | pkgproto $PROTO_ARGS | nawk -f mk-proto.awk > prototype | ||
78 | 293 | ||
79 | ## Step back a directory and now build the package. | 294 | ## Step back a directory and now build the package. |
80 | echo "Building package.." | 295 | echo "Building package.." |
81 | cd .. | 296 | cd .. |
82 | pkgmk -d . -f $FAKE_ROOT/prototype -o | 297 | pkgmk -d ${FAKE_ROOT} -f $FAKE_ROOT/prototype -o |
298 | echo | pkgtrans -os ${FAKE_ROOT} ${START}/$PKGNAME-$UNAME_S-$ARCH-$VERSION.pkg | ||
83 | rm -rf $FAKE_ROOT | 299 | rm -rf $FAKE_ROOT |
84 | echo | pkgtrans -os . $PKGNAME-$ARCH-$VERSION.pkg | 300 | |
85 | rm -rf $PKGNAME | ||