summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2019-09-12 21:28:34 +0200
committerLevente Polyak <anthraxx@archlinux.org>2019-09-28 00:15:48 +0200
commit5246cb9aa5bdc390c793dc261b28f3439aaad4c0 (patch)
tree42c391e3fae0eca76c83344c2598d446aa857811
parent144f8966608211f85fb492a4cce3c159989dd2eb (diff)
downloaddevtools-5246cb9aa5bdc390c793dc261b28f3439aaad4c0.tar.gz
devtools-5246cb9aa5bdc390c793dc261b28f3439aaad4c0.tar.xz
checkpkg: add option to avoid keeping the tmp dir
In some cases, like default makechrootpkg execution, the temporary directory used to assemble the differences is not required. Add an option to checkpkg that allows to get rid of that directory after run and call it automatically like that in makechrootpkg. Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
-rw-r--r--checkpkg.in45
-rw-r--r--doc/checkpkg.1.asciidoc10
-rw-r--r--makechrootpkg.in2
-rw-r--r--zsh_completion.in7
4 files changed, 61 insertions, 3 deletions
diff --git a/checkpkg.in b/checkpkg.in
index 335174c..e3d2c16 100644
--- a/checkpkg.in
+++ b/checkpkg.in
@@ -22,6 +22,48 @@ elif [[ -r "$HOME/.makepkg.conf" ]]; then
source "$HOME/.makepkg.conf"
fi
+usage() {
+ cat <<- _EOF_
+ Usage: ${BASH_SOURCE[0]##*/} [OPTIONS]
+
+ Searches for a locally built package corresponding to the PKGBUILD, and
+ downloads the last version of that package from the Pacman repositories.
+ It then compares the list of .so files provided by each version of the
+ package and outputs if there are soname differences for the new package.
+ A directory is also created using mktemp with files containing a file
+ list for both packages and a library list for both packages.
+
+ OPTIONS
+ -r, --rmdir Remove the temporary directory
+ -h, --help Show this help text
+_EOF_
+}
+
+RMDIR=0
+
+OPT_SHORT='rh'
+OPT_LONG=('rmdir' 'help')
+if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
+ exit 1
+fi
+set -- "${OPTRET[@]}"
+
+while :; do
+ case $1 in
+ -r|--rmdir)
+ RMDIR=1
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ --)
+ shift; break
+ ;;
+ esac
+ shift
+done
+
if [[ ! -f PKGBUILD ]]; then
die 'This must be run in the directory of a built package.'
fi
@@ -33,6 +75,7 @@ if [[ ${arch[0]} == 'any' ]]; then
fi
STARTDIR=$(pwd)
+(( RMDIR )) && trap 'rm -rf $TEMPDIR' EXIT INT TERM QUIT
TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX)
for _pkgname in "${pkgname[@]}"; do
@@ -92,4 +135,4 @@ for _pkgname in "${pkgname[@]}"; do
fi
done
-msg "Files saved to %s" "$TEMPDIR"
+(( RMDIR )) || msg "Files saved to %s" "$TEMPDIR"
diff --git a/doc/checkpkg.1.asciidoc b/doc/checkpkg.1.asciidoc
index 96ec645..c51cac4 100644
--- a/doc/checkpkg.1.asciidoc
+++ b/doc/checkpkg.1.asciidoc
@@ -19,6 +19,16 @@ outputs if there are soname differences for the new package. A directory is
also created using mktemp with files containing a file list for both packages
and a library list for both packages.
+Options
+-------
+
+*-r, --rmdir*::
+ Remove the temporary directory created to contain the file and library list
+ of both packages.
+
+*-h, --help*::
+ Show a help text
+
See Also
--------
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 90a812d..4238fc3 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -412,7 +412,7 @@ else
msg2 "Downloading current versions"
if pacman --noconfirm -Swdd --logfile /dev/null "${pkgnames[@]}"; then
msg2 "Checking packages"
- sudo -u "$makepkg_user" checkpkg
+ sudo -u "$makepkg_user" checkpkg --rmdir
else
warning "Skipped checkpkg due to missing packages"
fi
diff --git a/zsh_completion.in b/zsh_completion.in
index 45429bd..47719e5 100644
--- a/zsh_completion.in
+++ b/zsh_completion.in
@@ -1,4 +1,4 @@
-#compdef archbuild archco arch-nspawn archrelease commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco
+#compdef archbuild archco arch-nspawn archrelease commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco checkpkg
# License: Unspecified
m4_include(lib/valid-tags.sh)
@@ -54,6 +54,11 @@ _rebuildpkgs_args=(
'*:packages:_devtools_completions_all_packages'
)
+_checkpkg_args=(
+ '(-r --rmdir)'{-r,--rmdir}'[Remove the temporary directory]'
+ '(-h --help)'{-h,--help}'[Display usage]'
+)
+
_devtools_completions_all_packages() {
typeset -U packages
packages=($(_call_program packages pacman -Sql))