From 7893814a0bf3b28d7fe5ded43b13d4bf83e3cfaf Mon Sep 17 00:00:00 2001 From: OS Hazard Date: Thu, 29 Sep 2016 23:32:59 -0700 Subject: [PATCH] Ver 2.9 - Database metadata for local AUR packages. Add --gendb, --nodatabase flags. Add -P AUR patched pkgfile passthrough. Update manpages --- README.md | 36 +++++++++++++--- apacman | 111 ++++++++++++++++++++++++++++++++++++++++++++++--- apacman.8 | 33 +++++++++++---- apacman.conf | 5 +++ apacman.conf.5 | 33 +++++++++++++++ 5 files changed, 199 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 37166e7..cd5c192 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ArchLinux User Repository (AUR) helper ![AUR](https://img.shields.io/aur/votes/a **Total:** ![all downloads badge](https://img.shields.io/github/downloads/oshazard/apacman/total.svg) -**Previous:** ![previous release badge](https://img.shields.io/github/downloads/oshazard/apacman/v2.5/total.svg) +**Previous:** ![previous release badge](https://img.shields.io/github/downloads/oshazard/apacman/v2.6/total.svg) **Current:** ![downloads badge](https://img.shields.io/github/downloads/oshazard/apacman/latest/total.svg) @@ -13,10 +13,24 @@ ArchLinux User Repository (AUR) helper ![AUR](https://img.shields.io/aur/votes/a [Migrate wizard for AUR4](https://gist.github.com/oshazard/370c7ed631af2181ee51) Changelog: -* **NEW** improve -U to display packages removed from AUR as "unresolvable" -* **NEW** bug fix for --devel -* **NEW** merged fix that improves curl debugging -* **NEW** merged fix that removes split package support +========== +* **NEW** -P parameter uses AUR passthrough for pkgfile +* **NEW** Save installed AUR package metadata to database +* **NEW** --nodatabase parameter does not store AUR database +* **NEW** --gendb parameter to generate AUR database files +* **NEW** Display remaining packages in queue +* **NEW** --notify parameter for notify-send notifications +* **NEW** --noprogress to disable transaction progress +* **NEW** Enabled terminal title progress by default +* **NEW** --edit parameter to override 'noedit' option in config file +* **NEW** fix CLI flag precedence over config file + +Version 2.6 +----------- +* improve -U to display packages removed from AUR as "unresolvable" +* bug fix for --devel +* merged fix that improves curl debugging +* merged fix that removes split package support * merged pull requests for AUR5 support * improved virtual package support * improved -U handling @@ -28,6 +42,9 @@ Changelog: * --purgekeys parameter removes trusted PGP keys * fix for piping output * fix for yes/no dialog + +Version 2.0 +----------- * Split package support and shared source * Improved AUR4 support * Bug fix for AUR4 -Si @@ -35,6 +52,9 @@ Changelog: * --legacy flag for AUR3 * Preliminary AUR4 support * Signed package support + +Version 1.6 +----------- * Display [installed], [installed: VER], or [local: VER] in -Ss * --progress parameter sets terminal title to package status * Add AUR link to -Si info @@ -46,6 +66,9 @@ Changelog: * --nofail parameter to quit if a package does not build * --purgebuild parameter to remove unneeded build depends * --skiptest to avoid installing unit test packages + +Version 1.0 +----------- * Config file support (/etc/apacman.conf) * Cleaned up manpages * Replacement for pacsysclean (-L list installed packages by size) @@ -53,6 +76,9 @@ Changelog: * --noaur parameter to skip AUR packages * --warn parameter makes errors non-fatal (only enable if you know what you are doing) * Run as root workaround for Pacman 4.2+ + +Version 0.6 +----------- * All features from packer * Saves built AUR packages to /var/cache/apacman/pkg * Uses AUR package cache directory if applicable diff --git a/apacman b/apacman index 3754949..7597741 100755 --- a/apacman +++ b/apacman @@ -1,10 +1,12 @@ #!/bin/bash ###################################################################### # apacman - AUR wrapper forked from packer -version="2.8" +version="2.9" # Copyright OS Hazard # # New Features: +# * -P patched AUR passthrough for pkgfile +# * Save installed AUR package metadata to database # * Enabled --progress by default # * Fix CLI switch precedence over config file # * Improved support for virtual packages @@ -21,10 +23,12 @@ version="2.8" # * --asdeps install AUR packages non-explicitly # * --asexplicit install AUR packages explicitly # * --edit always ask to edit PKGBUILD +# * --gendb generate AUR database files # * --keepkeys do not remove imported PGP keys # * --purgekeys remove imported PGP keys # * --legacy backwards compatability for AUR3 (deprecated) # * --progress transaction status in terminal titlebar +# * --nodatabase do not store AUR database # * --nosource for security do not source PKGBUILDs (WIP) # * --noprogress no transaction status in titlebar # * --notify transaction status in notification @@ -68,6 +72,10 @@ apacmanconf='/etc/apacman.conf' gpgconf='/etc/pacman.d/gnupg/gpg.conf' downdir='/var/cache/pacman/pkg' savedir='/var/cache/apacman/pkg' +database='/var/lib/apacman' +pacmandb='/var/lib/pacman/sync/aur.db' +pkgfiledb='/var/cache/pkgfile/aur.files' +localrepo='aur' builddir="${TMPDIR:-/tmp}/pkgbuild-$UID" tmpdir="${TMPDIR:-/tmp}/apacmantmp-$UID" @@ -139,6 +147,7 @@ usage() { echo ' -Si - outputs info for package' echo ' -G - download and extract aur tarball only' echo ' -L - list installed packages by size' + echo ' -P - passthrough for pkgfile command' echo ' -W - view web comments for package' echo echo ' --asdeps - install AUR packages marked as dependencies' @@ -149,6 +158,7 @@ usage() { echo ' --cachevcs - installs cached VCS packages newer than AUR PKGBUILDs' echo ' --devel - update VCS (git, svn, hg) packages during -Su' echo ' --edit - always ask to edit PKGBUILD' + echo ' --gendb - generate AUR database files' echo ' --ignore - takes a comma-separated list of packages to ignore' echo ' --ignorearch - ignore a missing or incomplete architecture field' echo ' --keepkeys - do not remove imported PGP keys' @@ -156,6 +166,7 @@ usage() { echo ' --needed - do not install up-to-date packages' echo ' --noaur - do not actions for AUR' echo ' --noconfirm - do not prompt for any confirmation' + echo ' --nodatabase - do not store AUR database' echo ' --noedit - do not prompt to edit files' echo ' --nofail - do not continue if a package fails to build' echo ' --noprogress - no transaction status in titlebar' @@ -191,13 +202,15 @@ varstatus() { } infoconf() { - vars="apacmanconf builddir downdir editor makepkgconf pacmanconf savedir tmpdir usermakepkgconf" + vars="apacmanconf builddir database downdir editor localrepo makepkgconf" + vars="$vars pacmanconf pacmandb pkgfiledb savedir tmpdir usermakepkgconf" for i in $vars; do varstatus $i done - vars="asdeps asexplicit auronly buildonly cachevcs ignorearch keepkeys legacy needed noaur noconfirm" - vars="$vars noedit nofail preview progress purgebuild purgekeys quiet skipcache skipinteg skiptest warn" + vars="asdeps asexplicit auronly buildonly cachevcs ignorearch keepkeys legacy" + vars="$vars needed noaur noconfirm nodatabase noedit nofail preview progress" + vars="$vars purgebuild purgekeys quiet skipcache skipinteg skiptest warn" for j in $vars; do varstatus $j done @@ -571,6 +584,59 @@ isoutofdate() { [[ "$(jshon -Q -e results -a -e OutOfDate -u < "$tmpdir/$1.info")" = "1" ]] } +# Generate local AUR database +aurgendb() { + echo -e "${COLOR5}::${COLOR1} Generating AUR database...${ENDCOLOR}" + progress "Generating AUR DB" + runasroot mkdir -p ${database}/{local,raw} + savedpkgs=$(ls ${savedir}/*-*-{any,${makearch}}.pkg.{tar,tar.xz} 2>/dev/null) + runasroot repo-add ${database}/raw/aur.db.tar.gz $savedpkgs + runasroot tar -xzf ${database}/raw/aur.files.tar.gz -C ${database}/local/ + runasroot ln -s ${database}/raw/aur.db.tar.gz $pacmandb 2>/dev/null +} + +# Update AUR pkgfile database +aurpkgfile() { + pkgdir=$(mktemp -d) + + if [[ -d ${database}/local ]]; then + cd ${database}/local + aurlist=$(ls) + for aurpkg in $aurlist; do + grep -v "^%" $aurpkg/files | sed 's/^/\//' > $pkgdir/$aurpkg + done + fi + + cd "$pkgdir" + runasroot tar -czf ${database}/raw/pkgfile.tar.gz * + cd - >/dev/null + rm -r "$pkgdir" + runasroot ln -s ${database}/raw/pkgfile.tar.gz "$pkgfiledb" 2>/dev/null + echo -e "${COLOR5}::${COLOR1} Updated AUR database${ENDCOLOR}" +} + +# Update local AUR database ($1 is package, $2 is filename) +aurlocaldb() { + if [[ $nodatabase ]]; then + return + elif [[ ! -d $database ]] || [[ ! -f $pacmandb ]]; then + runasroot mkdir -p ${database}/{local,raw} + echo -e "${COLOR5}::${COLOR1} Checking AUR database${ENDCOLOR}" + savecount=$(ls $savedir 2>/dev/null | wc -l) + if [[ $savecount -gt 0 ]]; then + echo -e "${COLOR7}warning:${ENDCOLOR} need to run ${COLOR1}apacman --gendb${ENDCOLOR} (found $savecount AUR files!)" + else + runasroot repo-add -q ${database}/raw/aur.db.tar.gz 2>/dev/null + runasroot ln -s ${database}/raw/aur.db.tar.gz $pacmandb 2>/dev/null + fi + fi + + runasroot repo-add -q ${database}/raw/aur.db.tar.gz "$2" 2>/dev/null + pkgnamever=$(echo "$2" | awk -F "$savedir/" '{print $2}' | sed "s/-any.pkg.tar.*//g;s/-${makearch}.pkg.tar.*//g") + runasroot tar -C ${database}/local/ -x "$pkgnamever/" -zf ${database}/raw/aur.files.tar.gz && + aurpkgfile +} + # List bundle package files listbundle() { if [[ $bundle ]]; then @@ -610,6 +676,7 @@ buildstatus() { buildinstall() { if [[ $2 = dependency ]]; then runasroot $PACMAN ${PACOPTS[@]} --asdeps -U "$3" + aurlocaldb "$1" "$3" [[ $buildonly = 1 ]] && bundle+=("$3") [[ $buildonly = 1 ]] && purgedeps+=("$1") elif [[ $2 = explicit ]]; then @@ -617,13 +684,14 @@ buildinstall() { [[ $buildonly = 1 ]] && bundle+=("$3") [[ $buildonly != 1 ]] && progress "Installing ${pkgnum}/${totalcount} $1" [[ $buildonly != 1 ]] && runasroot $PACMAN ${PACOPTS[@]} -U "$3" + [[ $buildonly != 1 ]] && aurlocaldb "$1" "$3" fi } # Checks if aur cache is newer than aur ($1 is package, $2 is aur version) checkvcs() { cachefile=$(ls -t ${savedir}/${1}-*-{any,${makearch}}.pkg.{tar,tar.xz} 2>/dev/null | awk NR==1 | awk -F "${savedir}/${1}-" '{print $2}'); - cachever=$(echo "$cachefile" | sed "s/-any.pkg.tar.xz//g;s/-any.pkg.tar//g;s/-${makearch}.pkg.tar.xz//g;s/-${makearch}.pkg.tar//g"); + cachever=$(echo "$cachefile" | sed "s/-any.pkg.tar.*//g;s/-${makearch}.pkg.tar.*//g"); if [[ "$(LC_ALL=C vercmp "$cachever" "$2")" -gt 0 ]]; then echo -e "${COLOR7}warning:${ENDCOLOR} $1 -- ${COLOR7}verify cache newer than AUR${ENDCOLOR} ($pkgver-$pkgrel)" pkgfile="${savedir}/${1}-${cachefile}"; @@ -827,6 +895,25 @@ aurinstall() { fi } +# Passthrough for pkgfile +pkgfilehandling() { + if ! deptest pkgfile; then + err "${COLOR7}error:${ENDCOLOR} $1 requires \`pkgfile'" + return + fi + + if [[ ! -f $pacmandb ]]; then + echo -e "${COLOR7}warning:${ENDCOLOR} need to run ${COLOR1}apacman --gendb${ENDCOLOR}" + fi + + if [[ $1 = -P* ]] && [[ $1 != -P ]]; then + Parg=$(echo $1 | sed 's/P//g') + fi + + shift + pkgfile -C <(cat $pacmanconf | sed "$ a [$localrepo]") $Parg "$@" +} + # Install local packages (-U) localhandling() { pacmanarg="$1" @@ -1072,6 +1159,10 @@ pacwrap() { $pacmanbin "$@"; elif [[ $1 = -U* ]]; then localhandling "$@" + elif [[ $1 = -P* ]]; then + pkgfilehandling "$@"; + elif [[ $1 = --pkgfile ]]; then + pkgfilehandling "$@"; else runasroot $pacmanbin "$@"; fi; @@ -1103,6 +1194,7 @@ while [[ $1 ]]; do '--devel') devel='1' ;; '--edit') unset noedit ;; '--force') force='1' PACOPTS+=("--force");; + '--gendb') option=gendb ; escaperope='1' ;; '--ignore') ignorearg="$2" ; PACOPTS+=("--ignore" "$2") ; shift ;; '--ignorearch') MAKEPKGOPTS+=("--ignorearch");; '--keepkeys') keepkeys='1' ; export keepkeys ;; @@ -1111,11 +1203,13 @@ while [[ $1 ]]; do '--needed') needed='1' PACOPTS+=("--needed");; '--noaur') noaur='1' ; unset auronly ;; '--noconfirm') noconfirm='1' PACOPTS+=("--noconfirm") ; export noconfirm ;; + '--nodatabase') nodatabase='1' ;; '--noedit') noedit='1' ;; '--nofail') nofail='1' ;; '--noprogress') unset progress ;; '--nosource') nosource='1' ;; '--notify') progress='2' ;; + '--pkgfile') pacwrap "$@" ;; '--preview') preview='1' ;; '--progress') progress='1' ;; '--purgebuild') purgebuild='1' ;; @@ -1131,6 +1225,7 @@ while [[ $1 ]]; do '-V'|'--version') version ;; '--') shift ; packageargs+=("$@") ; break ;; -D*) pacwrap "$@" ;; + -P*) pacwrap "$@" ;; -Q*) pacwrap "$@" ;; -R*) pacwrap "$@" ;; -S*) pacwrap "$@" ;; @@ -1162,6 +1257,12 @@ fi [[ $escaperope != 1 && -z $packageargs ]] && err "${COLOR7}error:${ENDCOLOR} must specify a package." [[ $auronly && $noaur ]] && err "Parameters --auronly and --noaur conflict." +# Generate DB (--gendb) handling +if [[ $option = gendb ]]; then + aurgendb + exit +fi + # List (-L) handling if [[ $option = list ]]; then getlistpackages diff --git a/apacman.8 b/apacman.8 index 9fdf2de..09aca2f 100644 --- a/apacman.8 +++ b/apacman.8 @@ -56,7 +56,12 @@ Download and extract ABS and AUR package tarballs, but don\(cqt install anything .PP \fB\-L\fR .RS 4 -List installed packages by size (replacement for pacsysclean\&.) +List installed packages by size (replacement for \fIpacsysclean\fR command)\&. +.RE +.PP +\fB\-P, \-\-pkgfile\fR +.RS 4 +Patched AUR passthrough for \fIpkgfile\fR command\&. .RE .PP \fB\-W\fR @@ -64,12 +69,17 @@ List installed packages by size (replacement for pacsysclean\&.) View AUR comments\&. .RE .PP -\fB\-h\fR +\fB\-V\fR .RS 4 Show apacman version\&. .RE .PP -\fB\-h\fR +\fB\-v, \-\-verbose\fR +.RS 4 +Show enabled options\&. +.RE +.PP +\fB\-h, \-\-help\fR .RS 4 Show apacman usage\&. .RE @@ -107,6 +117,11 @@ Update development packages\&. (cvs, git\&...) Always ask to edit PKGBUILD (overrides 'noedit' option)\&. .RE .PP +\fB\-\-gendb\fR +.RS 4 +Generate AUR local package database\&. +.RE +.PP \fB\-\-ignore\fR <\'package\'> .RS 4 Ignore packages\&. Separate package names with a comma\&. @@ -142,6 +157,11 @@ Do not perform commands for the AUR\&. Perform commands without confirmation from the user\&. .RE .PP +\fB\-\-nodatabase\fR +.RS 4 +Do not store AUR database\&. +.RE +.PP \fB\-\-noedit\fR .RS 4 Perform commands without asking if the user wants to edit any installation files\&. @@ -164,7 +184,7 @@ Do not source PKGBUILDs, for security reasons (WIP)\&. .PP \fB\-\-notify\fR .RS 4 -Notification via notify\-send with transaction status\&. +Notification via \fInotify\-send\fR with transaction status\&. .RE .PP \fB\-\-preview\fR @@ -212,11 +232,6 @@ Skip the integrity check by ignoring AUR package MD5 sums\&. Avoid install of check unit test packages\&. .RE .PP -\fB\-\-verbose\fR -.RS 4 -Show enabled options\&. -.RE -.PP \fB\-\-warn\fR .RS 4 Treat errors as non-fatal warnings (only enable if you are know what you are doing\&.) diff --git a/apacman.conf b/apacman.conf index 2fd9862..9561acd 100644 --- a/apacman.conf +++ b/apacman.conf @@ -15,6 +15,7 @@ #needed=1 #noaur=1 #noconfirm=1 +#nodatabase=1 #noedit=1 #nofail=1 #preview=1 @@ -37,6 +38,10 @@ progress=1 #pacmanconf="/etc/pacman.conf" #downdir="/var/cache/pacman/pkg" #savedir="/var/cache/apacman/pkg" +#database="/var/lib/apacman" +#pacmandb="/var/lib/pacman/sync/aur.db" +#pkgfiledb="/var/cache/pkgfile/aur.files" +#localrepo="aur" #editor="nano -w" #pager="less -R" #RPCURL="https://aur.archlinux.org/rpc.php?type" diff --git a/apacman.conf.5 b/apacman.conf.5 index 3ccc710..fccd207 100644 --- a/apacman.conf.5 +++ b/apacman.conf.5 @@ -108,6 +108,11 @@ Do no actions for AUR (hint: useful with --warn)\&. Do not prompt for any confirmation\&. .RE .PP +\fBnodatabase =\fR 1 +.RS 4 +Do not store local AUR database\&. +.RE +.PP \fBnoedit =\fR 1 .RS 4 Do not prompt to edit files with EDITOR\&. @@ -202,6 +207,34 @@ Overrides the default location of the package cache directory\&. \fBDefault\fR: /var/cache/apacman/pkg .RE .PP +\fBdatabase =\fR path/to/database/dir +.RS 4 +Overrides the default location of the apacman DB directory\&. +.sp .5v +\fBDefault\fR: /var/lib/apacman +.RE +.PP +\fBpacmandb =\fR path/to/aur.db +.RS 4 +Overrides the default location of the locally installed AUR package DB\&. +.sp .5v +\fBDefault\fR: /var/lib/pacman/sync/aur.db +.RE +.PP +\fBpkgfiledb =\fR path/to/aur.files +.RS 4 +Overrides the default location of the pkgfile-format local AUR package DB\&. +.sp .5v +\fBDefault\fR: /var/cache/pkgfile/aur.files +.RE +.PP +\fBlocalrepo =\fR name +.RS 4 +Overrides the default name of the AUR repository\&. +.sp .5v +\fBDefault\fR: aur +.RE +.PP \fBeditor =\fR nano \-w .RS 4 Overrides the default text editor for PKGBUILDs\&.