catchup with lots of updates
[buildscripts] / tor-browser
index 9b3212cbc7330e7081bb9319f37894e3a5d38e25..9883473c3e09071b25d468aedb5c13a73756dbb2 100755 (executable)
@@ -39,42 +39,51 @@ vers=($(printf "%s\n" "$c" | sed -rn 's#.*href="([0-9]+\.[0-9]+[.0-9]*)/.*#\1#p'
 
 cd /a/opt
 
-ver=${vers[0]}
 dl() {
-  f=tor-browser-linux64-${ver}_en-US.tar.xz
+  f=tor-browser-linux64-${ver}_ALL.tar.xz
   if [[ -e $f ]]; then
     timestamp=$(stat -c %Y $f)
   else
     timestamp=0
   fi
+  ret=0
   echo wget -nv -N https://www.torproject.org/dist/torbrowser/$ver/$f
   wget -nv -N https://www.torproject.org/dist/torbrowser/$ver/$f || ret=$?
 }
-dl
-# 8 is return code for 404. for a new release, they might not have released to linux yet.
-if [[ $ret == 8 ]]; then
-  ver=${vers[1]}
+
+# some releases are for specific non-gnu oses
+for ((i=0; i<${#vers[@]}; i++)); do
+  ver=${vers[i]}
   dl
-fi
+  # 8 is return code for 404.
+  if [[ $ret != 8 ]]; then
+    break
+  fi
+done
 
 new_timestamp=$(stat -c %Y $f)
-if [[ $timestamp != $new_timestamp || ! -e /a/opt/tor-browser_en-US/Browser/start-tor-browser ]]; then
+if [[ $timestamp != $new_timestamp || ! -e /a/opt/tor-browser/Browser/start-tor-browser ]]; then
   # not already installed
-  rm -rf tor-browser_en-US
+  rm -rf tor-browser
   tar Jxf $f
 
+
+
   ## begin handlers customization
-  dest=/a/opt/tor-browser_en-US/Browser/TorBrowser/Data/Browser/profile.default/handlers.json
-  orig=/p/c/tor-handlers-orig.json
-  src=/p/c/tor-handlers.json
-  if diff -q $src $dest; then
-    echo "Error: handlers file changed. adjust based on upstream"
-    exit 1
-  fi
-  cp $src $dest
+  ## the default file doesn't exist anymore. i customized it to open magnet links,
+  ## it might work with removing the default stuff and keeping the magnet link part,
+  ## but I'd have to test and I don't care that much.
+  # dest=/a/opt/tor-browser/Browser/TorBrowser/Data/Browser/profile.default/handlers.json
+  # orig=/p/c/tor-handlers-orig.json
+  # src=/p/c/tor-handlers.json
+  # if ! diff -q $src $dest &>/dev/null; then
+  #   echo "Error: handlers file changed. adjust based on upstream"
+  #   exit 1
+  # fi
+  # cp $src $dest
   ## end handlers customization
 
-  cp /p/c/tor-user.js /a/opt/tor-browser_en-US/Browser/TorBrowser/Data/Browser/profile.default/user.js
+  cp /p/c/tor-user.js /a/opt/tor-browser/Browser/TorBrowser/Data/Browser/profile.default/user.js
 
 fi