cookutils rev 564 slitaz-tank
libcookiso.sh: Use unset instead of =.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Fri Jan 04 09:05:15 2013 +0000 (2013-01-04) |
parents | 80596b9857c9 |
children | 594175c90cf3 |
files | lib/libcookiso.sh |
line diff
1.1 --- a/lib/libcookiso.sh Mon Dec 31 17:13:41 2012 +0000 1.2 +++ b/lib/libcookiso.sh Fri Jan 04 09:05:15 2013 +0000 1.3 @@ -19,10 +19,10 @@ 1.4 newline > $log 1.5 fi 1.6 1.7 -if [ ! "$CONFIG_FILE" = "" ] ; then 1.8 +if [ ! "$CONFIG_FILE" = "" ]; then 1.9 . $CONFIG_FILE 1.10 else 1.11 - if [ "$COMMAND" = "gen-config" ] ; then 1.12 + if [ "$COMMAND" = "gen-config" ]; then 1.13 continue 1.14 else 1.15 echo "Unable to find any configuration file. Please read the docs" 1.16 @@ -121,7 +121,7 @@ 1.17 package=${tazpkg%-*} 1.18 i=$package 1.19 while true; do 1.20 - VERSION="" 1.21 + unset VERSION 1.22 eval $(grep -s ^VERSION= $INSTALLED/$i/receipt) 1.23 unset EXTRAVERSION 1.24 eval $(grep -s ^EXTRAVERSION= $INSTALLED/$i/receipt) 1.25 @@ -141,7 +141,7 @@ 1.26 # Check for the rootfs tree. 1.27 check_rootfs() 1.28 { 1.29 - if [ ! -d "$ROOTFS/etc" ] ; then 1.30 + if [ ! -d "$ROOTFS/etc" ]; then 1.31 echo -e "\nUnable to find a distro rootfs...\n" 1.32 exit 0 1.33 fi 1.34 @@ -150,7 +150,7 @@ 1.35 # Check for the boot dir into the root CD tree. 1.36 verify_rootcd() 1.37 { 1.38 - if [ ! -d "$ROOTCD/boot" ] ; then 1.39 + if [ ! -d "$ROOTCD/boot" ]; then 1.40 echo -e "\nUnable to find the rootcd boot directory...\n" 1.41 exit 0 1.42 fi 1.43 @@ -301,20 +301,20 @@ 1.44 deduplicate() 1.45 { 1.46 find "$@" -type f -size +0c -exec stat -c '%s-%a-%u-%g %i %h %n' {} \; | \ 1.47 - sort | ( save=0; old_attr=""; old_inode=""; old_link=""; old_file="" 1.48 - while read attr inode link file; do 1.49 - [ -L "$file" ] && continue 1.50 - if [ "$attr" = "$old_attr" -a "$inode" != "$old_inode" ]; then 1.51 - if cmp "$file" "$old_file" >/dev/null 2>&1 ; then 1.52 - rm -f "$file" 1.53 - ln "$old_file" "$file" 1.54 - inode="$old_inode" 1.55 - [ "$link" = "1" ] && save="$(expr $save + ${attr%%-*})" 1.56 - fi 1.57 - fi 1.58 - old_attr="$attr" ; old_inode="$inode" ; old_file="$file" 1.59 - done 1.60 - echo "$save bytes saved in duplicate files." 1.61 + sort | ( save=0; old_attr=""; old_inode=""; old_link=""; old_file="" 1.62 + while read attr inode link file; do 1.63 + [ -L "$file" ] && continue 1.64 + if [ "$attr" = "$old_attr" -a "$inode" != "$old_inode" ]; then 1.65 + if cmp "$file" "$old_file" >/dev/null 2>&1 ; then 1.66 + rm -f "$file" 1.67 + ln "$old_file" "$file" 1.68 + inode="$old_inode" 1.69 + [ "$link" = "1" ] && save="$(expr $save + ${attr%%-*})" 1.70 + fi 1.71 + fi 1.72 + old_attr="$attr" ; old_inode="$inode" ; old_file="$file" 1.73 + done 1.74 + echo "$save bytes saved in duplicate files." 1.75 ) 1.76 } 1.77 1.78 @@ -566,7 +566,7 @@ 1.79 --force) 1.80 DELETE_ROOTFS="true" 1.81 ;; 1.82 - *) if [ ! -f "$1" ] ; then 1.83 + *) if [ ! -f "$1" ]; then 1.84 echo -e "\nUnable to find the specified packages list." 1.85 echo -e "List name : $1\n" 1.86 exit 1 1.87 @@ -577,7 +577,7 @@ 1.88 shift 1.89 done 1.90 1.91 - if [ -d $ROOTFS ] ; then 1.92 + if [ -d $ROOTFS ]; then 1.93 # Delete $ROOTFS if --force is set on command line 1.94 if [ ! -z $DELETE_ROOTFS ]; then 1.95 rm -rf $ROOTFS 1.96 @@ -588,11 +588,15 @@ 1.97 exit 0 1.98 fi 1.99 fi 1.100 - if [ ! -f "$LIST_NAME" -a -d $INSTALLED ] ; then 1.101 + if [ ! -f "$LIST_NAME" -a -d $INSTALLED ]; then 1.102 # Build list with installed packages 1.103 for i in $(ls $INSTALLED); do 1.104 - eval $(grep ^VERSION= $INSTALLED/$i/receipt) 1.105 - EXTRAVERSION="" 1.106 + if [ $(grep -q ^_realver $INSTALLED/$i/receipt) ]; then 1.107 + VERSION=$(. $INSTALLED/$i/receipt 2>/dev/null ; echo $VERSION) 1.108 + else 1.109 + eval $(grep ^VERSION= $INSTALLED/$i/receipt) 1.110 + fi 1.111 + unset EXTRAVERSION 1.112 eval $(grep ^EXTRAVERSION= $INSTALLED/$i/receipt) 1.113 echo "$i-$VERSION$EXTRAVERSION" >> $LIST_NAME 1.114 done 1.115 @@ -647,7 +651,7 @@ 1.116 mkdir $TMP_MNT 1.117 if mount -r $CDROM $TMP_MNT 2> /dev/null; then 1.118 ln -s $TMP_MNT/boot / 1.119 - if [ ! -d "$ADDFILES/rootcd" ] ; then 1.120 + if [ ! -d "$ADDFILES/rootcd" ]; then 1.121 mkdir -p $ADDFILES/rootcd 1.122 for i in $(ls $TMP_MNT); do 1.123 [ "$i" = "boot" ] && continue 1.124 @@ -730,7 +734,7 @@ 1.125 cp $DISTRO_LIST $ROOTFS/etc/slitaz 1.126 fi 1.127 # Copy all files from $ADDFILES/rootfs to the rootfs. 1.128 - if [ -d "$ADDFILES/rootfs" ] ; then 1.129 + if [ -d "$ADDFILES/rootfs" ]; then 1.130 echo -n "Copying addfiles content to the rootfs... " 1.131 cp -a $ADDFILES/rootfs/* $ROOTFS 1.132 status 1.133 @@ -749,7 +753,7 @@ 1.134 cd $ROOTCD/boot 1.135 ln vmlinuz-* bzImage 1.136 status 1.137 - elif [ -d "$ROOTFS/boot" ] ; then 1.138 + elif [ -d "$ROOTFS/boot" ]; then 1.139 echo -n "Moving the boot directory..." 1.140 mv $ROOTFS/boot $ROOTCD 1.141 cd $ROOTCD/boot 1.142 @@ -759,7 +763,7 @@ 1.143 fi 1.144 cd $DISTRO 1.145 # Copy all files from $ADDFILES/rootcd to the rootcd. 1.146 - if [ -d "$ADDFILES/rootcd" ] ; then 1.147 + if [ -d "$ADDFILES/rootcd" ]; then 1.148 echo -n "Copying addfiles content to the rootcd... " 1.149 cp -a $ADDFILES/rootcd/* $ROOTCD 1.150 status 1.151 @@ -850,7 +854,7 @@ 1.152 FILES="$FLAVOR.pkglist" 1.153 echo -n "Creating file $FLAVOR.flavor..." 1.154 for i in rootcd rootfs; do 1.155 - if [ -d "$ADDFILES/$i" ] ; then 1.156 + if [ -d "$ADDFILES/$i" ]; then 1.157 FILES="$FILES\n$FLAVOR.$i" 1.158 ( cd "$ADDFILES/$i"; find . | \ 1.159 cpio -o -H newc 2> /dev/null | gzip -9 ) > $FLAVOR.$i 1.160 @@ -869,8 +873,12 @@ 1.161 ( cd $DISTRO; distro_sizes) >> $FLAVOR.desc 1.162 \rm -f $FLAVOR.pkglist $FLAVOR.nonfree 2> /dev/null 1.163 for i in $(ls $ROOTFS$INSTALLED); do 1.164 - eval $(grep ^VERSION= $ROOTFS$INSTALLED/$i/receipt) 1.165 - EXTRAVERSION="" 1.166 + if [ $(grep -q ^_realver $ROOTFS$INSTALLED/$i/receipt) ]; then 1.167 + eval $(. $ROOTFS$INSTALLED/$i/receipt 2>/dev/null ; echo $VERSION) 1.168 + else 1.169 + eval $(grep ^VERSION= $ROOTFS$INSTALLED/$i/receipt) 1.170 + fi 1.171 + unset EXTRAVERSION 1.172 eval $(grep ^EXTRAVERSION= $ROOTFS$INSTALLED/$i/receipt) 1.173 eval $(grep ^CATEGORY= $ROOTFS$INSTALLED/$i/receipt) 1.174 if [ "$CATEGORY" = "non-free" -a "${i%%-*}" != "get" ] 1.175 @@ -934,7 +942,7 @@ 1.176 fi 1.177 done 1.178 if [ -s $TMP_DIR/$FLAVOR.mirrors ]; then 1.179 - n="" 1.180 + unset n 1.181 while read line; do 1.182 mkdir -p $LOCALSTATE/undigest/$FLAVOR$n 1.183 echo "$line" > $LOCALSTATE/undigest/$FLAVOR$n/mirror 1.184 @@ -971,14 +979,14 @@ 1.185 newline 1.186 boldify "Cleaning : $DISTRO" 1.187 separator 1.188 - if [ -d "$DISTRO" ] ; then 1.189 - if [ -d "$ROOTFS" ] ; then 1.190 + if [ -d "$DISTRO" ]; then 1.191 + if [ -d "$ROOTFS" ]; then 1.192 echo -n "Removing the rootfs..." 1.193 rm -f $DISTRO/$INITRAMFS 1.194 rm -rf $ROOTFS 1.195 status 1.196 fi 1.197 - if [ -d "$ROOTCD" ] ; then 1.198 + if [ -d "$ROOTCD" ]; then 1.199 echo -n "Removing the rootcd..." 1.200 rm -rf $ROOTCD 1.201 status 1.202 @@ -1058,9 +1066,7 @@ 1.203 iso_size=$(($iso_size \ 1.204 + $(zcat $TMP_DIR/$FLAVOR.rootcd | wc -c ) / 100 )) 1.205 fi 1.206 - VERSION="" 1.207 - MAINTAINER="" 1.208 - ROOTFS_SELECTION="" 1.209 + unset VERSION MAINTAINER ROOTFS_SELECTION 1.210 ROOTFS_SIZE="$(cent2human $unpacked_size) (estimated)" 1.211 INITRAMFS_SIZE="$(cent2human $packed_size) (estimated)" 1.212 ISO_SIZE="$(cent2human $iso_size) (estimated)" 1.213 @@ -1213,19 +1219,19 @@ 1.214 # 1.215 check_root 1.216 ISO_IMAGE=$1 1.217 - if [ -z "$ISO_IMAGE" ] ; then 1.218 + if [ -z "$ISO_IMAGE" ]; then 1.219 echo -e "\nPlease specify the path to the ISO image." 1.220 echo -e "Example : `basename $0` image.iso /path/target\n" 1.221 exit 0 1.222 fi 1.223 # Set the distro path by checking for $3 on cmdline. 1.224 - if [ -n "$2" ] ; then 1.225 + if [ -n "$2" ]; then 1.226 TARGET=$2 1.227 else 1.228 TARGET=$DISTRO 1.229 fi 1.230 # Exit if existing distro is found. 1.231 - if [ -d "$TARGET/rootfs" ] ; then 1.232 + if [ -d "$TARGET/rootfs" ]; then 1.233 echo -e "\nA rootfs exists in : $TARGET" 1.234 echo -e "Please clean the distro tree or change directory path.\n" 1.235 exit 0 1.236 @@ -1378,7 +1384,7 @@ 1.237 status 1.238 fi 1.239 # Isolinux msg 1.240 - if grep -q "cooking-XXXXXXXX" /$ROOTCD/boot/isolinux/isolinux.*g; then 1.241 + if grep -q "cooking-XXXXXXXX" $ROOTCD/boot/isolinux/isolinux.*g; then 1.242 echo -n "Isolinux msg : Missing cooking date XXXXXXXX (ex `date +%Y%m%d`)" 1.243 todomsg 1.244 else 1.245 @@ -1903,7 +1909,7 @@ 1.246 # Move each initramfs to squashfs (or cromfs) 1.247 build_loram_rootfs() 1.248 { 1.249 - rootfs_sizes="" 1.250 + unset rootfs_sizes 1.251 for i in $TMP_DIR/iso/boot/rootfs*.gz; do 1.252 mkdir -p $TMP_DIR/fs 1.253 cd $TMP_DIR/fs 1.254 @@ -1980,7 +1986,7 @@ 1.255 set -- $append 1.256 shift 1.257 [ "$1" == "ifmem" ] && shift 1.258 - new="" 1.259 + unset new 1.260 while [ -n "$2" ]; do 1.261 local s 1.262 case "$1" in