diff options
-rw-r--r-- | src/abslibre-tools/Makefile | 2 | ||||
-rwxr-xr-x | src/abslibre-tools/libredbdiff | 86 | ||||
-rw-r--r-- | src/abslibre-tools/libredbdiff.conf | 6 | ||||
-rw-r--r-- | test/libredbdiff-test.sh | 4 |
4 files changed, 32 insertions, 66 deletions
diff --git a/src/abslibre-tools/Makefile b/src/abslibre-tools/Makefile index f9495d0..a1b7765 100644 --- a/src/abslibre-tools/Makefile +++ b/src/abslibre-tools/Makefile @@ -1,6 +1,4 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk include $(topsrcdir)/build-aux/Makefile.head.mk -$(outdir)/libredbdiff.pot: LIBREXGETTEXT_FLAGS += --simple=downloadfile:3 - include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/abslibre-tools/libredbdiff b/src/abslibre-tools/libredbdiff index dc479d4..04180be 100755 --- a/src/abslibre-tools/libredbdiff +++ b/src/abslibre-tools/libredbdiff @@ -42,17 +42,6 @@ field_pkgname_total="$((field_pkgname_prbl + field_pkgname_arch))" printf_format="%s %-${field_pkgname_prbl}s%-${field_pkgname_arch}s %s | %s\n" printf_format_noarch="%s %-${field_pkgname_total}s %s\n" -downloadfile() { - local outfile=$1 - local url=$2 - local mesg=("${@:3}") - - msg "${mesg[@]}" - if ! wget -q "$url" -O "$outfile"; then - die "Failed to download %q. Exiting." "$outfile" - fi -} - enablerepo() { local repo="$1" local conffile_arg="$2" @@ -75,70 +64,49 @@ createdir() { fi } -setmirror() { - local distro="$1" - local mirror="$2" - local mirrorlist="$3" - - if [[ -n "$mirror" ]]; then - local mirrorescaped - mirrorescaped="${mirror//./\\.}" - mirrorescaped="${mirrorescaped//\$/\\$}" - msg2 "Setting %s as the only enabled %s mirror." "$mirror" "$distro" - sed -i 's|^#\(Server = '"$mirrorescaped"'\)$|\1|' "$mirrorlist" - fi -} - initialize() { createdir "$statedir" if [[ ! -e "$conffile_prbl" ]] ; then - downloadfile \ - "$conffile_prbl" \ - "https://git.parabola.nu/abslibre.git/plain/libre/pacman/pacman.conf.x86_64" \ - "Downloading Parabola %q" pacman.conf - msg2 "Setting DBPath in %q" "$conffile_prbl" - sed -i "s|^#DBPath .*|DBPath = $dbpath_prbl|" "$conffile_prbl" - enablerepo nonprism "$conffile_prbl" - enablerepo pcr "$conffile_prbl" - enablerepo libre-multilib "$conffile_prbl" - enablerepo multilib "$conffile_prbl" + msg "Generating %s %q" Parabola pacman.conf + cp -T /usr/share/pacman/defaults/pacman.conf.x86_64 "$conffile_prbl" + sed -r \ + -e "s|/etc/pacman\.d/mirrorlist$|$mirrorlist_prbl|" \ + -e "s|^#?DBPath\s*=.*|DBPath = $dbpath_prbl|" \ + -e "s|^#?Architecture\s*=.*|Architecture = x86_64|" \ + -i "$conffile_prbl" + local repo + for repo in multilib {libre,pcr,nonprism}{,-multilib}; do + enablerepo "$repo" "$conffile_prbl" + done else warning "%q already exists. Skipping." "$conffile_prbl" fi if [[ ! -e "$conffile_arch" ]] ; then - downloadfile \ - "$conffile_arch" \ - "https://git.archlinux.org/svntogit/packages.git/plain/pacman/trunk/pacman.conf.x86_64" \ - "Downloading Arch %q" pacman.conf - msg2 "Setting DBPath in %q" "$conffile_arch" - sed -i "s|^#DBPath .*|DBPath = $dbpath_arch|" "$conffile_arch" - msg2 "Setting Arch mirrorlist file in %q" "$conffile_arch" - sed -i "s|/etc/pacman\.d/mirrorlist$|$mirrorlist_arch|" \ - "$conffile_arch" + msg "Generating %s %q" Arch pacman.conf + wget -q \ + -O "$conffile_arch" \ + "https://git.archlinux.org/svntogit/packages.git/plain/pacman/repos/core-x86_64/pacman.conf.x86_64" || + die "Failed to download %q. Exiting." "$conffile_arch" + sed -r \ + -e "s|/etc/pacman\.d/mirrorlist$|$mirrorlist_arch|" \ + -e "s|^#?DBPath\s*=.*|DBPath = $dbpath_arch|" \ + -e "s|^#?Architecture\s*=.*|Architecture = x86_64|" \ + -i "$conffile_arch" enablerepo multilib "$conffile_arch" else warning "%q already exists. Skipping." "$conffile_arch" fi if [[ ! -e "$mirrorlist_prbl" ]] ; then - downloadfile \ - "$mirrorlist_prbl" \ - "https://repo.parabola.nu/mirrorlist.txt" \ - "Downloading Parabola %q" mirrorlist - sed -i 's|^Server|#Server|' "$mirrorlist_prbl" - setmirror "Parabola" "$mirror_prbl" "$mirrorlist_prbl" + printf 'Server = %s\n' "$mirror_prbl" > "$mirrorlist_prbl" else warning "%q already exists. Skipping." "$mirrorlist_prbl" fi if [[ ! -e "$mirrorlist_arch" ]] ; then - downloadfile \ - "$mirrorlist_arch" \ - "https://git.archlinux.org/svntogit/packages.git/plain/pacman-mirrorlist/trunk/mirrorlist" \ - "Downloading Arch %q" mirrorlist - setmirror "Arch" "$mirror_arch" "$mirrorlist_arch" + printf 'Server = %s\n' "$mirror_arch" > "$mirrorlist_arch" else warning "%q already exists. Skipping." "$mirrorlist_arch" fi @@ -320,14 +288,14 @@ main_update() { fi createdir "$dbpath_prbl" - msg "Synchronizing %s pacman databases for Parabola" "$name" + msg "Synchronizing %s pacman databases for %s" "$name" "Parabola" pacman --config "$conffile_prbl" -Sy || - die "Failed to synchronize pacman database for Parabola. Exiting." + die "Failed to synchronize pacman database for %s. Exiting." Parabola createdir "$dbpath_arch" - msg "Synchronizing %s pacman databases for Arch" "$name" + msg "Synchronizing %s pacman databases for %s" "$name" "Arch" pacman --config "$conffile_arch" -Sy || - die "Failed to synchronize pacman database for Arch. Exiting." + die "Failed to synchronize pacman database for %s. Exiting." Arch msg "%s pacman databases are updated. %s is ready. Run %q -n to print results." \ "$name" "$name" "$cmd" diff --git a/src/abslibre-tools/libredbdiff.conf b/src/abslibre-tools/libredbdiff.conf index ed0fcb1..d92a832 100644 --- a/src/abslibre-tools/libredbdiff.conf +++ b/src/abslibre-tools/libredbdiff.conf @@ -3,7 +3,7 @@ statedir='/var/lib/libredbdiff' -mirror_prbl='http://repo.parabola.nu/$repo/os/$arch' -mirror_arch='http://mirrors.kernel.org/archlinux/$repo/os/$arch' +mirror_prbl='https://repomirror.parabola.nu/$repo/os/$arch' +mirror_arch='https://mirrors.kernel.org/archlinux/$repo/os/$arch' -repos=(libre pcr libre-multilib nonprism) +repos=(libre{,-multilib} pcr{,-multilib} nonprism{,-multilib}) diff --git a/test/libredbdiff-test.sh b/test/libredbdiff-test.sh index ca0aad4..fe73074 100644 --- a/test/libredbdiff-test.sh +++ b/test/libredbdiff-test.sh @@ -7,8 +7,8 @@ common_before() { mkdir -p "$XDG_CONFIG_HOME/libretools" printf '%s\n' \ 'statedir="$PWD"' \ - "mirror_prbl='http://repo.parabola.nu/\$repo/os/\$arch'" \ - "mirror_arch='http://mirrors.kernel.org/archlinux/\$repo/os/\$arch'" \ + "mirror_prbl='https://repo.parabola.nu/\$repo/os/\$arch'" \ + "mirror_arch='https://mirrors.kernel.org/archlinux/\$repo/os/\$arch'" \ 'repos=(libre)' \ > $XDG_CONFIG_HOME/libretools/libredbdiff.conf } |