summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsteban Carnevale <alfplayer@mailoo.org>2014-12-24 16:36:07 -0300
committerEsteban Carnevale <alfplayer@mailoo.org>2014-12-24 16:47:22 -0300
commit5e076b9c577f807d58b78667ab8cc2e3e83b5113 (patch)
treeafbbcc436097219f7f8e3db93852b906b73f4939
parentfea13e42550965fb95e03bbea8d034ffd1e15004 (diff)
libredbdiff-standalone: Remove it. Replaced with libredbdiff-with_init.
-rwxr-xr-xlibredbdiff-standalone230
1 files changed, 0 insertions, 230 deletions
diff --git a/libredbdiff-standalone b/libredbdiff-standalone
deleted file mode 100755
index d4b5512..0000000
--- a/libredbdiff-standalone
+++ /dev/null
@@ -1,230 +0,0 @@
-#!/bin/bash
-
-# alfplayer
-#
-# Compare package versions of latest packages in Parabola and Arch
-# The main version of this script is in libretools: https://projects.parabola.nu/packages/libretools.git/tree/src/abslibre-tools/libredbdiff
-
-progname="Libredbdiff"
-
-baseconfpath="/etc/libredbdiff"
-basedbpath="/var/lib/libredbdiff"
-
-conffile="$baseconfpath/pacman.conf.parabola"
-conffilearch="$baseconfpath/pacman.conf.archlinux"
-
-dbpath="$basedbpath/pacman.parabola"
-dbpatharch="$basedbpath/pacman.archlinux"
-
-mirrorlist="$baseconfpath/mirrorlist.parabola"
-mirrorlistarch="$baseconfpath/mirrorlist.archlinux"
-
-mirror='http://repo.parabola.nu/$repo/os/$arch'
-mirrorarch='http://mirrors.kernel.org/archlinux/$repo/os/$arch'
-
-repos="libre pcr libre-multilib nonprism"
-
-
-error() { echo -e "Error. $@" > /dev/stderr ; exit 1; }
-
-help() {
- echo -e "${progname}. Show [libre] packages that need to be updated from Arch repositories.\n\nUsage:\nlibredbdiff\t\tInitialize (first run) or update pacman databases\nlibredbdiff -n\t\tPrint results for all Parabola repos\nlibredbdiff -n [repository]\t\tPrint results for the specified Parabola repository"
-}
-
-while true ; do
- if [[ $1 =~ ^(-n|--noupdate)$ ]] ; then
- update=0
- shift
- elif [[ $1 =~ ^(-h|--help)$ ]] ; then
- echo "-h or --help was specified as command argument"
- help
- exit
- elif [[ $update == 0 ]] ; then
- if [[ $2 ]] ; then
- help
- error "Bad arguments. Nothing done."
- elif [[ $1 ]] ; then
- repo_arg="$1"
- for repo in ${repos} ; do
- if [[ "$repo" == "$repo_arg" ]] ; then
- found=1
- break
- fi
- done
- if [[ $found != 1 ]] ; then
- error "The specified Parabola repo \"${repo_arg}\" cannot be compared. It's not in the list of repos in the configuration variable \"repos\"."
- fi
- break
- elif [[ ! $1 ]] ; then
- break
- fi
- else
- break
- fi
-done
-
-
-if [[ $update != 0 ]] ; then
- if [[ $EUID != 0 ]] ; then
- error "The current user is not the user \"root\". To initialize $progname or update $progname pacman databases, the script must be run as root. Nothing done."
- fi
-
- [[ -d "$baseconfpath" && -d "$basedbpath" && -d "$dbpath" && -d "$dbpatharch" && -e "${conffile}" && -e "${conffilearch}" && -e "${mirrorlist}" && -e "${mirrorlist}" ]] || { echo "${progname} files are missing. Initializing." ; init=1 ; }
-
- createdir() {
- if [[ ! -e $1 ]] ; then
- echo "Creating directory $1"
- mkdir "$1" || error "Failed to create directory $1. Exiting."
- else
- [[ $init ]] && echo "Warning. ${1} already exists. Skipping."
- fi
- }
- createdir "$baseconfpath"
- createdir "$basedbpath"
- createdir "$dbpath"
- createdir "$dbpatharch"
-
- enable_repo() {
- repo="$1"
- conffile_arg="$2"
- echo "Enabling repo \"$repo\" in ${conffile_arg}"
- sed -i "s/\#\[$repo\]/[$repo]/" "${conffile_arg}"
- sed -i "\/\[$repo\]/,+1 s/#Include/Include/" "${conffile_arg}"
- }
-
- downloadfile() {
- if [[ ! -e $1 ]] ; then
- echo "$2"
- if wget -q "$3" -O "$1"; then
- return 255
- else
- error "Failed to download ${1}. Exiting."
- fi
- else
- [[ $init ]] && echo "Warning. ${1} already exists. Skipping."
- fi
- }
- downloadfile "${conffile}" "Downloading Parabola pacman.conf" "https://projects.parabola.nu/abslibre.git/plain/libre/pacman/pacman.conf.x86_64"
- if [[ $? == 255 ]] ; then
- sed -i "s|^#DBPath .*|DBPath = ${dbpath}|" "${conffile}"
- enable_repo nonprism "${conffile}"
- enable_repo pcr "${conffile}"
- enable_repo libre-multilib "${conffile}"
- enable_repo multilib "${conffile}"
- fi
-
- downloadfile "${conffilearch}" "Downloading Arch pacman.conf" "https://projects.archlinux.org/svntogit/packages.git/plain/pacman/trunk/pacman.conf.x86_64"
- if [[ $? == 255 ]] ; then
- sed -i "s|^#DBPath .*|DBPath = ${dbpatharch}|" "${conffilearch}"
- echo "Setting Arch mirrorlist file in ${conffilearch}"
- sed -i "s|/etc/pacman\.d/mirrorlist$|$baseconfpath/mirrorlist.archlinux|" "${conffilearch}"
- enable_repo multilib "${conffilearch}"
- fi
-
- setmirror() {
- local distro="$1"
- local mirror="$2"
- local mirrorlist="$3"
- [[ $init ]] && [[ $mirror ]] && {
- mirrorescaped="${mirror//./\\.}" ; mirrorescaped="${mirrorescaped//\$/\\$}"
- echo "Setting ${mirror} as the only enabled ${distro} mirror." && \
- sed -i 's|^#\(Server = '"${mirrorescaped}"'\)$|\1|' "${mirrorlist}"
- }
- }
-
- downloadfile "${mirrorlist}" "Downloading Parabola mirrorlist" "https://repo.parabola.nu/mirrorlist.txt"
- if [[ $? == 255 ]] ; then
- sed -i 's|^Server|#Server|' "${mirrorlist}"
- setmirror "Parabola" "$mirror" "$mirrorlist"
- fi
-
- downloadfile "${mirrorlistarch}" "Downloading Arch mirrorlist" "https://projects.archlinux.org/svntogit/packages.git/plain/pacman-mirrorlist/trunk/mirrorlist"
- if [[ $? == 255 ]] ; then
- setmirror "Arch" "$mirrorarch" "$mirrorlistarch"
- fi
-
- echo -e "\nSynchronizing $progname pacman databases for Parabola"
- pacman --config "${conffile}" -b "${dbpath}" -Sy || error "Failed to synchronize pacman database for Parabola. Exiting."
-
- echo -e "\nSynchronizing $progname pacman databases for Arch"
- pacman --config "${conffilearch}" -b "${dbpatharch}" -Sy || error "Failed to synchronize pacman database for Arch. Exiting."
-
- echo
- echo "$progname pacman databases are updated. $progname is ready. Run libredbdiff -n to print results."
- exit 0
-else
- filenotfound() {
- [[ ! -r $1 ]] && { error "Could not read $1. Nothing done.\nIt could be necessary to run libredbdiff without arguments as root to initialize ${progname}." ; }
- }
- filenotfound "${dbpath}"
- filenotfound "${dbpatharch}"
- filenotfound "${conffile}"
- filenotfound "${conffilearch}"
- filenotfound "${mirrorlist}"
- filenotfound "${mirrorlistarch}"
-fi # close "if [[ $update != 0 ]] ; then"
-
-if [[ $update == 0 ]] ; then
- unset provides ver verarch
- declare -Ax provides ver verarch
-
- expac_version_test() {
- if ! pkgname="$(pacman -Qoq expac)" ; then
- echo "The command expac could not be found installed. The package pcr/expac-relative 4-2.parabola1 (or later) must be installed." >&2
- exit 1
- elif [[ $pkgname == expac-git ]] ; then
- true
- elif [[ $pkgname == expac-relative ]] ; then
- if [[ $(vercmp "$(expac %v expac-relative)" 4-2.parabola1) == -1 ]] ; then
- echo "The version of expac-relative installed on the system is lower than needed." >&2
- exit 1
- fi
- else
- echo "expac command must be provided by pcr/expac-relative version 4-2.parabola1 (or later). This package must be installed." >&2
- exit 1
- fi
- }
-
- compare_pkgs() {
- if [[ ${verarch["$pkgname"]} ]] ; then
- cmp=$(vercmp ${ver["$pkgname"]} ${verarch["$pkgname"]})
- [[ $cmp -lt 0 ]] && echo "${pkgname} needs update from the Arch package of the same name. Versions: ${ver["$pkgname"]} - ${verarch["$pkgname"]}"
- elif [[ ${provides["$pkgname"]} ]] ; then
- for provide in ${provides["$pkgname"]} ; do
- [[ ${verarch["$provide"]} ]] && {
- cmp=$(vercmp "${ver["$pkgname"]}" "${verarch["$provide"]}")
- [[ $cmp -lt 0 ]] && echo "${pkgname} may need update from provide candidate ${provide}. Versions: ${ver["$pkgname"]} - ${verarch["$provide"]}"
- }
- done
- else
- echo "Could not find candidate to compare ${pkgname}"
- fi
- }
-
- expac_version_test
-
- while read -a line ; do
- verarch["${line[0]}"]="${line[1]}"
- done < <(pacman --dbpath "${dbpatharch}" --config "${conffilearch}" -Ss | grep -v '^ ' | awk -F/ '{print $2}')
-
- expac --config "${conffile}" -S '%r/%n %v %S' > /tmp/${progname}.parabola-packages
-
- print_cmp() {
- repo="$1"
- awk -F/ -v repo="$repo" '$1 == repo {print $2}' /tmp/${progname}.parabola-packages | while read -a line ; do
- ver["${line[0]}"]="${line[1]}"
- provides[${line[0]}]="${line[@]:2}"
- pkgname=${line[0]}
- compare_pkgs
- done
- }
-
- if [[ ${repo_arg} ]] ; then
- print_cmp "${repo_arg}"
- else
- for repo in ${repos} ; do
- echo "[$repo]"
- print_cmp "$repo"
- done
- fi
-fi # close "if [[ $update == 0 ]] ; then"