aboutsummaryrefslogtreecommitdiff
path: root/xpkg
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-18 18:49:13 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-18 18:49:37 +0200
commit123687a5aa3482b5ba9ca86179526c94422b409d (patch)
tree83fa480a7727cd67eb5840e7555d984478c53afd /xpkg
parent830afa08f95e2026f97b62d22484c27d42c104b1 (diff)
downloadpatches-123687a5aa3482b5ba9ca86179526c94422b409d.tar.gz
Add savepatch, xpkg scripts
Diffstat (limited to 'xpkg')
-rwxr-xr-xxpkg26
1 files changed, 26 insertions, 0 deletions
diff --git a/xpkg b/xpkg
new file mode 100755
index 0000000..c63962b
--- /dev/null
+++ b/xpkg
@@ -0,0 +1,26 @@
+#!/bin/sh -e
+
+# xpkg -- fetch and extract pkgsrc archive
+
+case "$PWD" in
+/usr/pkgsrc/*/*) ;;
+*) echo "${0##*/}: not in package directory" 1>&2; exit 1 ;;
+esac
+
+make fetch
+f=/usr/pkgsrc/distfiles/$(sed -n '/.*(\(.*\)).*/{s//\1/;p;q}' distinfo)
+d=$(tar -tf "$f" | head -1)
+
+opt=
+if [ -e "$d" ]; then
+ printf "%s: $d already exists; overwrite? " "${0##*/}"
+ read ans
+ case $ans in
+ y*) opt=-U ;;
+ *) exit 1 ;;
+ esac
+fi
+
+echo extracting archive... 1>&2
+tar -x $opt -f "$f"
+echo "$d"