wok-tiny view busybox/receipt @ rev 158

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