Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From b6baef10369cb6fdd1980968845535addbe8ef05 Mon Sep 17 00:00:00 2001
- From: Brli <brli@chakralinux.org>
- Date: Wed, 18 Oct 2023 17:56:21 +0800
- Subject: [PATCH] pkgre +1
- 1. replace variables with built-in ones
- 2. determine mode of files in package() phase instead of git repository
- 3. sed files in prepare() phase
- 4. complementary with shellcheck
- 5. directly install to files instead of create directory then install
- 6. change from tab to space
- 7. replace architecture-specific variables with $CARCH
- ---
- .SRCINFO | 17 ++++------
- PKGBUILD | 91 ++++++++++++++++++++------------------------------
- tor-browser.in | 35 +++++++++++--------
- 3 files changed, 64 insertions(+), 79 deletions(-)
- mode change 100755 => 100644 tor-browser.in
- diff --git a/.SRCINFO b/.SRCINFO
- index 60b16d6..e07bdb8 100644
- --- a/.SRCINFO
- +++ b/.SRCINFO
- @@ -1,7 +1,7 @@
- pkgbase = tor-browser-bin
- pkgdesc = Tor Browser Bundle: anonymous browsing using Firefox and Tor
- pkgver = 13.0
- - pkgrel = 2
- + pkgrel = 3
- url = https://www.torproject.org/projects/torbrowser.html
- install = tor-browser.install
- arch = i686
- @@ -28,24 +28,19 @@ pkgbase = tor-browser-bin
- optdepends = libnotify: Gnome dialog boxes
- provides = tor-browser
- conflicts = tor-browser
- - noextract = tor-browser-linux-i686-13.0.tar.xz
- noextract = tor-browser-linux-x86_64-13.0.tar.xz
- + source = https://dist.torproject.org/torbrowser/13.0/tor-browser-linux-x86_64-13.0.tar.xz
- + source = https://dist.torproject.org/torbrowser/13.0/tor-browser-linux-x86_64-13.0.tar.xz.asc
- source = tor-browser.desktop.in
- source = tor-browser.in
- source = tor-browser.png
- source = tor-browser.svg
- validpgpkeys = EF6E286DDA85EA2A4BA7DE684E2C6E8793298290
- + sha256sums = cdd98f6e6268e450e83a3a1bfbd4c30af0a02a02c7bcb8b76ce32171983c0d53
- + sha256sums = SKIP
- sha256sums = 5dd2b61bd4edf4d1499a81127f97a1de7ec272a885df97331b61969a5a07f05f
- - sha256sums = 1143d23e347605b498b3793992e84e95563efd94aa4da17837b37104a6d4a090
- + sha256sums = 41895ac8bd074af57579d9dece1ea66b9c3905d8395d66a5590c6dad554e0199
- sha256sums = f25ccf68b47f5eb14c6fec0664c74f30ea9c6c58d42fc6abac3b64670aaa3152
- sha256sums = 7b28b5dbe8ad573bb46e61b4d542b33e01ca240825ca640b4893fee6203b021f
- - source_i686 = https://dist.torproject.org/torbrowser/13.0/tor-browser-linux-i686-13.0.tar.xz
- - source_i686 = https://dist.torproject.org/torbrowser/13.0/tor-browser-linux-i686-13.0.tar.xz.asc
- - sha256sums_i686 = 1e5bf1d82e0317fc1c1e8f444be83d51480d1460e8916e4e017dc578ebd1f9f6
- - sha256sums_i686 = SKIP
- - source_x86_64 = https://dist.torproject.org/torbrowser/13.0/tor-browser-linux-x86_64-13.0.tar.xz
- - source_x86_64 = https://dist.torproject.org/torbrowser/13.0/tor-browser-linux-x86_64-13.0.tar.xz.asc
- - sha256sums_x86_64 = cdd98f6e6268e450e83a3a1bfbd4c30af0a02a02c7bcb8b76ce32171983c0d53
- - sha256sums_x86_64 = SKIP
- pkgname = tor-browser-bin
- diff --git a/PKGBUILD b/PKGBUILD
- index 076aefe..a7023f2 100644
- --- a/PKGBUILD
- +++ b/PKGBUILD
- @@ -1,3 +1,4 @@
- +# shellcheck disable=SC2034
- # Maintainer: grufo <madmurphy333 AT gmail DOT com>
- # Maintainer: Sebastian Jug <seb AT stianj DOT ug>
- # Contributor: midgard <arch.midgard AT janmaes DOT com>
- @@ -19,96 +20,76 @@
- _appname='tor-browser'
- pkgname="${_appname}-bin"
- pkgver='13.0'
- -pkgrel=2
- +pkgrel=3
- pkgdesc='Tor Browser Bundle: anonymous browsing using Firefox and Tor'
- url='https://www.torproject.org/projects/torbrowser.html'
- arch=('i686' 'x86_64')
- license=('GPL')
- depends=('libxt' 'startup-notification' 'mime-types' 'dbus-glib'
- - 'alsa-lib' 'desktop-file-utils' 'hicolor-icon-theme'
- - 'libvpx' 'icu' 'libevent' 'nss' 'hunspell' 'sqlite')
- + 'alsa-lib' 'desktop-file-utils' 'hicolor-icon-theme'
- + 'libvpx' 'icu' 'libevent' 'nss' 'hunspell' 'sqlite')
- optdepends=('zenity: simple dialog boxes'
- - 'kdialog: KDE dialog boxes'
- - 'gst-plugins-good: H.264 video'
- - 'gst-libav: H.264 video'
- - 'libpulse: PulseAudio audio driver'
- - 'libnotify: Gnome dialog boxes')
- + 'kdialog: KDE dialog boxes'
- + 'gst-plugins-good: H.264 video'
- + 'gst-libav: H.264 video'
- + 'libpulse: PulseAudio audio driver'
- + 'libnotify: Gnome dialog boxes')
- provides=("${_appname}")
- conflicts=("${_appname}")
- install="${_appname}.install"
- validpgpkeys=('EF6E286DDA85EA2A4BA7DE684E2C6E8793298290')
- -_tag_i686='linux-i686'
- -_tag_x86_64='linux-x86_64'
- _urlbase="https://dist.torproject.org/torbrowser/${pkgver}"
- -_archstr=$([[ "${CARCH}" == 'x86_64' ]] && echo -n "${_tag_x86_64}" || echo -n "${_tag_i686}")
- # Syntax: _dist_checksum 'linux-i686'/'linux-x86_64'
- _dist_checksum() {
- -
- - (curl --silent --fail "${_urlbase}/sha256sums-signed-build.txt" || \
- - curl --silent --fail "${_urlbase}/sha256sums-unsigned-build.txt") | \
- - awk "/${_appname}-${1}-${pkgver}.tar.xz$/"'{print $1}'
- + (curl --silent --fail "${_urlbase}/sha256sums-signed-build.txt" || \
- + curl --silent --fail "${_urlbase}/sha256sums-unsigned-build.txt") | \
- + awk "/${_appname}-${1}-${pkgver}.tar.xz$/"'{print $1}'
- }
- # Make a string suitable for `sed`, by escaping `[]/&$.*^\` - syntax: `_sed_escape STRING`
- _sed_escape() {
- - echo "${1}" | sed 's/[]\/&.*$^[]/\\&/g'
- + echo "${1}" | sed 's/[]\/&.*$^[]/\\&/g'
- }
- -source_i686=("${_urlbase}/${_appname}-${_tag_i686}-${pkgver}.tar.xz"{,.asc})
- -source_x86_64=("${_urlbase}/${_appname}-${_tag_x86_64}-${pkgver}.tar.xz"{,.asc})
- -source=("${_appname}.desktop.in"
- - "${_appname}.in"
- - "${_appname}.png"
- - "${_appname}.svg")
- +source=("${_urlbase}/${_appname}-linux-${CARCH}-${pkgver}.tar.xz"{,.asc}
- + "${_appname}.desktop.in"
- + "${_appname}.in"
- + "${_appname}.png"
- + "${_appname}.svg")
- ### IMPORTANT #################################################################
- # No need for `makepkg -g`: the following sha256sums¸don't need to be updated #
- # with each release, everything is done automatically! Leave them like this! #
- ###############################################################################
- -sha256sums=('5dd2b61bd4edf4d1499a81127f97a1de7ec272a885df97331b61969a5a07f05f'
- - '1313484fc0572d82067f5671327540fcab6747fd2d187f216e1fc8edf3581509'
- +sha256sums=("$(_dist_checksum linux-${CARCH})"
- + 'SKIP'
- + '5dd2b61bd4edf4d1499a81127f97a1de7ec272a885df97331b61969a5a07f05f'
- + '41895ac8bd074af57579d9dece1ea66b9c3905d8395d66a5590c6dad554e0199'
- 'f25ccf68b47f5eb14c6fec0664c74f30ea9c6c58d42fc6abac3b64670aaa3152'
- '7b28b5dbe8ad573bb46e61b4d542b33e01ca240825ca640b4893fee6203b021f')
- -sha256sums_i686=("$(_dist_checksum "${_tag_i686}")"
- - 'SKIP')
- -sha256sums_x86_64=("$(_dist_checksum "${_tag_x86_64}")"
- - 'SKIP')
- -
- -noextract=("${_appname}-${_tag_i686}-${pkgver}.tar.xz"
- - "${_appname}-${_tag_x86_64}-${pkgver}.tar.xz")
- -
- -package() {
- - cd "${srcdir}"
- +noextract=("${_appname}-linux-${CARCH}-${pkgver}.tar.xz")
- - local _sed_subst="
- - s/@PACKAGE_NAME@/$(_sed_escape "${_appname}")/g
- - s/@PACKAGE_VERSION@/$(_sed_escape "${pkgver}")/g
- - s/@PACKAGE_RELEASE@/$(_sed_escape "${pkgrel}")/g
- - s/@PACKAGE_ARCH@/$(_sed_escape "${_archstr}")/g
- - "
- +prepare() {
- + sed -i "s/@PACKAGE_NAME@/${_appname}/g
- + s/@PACKAGE_VERSION@/${pkgver}/g
- + s/@PACKAGE_RELEASE@/${pkgrel}/g
- + s/@PACKAGE_ARCH@/linux-${CARCH}/g" "${_appname}"{,.desktop}.in
- +}
- - install -dm755 "${pkgdir}/usr/bin"
- - sed "${_sed_subst}" "${_appname}.in" > "${pkgdir}/usr/bin/${_appname}"
- - chmod +x "${pkgdir}/usr/bin/${_appname}"
- +package() {
- + install -Dm755 "${srcdir}/${_appname}.in" "${pkgdir}/usr/bin/${_appname}"
- - install -dm755 \
- - "${pkgdir}/usr/share/icons/hicolor/scalable/apps" \
- - "${pkgdir}/usr/share/icons/hicolor/128x128/apps"
- + install -Dm644 "${srcdir}/${_appname}.png" "${pkgdir}/usr/share/icons/hicolor/128x128/apps/${_appname}.png"
- + install -Dm644 "${srcdir}/${_appname}.svg" "${pkgdir}/usr/share/icons/hicolor/scalable/apps/${_appname}.svg"
- - install -Dm644 "${srcdir}/${_appname}.png" "${pkgdir}/usr/share/icons/hicolor/128x128/apps/${_appname}.png"
- - install -Dm644 "${srcdir}/${_appname}.svg" "${pkgdir}/usr/share/icons/hicolor/scalable/apps/${_appname}.svg"
- + install -Dm644 "${srcdir}/${_appname}.desktop.in" "${pkgdir}/usr/share/applications/${_appname}.desktop"
- - install -dm755 "${pkgdir}/usr/share/applications"
- - sed "${_sed_subst}" "${_appname}.desktop.in" > \
- - "${pkgdir}/usr/share/applications/${_appname}.desktop"
- - install -Dm444 "${_appname}-${_archstr}-${pkgver}.tar.xz" \
- - "${pkgdir}/opt/${_appname}/${_appname}-${_archstr}-${pkgver}.tar.xz"
- + install -Dm444 "${_appname}-linux-${CARCH}-${pkgver}.tar.xz" \
- + "${pkgdir}/opt/${_appname}/${_appname}-linux-${CARCH}-${pkgver}.tar.xz"
- }
- -
- -
- diff --git a/tor-browser.in b/tor-browser.in
- old mode 100755
- new mode 100644
- index ebdaf5d..4dee26e
- --- a/tor-browser.in
- +++ b/tor-browser.in
- @@ -59,9 +59,11 @@ _inform_() {
- # syntax: _notify_ "${TITLE}" "${MESSAGE}"
- _notify_() {
- - which notify-send 2>/dev/null && notify-send \
- - --app-name="${_TB_PKGNAME_}" --icon="${_TB_PKGNAME_}" "${1}" \
- - "${2}" || echo -e "${0}: [${1}] ${2}" >&2
- + if ! notify-send --app-name="${_TB_PKGNAME_}" \
- + --icon="${_TB_PKGNAME_}" "${1}" "${2}"
- + then
- + echo -e "${0}: [${1}] ${2}" >&2
- + fi
- }
- @@ -71,7 +73,7 @@ _compare_ver_() {
- [[ "${1}" != "${2}" ]] || return 1
- - [[ "${1}" == "`echo -e "${1}\n${2}" | sort -V | head -n1`" ]]
- + [[ "${1}" == "$(echo -e "${1}\n${2}" | sort -V | head -n1)" ]]
- }
- @@ -84,18 +86,22 @@ _refresh_local_() {
- local DIR_IS_KEPT=0
- if [[ -d "${KEEP_DIR}" ]]; then
- - [[ -d "${KEPT_DIR}" ]] && rm -rf "${KEPT_DIR}" || mkdir -p "${CACHE_DIR}"
- + if [[ -d "${KEPT_DIR}" ]]; then
- + rm -rf "${KEPT_DIR}"; else
- + mkdir -p "${CACHE_DIR}"
- + fi
- mv "${KEEP_DIR}" "${KEPT_DIR}"
- echo "${0}: Preserving files in ${KEPT_DIR}/." >> "${_TB_LOG_FILE_}"
- DIR_IS_KEPT=1
- fi
- echo "${0}: Extracting files to ${_TB_APP_DIR_}." >> "${_TB_LOG_FILE_}"
- - rm -rf "${_TB_APP_DIR_}"/*
- + rm -rf "${_TB_APP_DIR_:?}"/*
- tar -xJf "/opt/${_TB_PKGNAME_}/tor-browser-${_TB_ARCH_}-${_TB_VERSION_}.tar.xz" \
- --strip-components=1 -C "${_TB_APP_DIR_}" >> \
- - "${_TB_LOG_FILE_}" 2>&1 && _notify_ 'Tor Browser' \
- + "${_TB_LOG_FILE_}" 2>&1
- + _notify_ 'Tor Browser' \
- 'A new version of Tor Browser has been installed' || \
- _inform_ 'Error' \
- "The tor-browser archive could not be extracted to your home directory. \
- @@ -121,7 +127,8 @@ _aur_update_() {
- fi
- local DO_UPDATE=0
- - local TMP_PKGBUILD="$(mktemp -d)"
- + local TMP_PKGBUILD
- + TMP_PKGBUILD="$(mktemp -d)"
- cd "${TMP_PKGBUILD}"
- @@ -133,15 +140,17 @@ _aur_update_() {
- cd "${TMP_PKGBUILD}/${_TB_PKGNAME_}"
- - local AUR_VERSION="$(grep 'pkgver' '.SRCINFO' | cut -d = -f2 | sed -e 's/^[[:space:]]*//')"
- - local AUR_RELEASE="$(grep 'pkgrel' '.SRCINFO' | cut -d = -f2 | sed -e 's/^[[:space:]]*//')"
- + local AUR_VERSION
- + local AUR_RELEASE
- + AUR_VERSION="$(grep 'pkgver' '.SRCINFO' | cut -d = -f2 | sed -e 's/^[[:space:]]*//')"
- + AUR_RELEASE="$(grep 'pkgrel' '.SRCINFO' | cut -d = -f2 | sed -e 's/^[[:space:]]*//')"
- if _compare_ver_ "${_TB_VERSION_}" "${AUR_VERSION}"; then
- echo "Found new version (${_TB_VERSION_} -> ${AUR_VERSION})..."
- DO_UPDATE=1
- elif [[ "${_TB_VERSION_}" == "${AUR_VERSION}" ]] && \
- [[ "${_TB_RELEASE_}" != "${AUR_RELEASE}" ]] && \
- - [[ "${_TB_RELEASE_}" == "`echo -e "${_TB_RELEASE_}\n${AUR_RELEASE}" | sort | head -n1`" ]]; then
- + [[ "${_TB_RELEASE_}" == "$(echo -e "${_TB_RELEASE_}\n${AUR_RELEASE}" | sort | head -n1)" ]]; then
- echo 'Found new PKGBUILD...'
- DO_UPDATE=1
- else
- @@ -200,14 +209,14 @@ _TB_APP_DIR_="${_TB_HOME_DIR_}/app"
- cd "${_TB_HOME_DIR_}"
- # get the installed version
- -while read _TB_VER_LINE_; do
- +while read -r _TB_VER_LINE_; do
- _TB_INSTALLED_VERSION_="${_TB_VER_LINE_}"
- done < "${_TB_VER_FILE_}"
- # start update if old or no tor-browser is installed
- if [[ "${_TB_INSTALLED_VERSION_}" == "${_TB_VERSION_}" ]] && [[ ${_TB_REFRESH_} -eq 0 ]]; then
- # clear log
- - > "${_TB_LOG_FILE_}"
- + :>| "${_TB_LOG_FILE_}"
- else
- echo "${0}: Your version in ${_TB_HOME_DIR_} is outdated or you do not have installed ${_TB_PKGNAME_} yet." > "${_TB_LOG_FILE_}"
- _refresh_local_
- --
- 2.42.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement