wok-tiny view busybox/receipt @ rev 173

Fix ctorrent-dnh & tfttest
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jul 14 09:04:04 2021 +0000 (2021-07-14)
parents c21687abfa6a
children 00ad93bee405
line source
1 # SliTaz package receipt.
3 PACKAGE="busybox"
4 VERSION="1.28-20170822"
5 GIT_TAG="753c4045e4f287fc4b4788afd94f58738a7f04b4"
6 CATEGORY="base-system"
7 SHORT_DESC="Busybox combines tiny versions of many common UNIX utilities."
8 MAINTAINER="pascal.bellard@slitaz.org"
9 LICENSE="GPL2"
10 [ -n "$TARGET" ] || TARGET="i486"
11 DEPENDS=""
12 BUILD_DEPENDS="bzip2 uclibc-cross-compiler-$TARGET wget"
13 TARBALL="$PACKAGE-$VERSION.tar.bz2"
14 WEB_SITE="http://www.busybox.net/"
15 WGET_URL="https://git.busybox.net/busybox/snapshot/busybox-$GIT_TAG.tar.bz2"
16 CONFIG_FILES="/etc/rcS.conf /etc/hostname /etc/fstab /etc/init.d/local.sh"
17 AUTO_SELECTION="always"
19 apply_bb_patchs()
20 {
21 cd $src
22 while read file; do
23 [ -f done.$file ] && continue
24 echo "Apply $file..."
25 patch -p1 < $stuff/$PACKAGE-git-$file || return 1
26 touch done.$file
27 done <<EOT
28 stat.u
29 ris.u
30 zmodules.u
31 cmdline.u
32 fbvnc.u
33 cpio.u
34 scriptreplay.u
35 ash.u
36 EOT
37 [ $(. $WOK/linux/receipt; printf "%d%02d%02d" ${VERSION//./ }) -le 20626 ] &&
38 echo apply 0001-mdev-create-devices-from-sys-dev.patch &&
39 patch -p1 -R < $stuff/0001-mdev-create-devices-from-sys-dev.patch
40 cp $stuff/$PACKAGE-git.config .config
41 var="CONFIG_CROSS_COMPILER_PREFIX"
42 sed -i "s/.*$var.*/$var=\"uclibc-$TARGET-\"/" .config
43 }
45 # Rules to configure and make the package.
46 compile_rules()
47 {
48 { apply_bb_patchs &&
49 make oldconfig &&
50 make &&
51 make install
52 } || return 1
53 echo "Chmod 4755 on busybox binary..."
54 chmod 4755 _install/bin/busybox
55 mkdir -p _install/lib
56 LD_LIBRARY_PATH=/usr/share/uclibc-cross-compiler-$TARGET/lib \
57 uclibc-$TARGET-ldd busybox 2> /dev/null | \
58 awk '/=>/ { print $3 }' | while read file ; do
59 cp -a $file _install/lib
60 while [ -L "$file" ]; do
61 dir="$(dirname $file)/"
62 file="$(readlink $file)"
63 case "$file" in
64 /*) ;;
65 *) file="$dir$file";;
66 esac
67 cp -a "$file" _install/lib
68 done
69 done
70 chown 0.0 _install/lib/*
71 }
73 # Rules to gen a SliTaz package suitable for Tazpkg.
74 genpkg_rules()
75 {
76 mkdir $fs/boot $fs/bin $fs/sbin
77 cp -a $WOK/base-tiny/stuff/. $fs/
78 cp -a $src/_install/lib $fs/
79 cp -a $src/_install/bin/busybox $fs/bin
80 for i in /bin/sh /bin/login /bin/false /sbin/mdev /init ; do
81 ln $fs/bin/busybox $fs$i
82 done
83 mkdir -p $fs/etc/init.d
84 # Busybox config files.
85 cp $stuff/busybox.conf $fs/etc
86 chmod 600 $fs/etc/busybox.conf
87 touch $fs/etc/resolv.conf
88 cp $stuff/daemon $fs/etc/init.d
89 for i in crond klogd syslogd ; do
90 grep -qi config_$i=y $src/.config &&
91 ln -s daemon $fs/etc/init.d/$i
92 done
93 sed -i 's|network.sh ||' $fs/etc/rcS.conf
94 sed -i 's|.*Executing all initialization scripts.*|echo -n "Setting hostname..."\
95 hostname -F /etc/hostname\
96 status\n&|' $fs/etc/init.d/rcS
97 rm -f $fs/etc/init.d/network.sh $fs/etc/network.conf \
98 $fs/etc/services $fs/etc/networks $fs/etc/inetd.conf \
99 $fs/etc/host.conf $fs/etc/hosts
101 sed -i '2,$s/^#.*//;/^$/d' $fs/etc/init.d/rc* $fs/etc/init.d/daemon \
102 $fs/etc/init.d/*.sh
103 sed -i 's/^#.*//;/^$/d' $fs/etc/*.conf $fs/etc/*tab \
104 $fs/etc/profile $fs/etc/securetty $fs/etc/shells
105 find $fs -exec touch -r $fs {} \;
106 cp $stuff/busybox-git.config $fs/boot/config-busybox
107 }
109 config_form()
110 {
111 if [ -z "$BBHOST" ]; then
112 [ -n "$PASSWORD" ] || PASSWORD=root
113 [ -n "$BBHOST" ] || BBHOST=slitaz
114 [ -n "$FSTAB" ] || FSTAB='/dev/hda1 /mnt ext3 defaults 0 2'
115 [ -n "$RC_LOCAL" ] || RC_LOCAL='[ -x /mnt/boot/init ] && /mnt/boot/init'
116 fi
117 cat <<EOT
118 <table>
119 <tr>
120 <td>Root password (empty=disable)</td>
121 <td><input type="text" name="PASSWORD" value="$PASSWORD" /></td>
122 </tr>
123 <tr>
124 <td>Host name</td>
125 <td><input type="text" name="BBHOST" value="$BBHOST" /></td>
126 </tr>
127 <tr>
128 <td>Filesystems</td>
129 <td><textarea name="FSTAB" cols="60" wrap="off">
130 $FSTAB
131 </textarea></td>
132 </tr>
133 <tr>
134 <td>Additional boot commands</td>
135 <td><textarea name="RC_LOCAL" cols="60" wrap="off">
136 $RC_LOCAL
137 </textarea></td>
138 </tr>
139 </table>
140 <input type="checkbox" name="KEEP_MODULES" ${KEEP_MODULES:+checked="checked" }/>
141 Do not remove the modules files after loading modules.
142 <p>
143 <input type="checkbox" name="STUPID" ${STUPID:+ckecked="ckecked" }/>
144 Read floppy sector by sector instead of track by track (slow, stupid but safe).
145 EOT
146 }
148 post_install()
149 {
150 chmod 4755 $1/bin/busybox
151 ln -fs /proc/mounts $1/etc/mtab
152 cat >> $1/boot/mkrootfs.pre_exec <<EOT
153 if [ -s modules ]; then
154 while read mod; do
155 sed -i "s/LOAD_MODULES=./&\$mod /" etc/rcS.conf
156 done < modules
157 grep ^LOAD_MODULES= etc/rcS.conf >> etc/packages.conf
158 cp etc/packages.conf boot/packages.conf
159 rm -f modules
160 fi
161 EOT
162 [ "$STUPID" ] && cat >> $1/boot/mkrootfs.pre_exec <<EOT
163 for i in boot/bzImage boot/memtest boot/ipxe boot/plop boot/x86test; do
164 [ -s \$i ] || continue
165 dd if=\$i bs=512 count=1 | \\
166 sed "s|\$(echo -en '\x64\x66\x8F\x47\x78')|\$(echo -en '\x5E\x5E\x90\x90\x90')|" | \\
167 sed "s|\$(echo -en '\x66\x8F\x47\x78')|\$(echo -en '\x5E\x5E\x90\x90')|" | \\
168 sed "s|\$(echo -en '\x77\x02\xB0\x01')|\$(echo -en '\x90\x90\xB0\x01')|" | \\
169 sed "s|\$(echo -en '\x98\xCD\x13')|\$(echo -en '\x98\x90\x90')|" | \\
170 sed "s|\$(echo -en '\x60\xCD\x13')|\$(echo -en '\x60\x90\x90')|" | \\
171 sed "s|\$(echo -en '\xB0\x31\x1C\x03\xB4\x0E')|\$(echo -en '\xB0\x31\x14\xFD\xB4\x0E')|" | \\
172 dd of=\$i conv=notrunc
173 done
174 EOT
175 sed -i "s/^KEEP_MODULES=\"\"/KEEP_MODULES=\"$KEEP_MODULES\"/" \
176 $1/etc/rcS.conf
177 if [ -n "$PASSWORD" ]; then
178 case "$PASSWORD" in
179 \$1\$*)
180 sed -i "s|^root:[^:]*|root:$PASSWORD|" $1/etc/shadow ;;
181 *)
182 mkdir $1/fs
183 cp -a $1/bin $1/lib $1/etc $1/fs
184 echo "root:$PASSWORD" | chroot $1/fs/ busybox chpasswd -m
185 cp $1/fs/etc/passwd $1/etc/
186 rm -rf $1/fs
187 esac
188 else
189 sed -i 's/^root:[^:]*:/root::/' $1/etc/passwd
190 mkdir $1/root 2> /dev/null
191 cat > $1/root/.profile <<EOT
192 grep -qs ^root:: /etc/passwd /etc/shadow && passwd
193 EOT
194 fi
195 [ -n "$BBHOST" ] && echo $BBHOST > $1/etc/hostname
196 [ -n "$FSTAB" ] && dos2unix >> $1/etc/fstab <<EOT
197 $FSTAB
198 EOT
199 [ -n "$RC_LOCAL" ] && dos2unix >> $1/etc/init.d/local.sh <<EOT
200 $RC_LOCAL
201 EOT
202 }