tazusb rev 181

tazusb: extend to "tazusb writefs [compression] [path]"
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sun Aug 09 02:56:14 2015 +0300 (2015-08-09)
parents 8ddffadf56a6
children 6486fbd6dccf
files po/tazusb/el.po po/tazusb/fr.po po/tazusb/pl.po po/tazusb/pt_BR.po po/tazusb/ru.po po/tazusb/tazusb.pot po/tazusb/zh_CN.po tazusb tazusb-box
line diff
     1.1 --- a/po/tazusb/el.po	Sat Aug 01 22:49:04 2015 +0300
     1.2 +++ b/po/tazusb/el.po	Sun Aug 09 02:56:14 2015 +0300
     1.3 @@ -300,8 +300,8 @@
     1.4  "για τις καθυστερημένες εγγραφές!"
     1.5  
     1.6  #: tazusb:541
     1.7 -msgid "%s is located in /"
     1.8 -msgstr "Το %s τοποθετήθηκε στο /"
     1.9 +msgid "%s is located in %s"
    1.10 +msgstr "Το %s τοποθετήθηκε στο %s"
    1.11  
    1.12  #: tazusb:545
    1.13  #, fuzzy
     2.1 --- a/po/tazusb/fr.po	Sat Aug 01 22:49:04 2015 +0300
     2.2 +++ b/po/tazusb/fr.po	Sun Aug 09 02:56:14 2015 +0300
     2.3 @@ -286,8 +286,8 @@
     2.4  "les écritures différées."
     2.5  
     2.6  #: tazusb:541
     2.7 -msgid "%s is located in /"
     2.8 -msgstr "Le fichier %s est dans /"
     2.9 +msgid "%s is located in %s"
    2.10 +msgstr "Le fichier %s est dans %s"
    2.11  
    2.12  #: tazusb:545
    2.13  #, fuzzy
     3.1 --- a/po/tazusb/pl.po	Sat Aug 01 22:49:04 2015 +0300
     3.2 +++ b/po/tazusb/pl.po	Sun Aug 09 02:56:14 2015 +0300
     3.3 @@ -289,8 +289,8 @@
     3.4  "proszę pamiętać aby odmontować urządzenie przed odłączeniem od komputera!"
     3.5  
     3.6  #: tazusb:541
     3.7 -msgid "%s is located in /"
     3.8 -msgstr "%s jest zlokalizowany w /"
     3.9 +msgid "%s is located in %s"
    3.10 +msgstr "%s jest zlokalizowany w %s"
    3.11  
    3.12  #: tazusb:545
    3.13  msgid "Root filesystem size: %s"
     4.1 --- a/po/tazusb/pt_BR.po	Sat Aug 01 22:49:04 2015 +0300
     4.2 +++ b/po/tazusb/pt_BR.po	Sun Aug 09 02:56:14 2015 +0300
     4.3 @@ -278,8 +278,8 @@
     4.4  msgstr "Movendo %s para a mídia. Lembre-se de desmontar o dispositivo!"
     4.5  
     4.6  #: tazusb:541
     4.7 -msgid "%s is located in /"
     4.8 -msgstr "%s localizado em /"
     4.9 +msgid "%s is located in %s"
    4.10 +msgstr "%s localizado em %s"
    4.11  
    4.12  #: tazusb:545
    4.13  #, fuzzy
     5.1 --- a/po/tazusb/ru.po	Sat Aug 01 22:49:04 2015 +0300
     5.2 +++ b/po/tazusb/ru.po	Sun Aug 09 02:56:14 2015 +0300
     5.3 @@ -287,8 +287,8 @@
     5.4  "записи!"
     5.5  
     5.6  #: tazusb:541
     5.7 -msgid "%s is located in /"
     5.8 -msgstr "Файл %s расположен в /"
     5.9 +msgid "%s is located in %s"
    5.10 +msgstr "Файл %s расположен в %s"
    5.11  
    5.12  #: tazusb:545
    5.13  msgid "Root filesystem size: %s"
     6.1 --- a/po/tazusb/tazusb.pot	Sat Aug 01 22:49:04 2015 +0300
     6.2 +++ b/po/tazusb/tazusb.pot	Sun Aug 09 02:56:14 2015 +0300
     6.3 @@ -268,7 +268,7 @@
     6.4  msgstr ""
     6.5  
     6.6  #: tazusb:541
     6.7 -msgid "%s is located in /"
     6.8 +msgid "%s is located in %s"
     6.9  msgstr ""
    6.10  
    6.11  #: tazusb:545
     7.1 --- a/po/tazusb/zh_CN.po	Sat Aug 01 22:49:04 2015 +0300
     7.2 +++ b/po/tazusb/zh_CN.po	Sun Aug 09 02:56:14 2015 +0300
     7.3 @@ -274,8 +274,8 @@
     7.4  msgstr "移动%s到LiveUSB媒体。请记住取消延迟写入!"
     7.5  
     7.6  #: tazusb:541
     7.7 -msgid "%s is located in /"
     7.8 -msgstr "%s位于 /"
     7.9 +msgid "%s is located in %s"
    7.10 +msgstr "%s位于 %s"
    7.11  
    7.12  #: tazusb:545
    7.13  #, fuzzy
     8.1 --- a/tazusb	Sat Aug 01 22:49:04 2015 +0300
     8.2 +++ b/tazusb	Sun Aug 09 02:56:14 2015 +0300
     8.3 @@ -13,7 +13,7 @@
     8.4  
     8.5  . /lib/libtaz.sh
     8.6  
     8.7 -# Export package name for gettext.
     8.8 +# i18n
     8.9  export TEXTDOMAIN='tazusb'
    8.10  
    8.11  COMMAND="$1"
    8.12 @@ -102,21 +102,6 @@
    8.13  }
    8.14  
    8.15  
    8.16 -# Format target device and label partition.
    8.17 -
    8.18 -mkfs_ext3() {
    8.19 -	_n 'Please specify a label for the partition (TazUSB): '
    8.20 -	read label
    8.21 -
    8.22 -	[ -z "$label" ] && label='TazUSB'
    8.23 -
    8.24 -	_ 'Label: %s' "$label"
    8.25 -	echo "Mkfs: mkfs.ext3 -L \"$label\" $DEVICE"
    8.26 -	newline; sleep 2
    8.27 -	mkfs.ext3 -L "$label" $DEVICE
    8.28 -}
    8.29 -
    8.30 -
    8.31  # Get label for device
    8.32  
    8.33  get_label() {
    8.34 @@ -126,6 +111,18 @@
    8.35  }
    8.36  
    8.37  
    8.38 +# Format target device and label partition.
    8.39 +
    8.40 +mkfs_ext3() {
    8.41 +	get_label
    8.42 +
    8.43 +	_ 'Label: %s' "$label"
    8.44 +	echo "Mkfs: mkfs.ext3 -L \"$label\" $DEVICE"
    8.45 +	newline; sleep 2
    8.46 +	mkfs.ext3 -L "$label" $DEVICE
    8.47 +}
    8.48 +
    8.49 +
    8.50  # Get fs type. Supported fs are ext3, ext2, fat32
    8.51  
    8.52  get_fs_type() {
    8.53 @@ -370,9 +367,8 @@
    8.54  # will activate it, useful for low memory systems
    8.55  
    8.56  gen_swap_file() {
    8.57 -	newline
    8.58 -	boldify "$(_n 'Gen swap')"
    8.59 -	separator
    8.60 +	title "$(_n 'Gen swap')"
    8.61 +
    8.62  	longline "$(_ "Generate a swap file in %s that will be activated on each \
    8.63  boot to have more memory available (empty value to exit)." '/home/swap')"
    8.64  	newline
    8.65 @@ -399,9 +395,8 @@
    8.66  # Clean out old backups to save disk space
    8.67  
    8.68  clean_usb() {
    8.69 -	newline
    8.70 -	boldify "$(_n 'Clean')"
    8.71 -	separator
    8.72 +	title "$(_n 'Clean')"
    8.73 +
    8.74  	longline "$(_n 'Remove old %s backup filesystems to free up disk space.' \
    8.75  'rootfs.gz.unixtimestamp')"
    8.76  	newline
    8.77 @@ -429,19 +424,22 @@
    8.78  	writefs)
    8.79  		# Writefs to rootfs.gz
    8.80  		check_root
    8.81 -		if [ -z "$2" ]; then
    8.82 -			COMPRESSION='none'
    8.83 -		else
    8.84 -			COMPRESSION="$2"
    8.85 -		fi
    8.86 +		# Compression type (optional): lzma, gzip, none. Default is none
    8.87 +		COMPRESSION="${2:-none}"
    8.88 +		# Full path to rootfs.gz (optional). Default is /rootfs.gz
    8.89 +		ROOTFS_PATH="${3:-/rootfs.gz}"
    8.90 +		# File name
    8.91 +		ROOTFS="$(basename "$ROOTFS_PATH")"
    8.92 +
    8.93  		# Start info
    8.94  		title 'Write filesystem'
    8.95  
    8.96  		longline "$(_ "The command writefs will write all the current \
    8.97  filesystem into a suitable cpio archive (%s) usable on a bootable \
    8.98 -LiveUSB media." 'rootfs.gz')"
    8.99 +LiveUSB media." "$ROOTFS")"
   8.100  		newline
   8.101  		_ 'Archive compression: %s' "$(colorize 36 "$COMPRESSION")"
   8.102 +		newline
   8.103  
   8.104  		# Clear out tazpkg cache
   8.105  		rm /var/lib/tazpkg/*.bak /var/cache/tazpkg/* -r -f
   8.106 @@ -449,8 +447,8 @@
   8.107  		# Optionally remove sound card selection and screen resolution.
   8.108  		_ 'Do you wish to remove the sound card and screen configs?'
   8.109  		_n 'Press ENTER to keep or answer (No|yes|exit): '
   8.110 -		read anser
   8.111 -		case $anser in
   8.112 +		read answer
   8.113 +		case $answer in
   8.114  			e|E|"exit"|Exit)
   8.115  				exit 0 ;;
   8.116  			y|Y|yes|Yes)
   8.117 @@ -467,8 +465,8 @@
   8.118  		# Optionally remove i18n settings
   8.119  		_ 'Do you wish to remove local/keymap settings?'
   8.120  		_n 'Press ENTER to keep or answer (No|yes|exit): '
   8.121 -		read anser
   8.122 -		case $anser in
   8.123 +		read answer
   8.124 +		case $answer in
   8.125  			e|E|"exit"|Exit)
   8.126  				exit 0 ;;
   8.127  			y|Y|yes|Yes)
   8.128 @@ -481,6 +479,7 @@
   8.129  				sed  -i  's/^INCLUDE i18n.cfg/# &/' /home/boot/*linux/*linux.c* ;;
   8.130  		esac
   8.131  		status
   8.132 +		newline
   8.133  
   8.134  		# Clean-up files by default
   8.135  		mv -f /var/log/wtmp /tmp/tazusb-wtmp
   8.136 @@ -508,37 +507,40 @@
   8.137  		done
   8.138  
   8.139  		# Generate initramfs with specified compression
   8.140 -		if [ "$COMPRESSION" == 'lzma' ]; then
   8.141 -			_n 'Creating %s with lzma compression... ' 'rootfs.gz'
   8.142 -			cpio -o -H newc | lzma e -si -so > /rootfs.gz
   8.143 -
   8.144 -		elif [ "$COMPRESSION" == 'gzip' ]; then
   8.145 -			_n 'Creating %s with gzip compression... ' 'rootfs.gz'
   8.146 -			cpio -o -H newc | gzip -9 > /rootfs.gz
   8.147 -
   8.148 -		else
   8.149 -			_n 'Creating %s without compression... ' 'rootfs.gz'
   8.150 -			cpio -o -H newc > /rootfs.gz
   8.151 -		fi < /tmp/list
   8.152 +		case "$COMPRESSION" in
   8.153 +			lzma)
   8.154 +				_n 'Creating %s with lzma compression... ' "$ROOTFS"
   8.155 +				cpio -o -H newc | lzma e -si -so > "$ROOTFS_PATH"
   8.156 +				;;
   8.157 +			gzip)
   8.158 +				_n 'Creating %s with gzip compression... ' "$ROOTFS"
   8.159 +				cpio -o -H newc | gzip -9 > "$ROOTFS_PATH"
   8.160 +				;;
   8.161 +			*)
   8.162 +				_n 'Creating %s without compression... ' "$ROOTFS"
   8.163 +				cpio -o -H newc > "$ROOTFS_PATH"
   8.164 +				;;
   8.165 +		esac < /tmp/list
   8.166  
   8.167  		mv -f /tmp/tazusb-wtmp /var/log/wtmp
   8.168  
   8.169  		# Get initramfs size
   8.170 -		size=$(du -sh /rootfs.gz | cut -f1)
   8.171 +		size=$(du -sh "$ROOTFS_PATH" | cut -f1)
   8.172  
   8.173  		# If the bootable medium is where it should be, copy across
   8.174 -		if (test -e /home/boot/bzImage); then
   8.175 -			longline "$(_ 'Moving %s to media. Remember to unmount for delayed writes!' 'rootfs.gz')"
   8.176 +		if [ -e /home/boot/bzImage ]; then
   8.177 +			longline "$(_ 'Moving %s to media. Remember to unmount for delayed writes!' "$ROOTFS")"
   8.178  
   8.179  			# Move the old filesystem with the unix timestamp for reference
   8.180 -			if (test -e /home/boot/previous.gz); then
   8.181 +			if [ -e /home/boot/previous.gz ]; then
   8.182  				mv /home/boot/previous.gz /home/boot/rootfs.gz.$(date +%s)
   8.183  			fi
   8.184  			
   8.185  			mv /home/boot/rootfs.gz /home/boot/previous.gz
   8.186 -			mv /rootfs.gz /home/boot/.
   8.187 +			mv "$ROOTFS_PATH" /home/boot/rootfs.gz
   8.188 +			_ '%s is located in %s' 'rootfs.gz' '/home/boot'
   8.189  		else
   8.190 -			_ '%s is located in /' 'rootfs.gz'
   8.191 +			_ '%s is located in %s' "$ROOTFS" "$(dirname "$ROOTFS_PATH")"
   8.192  		fi
   8.193  
   8.194  		separator
     9.1 --- a/tazusb-box	Sat Aug 01 22:49:04 2015 +0300
     9.2 +++ b/tazusb-box	Sun Aug 09 02:56:14 2015 +0300
     9.3 @@ -27,7 +27,7 @@
     9.4  opts="--window-icon=$icon --height=220 --width=520 --center --on-top"
     9.5  
     9.6  
     9.7 -# I18n
     9.8 +# i18n
     9.9  
    9.10  export TEXTDOMAIN='tazusb-box'
    9.11  
    9.12 @@ -54,7 +54,7 @@
    9.13  
    9.14  list_devices() {
    9.15  	if [ -d /proc/scsi/usb-storage ]; then
    9.16 -		dev="$(blkid | cut -d":" -f1)"
    9.17 +		dev="$(blkid | cut -d: -f1)"
    9.18  		echo $dev | sed s'/ /!/'g
    9.19  	else
    9.20  		_ 'No USB media found'
    9.21 @@ -92,7 +92,7 @@
    9.22  		exit 0
    9.23  	fi
    9.24  	if echo "$main" | grep -q ".iso|"; then
    9.25 -		iso=$(echo $main | cut -d "|" -f 1)
    9.26 +		iso=$(echo $main | cut -d "|" -f1)
    9.27  		yes '' | tazusb gen-iso2usb $iso $dev --output=raw | output
    9.28  	else
    9.29  		yes '' | tazusb gen-liveusb $dev --output=raw | output