Skip to content

Commit

Permalink
Ver 3.0 - Fix #71 --flag=parameter syntax. Add --savedir flag
Browse files Browse the repository at this point in the history
  • Loading branch information
oshazard committed Oct 5, 2016
1 parent d09533a commit 35603ea
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
31 changes: 26 additions & 5 deletions apacman
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
######################################################################
# apacman - AUR wrapper forked from packer
version="2.9"
version="3.0"
# Copyright OS Hazard <[email protected]>
#
# New Features:
# * --savedir <dir>, --savedir=<dir>
# * Install AUR packages offline
# * --testing for unit testing purposes only
# * Regex matching for searching packages
Expand Down Expand Up @@ -186,6 +187,7 @@ usage() {
echo ' --purgekeys - remove trusted PGP keys'
echo ' --quickcheck - check for updates and exit'
echo ' --quiet - only output package name for searches'
echo ' --savedir - takes a path as the cache directory'
echo ' --skipcache - skips check for pre-built package in cache directory'
echo ' --skipinteg - when using makepkg, do not check md5s'
echo ' --skiptest - when using makepkg, do not parse check() test deps'
Expand Down Expand Up @@ -228,14 +230,14 @@ infoconf() {
# Called whenever anything needs to be run as root ($@ is the command)
runasroot() {
if [[ $testing == 1 ]]; then
fakechroot fakeroot "$@"
fakeroot "$@" || code='1'
elif [[ $UID -eq 0 ]]; then
"$@"
"$@" || code='1'
elif sudo -v &>/dev/null && sudo -l "$@" &>/dev/null; then
sudo -E "$@"
sudo -E "$@" || code='1'
else
echo -n "root "
su -c "$(printf '%q ' "$@")"
su -c "$(printf '%q ' "$@")" || code='1'
fi
}

Expand Down Expand Up @@ -1252,6 +1254,9 @@ loadconfig() {
return
elif [[ $flag = "--config" ]]; then
nextflag='1'
elif [[ $flag = --config* ]]; then
apacmanconf="$flag"
return
fi
done
}
Expand Down Expand Up @@ -1295,11 +1300,13 @@ while [[ $1 ]]; do
'--buildonly') buildonly='1' ;;
'--cachevcs') cachevcs='1' ;;
'--config') config='1' ; shift ;;
--config=*) config='1' ; equals+=("--config") ;;
'--devel') devel='1' ;;
'--edit') unset noedit ;;
'--force') force='1' PACOPTS+=("--force");;
'--gendb') option=gendb ; escaperope='1' ;;
'--ignore') ignorearg="$2" ; PACOPTS+=("--ignore" "$2") ; shift ;;
--ignore=*) ignorearg="$1" ; equals+=("--ignore") ;;
'--ignorearch') MAKEPKGOPTS+=("--ignorearch");;
'--keepkeys') keepkeys='1' ; export keepkeys ;;
'--legacy') legacy='1' ;;
Expand All @@ -1320,6 +1327,8 @@ while [[ $1 ]]; do
'--purgekeys') purgekeys='1' ;;
'--quickcheck') quickcheck='1' ;;
'--quiet') quiet='1' ;;
'--savedir') savedir="$2" ; shift ;;
--savedir=*) savedir="$1"; equals+=("--savedir") ;;
'--skipcache') skipcache='1' ;;
'--skipinteg') skipinteg='1' ; MAKEPKGOPTS+=("--skipinteg");;
'--skiptest') skiptest='1' ; MAKEPKGOPTS+=("--nocheck");;
Expand All @@ -1342,6 +1351,18 @@ while [[ $1 ]]; do
shift
done

# Handles alternative syntax --flag=parameter
for eqvar in "${equals[@]}"; do
if [[ $eqvar = "--config" ]]; then
apacmanconf=$(echo "$apacmanconf" | awk -F "=" '{print $2}')
elif [[ $eqvar = "--ignore" ]]; then
ignorearg=$(echo "$ignorearg" | awk -F "=" '{print $2}')
PACOPTS+=("--ignore" "$ignorearg")
elif [[ $eqvar = "--savedir" ]]; then
savedir=$(echo "$savedir" | awk -F "=" '{print $2}')
fi
done

# Set tmpfile stuff, clean tmpdir
rm -rf "$tmpdir" &>/dev/null
mkdir -p "$tmpdir"
Expand Down
19 changes: 13 additions & 6 deletions apacman.8
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: apacman
.\" Author: [see the "Authors" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: 09/29/2016
.\" Date: 10/05/2016
.\" Manual: apacman Manual
.\" Source: apacman
.\" Language: English
.\"
.TH "APACMAN" "8" "09/29/2017" "apacman" "apacman Manual"
.TH "APACMAN" "8" "10/05/2016" "apacman" "apacman Manual"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
Expand All @@ -25,8 +25,8 @@ apacman \- AUR wrapper forked from packer
\fIapacman\fR <operation> [options] [packages]
.SH "DESCRIPTION"
.sp
apacman is a bash wrapper forked from packer for pacman and the ArchLinux User Repository (AUR)\&. It adds package saving functionality and some extra
pass-through options for makepkg and pacman.
apacman is a bash wrapper forked from packer for pacman and the ArchLinux User Repository (AUR)\&. It adds package saving functionality and some extra
pass-through options for makepkg and pacman.
.SH "OPERATIONS"
.PP
\fB\-Ss\fR
Expand Down Expand Up @@ -97,7 +97,7 @@ Build packages but do not install them then post\-install remove unneeded build
\fBNote:\fR list of package filenames stored in \fI$tmpdir/bundle\&.lst\fB
.RE
.PP
\fB\-\-config\fR <\'file\'>
\fB\-\-config\fR \fIfilename\fR, \fB\-\-config=\fR\fIfilename\fR
.RS 4
Use alternate configuration file\&.
.RE
Expand All @@ -122,7 +122,7 @@ Always ask to edit PKGBUILD (overrides 'noedit' option)\&.
Generate AUR local package database\&.
.RE
.PP
\fB\-\-ignore\fR <\'package\'>
\fB\-\-ignore\fR \fIpackage\fR, \fB\-\-ignore=\fR\fIpkg1\fR,\fIpkg2\fR,\fIpkg3\fR
.RS 4
Ignore packages\&. Separate package names with a comma\&.
.RE
Expand Down Expand Up @@ -217,6 +217,11 @@ Check for updates and exit\&.
Turn off package descriptions\&.
.RE
.PP
\fB\-\-savedir\fR \fIdirectory\fR, \fB\-\-savedir=\fR\fIdirectory\fR
.RS 4
Use alternate cache directory\&.
.RE
.PP
\fB\-\-skipcache\fR
.RS 4
skips check for pre-built package in cache directory\&.
Expand Down Expand Up @@ -383,6 +388,8 @@ IgnorePkg
.sp
\fBpacman\fR(8)
.sp
\fBpkgfile\fR(1)
.sp
\fBpacker\fR(8)

.SH "AUTHORS"
Expand Down
2 changes: 1 addition & 1 deletion test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ virtualpkg="ttf-font"
[ "$status" -eq 0 ]
}

@test "invoke with '-S' parameter fails to build package from AUR" {
@test "invoke with '-S' parameter fails to build broken package from AUR" {
run $APACMAN $testing $noconfirm $buildonly $skipcache -S $badpkg
[ "$status" -eq 1 ]
}
Expand Down

0 comments on commit 35603ea

Please sign in to comment.