From dcaca30f938f1c28767eb8cf5a21a02289fc3a41 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 2 May 2017 22:50:10 -0400 Subject: libredbdiff: Use _prbl for Parabola vars and _arch for Arch vars. libredbdiff used VARNAME for Parabola variables, and VARNAME_arch for Arch variables. I found it confusing. Instead, consistently use VARNAME_prbl for Parabola variables and VARNAME_arch for Arch variables; this allows the reader to more easily see the parallels between the handling of each. --- src/abslibre-tools/libredbdiff | 133 +++++++++++++++++------------------- src/abslibre-tools/libredbdiff.conf | 4 +- 2 files changed, 66 insertions(+), 71 deletions(-) (limited to 'src/abslibre-tools') diff --git a/src/abslibre-tools/libredbdiff b/src/abslibre-tools/libredbdiff index eadb0a4..5ef1029 100755 --- a/src/abslibre-tools/libredbdiff +++ b/src/abslibre-tools/libredbdiff @@ -23,28 +23,25 @@ name="Libredbdiff" . "$(librelib conf)" load_files libredbdiff || exit 1 -baseconfpath="$statedir" -basedbpath="$statedir" +conffile_prbl="$statedir/pacman.conf.parabola" +conffile_arch="$statedir/pacman.conf.archlinux" -conffile="$baseconfpath/pacman.conf.parabola" -conffilearch="$baseconfpath/pacman.conf.archlinux" +dbpath_prbl="$statedir/pacman.parabola" +dbpath_arch="$statedir/pacman.archlinux" -dbpath="$basedbpath/pacman.parabola" -dbpatharch="$basedbpath/pacman.archlinux" +mirrorlist_prbl="$statedir/mirrorlist.parabola" +mirrorlist_arch="$statedir/mirrorlist.archlinux" -mirrorlist="$baseconfpath/mirrorlist.parabola" -mirrorlistarch="$baseconfpath/mirrorlist.archlinux" - -field_pkgname_parabola=30 +field_pkgname_prbl=30 field_pkgname_arch=30 cmd="${0##*/}" arch_packages_tmp="/tmp/$cmd.arch-packages" -parabola_packages_tmp="/tmp/$cmd.parabola-packages" +prbl_packages_tmp="/tmp/$cmd.parabola-packages" -field_pkgname_total="$((field_pkgname_parabola + field_pkgname_arch))" -printf_format="%s %-${field_pkgname_parabola}s%-${field_pkgname_arch}s %s | %s\n" +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() { @@ -103,54 +100,53 @@ arguments as root to initialize %s." "$cmd" "$name" } initialize() { - createdir "$baseconfpath" - createdir "$basedbpath" + createdir "$statedir" downloadfile \ - "$conffile" \ + "$conffile_prbl" \ "https://projects.parabola.nu/abslibre.git/plain/libre/pacman/pacman.conf.x86_64" \ "Downloading Parabola %q" \ pacman.conf if [[ $? == 255 ]] ; then - msg2 "Setting DBPath in %q" "$conffile" - sed -i "s|^#DBPath .*|DBPath = $dbpath|" "$conffile" - enablerepo nonprism "$conffile" - enablerepo pcr "$conffile" - enablerepo libre-multilib "$conffile" - enablerepo multilib "$conffile" + 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" fi downloadfile \ - "$conffilearch" \ + "$conffile_arch" \ "https://projects.archlinux.org/svntogit/packages.git/plain/pacman/trunk/pacman.conf.x86_64" \ "Downloading Arch %q" \ pacman.conf if [[ $? == 255 ]] ; then - msg2 "Setting DBPath in %q" "$conffilearch" - sed -i "s|^#DBPath .*|DBPath = $dbpatharch|" "$conffilearch" - msg2 "Setting Arch mirrorlist file in %q" "$conffilearch" - sed -i "s|/etc/pacman\.d/mirrorlist$|$baseconfpath/mirrorlist.archlinux|" \ - "$conffilearch" - enablerepo multilib "$conffilearch" + 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" + enablerepo multilib "$conffile_arch" fi downloadfile \ - "$mirrorlist" \ + "$mirrorlist_prbl" \ "https://repo.parabola.nu/mirrorlist.txt" \ "Downloading Parabola %q" \ mirrorlist if [[ $? == 255 ]] ; then - sed -i 's|^Server|#Server|' "$mirrorlist" - setmirror "Parabola" "$mirror" "$mirrorlist" + sed -i 's|^Server|#Server|' "$mirrorlist_prbl" + setmirror "Parabola" "$mirror_prbl" "$mirrorlist_prbl" fi downloadfile \ - "$mirrorlistarch" \ + "$mirrorlist_arch" \ "https://projects.archlinux.org/svntogit/packages.git/plain/pacman-mirrorlist/trunk/mirrorlist" \ "Downloading Arch %q" \ mirrorlist if [[ $? == 255 ]] ; then - setmirror "Arch" "$mirrorarch" "$mirrorlistarch" + setmirror "Arch" "$mirror_arch" "$mirrorlist_arch" fi } @@ -168,29 +164,29 @@ repo_test() { compare_pkgs() { local cmp - if [[ -n "${verarch[$pkgname]}" ]] ; then - cmp=$(vercmp "${ver[$pkgname]}" "${verarch[$pkgname]}") + if [[ -n "${ver_arch[$pkgname]}" ]] ; then + cmp=$(vercmp "${ver_prbl[$pkgname]}" "${ver_arch[$pkgname]}") if [[ "$cmp" -lt 0 ]]; then printf "$printf_format" \ '=' \ "$pkgname" \ "" \ - "${ver[$pkgname]}" \ - "${verarch[$pkgname]}" + "${ver_prbl[$pkgname]}" \ + "${ver_arch[$pkgname]}" fi elif [[ -n "${provides[$pkgname]}" ]]; then local _provides provide read -r -a _provides <<<"${provides[$pkgname]}" for provide in "${_provides[@]}"; do - if [[ -n "${verarch[$provide]}" ]]; then - cmp=$(vercmp "${ver[$pkgname]}" "${verarch[$provide]}") + if [[ -n "${ver_arch[$provide]}" ]]; then + cmp=$(vercmp "${ver_prbl[$pkgname]}" "${ver_arch[$provide]}") if [[ "$cmp" -lt 0 ]]; then printf "$printf_format" \ 'p' \ "$pkgname" \ "$provide" \ - "${ver[$pkgname]}" \ - "${verarch[$provide]}" + "${ver_prbl[$pkgname]}" \ + "${ver_arch[$provide]}" fi fi done @@ -198,7 +194,7 @@ compare_pkgs() { printf "$printf_format_noarch" \ 'o' \ "$pkgname" \ - "${ver[$pkgname]}" + "${ver_prbl[$pkgname]}" fi } @@ -206,9 +202,9 @@ print_cmp() { local repo="$1" awk -F/ -v repo="$repo" \ '$1 == repo {print $2}' \ - "$parabola_packages_tmp" | \ + "$prbl_packages_tmp" | \ while read -a line ; do - ver["${line[0]}"]="${line[1]}" + ver_prbl["${line[0]}"]="${line[1]}" provides["${line[0]}"]="${line[*]:2}" pkgname="${line[0]}" compare_pkgs @@ -274,37 +270,36 @@ main() { "$name" \ "$cmd" fi - check_vars libredbdiff statedir mirror mirrorarch || exit 1 + check_vars libredbdiff statedir mirror_prbl mirror_arch || exit 1 - if ! [[ -e "$conffile" && \ - -e "$conffilearch" && \ - -e "$mirrorlist" && \ - -e "$mirrorlist" ]]; then + if ! [[ -e "$conffile_prbl" && \ + -e "$conffile_arch" && \ + -e "$mirrorlist_prbl" && \ + -e "$mirrorlist_arch" ]]; then warning "At least one %s configuration file is missing." \ "$name" msg "Downloading and preparing missing configuration files." init=1 fi - createdir "$baseconfpath" - createdir "$basedbpath" + createdir "$statedir" initialize - if ! [[ -d "$dbpath" && \ - -d "$dbpatharch" ]]; then + if ! [[ -d "$dbpath_prbl" && \ + -d "$dbpath_arch" ]]; then warning "At least one %s pacman DB directory is missing. Synchronizing %s DB files." \ "$name" "$name" fi - createdir "$dbpath" + createdir "$dbpath_prbl" msg "Synchronizing %s pacman databases for Parabola" "$name" - pacman --config "$conffile" -Sy || + pacman --config "$conffile_prbl" -Sy || die "Failed to synchronize pacman database for Parabola. Exiting." - createdir "$dbpatharch" + createdir "$dbpath_arch" msg "Synchronizing %s pacman databases for Arch" "$name" - pacman --config "$conffilearch" -Sy || + pacman --config "$conffile_arch" -Sy || die "Failed to synchronize pacman database for Arch. Exiting." msg "%s pacman databases are updated. %s is ready. Run %q -n to print results." \ @@ -313,15 +308,15 @@ main() { else check_vars libredbdiff statedir repos || exit 1 - filenotfound "$dbpath/sync/libre.db" - filenotfound "$dbpatharch/sync/core.db" - filenotfound "$conffile" - filenotfound "$conffilearch" + filenotfound "$dbpath_prbl/sync/libre.db" + filenotfound "$dbpath_arch/sync/core.db" + filenotfound "$conffile_prbl" + filenotfound "$conffile_arch" - unset provides ver verarch - declare -gA provides ver verarch + unset provides ver_prbl ver_arch + declare -gA provides ver_prbl ver_arch - pacman --config "$conffilearch" -Ss | \ + pacman --config "$conffile_arch" -Ss | \ grep -v '^ ' | \ awk -F/ '{print $2}' \ > "$arch_packages_tmp" || \ @@ -329,13 +324,13 @@ main() { chmod 777 "$arch_packages_tmp" while read -a line; do - verarch["${line[0]}"]="${line[1]}" + ver_arch["${line[0]}"]="${line[1]}" done < "$arch_packages_tmp" - expac --config "$conffile" -S '%r/%n %v %S' \ - > "$parabola_packages_tmp" || \ + expac --config "$conffile_prbl" -S '%r/%n %v %S' \ + > "$prbl_packages_tmp" || \ die "expac command to get Parabola package data has failed. Exiting." - chmod 777 "$parabola_packages_tmp" + chmod 777 "$prbl_packages_tmp" if [[ -n "$repo_arg" ]] ; then print_cmp "$repo_arg" diff --git a/src/abslibre-tools/libredbdiff.conf b/src/abslibre-tools/libredbdiff.conf index 4ec024b..ed0fcb1 100644 --- a/src/abslibre-tools/libredbdiff.conf +++ b/src/abslibre-tools/libredbdiff.conf @@ -3,7 +3,7 @@ statedir='/var/lib/libredbdiff' -mirror='http://repo.parabola.nu/$repo/os/$arch' -mirrorarch='http://mirrors.kernel.org/archlinux/$repo/os/$arch' +mirror_prbl='http://repo.parabola.nu/$repo/os/$arch' +mirror_arch='http://mirrors.kernel.org/archlinux/$repo/os/$arch' repos=(libre pcr libre-multilib nonprism) -- cgit v1.2.2