diff options
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 9 | ||||
-rwxr-xr-x | tor-browser.sh | 129 |
3 files changed, 96 insertions, 46 deletions
@@ -1,7 +1,7 @@ pkgbase = tor-browser pkgdesc = Tor Browser Bundle: Anonymous browsing using firefox and tor (language-agnostic PKGBUILD) pkgver = 7.0.2 - pkgrel = 1 + pkgrel = 2 url = https://www.torproject.org/projects/torbrowser.html install = tor-browser.install arch = i686 @@ -38,7 +38,7 @@ pkgbase = tor-browser md5sums = f294787c2d7993b2f6022e6014e582e7 md5sums = ef1de5f4e269f1084f20122d2703e954 md5sums = 494afbfa60fb4ce21840244cc3f7208c - md5sums = 3ef08aff0e2afebb1a2a7ffbf8f65897 + md5sums = 89c79b0578782225b7a8ae1dedcc3365 source_i686 = https://dist.torproject.org/torbrowser/7.0.2/tor-browser-linux32-7.0.2_en-US.tar.xz source_i686 = https://dist.torproject.org/torbrowser/7.0.2/tor-browser-linux32-7.0.2_en-US.tar.xz.asc md5sums_i686 = SKIP @@ -12,7 +12,7 @@ pkgname='tor-browser' pkgver='7.0.2' -pkgrel=1 +pkgrel=2 pkgdesc='Tor Browser Bundle: Anonymous browsing using firefox and tor (language-agnostic PKGBUILD)' url='https://www.torproject.org/projects/torbrowser.html' arch=('i686' 'x86_64') @@ -75,9 +75,9 @@ source=("${pkgname}.desktop" "${pkgname}.sh") md5sums=('f294787c2d7993b2f6022e6014e582e7' - 'ef1de5f4e269f1084f20122d2703e954' - '494afbfa60fb4ce21840244cc3f7208c' - '3ef08aff0e2afebb1a2a7ffbf8f65897') + 'ef1de5f4e269f1084f20122d2703e954' + '494afbfa60fb4ce21840244cc3f7208c' + '89c79b0578782225b7a8ae1dedcc3365') md5sums_i686=('SKIP' 'SKIP') md5sums_x86_64=('SKIP' @@ -94,6 +94,7 @@ package() { sed -i "s/REPL_NAME/${pkgname}/g" "${pkgname}.sh" sed -i "s/REPL_VERSION/${pkgver}/g" "${pkgname}.sh" + sed -i "s/REPL_RELEASE/${pkgrel}/g" "${pkgname}.sh" sed -i "s/REPL_LANGUAGE/${_language}/g" "${pkgname}.sh" install -Dm 644 "${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop" diff --git a/tor-browser.sh b/tor-browser.sh index 288b7561ec2e..d54faa917191 100755 --- a/tor-browser.sh +++ b/tor-browser.sh @@ -4,6 +4,7 @@ # Copyright (C) 2012 Alessio Sergi <al3hex at gmail dot com> # modified 2012 for tor-browser (Max Roder <maxroder at web dot de>) # modified 2014 by Yardena Cohen <yardenack at gmail dot com> +# modified 2017 by grufo <madmurphy333 at gmail dot com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,45 +22,86 @@ set -e # filled by the PKGBUILD -NAME='REPL_NAME' -VERSION='REPL_VERSION' -LANGUAGE="REPL_LANGUAGE" +TB_PKGNAME='REPL_NAME' +TB_VERSION='REPL_VERSION' +TB_RELEASE='REPL_RELEASE' +TB_LANGUAGE="REPL_LANGUAGE" ARCH=$(getconf LONG_BIT) notify() { - local title="$1" - local message="$2" - - if [ $(which zenity 2>/dev/null) ]; then - zenity --info --title "$title" --text "$message" - elif [ $(which notify-send 2>/dev/null) ]; then - notify-send "$title" "$message" - elif [ $(which kdialog 2>/dev/null) ]; then - kdialog --title "$title" --passivepopup "$message" - else - echo -e "$0: [$title] $message" >&2 - fi + local title="${1}" + local message="${2}" + + if [ $(which zenity 2>/dev/null) ]; then + zenity --info --title "${title}" --text "${message}" + elif [ $(which notify-send 2>/dev/null) ]; then + notify-send "${title}" "${message}" + elif [ $(which kdialog 2>/dev/null) ]; then + kdialog --title "${title}" --passivepopup "${message}" + else + echo -e "${0}: [${title}] ${message}" >&2 + fi +} + +compare_versions() { + [ "${1}" = "${2}" ] && return 1 || [ "${1}" = "`echo -e "${1}\n${2}" | sort -V | head -n1`" ] } update() { - echo "$0: Extracting files to $INSTALL_DIRECTORY." >> $LOG_FILE - rm -rf $INSTALL_DIRECTORY/* - tar --strip-components=1 -xJf /opt/$NAME/tor-browser-linux${ARCH}-${VERSION}_${LANGUAGE}.tar.xz \ - -C $INSTALL_DIRECTORY >> $LOG_FILE 2>&1 || notify "Error" \ + echo "${0}: Extracting files to ${TB_APP_DIR}." >> "${TB_LOG_FILE}" + rm -rf "${TB_APP_DIR}"/* + tar --strip-components=1 -xJf "/opt/${TB_PKGNAME}/tor-browser-linux${ARCH}-${TB_VERSION}_${TB_LANGUAGE}.tar.xz" \ + -C "${TB_APP_DIR}" >> "${TB_LOG_FILE}" 2>&1 || notify "Error" \ "The tor-browser archive could not be extracted to your home directory. \ - \nCheck permissions of $INSTALL_DIRECTORY. \ - \nThe error log can be found in $LOG_FILE." + \nCheck permissions of ${TB_APP_DIR}. \ + \nThe error log can be found in ${TB_LOG_FILE}." + + [[ -f "${TB_APP_DIR}/Browser/start-tor-browser" ]] && echo "${TB_VERSION}" > "${TB_VER_FILE}" +} + +aur_update() { + + local DO_UPDATE='0' + local TMP_PKGBUILD="$(mktemp -d)" + + if [ "$(id -u)" == '0' ]; then + echo 'It is not a good idea to do this as root. Abort.' 1>&2 + exit 1 + fi + + cd "${TMP_PKGBUILD}" + + curl --silent "https://aur.archlinux.org/cgit/aur.git/snapshot/${TB_PKGNAME}.tar.gz" | tar xz + + cd "${TMP_PKGBUILD}/${TB_PKGNAME}" + + local NEW_VERSION="$(grep 'pkgver' '.SRCINFO' | cut -d = -f2 | sed -e 's/^[[:space:]]*//')" + local NEW_RELEASE="$(grep 'pkgrel' '.SRCINFO' | cut -d = -f2 | sed -e 's/^[[:space:]]*//')" + + if compare_versions ${TB_VERSION} ${NEW_VERSION}; then + echo 'Found new version.' + local DO_UPDATE='1' + elif [ "${TB_VERSION}" == "${NEW_VERSION}" ] && [ "${TB_RELEASE}" != "${NEW_RELEASE}" ] && [ "${TB_RELEASE}" = "`echo -e "${TB_RELEASE}\n${NEW_RELEASE}" | sort | head -n1`" ]; then + echo 'Found new PKGBUILD release.' + local DO_UPDATE='1' + else + echo 'Everything is up to date' + fi + + [ "${DO_UPDATE}" == '1' ] && makepkg -si + + rm -rf "${TMP_PKGBUILD}" - [[ -f $INSTALL_DIRECTORY/Browser/start-tor-browser ]] && echo $VERSION > $VERSION_FILE } usage() { - cat <<EOF + cat <<EOF Usage: ${0##*/} [option] Options: -h|--help Show this help message and exit + -a|--aurupdate Search for a new release on Arch User Repository (AUR) and install it -u|--update Force update of the copy in your home directory --dir=<directory> The Tor-Browser directory to use @@ -67,42 +109,49 @@ Options: EOF } -DIRECTORY=~/.$NAME +DIRECTORY=~/.${TB_PKGNAME} + +# remove old INSTALL directory (temporary command to be removed in the next versions) +if [ -d "${DIRECTORY}/INSTALL" ]; then + rm -rf "${DIRECTORY}" +fi + args=() for arg; do - case "$arg" in - -h|--help) usage; exit 0 ;; + case "${arg}" in + -h|--help) usage; exit 0 ;; + -a|--aurupdate) aur_update; exit 0 ;; -u|--update) update=1 ;; - --dir=*) DIRECTORY="${arg#*=}" ;; + --dir=*) DIRECTORY="${arg#*=}" ;; *) args+=("$arg") ;; esac done -INSTALL_DIRECTORY=$DIRECTORY/INSTALL -VERSION_FILE=$DIRECTORY/VERSION -LOG_FILE=$DIRECTORY/LOG +TB_APP_DIR="${DIRECTORY}/APP" +TB_VER_FILE="${DIRECTORY}/VERSION" +TB_LOG_FILE="${DIRECTORY}/LOG" # create directory, if it is missing (e.g. first run) -[[ ! -d "$INSTALL_DIRECTORY" ]] && mkdir -p "$INSTALL_DIRECTORY" -cd "$DIRECTORY" +[[ ! -d "${TB_APP_DIR}" ]] && mkdir -p "${TB_APP_DIR}" +cd "${DIRECTORY}" # create version file if missing -[[ ! -f $VERSION_FILE ]] && echo 0 > $VERSION_FILE +[[ ! -f "${TB_VER_FILE}" ]] && echo 0 > "${TB_VER_FILE}" -#get installed version +# get installed version while read line do - INSTALLED_VERSION=$line -done < $VERSION_FILE + TB_INSTALLED_VERSION="${line}" +done < ${TB_VER_FILE} # start update if old or no tor-browser is installed -if [[ "$INSTALLED_VERSION" == "$VERSION" ]] && [[ $update != 1 ]]; then +if [[ "${TB_INSTALLED_VERSION}" == "${TB_VERSION}" ]] && [[ ${update} != 1 ]]; then # clear log - > $LOG_FILE + > "${TB_LOG_FILE}" else - echo "$0: Your version in $DIRECTORY is outdated or you do not have installed $NAME yet." > $LOG_FILE + echo "${0}: Your version in ${DIRECTORY} is outdated or you do not have installed ${TB_PKGNAME} yet." > "${TB_LOG_FILE}" update fi # start tor-browser -cd $INSTALL_DIRECTORY/Browser && ./start-tor-browser "${args[@]}" +cd "${TB_APP_DIR}/Browser" && ./start-tor-browser "${args[@]}" |