tazlito rev 416

Separate module "calc_sizes", tweak Makefile
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Feb 24 22:02:58 2016 +0200 (2016-02-24)
parents 6ac6d30d100b
children 9d0d7bf20e90
files Makefile modules/calc_sizes tazlito
line diff
     1.1 --- a/Makefile	Wed Feb 24 02:54:36 2016 +0200
     1.2 +++ b/Makefile	Wed Feb 24 22:02:58 2016 +0200
     1.3 @@ -4,7 +4,9 @@
     1.4  SBINDIR?=/sbin
     1.5  PREFIX?=/usr
     1.6  DOCDIR?=/usr/share/doc
     1.7 +MANDIR?=/usr/share/man
     1.8  LINGUAS?=el es fr pl pt_BR ru zh_CN zh_TW
     1.9 +MODULES:=$(shell ls modules)
    1.10  
    1.11  all:
    1.12  
    1.13 @@ -34,23 +36,37 @@
    1.14  	install -m 0755 -d $(DESTDIR)$(PREFIX)/bin
    1.15  	install -m 0777 tazlito $(DESTDIR)$(PREFIX)/bin
    1.16  	-[ "$(VERSION)" ] && sed -i 's/^VERSION=[0-9].*/VERSION=$(VERSION)/' $(DESTDIR)$(PREFIX)/bin/tazlito
    1.17 -	ln -s tazlito $(DESTDIR)$(PREFIX)/bin/deduplicate
    1.18 -	ln -s tazlito $(DESTDIR)$(PREFIX)/bin/reduplicate
    1.19 +	ln -sf tazlito $(DESTDIR)$(PREFIX)/bin/deduplicate
    1.20 +	ln -sf tazlito $(DESTDIR)$(PREFIX)/bin/reduplicate
    1.21  	install -m 0777 tazlito-wiz $(DESTDIR)$(PREFIX)/bin
    1.22 +
    1.23 +	install -m 0755 -d $(DESTDIR)$(PREFIX)/libexec/tazlito
    1.24 +	@for module in $(MODULES); do \
    1.25 +		install -m 0777 modules/$$module $(DESTDIR)$(PREFIX)/libexec/tazlito; \
    1.26 +	done;
    1.27 +
    1.28  	install -m 0755 -d $(DESTDIR)/etc/tazlito
    1.29  	install -m 0644 tazlito.conf $(DESTDIR)/etc/tazlito
    1.30 +
    1.31  	install -m 0755 -d $(DESTDIR)/usr/share/doc
    1.32  	install -m 0755 -d $(DESTDIR)/var/www/tazpanel/menu.d/boot
    1.33  	install -m 0755 -d $(DESTDIR)/var/www/tazpanel/styles/default/images
    1.34  	cp -a applications $(DESTDIR)/usr/share
    1.35  	cp -a doc $(DESTDIR)/usr/share/doc/tazlito
    1.36 +
    1.37  	cp -a live.cgi $(DESTDIR)/var/www/tazpanel
    1.38 -	ln -s ../../live.cgi $(DESTDIR)/var/www/tazpanel/menu.d/boot/live
    1.39 +	ln -sf ../../live.cgi $(DESTDIR)/var/www/tazpanel/menu.d/boot/live
    1.40  	cp -a tazlito.png $(DESTDIR)/var/www/tazpanel/styles/default/images
    1.41 -	# i18n
    1.42 +
    1.43  	mkdir -p $(DESTDIR)$(PREFIX)/share/locale
    1.44  	cp -a po/mo/* $(DESTDIR)$(PREFIX)/share/locale
    1.45  
    1.46 +	install -m 0755 -d $(DESTDIR)$(MANDIR)/man1
    1.47 +	install -m 0755 -d $(DESTDIR)$(MANDIR)/man5
    1.48 +	install -m 0644 man/tazlito.1 $(DESTDIR)$(MANDIR)/man1
    1.49 +	install -m 0644 man/tazlito.conf.5 $(DESTDIR)$(MANDIR)/man5
    1.50 +	install -m 0644 man/flavor.5 $(DESTDIR)$(MANDIR)/man5
    1.51 +
    1.52  # Uninstallation commands.
    1.53  
    1.54  uninstall:
    1.55 @@ -58,12 +74,13 @@
    1.56  	rm -f $(PREFIX)/bin/deduplicate
    1.57  	rm -f $(PREFIX)/bin/reduplicate
    1.58  	rm -f $(PREFIX)/bin/tazlito-wiz
    1.59 -	rm -f $(PREFIX)/var/www/tazpanel/menu.d/boot/live
    1.60 -	rm -f $(PREFIX)/var/www/tazpanel/styles/default/images/tazlito.png
    1.61 -	rm -f $(PREFIX)/var/www/tazpanel/live.cgi
    1.62 -	rm -rf $(PREFIX)/etc/tazlito
    1.63 -	rm -rf $(PREFIX)/usr/share/doc/tazlito
    1.64 -	rm -rf $(PREFIX)/usr/share/applications/tazlito*.desktop
    1.65 +	rm -f /var/www/tazpanel/menu.d/boot/live
    1.66 +	rm -f /var/www/tazpanel/styles/default/images/tazlito.png
    1.67 +	rm -f /var/www/tazpanel/live.cgi
    1.68 +	rm -rf $(PREFIX)/libexec/tazlito
    1.69 +	rm -rf /etc/tazlito
    1.70 +	rm -rf $(PREFIX)/share/doc/tazlito
    1.71 +	rm -rf $(PREFIX)/share/applications/tazlito*.desktop
    1.72  	rm -rf $(PREFIX)/share/locale/*/LC_MESSAGES/tazlito.mo
    1.73  
    1.74  clean:
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/modules/calc_sizes	Wed Feb 24 22:02:58 2016 +0200
     2.3 @@ -0,0 +1,166 @@
     2.4 +#!/usr/bin/awk -f
     2.5 +# calc_sizes - module of TazLito - SliTaz Live Tool.
     2.6 +
     2.7 +# Calculate sizes (estimated) and real packages number (including all dependencies)
     2.8 +# using given extracted flavor and current mirrors.
     2.9 +#
    2.10 +# Input: <unpacked flavor dir> <flavor name> [<output full list file>]
    2.11 +# Output in human readable form:
    2.12 +# <unpacked size> <packed size> <size of ISO> <number of packages>
    2.13 +# File $1/err output: unknown packages
    2.14 +# File $1/warn output: warnings about missing packages
    2.15 +# TODO: use 'equivalent packages' rules
    2.16 +
    2.17 +BEGIN {
    2.18 +	FS = "\t";
    2.19 +	K = 1024; M = K * 1024; G = M * 1024;
    2.20 +	dir = ARGV[1]; flavor = ARGV[2]; outfile = ARGV[3];
    2.21 +
    2.22 +	# Get listing of dir
    2.23 +	"ls " dir " | tr '\n' ' '" | getline lsdir;
    2.24 +
    2.25 +	# Calculate rootfs_p, rootfs_u, and rootcd_u
    2.26 +	if (index(lsdir, flavor ".rootfs")) {
    2.27 +		"wc -c < " dir "/" flavor ".rootfs"       | getline rootfs_p;
    2.28 +		"zcat "    dir "/" flavor ".rootfs|wc -c" | getline rootfs_u;
    2.29 +	}
    2.30 +	if (index(lsdir, flavor ".rootcd"))
    2.31 +		"zcat "    dir "/" flavor ".rootcd | wc -c" | getline rootcd_u;
    2.32 +
    2.33 +	errfile  = dir "/err";
    2.34 +	warnfile = dir "/warn";
    2.35 +	system("rm " errfile " " warnfile " " outfile " 2>/dev/null");
    2.36 +
    2.37 +	root = ENVIRON["root"];
    2.38 +
    2.39 +	# Get list of 'packages.info' lists using priority
    2.40 +	pkgdb = root "/var/lib/tazpkg";
    2.41 +	"ls " pkgdb " | tr '\n' ' '" | getline lsdir;
    2.42 +	if (! index(lsdir, "packages.info"))
    2.43 +		"tazpkg recharge --root=" root " >/dev/null 2>&1";
    2.44 +	if (index(lsdir, "priority"))
    2.45 +		"cat " pkgdb "/priority | tr '\n' ' '" | getline loop;
    2.46 +	loop = loop "main";
    2.47 +	if (index(lsdir, "undigest"))
    2.48 +		"ls " pkgdb "/undigest | tr '\n' ' '" | getline undigest;
    2.49 +	loop = loop " " undigest;
    2.50 +	split(loop, repos, / +/);
    2.51 +	ARGC = 1;
    2.52 +	for (i in repos) {
    2.53 +		if (repos[i] && ! arr[repos[i]]) {
    2.54 +			arr[repos[i]] = 1;
    2.55 +			if (repos[i] == "main")
    2.56 +				pi = pkgdb "/packages.info";
    2.57 +			else
    2.58 +				pi = pkgdb "/undigest/" repos[i] "/packages.info";
    2.59 +			if (!system("test -e "pi)) {
    2.60 +				ARGV[ARGC] = pi;
    2.61 +				ARGC ++;
    2.62 +			}
    2.63 +		}
    2.64 +	}
    2.65 +	ARGV[ARGC] = dir "/" flavor ".pkglist"; ARGC ++;
    2.66 +}
    2.67 +
    2.68 +# Convert human-readable format to bytes
    2.69 +function h2b(h) {
    2.70 +	if (h ~ "K")	return h * K;
    2.71 +	if (h ~ "M")	return h * M;
    2.72 +	if (h ~ "G")	return h * G;
    2.73 +					return h;
    2.74 +}
    2.75 +
    2.76 +# Convert bytes to human-readable format
    2.77 +function b2h(b,   p) {
    2.78 +	     if (b >= G)	{ b /= G; p = "G"; }
    2.79 +	else if (b >= M)	{ b /= M; p = "M"; }
    2.80 +	else				{ b /= K; p = "K"; }
    2.81 +	if (b >= 100)	return sprintf(  "%d%s", b, p);
    2.82 +	else			return sprintf("%.1f%s", b, p);
    2.83 +}
    2.84 +
    2.85 +# Mark package with its dependencies (to be processed later)
    2.86 +function mark_deps(pkg,   localdepend, localdepends) {
    2.87 +	if (sizes[pkg]) {
    2.88 +		if (! pkgs[pkg]) {
    2.89 +			pkgs[pkg] = sizes[pkg];
    2.90 +
    2.91 +			if (depends[pkg]) {
    2.92 +				split(depends[pkg], localdepends, " ");
    2.93 +				# Recursive call
    2.94 +				for (localdepend in localdepends)
    2.95 +					mark_deps(localdepends[localdepend]);
    2.96 +			}
    2.97 +		}
    2.98 +	} else {
    2.99 +		printf "  %s\n", $1 >> errfile;
   2.100 +	}
   2.101 +}
   2.102 +
   2.103 +# Calculate unpacked and packed sizes of /boot
   2.104 +function calc(pkg, size_u, size_p) {
   2.105 +	if (pkgs[pkg]) {
   2.106 +		boot_u += h2b(size_u);
   2.107 +		boot_p += h2b(size_p);
   2.108 +	}
   2.109 +}
   2.110 +
   2.111 +# main loop
   2.112 +{
   2.113 +	if (FILENAME ~ ".info") {
   2.114 +		# Step #1: fill arrays "sizes" and "depends"
   2.115 +		if (! sizes[$1]) {
   2.116 +			  sizes[$1] = $7;
   2.117 +			depends[$1] = $8;
   2.118 +		}
   2.119 +	} else {
   2.120 +		# Step #2: mark packages and its dependencies
   2.121 +		mark_deps($1);
   2.122 +	}
   2.123 +}
   2.124 +
   2.125 +END {
   2.126 +	# Calculate sums for all marked packages and its deps
   2.127 +	for (pkg in pkgs) {
   2.128 +		num_pkgs ++;
   2.129 +		split(pkgs[pkg], s, " ");
   2.130 +		size_packed   += h2b(s[1]);
   2.131 +		size_unpacked += h2b(s[2]);
   2.132 +		if (outfile) print pkg >> outfile;
   2.133 +	}
   2.134 +	# Add files placed in flavor.rootfs
   2.135 +	size_packed   += rootfs_p;
   2.136 +	size_unpacked += rootfs_u;
   2.137 +
   2.138 +	# Check critical packages: "syslinux" and one of the packages containing "vmlinuz*"
   2.139 +	if (! pkgs["syslinux"]) printf "  * Syslinux\n" >> warnfile;
   2.140 +	if (! pkgs["linux"]       && ! pkgs["linux-without-modules"] && \
   2.141 +		! pkgs["linux64"]     && ! pkgs["linux64-without-modules"] && \
   2.142 +		! pkgs["linux-libre"] && ! pkgs["linux-libre-without-modules"] && \
   2.143 +		! pkgs["linux-uml"]) printf "  * Linux kernel\n" >> warnfile;
   2.144 +
   2.145 +	# Calculate unpacked and packed sizes of /boot
   2.146 +	calc("syslinux",					"156K",  "120K" );
   2.147 +	calc("gpxe",						"196K",  "188K" );
   2.148 +	calc("ipxe",						"316K",  "312K" );
   2.149 +	calc("memtest",						"52K",   "48K"  );
   2.150 +	calc("memtest-serial",				"52K",   "48K"  );
   2.151 +	calc("slitaz-configs-base",			"36K",   "28K"  );
   2.152 +	calc("linux",						"2.8M",  "2.8M" );
   2.153 +	calc("linux-without-modules",		"12.6M", "12.8M");
   2.154 +	calc("linux64",						"3.0M",  "3.0M" );
   2.155 +	calc("linux64-without-modules",		"13.2M", "13.4M");
   2.156 +	calc("linux-libre",					"2.3M",  "2.3M" );
   2.157 +	calc("linux-libre-without-modules",	"6.9M",  "6.9M" );
   2.158 +	calc("linux-uml",					"3.0M",  "1.1M" );
   2.159 +
   2.160 +	# /boot is moved away from rootfs
   2.161 +	size_packed   -= boot_p;
   2.162 +	size_unpacked -= boot_u;
   2.163 +
   2.164 +	# Add rootcd payload and /boot content sizes
   2.165 +	size_iso = size_packed + rootcd_u + boot_u;
   2.166 +
   2.167 +	printf "%s %s ",  b2h(size_unpacked), b2h(size_packed);
   2.168 +	printf "%s %d\n", b2h(size_iso), num_pkgs;
   2.169 +}
     3.1 --- a/tazlito	Wed Feb 24 02:54:36 2016 +0200
     3.2 +++ b/tazlito	Wed Feb 24 22:02:58 2016 +0200
     3.3 @@ -59,6 +59,13 @@
     3.4  }
     3.5  
     3.6  
     3.7 +# Run Tazlito module
     3.8 +module() {
     3.9 +	local mod="$1"; shift
    3.10 +	/usr/libexec/tazlito/$mod $@
    3.11 +}
    3.12 +
    3.13 +
    3.14  
    3.15  # Try to include config file, continue if command is gen-config or exit.
    3.16  # The main config used by default is in /etc/tazlito.
    3.17 @@ -271,7 +278,7 @@
    3.18  	cd - >/dev/null
    3.19  	title 'Generating ISO image'
    3.20  
    3.21 -	echo "Generating $1"
    3.22 +	_ 'Generating %s' "$1"
    3.23  	make_bzImage_hardlink $2/boot
    3.24  	genisoimage -R   -o $1   -b boot/isolinux/isolinux.bin \
    3.25  		-c boot/isolinux/boot.cat   -no-emul-boot   -boot-load-size 4 \
    3.26 @@ -443,7 +450,7 @@
    3.27  				fi
    3.28  				old_attr="$attr" ; old_inode="$inode" ; old_file="$file"
    3.29  			done
    3.30 -			echo "$save Kbytes saved in $hardlinks duplicate files."
    3.31 +			_ '%s Kbytes saved in %s duplicate files.' "$save" "$hardlinks"
    3.32  		)
    3.33  
    3.34  	find "$@" -type l -xdev -exec stat -c '%s-%u-%g-TARGET- %i %h %n' {} \; | sort | \
    3.35 @@ -466,7 +473,7 @@
    3.36  					old_inode="$inode"
    3.37  				fi
    3.38  			done
    3.39 -			echo "$hardlinks duplicate symlinks."
    3.40 +			_ '%s duplicate symlinks.' "$hardlinks"
    3.41  		)
    3.42  }
    3.43  
    3.44 @@ -506,7 +513,7 @@
    3.45  		sec=$time
    3.46  		div=$(( ($time + 30) / 60))
    3.47  		[ "$div" -ne 0 ] && min="~ ${div}m"
    3.48 -		echo "Build time      : ${sec}s $min"
    3.49 +		_ 'Build time      : %ss %s' "$sec" "$min"
    3.50  	fi
    3.51  	cat <<EOT
    3.52  Build date      : $(date +%Y%m%d)
    3.53 @@ -688,7 +695,7 @@
    3.54  
    3.55  update_bootconfig() {
    3.56  	local files
    3.57 -	echo -n "Updating boot config files..."
    3.58 +	action 'Updating boot config files...'
    3.59  	files="$(grep -l 'include common' $1/*.cfg)"
    3.60  	for file in $files; do
    3.61  		awk -v n=$(echo $2 | awk '{ print NF/2 }') '{
    3.62 @@ -820,14 +827,12 @@
    3.63  
    3.64  install_package() {
    3.65  	if [ -z "$2" ]; then
    3.66 -		_n 'Install package %s? ' "$1"
    3.67 +		answer=$(yesorno "$(_ 'Install package %s?' "$1")" 'n')
    3.68  	else
    3.69 -		_n 'Install package %s for Kernel %s? ' "$1" "$2"
    3.70 +		answer=$(yesorno "$(_n 'Install package %s for Kernel %s? ' "$1" "$2")" 'n')
    3.71  	fi
    3.72 -	echo -n '[y = yes] '
    3.73 -	read answer
    3.74  	case "$answer" in
    3.75 -		y*|Y*|o*|O*)
    3.76 +		y)
    3.77  			# We don't want package on host cache.
    3.78  			action 'Getting and installing package: %s' "$1"
    3.79  			yes y | tazpkg get-install $1 --quiet 2>&1 >> $log || exit 1
    3.80 @@ -904,13 +909,13 @@
    3.81  			cp /usr/share/boot/httpfs-static $TMP_DIR/initfs/bin/httpfs
    3.82  		else
    3.83  			[ ! -f /usr/bin/httpfs ] && ! install_package httpfs-fuse && return 1
    3.84 -			cp /usr/bin/httpfs $TMP_DIR/initfs/bin
    3.85 -			cp -a /lib/librt* $TMP_DIR/initfs/lib
    3.86 -			cp -a /lib/libdl* $TMP_DIR/initfs/lib
    3.87 -			cp -a /lib/libpthread* $TMP_DIR/initfs/lib
    3.88 +			cp /usr/bin/httpfs      $TMP_DIR/initfs/bin
    3.89 +			cp -a /lib/librt*       $TMP_DIR/initfs/lib
    3.90 +			cp -a /lib/libdl*       $TMP_DIR/initfs/lib
    3.91 +			cp -a /lib/libpthread*  $TMP_DIR/initfs/lib
    3.92  			cp -a /usr/lib/libfuse* $TMP_DIR/initfs/lib
    3.93 -			cp -a /lib/libresolv* $TMP_DIR/initfs/lib
    3.94 -			cp -a /lib/libnss_dns* $TMP_DIR/initfs/lib
    3.95 +			cp -a /lib/libresolv*   $TMP_DIR/initfs/lib
    3.96 +			cp -a /lib/libnss_dns*  $TMP_DIR/initfs/lib
    3.97  			need_lib=true
    3.98  		fi
    3.99  		cd $TMP_DIR/initfs
   3.100 @@ -920,7 +925,7 @@
   3.101  		done
   3.102  		cd - > /dev/null
   3.103  		longline "Default URLs for /iso/$(cat $TMP_DIR/initfs/etc/slitaz-release)/flavors/slitaz-loram-cdrom.iso /iso/$(cat $TMP_DIR/initfs/etc/slitaz-release)/flavors/slitaz-$(cat $TMP_DIR/initfs/etc/slitaz-release)-loram-cdrom.iso: $urliso"
   3.104 -		echo -n "List of URLs to insert: "
   3.105 +		_n 'List of URLs to insert: '
   3.106  		read -t 30 urliso2
   3.107  		urliso="$urliso2 $urliso"
   3.108  	fi
   3.109 @@ -1304,7 +1309,7 @@
   3.110  		ln -s "$fresh" '/var/www/tazlito/fresh'
   3.111  		# Setup first undigest mirror
   3.112  		mkdir -p "$undigest/fresh"
   3.113 -		echo "http://localhost/tazlito/fresh/" > "$undigest/fresh/mirror"
   3.114 +		echo 'http://localhost/tazlito/fresh/' > "$undigest/fresh/mirror"
   3.115  		echo 'fresh' >> "$priority"
   3.116  		# Rebuild mirror DB if needed
   3.117  		[ ! -e "$fresh/IDs" ] && tazpkg mkdb "$fresh" --forced --root=''
   3.118 @@ -1328,7 +1333,7 @@
   3.119  		ln -s "$repacked" '/var/www/tazlito/repacked'
   3.120  		# Setup second undigest mirror
   3.121  		mkdir -p "$undigest/repacked"
   3.122 -		echo "http://localhost/tazlito/repacked/" > "$undigest/repacked/mirror"
   3.123 +		echo 'http://localhost/tazlito/repacked/' > "$undigest/repacked/mirror"
   3.124  		echo 'repacked' >> "$priority"
   3.125  		# Rebuild mirror DB if needed
   3.126  		[ ! -e "$repacked/IDs" ] && tazpkg mkdb "$repacked" --forced --root=''
   3.127 @@ -1410,7 +1415,7 @@
   3.128  			# Collect package names
   3.129  			FS = "\t"; pkg[$1] = 1;
   3.130  		} else {
   3.131 -			FS = "-"; OFS = "-"; $0 = $0;		# Fix bug with FS for first record
   3.132 +			FS = OFS = "-"; $0 = $0;		# Fix bug with FS for first record
   3.133  			while (NF > 1 && ! pkg[$0])
   3.134  				NF --;
   3.135  			printf "%s\n", $0;
   3.136 @@ -1423,132 +1428,6 @@
   3.137  }
   3.138  
   3.139  
   3.140 -# Calculate sizes (estimated) and real packages number (including all dependencies)
   3.141 -# using given extracted flavor and current mirrors.
   3.142 -#
   3.143 -# Input: <unpacked flavor dir> <flavor name> [<output full list file>]
   3.144 -# Output in human readable form:
   3.145 -# <unpacked size> <packed size> <size of ISO> <number of packages>
   3.146 -# File $1/err output: unknown packages
   3.147 -# File $1/warn output: warnings about missing packages
   3.148 -# TODO: use 'equivalent packages' rules
   3.149 -
   3.150 -calc_sizes() {
   3.151 -	local dir="$1" flavor="$2" outfile="$3"
   3.152 -	local rootfs_packed=0 rootfs_unpacked=0 rootcd_unpacked=0
   3.153 -
   3.154 -	if [ -s "$dir/$flavor.rootfs" ]; then
   3.155 -		rootfs_packed="$(wc -c < "$dir/$flavor.rootfs")";
   3.156 -		rootfs_unpacked="$(zcat  "$dir/$flavor.rootfs" | wc -c)";
   3.157 -	fi
   3.158 -	if [ -s "$dir/$flavor.rootcd" ]; then
   3.159 -		rootcd_unpacked="$(zcat  "$dir/$flavor.rootcd" | wc -c)";
   3.160 -	fi
   3.161 -
   3.162 -	awk -F$'\t' \
   3.163 -	-vrootfs_p="$rootfs_packed" -vrootfs_u="$rootfs_unpacked" -vrootcd_u="$rootcd_unpacked" \
   3.164 -	-voutfile="$outfile" -verrfile="$dir/err" -vwarnfile="$dir/warn" '
   3.165 -	BEGIN {
   3.166 -		K = 1024; M = K * 1024; G = M * 1024;
   3.167 -	}
   3.168 -	function h2b(h) {
   3.169 -		# Convert human-readable format to bytes
   3.170 -		if (h ~ "K")	return h * K;
   3.171 -		if (h ~ "M")	return h * M;
   3.172 -		if (h ~ "G")	return h * G;
   3.173 -						return h;
   3.174 -	}
   3.175 -	function b2h(b,   p) {
   3.176 -		# Convert bytes to human-readable format
   3.177 -		     if (b >= G)	{ b /= G; p = "G"; }
   3.178 -		else if (b >= M)	{ b /= M; p = "M"; }
   3.179 -		else				{ b /= K; p = "K"; }
   3.180 -		if (b >= 100)	printf   "%d%s\n", b, p;
   3.181 -		else			printf "%.1f%s\n", b, p;
   3.182 -	}
   3.183 -	function mark_deps(pkg,   localdepend, localdepends) {
   3.184 -		# Mark package with its dependencies (to be processed later)
   3.185 -		if (sizes[pkg]) {
   3.186 -			if (! pkgs[pkg]) {
   3.187 -				pkgs[pkg] = sizes[pkg];
   3.188 -
   3.189 -				if (depends[pkg]) {
   3.190 -					split(depends[pkg], localdepends, " ");
   3.191 -					# Recursive call
   3.192 -					for (localdepend in localdepends)
   3.193 -						mark_deps(localdepends[localdepend]);
   3.194 -				}
   3.195 -			}
   3.196 -		} else {
   3.197 -			printf "  %s\n", $1 >> errfile;
   3.198 -		}
   3.199 -	}
   3.200 -	function calc(pkg, size_u, size_p) {
   3.201 -		# Calculate unpacked and packed sizes of /boot
   3.202 -		if (pkgs[pkg]) { boot_u += h2b(size_u); boot_p += h2b(size_p); }
   3.203 -	}
   3.204 -	# main loop
   3.205 -	{
   3.206 -		if (FILENAME ~ "packages.info") {
   3.207 -			# Step #1: fill arrays "sizes" and "depends"
   3.208 -			if (! sizes[$1]) {
   3.209 -				  sizes[$1] = $7;
   3.210 -				depends[$1] = $8;
   3.211 -			}
   3.212 -		} else {
   3.213 -			# Step #2: mark packages and its dependencies
   3.214 -			mark_deps($1);
   3.215 -		}
   3.216 -	}
   3.217 -	END {
   3.218 -		# Calculate sums for all marked packages and its deps
   3.219 -		for (pkg in pkgs) {
   3.220 -			num_pkgs ++;
   3.221 -			split(pkgs[pkg], s, " ");
   3.222 -			size_packed   += h2b(s[1]);
   3.223 -			size_unpacked += h2b(s[2]);
   3.224 -			if (outfile) print pkg >> outfile;
   3.225 -		}
   3.226 -		# Add files placed in flavor.rootfs
   3.227 -		size_packed   += rootfs_p;
   3.228 -		size_unpacked += rootfs_u;
   3.229 -
   3.230 -		# Check critical packages: "syslinux" and one of the packages containing "vmlinuz*"
   3.231 -		printf "" > warnfile;
   3.232 -		if (! pkgs["syslinux"]) printf "  * Syslinux\n" >> warnfile;
   3.233 -		if (! pkgs["linux"]       && ! pkgs["linux-without-modules"] && \
   3.234 -			! pkgs["linux64"]     && ! pkgs["linux64-without-modules"] && \
   3.235 -			! pkgs["linux-libre"] && ! pkgs["linux-libre-without-modules"] && \
   3.236 -			! pkgs["linux-uml"]) printf "  * Linux kernel\n" >> warnfile;
   3.237 -
   3.238 -		# Calculate unpacked and packed sizes of /boot
   3.239 -		calc("syslinux",					"156K",  "120K" );
   3.240 -		calc("gpxe",						"196K",  "188K" );
   3.241 -		calc("ipxe",						"316K",  "312K" );
   3.242 -		calc("memtest",						"52K",   "48K"  );
   3.243 -		calc("memtest-serial",				"52K",   "48K"  );
   3.244 -		calc("slitaz-configs-base",			"36K",   "28K"  );
   3.245 -		calc("linux",						"2.8M",  "2.8M" );
   3.246 -		calc("linux-without-modules",		"12.6M", "12.8M");
   3.247 -		calc("linux64",						"3.0M",  "3.0M" );
   3.248 -		calc("linux64-without-modules",		"13.2M", "13.4M");
   3.249 -		calc("linux-libre",					"2.3M",  "2.3M" );
   3.250 -		calc("linux-libre-without-modules",	"6.9M",  "6.9M" );
   3.251 -		calc("linux-uml",					"3.0M",  "1.1M" );
   3.252 -
   3.253 -		# /boot is moved away from rootfs
   3.254 -		size_packed   -= boot_p;
   3.255 -		size_unpacked -= boot_u;
   3.256 -
   3.257 -		# Add rootcd payload and /boot content sizes
   3.258 -		size_iso = size_packed + rootcd_u + boot_u;
   3.259 -
   3.260 -		printf "%s %s ",  b2h(size_unpacked), b2h(size_packed);
   3.261 -		printf "%s %d\n", b2h(size_iso), num_pkgs;
   3.262 -	}' $(pi_lists) "$dir/$flavor.pkglist"
   3.263 -}
   3.264 -
   3.265 -
   3.266  # Display list of unknown packages (informative)
   3.267  
   3.268  display_unknown() {
   3.269 @@ -1980,7 +1859,7 @@
   3.270  		action 'Updating %s...' "$flavor.desc"
   3.271  
   3.272  		[ -f "$flv_dir/$flavor.mirrors" ] && setup_mirrors "$flv_dir/$flavor.mirrors" >/dev/null
   3.273 -		set -- $(calc_sizes "$flv_dir" "$flavor")
   3.274 +		set -- $(module calc_sizes "$flv_dir" "$flavor")
   3.275  		restore_mirrors >/dev/null
   3.276  
   3.277  		sed -i -e '/Image is ready/d' \
   3.278 @@ -2090,7 +1969,7 @@
   3.279  		fi
   3.280  
   3.281  		unset VERSION MAINTAINER ROOTFS_SELECTION
   3.282 -		set -- $(calc_sizes "$tmp_dir" "$flavor")
   3.283 +		set -- $(module calc_sizes "$tmp_dir" "$flavor")
   3.284  		ROOTFS_SIZE="$1 (estimated)"
   3.285  		INITRAMFS_SIZE="$2 (estimated)"
   3.286  		ISO_SIZE="$3 (estimated)"
   3.287 @@ -2158,7 +2037,7 @@
   3.288  		grep -q  '^Rootfs list' description &&
   3.289  			grep '^Rootfs list' description | sed 's/.*: \(.*\)$/\1/' > /etc/tazlito/rootfs.list
   3.290  
   3.291 -		action 'Updating tazlito.conf...'
   3.292 +		action 'Updating %s...' 'tazlito.conf'
   3.293  		[ -f tazlito.conf ] || cp /etc/tazlito/tazlito.conf .
   3.294  		grep -v "^#VOLUM_NAME" < tazlito.conf | \
   3.295  		sed "s/^VOLUM_NA/VOLUM_NAME=\"SliTaz $flavor\"\\n#VOLUM_NA/" \
   3.296 @@ -2181,11 +2060,11 @@
   3.297  		flavordata $2 | (cd $TMP_DIR/flavor; cpio -i 2>/dev/null)
   3.298  		if [ -s $TMP_DIR/iso/boot/rootfs1.gz -a \
   3.299  		   ! -s $TMP_DIR/flavor/*.desc ]; then
   3.300 -			echo "META flavors are not supported."
   3.301 +			_ 'META flavors are not supported.'
   3.302  			umount -d $TMP_DIR/iso
   3.303  		elif [ ! -s $TMP_DIR/iso/boot/rootfs.gz -a \
   3.304  		       ! -s $TMP_DIR/iso/boot/rootfs1.gz ]; then
   3.305 -			echo "No /boot/rootfs.gz in ISO image. Needs a SliTaz ISO."
   3.306 +			_ 'No %s in ISO image. Needs a SliTaz ISO.' '/boot/rootfs.gz'
   3.307  			umount -d $TMP_DIR/iso
   3.308  		else
   3.309  			for i in $(ls -r $TMP_DIR/iso/boot/rootfs*gz); do
   3.310 @@ -2193,7 +2072,8 @@
   3.311  				( cd $TMP_DIR/rootfs ; cpio -idmu > /dev/null 2>&1 )
   3.312  			done
   3.313  			if [ ! -s $TMP_DIR/rootfs/etc/slitaz-release ]; then
   3.314 -				echo "No file /etc/slitaz-release in /boot/rootfs.gz of iso image. Needs a non loram SliTaz iso."
   3.315 +				_ 'No file %s in %s of ISO image. Needs a non-loram SliTaz ISO.' \
   3.316 +					'/etc/slitaz-release' '/boot/rootfs.gz'
   3.317  				umount -d $TMP_DIR/iso
   3.318  			else
   3.319  				ROOTFS_SIZE=$(du -hs $TMP_DIR/rootfs | awk '{ print $1 }')
   3.320 @@ -2227,8 +2107,8 @@
   3.321  					unset VERSION MAINTAINER
   3.322  					echo -en "Flavor short description \007: "; read -t 30 DESCRIPTION
   3.323  					if [ -n "$DESCRIPTION" ]; then
   3.324 -						echo -en "Flavor version : "; read -t 30 VERSION
   3.325 -						echo -en "Flavor maintainer (your email) : "; read -t 30 MAINTAINER
   3.326 +						_n 'Flavor version : '; read -t 30 VERSION
   3.327 +						_n 'Flavor maintainer (your email) : '; read -t 30 MAINTAINER
   3.328  					fi
   3.329  
   3.330  					cat > $TMP_DIR/$FLAVOR.desc <<EOT
   3.331 @@ -2325,7 +2205,7 @@
   3.332  			tmp_dir="$(mktemp -d)"
   3.333  			cp "$LIST_NAME" "$tmp_dir/flavor.pkglist"
   3.334  			touch "$tmp_dir/full.pkglist"
   3.335 -			calc_sizes "$tmp_dir" 'flavor' "$tmp_dir/full.pkglist" >/dev/null
   3.336 +			module calc_sizes "$tmp_dir" 'flavor' "$tmp_dir/full.pkglist" >/dev/null
   3.337  
   3.338  			awk -F$'\t' '{printf "%s %s\n", $1, $2}' "$LOCALSTATE/installed.info" | \
   3.339  			while read pkgname pkgver; do
   3.340 @@ -2465,12 +2345,12 @@
   3.341  
   3.342  				cd $DISTRO
   3.343  				if [ -s $flavor.rootfs ]; then
   3.344 -					echo -n "Adding $flavor rootfs extra files..."
   3.345 +					_n 'Adding %s rootfs extra files...' "$flavor"
   3.346  					zcat < $flavor.rootfs | ( cd ${ROOTFS}0$n ; cpio -idmu )
   3.347  				fi
   3.348  
   3.349  				action 'Moving %s to %s' "list-packages0$n" "rootfs0$n"
   3.350 -				mv $DISTRO/list-packages0$n ${ROOTFS}0$n/etc/tazlito/distro-packages.list
   3.351 +				mv "$DISTRO/list-packages0$n" "${ROOTFS}0$n/etc/tazlito/distro-packages.list"
   3.352  				status
   3.353  
   3.354  				rm -f $flavor.flavor install-list
   3.355 @@ -2483,15 +2363,14 @@
   3.356  			i=$(($n+1))
   3.357  			while [ $n -gt 0 ]; do
   3.358  				mv ${ROOTFS}0$n ${ROOTFS}$i
   3.359 -				echo "Compressing ${ROOTFS}0$n ($(du -hs ${ROOTFS}$i | awk '{ print $1 }'))..."
   3.360 +				_ 'Compressing %s (%s)...' "${ROOTFS}0$n" "$(du -hs ${ROOTFS}$i | awk '{ print $1 }')"
   3.361  				gen_initramfs ${ROOTFS}$i
   3.362  				n=$(($n-1))
   3.363  				i=$(($i-1))
   3.364  			done
   3.365  			mv $ROOTFS ${ROOTFS}$i
   3.366  			gen_initramfs ${ROOTFS}$i
   3.367 -			update_bootconfig $ROOTCD/boot/isolinux \
   3.368 -				"$(cat /etc/tazlito/rootfs.list)"
   3.369 +			update_bootconfig "$ROOTCD/boot/isolinux" "$(cat /etc/tazlito/rootfs.list)"
   3.370  		else
   3.371  			# Initramfs and ISO image stuff.
   3.372  			gen_initramfs $ROOTFS
   3.373 @@ -2537,16 +2416,16 @@
   3.374  		check_rootfs
   3.375  		title 'Checking distro: %s' "$ROOTFS"
   3.376  		# SliTaz release info.
   3.377 -		if [ ! -f "$ROOTFS/etc/slitaz-release" ]; then
   3.378 -			echo "Missing release info : /etc/slitaz-release"
   3.379 +		rel='/etc/slitaz-release'
   3.380 +		if [ ! -f "$ROOTFS$rel" ]; then
   3.381 +			_ 'Missing release info: %s' "$rel"
   3.382  		else
   3.383 -			release=$(cat $ROOTFS/etc/slitaz-release)
   3.384 -			echo -n "Release      : $release"
   3.385 +			action 'Release      : %s' "$(cat $ROOTFS$rel)"
   3.386  			status
   3.387  		fi
   3.388  		# Tazpkg mirror.
   3.389  		if [ ! -f "$ROOTFS$LOCALSTATE/mirror" ]; then
   3.390 -			echo -n "Mirror URL   : Missing $LOCALSTATE/mirror"
   3.391 +			action 'Mirror URL   : Missing %s' "$LOCALSTATE/mirror"
   3.392  			todomsg
   3.393  		else
   3.394  			action 'Mirror configuration exists...'
   3.395 @@ -2554,7 +2433,7 @@
   3.396  		fi
   3.397  		# Isolinux msg
   3.398  		if grep -q "cooking-XXXXXXXX" /$ROOTCD/boot/isolinux/isolinux.*g; then
   3.399 -			echo -n "Isolinux msg : Missing cooking date XXXXXXXX (ex $(date +%Y%m%d))"
   3.400 +			action 'Isolinux msg : Missing cooking date XXXXXXXX (ex %s)' "$(date +%Y%m%d)"
   3.401  			todomsg
   3.402  		else
   3.403  			action 'Isolinux message seems good...'
   3.404 @@ -2589,36 +2468,28 @@
   3.405  
   3.406  		# Optionally remove sound card selection and screen resolution.
   3.407  		if [ -z $LaunchedByTazpanel ]; then
   3.408 -		echo "Do you wish to remove the sound card and screen configs ? "
   3.409 -		echo -n "Press ENTER to keep or answer (No|yes|exit): "
   3.410 -		read anser
   3.411 +		anser=$(yesorno 'Do you wish to remove the sound card and screen configs?' 'n')
   3.412  		case $anser in
   3.413 -			e|E|"exit"|Exit)
   3.414 -				exit 0 ;;
   3.415 -			y|Y|yes|Yes)
   3.416 -				echo -n "Removing current sound card and screen configurations..."
   3.417 +			y)
   3.418 +				action 'Removing current sound card and screen configurations...'
   3.419  				rm -f /var/lib/sound-card-driver
   3.420  				rm -f /var/lib/alsa/asound.state
   3.421  				rm -f /etc/X11/xorg.conf ;;
   3.422  			*)
   3.423 -				echo -n "Keeping current sound card and screen configurations..." ;;
   3.424 +				action 'Keeping current sound card and screen configurations...' ;;
   3.425  		esac
   3.426  		status
   3.427  		newline
   3.428  
   3.429  		# Optionally remove i18n settings
   3.430 -		echo "Do you wish to remove local/keymap settings ? "
   3.431 -		echo -n "Press ENTER to keep or answer (No|yes|exit): "
   3.432 -		read anser
   3.433 +		anser=$(yesorno 'Do you wish to remove locale/keymap settings?' 'n')
   3.434  		case $anser in
   3.435 -			e|E|"exit"|Exit)
   3.436 -				exit 0 ;;
   3.437 -			y|Y|yes|Yes)
   3.438 -				echo "Removing current locale/keymap settings..."
   3.439 +			y)
   3.440 +				action 'Removing current locale/keymap settings...'
   3.441  				newline > /etc/locale.conf
   3.442  				newline > /etc/keymap.conf ;;
   3.443  			*)
   3.444 -				echo "Keeping current locale/keymap settings..." ;;
   3.445 +				action 'Keeping current locale/keymap settings...' ;;
   3.446  		esac
   3.447  		status
   3.448  		fi
   3.449 @@ -2670,7 +2541,7 @@
   3.450  		# Move freshly generated rootfs to the cdrom.
   3.451  		mkdir -p $ROOTCD/boot
   3.452  		mv -f /$INITRAMFS $ROOTCD/boot
   3.453 -		echo "Located in: $ROOTCD/boot/$INITRAMFS"
   3.454 +		_ 'Located in: %s' "$ROOTCD/boot/$INITRAMFS"
   3.455  
   3.456  		# Now we need the kernel and isolinux files.
   3.457  		copy_from_cd() {
   3.458 @@ -2680,7 +2551,7 @@
   3.459  			umount /media/cdrom
   3.460  		}
   3.461  
   3.462 -		bootloader='/var/lib/tazpkg/installed/syslinux/volatile.cpio.gz'
   3.463 +		bootloader="$LOCALSTATE/installed/syslinux/volatile.cpio.gz"
   3.464  		if  mount /dev/cdrom /media/cdrom 2>/dev/null; then
   3.465  			copy_from_cd;
   3.466  		elif  mount | grep /media/cdrom; then
   3.467 @@ -2709,7 +2580,7 @@
   3.468  		touch /tmp/.write-iso
   3.469  		newline
   3.470  		cd $DISTRO
   3.471 -		echo "Generating ISO image..."
   3.472 +		_ 'Generating ISO image...'
   3.473  		genisoimage -R   -o $ISO_NAME.iso   -b boot/isolinux/isolinux.bin \
   3.474  		-c boot/isolinux/boot.cat   -no-emul-boot   -boot-load-size 4 \
   3.475  		-V "SliTaz"   -p "$(id -un)"   -input-charset utf-8 \
   3.476 @@ -2728,14 +2599,13 @@
   3.477  		md5sum $ISO_NAME.iso > $ISO_NAME.md5
   3.478  		status
   3.479  
   3.480 -		separator
   3.481 -		echo "ISO image: $(du -sh $DISTRO/$ISO_NAME.iso)"
   3.482 +		footer "ISO image: $(du -sh $DISTRO/$ISO_NAME.iso)"
   3.483  		rm -f /tmp/.write-iso
   3.484 -		newline
   3.485 +
   3.486  		if [ -z $LaunchedByTazpanel ]; then
   3.487 -		echo -n "Exit or burn ISO to CD-ROM (Exit|burn)? "; read anser
   3.488 +		anser=$(yesorno 'Burn ISO to CD-ROM?' 'n')
   3.489  		case $anser in
   3.490 -			burn)
   3.491 +			y)
   3.492  				umount /dev/cdrom 2>/dev/null
   3.493  				eject
   3.494  				echo -n "Please insert a blank CD-ROM and press ENTER..."
   3.495 @@ -2817,7 +2687,7 @@
   3.496  		make_bzImage_hardlink $TMP_DIR/iso/boot
   3.497  		umount -d $TMP_DIR/mnt
   3.498  		if [ -f $TMP_DIR/iso/boot/rootfs1.gz ]; then
   3.499 -			echo "$1 is already a merged iso. Aborting."
   3.500 +			_ '%s is already a merged iso. Aborting.' "$1"
   3.501  			cleanup_merge
   3.502  		fi
   3.503  		if [ ! -f $TMP_DIR/iso/boot/isolinux/ifmem.c32 -a
   3.504 @@ -2835,7 +2705,7 @@
   3.505  			cp /boot/isolinux/ifmem.c32 $TMP_DIR/iso/boot/isolinux
   3.506  		fi
   3.507  
   3.508 -		action 'Extracting iso/rootfs.gz'
   3.509 +		action 'Extracting %s' 'iso/rootfs.gz'
   3.510  		extract_rootfs $TMP_DIR/iso/boot/rootfs.gz $TMP_DIR/rootfs1 &&
   3.511  			[ -d $TMP_DIR/rootfs1/etc ]
   3.512  		status || cleanup_merge
   3.513 @@ -2855,11 +2725,11 @@
   3.514  			status || cleanup_merge
   3.515  
   3.516  			mergefs $TMP_DIR/rootfs$n $TMP_DIR/rootfs$p
   3.517 -			action 'Creating rootfs%s.gz' "$p"
   3.518 +			action 'Creating %s' "rootfs$p.gz"
   3.519  			pack_rootfs "$TMP_DIR/rootfs$p" "$TMP_DIR/iso/boot/rootfs$p.gz"
   3.520  			status
   3.521  		done
   3.522 -		action 'Creating rootfs%s.gz' "$n"
   3.523 +		action 'Creating %s' "rootfs$n.gz"
   3.524  		pack_rootfs "$TMP_DIR/rootfs$n" "$TMP_DIR/iso/boot/rootfs$n.gz"
   3.525  		status
   3.526  		rm -f $TMP_DIR/iso/boot/rootfs.gz