wok-current view busybox/receipt @ rev 19348
busybox: accept local variables out of function
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Jul 23 10:12:39 2016 +0200 (2016-07-23) |
parents | 62af77d35692 |
children | 2be6ee0ddc5a |
line source
1 # SliTaz package receipt.
3 PACKAGE="busybox"
4 VERSION="1.25.0"
5 CATEGORY="base-system"
6 SHORT_DESC="Busybox combines tiny versions of many common UNIX utilities."
7 MAINTAINER="pascal.bellard@slitaz.org"
8 LICENSE="GPL2"
9 TARBALL="$PACKAGE-$VERSION.tar.bz2"
10 WEB_SITE="http://www.busybox.net/"
11 WGET_URL="http://www.busybox.net/downloads/$TARBALL"
12 HOST_ARCH="i486 arm"
14 DEPENDS="slitaz-base-files glibc-base ncurses-common"
15 BUILD_DEPENDS="bzip2 pam pam-dev gettext-tools uclibc-cross-compiler-i486 \
16 musl-libc-dev dietlibc"
18 CONFIG_FILES="/etc/dnsd.conf /etc/inetd.conf /etc/udhcpd.conf \
19 /etc/resolv.conf /etc/httpd.conf"
20 AUFS_NOT_RAMFS="uclibc-cross-compiler-i486 is not compatible with aufs+tmpfs 8("
22 # Handle cross compilation
23 case "$ARCH" in
24 arm*) BUILD_DEPENDS="bzip2" ;;
25 esac
27 # Busybox patches
28 apply_bb_patchs()
29 {
30 while read file; do
31 [ -f done.$file ] && continue
32 echo "Apply $file..."
33 patch -p1 < $stuff/$PACKAGE-${VERSION%.*}-$file || return 1
34 touch done.$file
35 done <<EOT
36 tar.u
37 stat.u
38 ris.u
39 zmodules.u
40 printable.u
41 cmdline.u
42 diff.u
43 diet.u
44 losetup.u
45 fbvnc.u
46 cpio.u
47 ftpd.u
48 scriptreplay.u
49 shutdown.u
50 EOT
51 cp $stuff/$PACKAGE-${VERSION%.*}.config .config
53 # Tmp hack: we may need to fix some slitaz scripts...
54 sed -i 's/_and_raise_error\(."not in a function\)/\1/' shell/ash.c
55 }
57 # Rules to configure and make the package.
58 compile_rules()
59 {
60 case "$ARCH" in
61 arm*)
62 echo "cook: CROSS_COMPILE=$CROSS_COMPILE"
63 apply_bb_patchs &&
64 cp $stuff/arm/$PACKAGE.config .config
65 make oldconfig &&
66 make && make install || return 1
67 chmod 4755 $src/_install/bin/busybox ;;
68 x86_64) echo "TODO" ;;
69 i?86)
70 apply_bb_patchs &&
71 make oldconfig &&
72 make && make install || return 1
73 strip --strip-unneeded -R .eh_frame -R .eh_frame_hdr \
74 $src/_install/bin/busybox
75 mv docs/busybox.1 docs/busybox.base.1
77 # prepare busybox-pam package
78 sed -i 's/# CONFIG_PAM is not set/CONFIG_PAM=y/' .config
79 make oldconfig && make || return 1
80 strip --strip-unneeded -R .eh_frame -R .eh_frame_hdr busybox
81 mv busybox busybox-pam
82 mv docs/busybox.1 docs/busybox.pam.1
84 # prepare busybox-static package
85 if [ -x /usr/bin/uclibc-i486-gcc ]; then
86 cp $stuff/$PACKAGE-${VERSION%.*}.config-static .config
87 make oldconfig && make || return 1
88 cp busybox busybox-static
89 mv busybox busybox-uclibc
90 mv -f docs/busybox.1 docs/busybox.static.1
91 fi
93 if [ -x /usr/bin/musl-gcc ]; then
94 # prepare busybox-musl package
95 cp $stuff/$PACKAGE-${VERSION%.*}.config-static .config
96 sed -i 's|uclibc-i486-||' .config
97 make oldconfig && make CC=musl-gcc || return 1
98 mv busybox busybox-musl
99 mv -f docs/busybox.1 docs/busybox.static.1
100 fi
102 if [ -x /usr/lib/diet/bin/diet ]; then
103 # prepare busybox-diet package
104 cp $stuff/$PACKAGE-${VERSION%.*}.config-static .config
105 sed -i 's|uclibc-i486-||;s|CFLAGS="|&-D_BSD_SOURCE |;s|LDFLAGS="|&-Wl,--allow-multiple-definition |;s|LDLIBS="|&compat rpc |' .config
106 make oldconfig && make CC="/usr/lib/diet/bin/diet gcc" || return 1
107 mv busybox busybox-diet
108 mv -f docs/busybox.1 docs/busybox.static.1
109 fi
111 # prepare ssfs-busybox package
112 rootfs=$src/ssfs-busybox/usr/share/ssfs/rootfs
113 mkdir -p $rootfs/etc
114 cp $stuff/$PACKAGE-${VERSION%.*}.config-ssfs .config
115 make oldconfig && make busybox &&
116 make CONFIG_PREFIX=$rootfs install || return 1
117 cp $stuff/busybox.conf-ssfs $rootfs/etc/busybox.conf
118 chown -R 0.0 $rootfs/etc
119 chmod 0600 $rootfs/etc/busybox.conf
120 chmod 4755 $rootfs/bin/busybox
122 # Compile translations
123 make -C $stuff/po install
124 cp docs/busybox.base.1 docs/busybox.1
126 ;;
128 esac
129 }
131 # Cross compilation check.
132 testsuite()
133 {
134 readelf -h $src/_install/bin/busybox
135 }
137 # Rules to gen a SliTaz package suitable for Tazpkg.
138 genpkg_rules()
139 {
140 mkdir -p $install/usr/share/man/man1 $install/usr/share/doc/busybox
141 cp -a $src/_install/* $fs
142 cp -a $src/docs/busybox.1 $install/usr/share/man/man1/busybox.1
143 cp -a $src/docs/*.txt $install/usr/share/doc/busybox
144 cp -a $src/docs/*.htm* $install/usr/share/doc/busybox
145 cp -a $src/docs/cgi $install/usr/share/doc/busybox
146 [ -e $fs/sbin/ip ] && ln -s busybox $fs/bin/ip
147 rm -f $fs/bin/bbconfig $fs/usr/bin/ar
148 mkdir -p $fs/etc/init.d $fs/var/spool/cron/crontabs $fs/var/spool/lpd \
149 $fs/var/lib/misc
151 # Busybox config files.
152 for f in busybox.conf dnsd.conf udhcpd.conf inetd.conf httpd.conf \
153 syslog.conf zcip.script
154 do
155 cp $stuff/$f $fs/etc
156 done
157 chown -R 0.0 $fs/etc
158 chmod 600 $fs/etc/busybox.conf
159 touch $fs/etc/resolv.conf
161 # Daemon scripts.
162 cp $stuff/daemon $fs/etc/init.d
163 DAEMON="crond dnsd ftpd httpd inetd lpd klogd ntpd syslogd telnetd tftpd udhcpd zcip"
164 for i in $DAEMON; do
165 grep -qi config_$i=y $stuff/$PACKAGE-${VERSION%.*}.config &&
166 ln -s daemon $fs/etc/init.d/$i
167 done
168 rm $fs/linuxrc 2> /dev/null
169 mkdir -p $fs/etc/modprobe.d
171 # Udhcpc stuff.
172 mkdir -p $fs/usr/share/udhcpc
173 cp $stuff/udhcp.script $fs/usr/share/udhcpc/default.script
174 chmod +x $fs/usr/share/udhcpc/default.script
176 # Httpd stuff.
177 ln -s /usr/lib/slitaz/httphelper.sh $fs/usr/bin/httpd_helper.sh
178 cp -a $stuff/www $fs/var
180 # Update copyright year
181 grep -rl 'copy; 2' $fs/var/www | xargs \
182 sed -i "s/copy; [0-9]*/copy; $(date +%Y)/"
184 # Remove kmod & core-util-mount links
185 while read link; do
186 rm -f $fs$link
187 done <<EOT
188 /bin/mount
189 /bin/mountpoint
190 /bin/umount
191 /sbin/depmod
192 /sbin/insmod
193 /sbin/modinfo
194 /sbin/modprobe
195 /sbin/rmmod
196 EOT
197 }
199 # GNU utils stuff.
200 pre_install()
201 {
202 local i
203 [ -s $1/etc/resolv.conf ] &&
204 cp -a $1/etc/resolv.conf $1/etc/resolv.conf-busybox-install
205 answer=""
206 for i in $(cat "$1$INSTALLED/$PACKAGE/files.list"); do
207 [ -f "$1$i" ] || continue
208 case "$i" in
209 /bin/busybox) continue ;;
210 *bin/*) ;;
211 *) continue ;;
212 esac
213 if [ -z "$answer" ]; then
214 echo -n "Keep installed GNU utilities ? "
215 read -t 30 answer # by default: keep
216 case "$answer" in
217 n*|N*) break;;
218 *) answer="Y";;
219 esac
220 fi
221 cp -a "$1$i" "$1$i-busybox-install"
222 done
223 }
225 post_install()
226 {
227 local i
228 [ -f $1/etc/resolv.conf-busybox-install ] &&
229 mv -f $1/etc/resolv.conf-busybox-install $1/etc/resolv.conf
230 while read i ; do
231 [ -f "$1$i-busybox-install" ] || continue
232 mv "$1$i-busybox-install" "$1$i"
233 done < "$1$INSTALLED/$PACKAGE/files.list"
234 chmod 4755 "$1/bin/busybox"
236 touch $1/etc/daemons.conf
237 # /etc/daemons.conf (tftp + dnsd + httpd may not be present)
238 if ! grep -q ^DNSD_OPTIONS $1/etc/daemons.conf; then
239 echo '# Domain name server options.' >> $1/etc/daemons.conf
240 echo 'DNSD_OPTIONS="-d"' >> $1/etc/daemons.conf
241 echo '' >> $1/etc/daemons.conf
242 fi
243 if ! grep -q ^TFTPD_OPTIONS $1/etc/daemons.conf; then
244 echo '# Tftp daemon options.' >> $1/etc/daemons.conf
245 echo 'TFTPD_OPTIONS="-r /boot"' >> $1/etc/daemons.conf
246 echo '' >> $1/etc/daemons.conf
247 fi
248 sed -i "s/copy; 20../copy; $(date +%Y)/" $1/var/www/httpd/404.html
249 }
251 pre_remove()
252 {
253 # We can not remove this package !
254 exit 1
255 }