Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merging keenerd's --preview changes

  • Loading branch information...
commit 78290635ef4c171ec427f52aaef114b1a7f71e18 1 parent 7c24afa
@bruenig bruenig authored
Showing with 19 additions and 3 deletions.
  1. +14 −3 packer
  2. +5 −0 packer.8
View
17 packer
@@ -67,6 +67,7 @@ usage() {
echo ' --auronly - only do actions for aur'
echo ' --devel - update devel packages during -Su'
echo ' --skipinteg - when using makepkg, do not check md5s'
+ echo ' --preview - edit pkgbuild before sourcing'
echo ' -h - outputs this message'
exit
}
@@ -128,7 +129,7 @@ existsinlocal() {
# Scrapes the aur deps from PKGBUILDS and puts in globally available dependencies array
scrapeaurdeps() {
- pkginfo "$1"
+ pkginfo "$1" "$preview"
. "$tmpdir/$1.PKGBUILD"
IFS=$'\n'
dependencies=( $(echo -e "${depends[*]}\n${makedepends[*]}" | sed -e 's/=.*//' -e 's/>.*//' -e 's/<.*//'| sort -u) )
@@ -234,10 +235,17 @@ pkglink() {
echo "${PKGURL}$(jshon -Q -e results -e URLPath -u < "$tmpdir/$1.info")"
}
+# downloads pkgbuild ($1), edits if $2 is set
pkginfo() {
if ! [[ -f "$tmpdir/$1.PKGBUILD" ]]; then
pkgpath=$(pkglink $1)
curl -Lfs "${pkgpath%/*}/PKGBUILD" > "$tmpdir/$1.PKGBUILD"
+ if [[ $2 ]]; then
+ # rename for syntax highlighting
+ ln -sf "$tmpdir/$1.PKGBUILD" "$tmpdir/PKGBUILD"
+ confirm_edit "${COLOR6}Edit $1 PKGBUILD with \$EDITOR? [Y/n]${ENDCOLOR} " "$tmpdir/PKGBUILD"
+ rm -f "$tmpdir/PKGBUILD"
+ fi
fi
}
@@ -286,7 +294,9 @@ aurinstall() {
mkdir "$1"
tar xf "$1.tar.gz" -C "$1" --strip-components=1
cd "$1"
-
+ if [[ $preview && -s "$tmpdir/$1.PKGBUILD" ]]; then
+ cp "$tmpdir/$1.PKGBUILD" PKGBUILD
+ fi
# customizepkg
if [[ -f "/etc/customizepkg.d/$1" ]] && type -t customizepkg &>/dev/null; then
echo "Applying customizepkg instructions..."
@@ -472,6 +482,7 @@ while [[ $1 ]]; do
'--auronly') auronly='1' ;;
'--devel') devel='1' ;;
'--skipinteg') MAKEPKGOPTS="--skipinteg" ;;
+ '--preview') preview='1' ;;
'--') shift ; packageargs+=("$@") ; break ;;
-*) echo "packer: Option \`$1' is not valid." ; exit 5 ;;
*) packageargs+=("$1") ;;
@@ -698,7 +709,7 @@ if [[ $option = info ]]; then
echo -e "$results"
exit
else # Check to see if it is in the aur
- pkginfo "$package"
+ pkginfo "$package" "$preview"
[[ -s "$tmpdir/$package.PKGBUILD" ]] || err "${COLOR7}error:${ENDCOLOR} package '$package' was not found"
. "$tmpdir/$package.PKGBUILD"
View
5 packer.8
@@ -88,6 +88,11 @@ Update development packages\&. (cvs, git\&...)
.RS 4
Skip the integrity check by ignoring AUR package MD5 sums\&.
.RE
+.PP
+\fB\-\-preview\fR
+.RS 4
+Always offer to edit the pkgbuild before sourcing it. To always force preview, 'alias packer="packer --preview"'
+.RE
.SH "INTERACTIVE MODE"
.sp
Use packer without any operations or options to use the interactive mode\&. Packer will show a numbered list of search results\&. To install a package, enter the corresponding number\&.
Please sign in to comment.
Something went wrong with that request. Please try again.