$OpenBSD$ index a5f2329..7f93a21 100755 --- tools/update-packaging/common.sh.orig Fri Feb 20 15:40:39 2015 +++ tools/update-packaging/common.sh Fri Feb 20 15:40:39 2015 @@ -9,6 +9,8 @@ # # ----------------------------------------------------------------------------- +QUIET=0 + # By default just assume that these tools exist on our path MAR=${MAR:-mar} BZIP2=${BZIP2:-bzip2} @@ -21,6 +23,12 @@ notice() { echo "$*" 1>&2 } +verbose_notice() { + if [ $QUIET -eq 0 ]; then + notice "$*" + fi +} + get_file_size() { info=($(ls -ln "$1")) echo ${info[4]} @@ -59,16 +67,16 @@ make_add_instruction() { # Use the subdirectory of the extensions folder as the file to test # before performing this add instruction. testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/') - notice " add-if \"$testdir\" \"$f\"" - echo "add-if \"$testdir\" \"$f\"" >> $filev2 - if [ ! $filev3 = "" ]; then - echo "add-if \"$testdir\" \"$f\"" >> $filev3 + verbose_notice " add-if \"$testdir\" \"$f\"" + echo "add-if \"$testdir\" \"$f\"" >> "$filev2" + if [ ! "$filev3" = "" ]; then + echo "add-if \"$testdir\" \"$f\"" >> "$filev3" fi else - notice " add \"$f\"$forced" - echo "add \"$f\"" >> $filev2 - if [ ! $filev3 = "" ]; then - echo "add \"$f\"" >> $filev3 + verbose_notice " add \"$f\"$forced" + echo "add \"$f\"" >> "$filev2" + if [ ! "$filev3" = "" ]; then + echo "add \"$f\"" >> "$filev3" fi fi } @@ -100,8 +108,19 @@ make_add_if_not_instruction() { f="$1" filev3="$2" - notice " add-if-not \"$f\" \"$f\"" - echo "add-if-not \"$f\" \"$f\"" >> $filev3 + verbose_notice " add-if-not \"$f\" \"$f\"" + echo "add-if-not \"$f\" \"$f\"" >> "$filev3" +} + +make_addsymlink_instruction() { + link="$1" + target="$2" + filev2="$3" + filev3="$4" + + verbose_notice " addsymlink: $link -> $target" + echo "addsymlink \"$link\" \"$target\"" >> "$filev2" + echo "addsymlink \"$link\" \"$target\"" >> "$filev3" } make_patch_instruction() { @@ -114,13 +133,13 @@ make_patch_instruction() { # Use the subdirectory of the extensions folder as the file to test # before performing this add instruction. testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/') - notice " patch-if \"$testdir\" \"$f.patch\" \"$f\"" - echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> $filev2 - echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> $filev3 + verbose_notice " patch-if \"$testdir\" \"$f.patch\" \"$f\"" + echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> "$filev2" + echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> "$filev3" else - notice " patch \"$f.patch\" \"$f\"" - echo "patch \"$f.patch\" \"$f\"" >> $filev2 - echo "patch \"$f.patch\" \"$f\"" >> $filev3 + verbose_notice " patch \"$f.patch\" \"$f\"" + echo "patch \"$f.patch\" \"$f\"" >> "$filev2" + echo "patch \"$f.patch\" \"$f\"" >> "$filev3" fi } @@ -163,19 +182,19 @@ append_remove_instructions() { fi fi if [ $(echo "$f" | grep -c '\/$') = 1 ]; then - notice " rmdir \"$fixedprefix$f\"" - echo "rmdir \"$fixedprefix$f\"" >> $filev2 - echo "rmdir \"$fixedprefix$f\"" >> $filev3 + verbose_notice " rmdir \"$fixedprefix$f\"" + echo "rmdir \"$fixedprefix$f\"" >> "$filev2" + echo "rmdir \"$fixedprefix$f\"" >> "$filev3" elif [ $(echo "$f" | grep -c '\/\*$') = 1 ]; then # Remove the * f=$(echo "$f" | sed -e 's:\*$::') - notice " rmrfdir \"$fixedprefix$f\"" - echo "rmrfdir \"$fixedprefix$f\"" >> $filev2 - echo "rmrfdir \"$fixedprefix$f\"" >> $filev3 + verbose_notice " rmrfdir \"$fixedprefix$f\"" + echo "rmrfdir \"$fixedprefix$f\"" >> "$filev2" + echo "rmrfdir \"$fixedprefix$f\"" >> "$filev3" else - notice " remove \"$fixedprefix$f\"" - echo "remove \"$fixedprefix$f\"" >> $filev2 - echo "remove \"$fixedprefix$f\"" >> $filev3 + verbose_notice " remove \"$fixedprefix$f\"" + echo "remove \"$fixedprefix$f\"" >> "$filev2" + echo "remove \"$fixedprefix$f\"" >> "$filev3" fi fi fi @@ -185,6 +204,10 @@ append_remove_instructions() { # List all files in the current directory, stripping leading "./" # Pass a variable name and it will be filled as an array. +# To support Tor Browser updates, skip the following files: +# TorBrowser/Data/Browser/profiles.ini +# TorBrowser/Data/Browser/profile.default/bookmarks.html +# TorBrowser/Data/Tor/torrc list_files() { count=0 @@ -197,6 +220,11 @@ list_files() { | sed 's/\.\/\(.*\)/\1/' \ | sort -r > "temp-filelist" while read file; do + if [ "$file" = "TorBrowser/Data/Browser/profiles.ini" -o \ + "$file" = "TorBrowser/Data/Browser/profile.default/bookmarks.html" -o \ + "$file" = "TorBrowser/Data/Tor/torrc" ]; then + continue; + fi eval "${1}[$count]=\"$file\"" (( count++ )) done < "temp-filelist" @@ -218,3 +246,19 @@ list_dirs() { done < "temp-dirlist" rm "temp-dirlist" } + +# List all symbolic links in the current directory, stripping leading "./" +list_symlinks() { + count=0 + + find . -type l \ + | sed 's/\.\/\(.*\)/\1/' \ + | sort -r > "temp-symlinklist" + while read symlink; do + target=$(readlink "$symlink") + eval "${1}[$count]=\"$symlink\"" + eval "${2}[$count]=\"$target\"" + (( count++ )) + done < "temp-symlinklist" + rm "temp-symlinklist" +}