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