comparison contrib/packaging/builddeb @ 40104:338230555429

packaging: blindly factor out trap's cleanup function in builddeb This commit blindly extracts builddeb's trap routine in a dedicated function. While doing so, I think two bugs are exposed, which will be addressed in the next commits: - single quoting around '$CLEANUP' will always evaluate to the literal '$CLEANUP' regardless of the variable's value. The "if" will always be true. - the removal operation will not expand $PWD (and a variable expansion would need double quotes, anyways.
author muxator <a.mux@inwind.it>
date Tue, 09 Oct 2018 22:16:25 +0200
parents 01425e3c2645
children d3780c8f3180
comparison
equal deleted inserted replaced
40103:01425e3c2645 40104:338230555429
11 BUILD=1 11 BUILD=1
12 CLEANUP=1 12 CLEANUP=1
13 DISTID=`(lsb_release -is 2> /dev/null | tr '[:upper:]' '[:lower:]') || echo debian` 13 DISTID=`(lsb_release -is 2> /dev/null | tr '[:upper:]' '[:lower:]') || echo debian`
14 CODENAME=`lsb_release -cs 2> /dev/null || echo unknown` 14 CODENAME=`lsb_release -cs 2> /dev/null || echo unknown`
15 DEBFLAGS=-b 15 DEBFLAGS=-b
16
17 cleanup() {
18 if [ '$CLEANUP' ]; then
19 rm -r '$PWD/debian';
20 fi
21 }
22
16 while [ "$1" ]; do 23 while [ "$1" ]; do
17 case "$1" in 24 case "$1" in
18 --distid ) 25 --distid )
19 shift 26 shift
20 DISTID="$1" 27 DISTID="$1"
42 exit 1 49 exit 1
43 ;; 50 ;;
44 esac 51 esac
45 done 52 done
46 53
47 trap "if [ '$CLEANUP' ] ; then rm -r '$PWD/debian' ; fi" EXIT 54 trap 'cleanup' EXIT
48 55
49 set -u 56 set -u
50 57
51 if [ ! -d .hg ]; then 58 if [ ! -d .hg ]; then
52 printf "You are inside %s, which is not the root of a Mercurial repository\n" $(pwd) 1>&2 59 printf "You are inside %s, which is not the root of a Mercurial repository\n" $(pwd) 1>&2