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>
This commit is contained in:
Levente Polyak 2019-09-12 21:28:34 +02:00
parent 144f896660
commit 5246cb9aa5
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
4 changed files with 61 additions and 3 deletions

View File

@ -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"

View File

@ -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
--------

View File

@ -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

View File

@ -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))