diff options
author | Einhard Leichtfuß <alguien@respiranto.de> | 2022-04-29 14:58:55 +0200 |
---|---|---|
committer | Einhard Leichtfuß <alguien@respiranto.de> | 2022-04-29 14:58:55 +0200 |
commit | 915faab9c074a0a30b8321c3836d0b35f475e94d (patch) | |
tree | 522b4109f2d43ff06db001b329ec1e09884cf6c8 /update.sh | |
parent | 90a0069d9bb72bf3caf59e2411a144f9e3afd2d3 (diff) |
Use proper .bash suffix
Diffstat (limited to 'update.sh')
-rwxr-xr-x | update.sh | 211 |
1 files changed, 0 insertions, 211 deletions
diff --git a/update.sh b/update.sh deleted file mode 100755 index f011164..0000000 --- a/update.sh +++ /dev/null @@ -1,211 +0,0 @@ -#!/usr/bin/env bash -# -# update.sh - script to check for updates and perform them (on the PKGBUILDs) -# -# Copyright 2018,2022 Einhard Leichtfuß -# -# This file is part of aur-fd-scripts -# -# aur-fd-scripts is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# aur-fd-scripts is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with aur-fd-scripts. If not, see <https://www.gnu.org/licenses/>. -# - -# usage: $0 dir type [--nopull] [-u xyz-uvw|-ua|-uaf] -# $1 base directory: string -# $2 type: (src|bin|svn) -# $4 option: --nopull {can be omitted} -# ${4,5} update force mode: (-u lang1-lang2|-ua|-uaf) {can be omitted} -# -u x: Update x, even if it appears up to date. -# -ua: Update all that are out of date. -# -uaf: Update all, even if they appear up to date. - - -script_path="$(realpath "$0")" -script_dir="${script_path%/*}" - -. "${script_dir}/basic.sh" || exit 1 - - -function main -{ - if [ "$#" -lt 2 ] - then - echo "Usage: $0 <base_dir> <type> [--nopull] [-u <xy>-<zw>|-ua|-uaf]" >&2 - exit 1 - else - cd "$1" || exit 1 - fi - - type="$2" - - if [ "$3" = "--nopull" ] - then - nopull=true - shift 3 - else - nopull=false - shift 2 - fi - - - init - if [[ "$type" == src ]] - then - handle_all src '' src "$@" - elif [[ "$type" == bin ]] - then - handle_all bin -bin dictd "$@" - elif [[ "$type" == svn ]] - then - handle_all_vcs svn -svn "$@" - else - echo "Type ${type} not supported." >&2 - exit 1 - fi -} - - -# Update PKGBUILD and .SRCINFO -# -# requires: $lang, $ext, $type, $ver, $convver to be set; -# $PWD == <base directory>/<type>/<lang> -# -function update -{ - echo "Updating ${lang}${ext} (${pkgver} -> ${convver})..." - - lang_a="${long[${lang%-*}]}" - lang_b="${long[${lang#*-}]}" - - input "${script_dir}/${type}/sample.PKGBUILD" - - replace '%MAINTAINER%' "$maintainer" - replace '%LANG%' "$lang" - replace '%LANG_A%' "$lang_a" - replace '%LANG_B%' "$lang_b" - replace '%VER%' "$convver" - replace '%LICENSES%' "${licenses[$lang]}" - replace '%CHECKSUM%' "$checksum" - - replace_line '%CONTRS%' "${contrs[${lang}${ext}]}" normal - - if [[ "$ver" == "$convver" ]] - then - delete_line '^_pkgver=\$\{pkgver\/\/_\/-\}$' - replace '_pkgver' 'pkgver' - fi - - replace_line '%PREPARE%' "${prepare[${lang}${ext}]}" rm-plus-one - - write PKGBUILD - makepkg --printsrcinfo > .SRCINFO -} - - -# Check for updates for src / bin packages and optionally update them. -# -# $1 type: (src|bin) -# $2 suffix: (|-bin) -# $3 platform: (src|dictd) -# ${@:4} args: $@ -# -# requires: $PWD == <base directory> -# -function handle_all -{ - type="$1" - ext="$2" - platform="$3" - shift 3 - - curl -sSO https://freedict.org/freedict-database.json || exit 1 - - cd "$type" || exit 1 - - for lang in ${langs[@]} - do - cd $lang || exit 1 - $nopull || git pull -q - pkgver="$(sed -En 's/\s*pkgver\s*=\s*(.+)\s*/\1/p' .SRCINFO)" - data="$(jq -r ".[] | select(.name == \"${lang}\") | .releases[] | select(.platform==\"${platform}\")" ../../freedict-database.json)" - ver="$(jq -r '.version' <<< "$data")" - url="$(jq -r '.URL' <<< "$data")" - checksum="$(jq -r '.checksum' <<< "$data")" - convver="${ver//-/_}" - - if [[ "$pkgver" != "$convver" ]] - then - echo "${lang}${ext} requires update (${pkgver} -> ${convver})." - ureq=true - else - ureq=false - fi - - if [[ "$url" != "https://download.freedict.org/dictionaries/${lang}/${ver}/freedict-${lang}-${ver}.${platform}.tar.xz" ]] - then - echo "${lang}${ext} URL changed (${url})." - else - if [[ "$1" == "-u" && "$2" == "$lang" ]] \ - || ([[ "$1" == "-ua" ]] && $ureq) \ - || [[ "$1" == "-uaf" ]] - then - update - fi - fi - - cd .. - done - - cd .. -} - - -# Check for updates for VCS (svn) packages and optionally update them. -# -# $1 type: (svn) -# $2 suffix: (-svn) -# ${@:3} args: $@ -# -# requires: $PWD == <base directory> -# -function handle_all_vcs -{ - type="$1" - ext="$2" - shift 2 - - cd "$type" || exit 1 - - for lang in "${vcs_langs[@]}" - do - cd $lang || exit 1 - $nopull || git pull -q - pkgver="$(sed -En 's/\s*pkgver\s*=\s*(.+)\s*/\1/p' .SRCINFO)" - makepkg --nobuild --nodeps > /dev/null 2>&1 - ver="$(makepkg --printsrcinfo \ - | sed -En 's/\s*pkgver\s*=\s*(.+)\s*/\1/p')" - convver="$ver" - - if [[ "$1" == "-u" && "$2" == "$lang" ]] || [[ "$1" == "-uaf" ]] - then - update - fi - - cd .. - done - - cd .. -} - - -main "$@" |