diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-05-02 16:56:40 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-05-03 01:40:47 -0400 |
commit | 43bbfe78d09f95edd216487f944fbf03f33ed6c4 (patch) | |
tree | ef4d56c72473cfcd6fec74f0d5e8b8de58c8292b /src/abslibre-tools/libredbdiff | |
parent | c326914167f1be1d4e1ccdd79a78cd92b96c15a1 (diff) |
libredbdiff: simplify config file generation
Diffstat (limited to 'src/abslibre-tools/libredbdiff')
-rwxr-xr-x | src/abslibre-tools/libredbdiff | 86 |
1 files changed, 27 insertions, 59 deletions
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" |