tazpkg diff modules/bb @ rev 931

Add module/bb: manage Busybox applets.
Remove function definitions that are now in the /lib/libtaz.sh (die, im).
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sun Jan 08 11:24:12 2017 +0200 (2017-01-08)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/bb	Sun Jan 08 11:24:12 2017 +0200
     1.3 @@ -0,0 +1,45 @@
     1.4 +#!/bin/sh
     1.5 +# TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
     1.6 +# bb - TazPkg module
     1.7 +# Manage Busybox applets
     1.8 +
     1.9 +
    1.10 +# Input: $1 - command:
    1.11 +#    restore   restore missing Busybox applets
    1.12 +#    replaced  list of the replaced Busybox applets
    1.13 +#
    1.14 +# Variable $root points to the root of the installation
    1.15 +
    1.16 +
    1.17 +# Connect function libraries
    1.18 +. /lib/libtaz.sh
    1.19 +
    1.20 +
    1.21 +
    1.22 +
    1.23 +[ ! -x "$root/bin/busybox" ] && die 'Busybox is not installed in the %s. Exit.' "$root"
    1.24 +
    1.25 +# Full list but skipping some applets: bbconfig, linuxrc
    1.26 +applets_list=$($root/bin/busybox --list-full | grep -v 'bbconfig\|linuxrc')
    1.27 +
    1.28 +case $1 in
    1.29 +	restore)
    1.30 +		mkdir -p "$root/sbin" "$root/usr/bin" "$root/usr/sbin"
    1.31 +		for applet in $applets_list; do
    1.32 +			if [ ! -x "$root/$applet" ]; then
    1.33 +				action 'Restoring Busybox applet %s...' "$(basename $applet)"
    1.34 +				case $(dirname $applet) in
    1.35 +					bin)      ln -sf           'busybox' "$root/$applet";;
    1.36 +					sbin)     ln -sf    '../bin/busybox' "$root/$applet";;
    1.37 +					usr/*bin) ln -sf '../../bin/busybox' "$root/$applet";;
    1.38 +				esac
    1.39 +				status
    1.40 +			fi
    1.41 +		done
    1.42 +		;;
    1.43 +	replaced)
    1.44 +		ls -l $(echo "$applets_list" | sed "s|^|$root/|") 2>/dev/null | \
    1.45 +		awk -vr="$root" '{if ($0 !~ /busybox$/){sub(r, ""); print $9}}'
    1.46 +		;;
    1.47 +esac
    1.48 +