summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-05-02 16:56:40 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-05-03 01:40:47 -0400
commit43bbfe78d09f95edd216487f944fbf03f33ed6c4 (patch)
treeef4d56c72473cfcd6fec74f0d5e8b8de58c8292b /src
parentc326914167f1be1d4e1ccdd79a78cd92b96c15a1 (diff)
libredbdiff: simplify config file generation
Diffstat (limited to 'src')
-rw-r--r--src/abslibre-tools/Makefile2
-rwxr-xr-xsrc/abslibre-tools/libredbdiff86
-rw-r--r--src/abslibre-tools/libredbdiff.conf6
3 files changed, 30 insertions, 64 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})