Skip to content

Commit e23a2da

Browse files
committed
dummy-dependency: fix, implement actual package remove or purge
1 parent b70b5dd commit e23a2da

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

usr/bin/dummy-dependency

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ Description: dummy-package for '${package_to_replace}'
7070
echo "$0: INFO: Dummy package created."
7171
}
7272

73-
# Validate package name, see
74-
# https://www.debian.org/doc/debian-policy/ch-controlfields.html#source
73+
## Validate package name, see
74+
## https://www.debian.org/doc/debian-policy/ch-controlfields.html#source
7575
if ! grep --quiet '^[a-z0-9]\+[a-z0-9+-.]\+$' -- <<< "${package_to_replace}" ; then
7676
echo "$0: ERROR: Package name is invalid, check for typos" >&2
7777
exit 1
@@ -83,7 +83,7 @@ Description: dummy-package for '${package_to_replace}'
8383
# exit 1
8484
# fi
8585

86-
## Ensure $TMPDIR is set
86+
## Ensure ${TMPDIR} is set
8787
if [ ! -v TMPDIR ]; then
8888
TMPDIR=''
8989
fi
@@ -126,15 +126,30 @@ Description: dummy-package for '${package_to_replace}'
126126
#lintian --pedantic --info --display-info "${deb_file_copy}"
127127

128128
echo "$0: Executing: apt-get $yes_option install -- ${deb_file_copy}"
129-
if ! apt-get $yes_option install -- "${deb_file_copy}" ; then
129+
if apt-get $yes_option install -- "${deb_file_copy}" ; then
130+
echo "$0: INFO: Dummy package installed."
131+
else
130132
echo "$0: ERROR: 'apt-get install' command failed!" >&2
131133
exit 1
132134
fi
133-
echo "$0: INFO: Dummy package installed."
134135

135-
if [ "${remove_option}" = '--purge' ]; then
136+
echo "$0: INFO: Removing package: '${package_to_replace}'"
137+
if [ "${remove_option}" = '--remove' ]; then
138+
echo "$0: INFO: Not purging old package configuration files... (Because not using '--purge'.)"
139+
echo "$0: INFO: Executing: apt-get $yes_option remove -- ${package_to_replace}"
140+
if apt-get $yes_option remove -- ${package_to_replace} ; then
141+
echo "$0: INFO: Package removed."
142+
else
143+
echo "$0: ERROR: 'apt-get remove' command failed!" >&2
144+
fi
145+
elif [ "${remove_option}" = '--purge' ]; then
136146
echo "$0: INFO: Purging old package configuration files..."
137147
echo "$0: INFO: Executing: apt-get $yes_option purge -- ${package_to_replace}"
148+
if apt-get $yes_option purge -- ${package_to_replace} ; then
149+
echo "$0: INFO: Package purged."
150+
else
151+
echo "$0: ERROR: 'apt-get purge' command failed!" >&2
152+
fi
138153
fi
139154

140155
cleanup

0 commit comments

Comments
 (0)