comparison packaging/linux-installer.inc.in @ 728:2d64ff7e22e8

Factored out recursive deletion of empty dirs.
author Sascha Wilde <wilde@intevation.de>
date Thu, 03 Jul 2014 10:43:39 +0200
parents feaabee15e72
children efc2d16ab514
comparison
equal deleted inserted replaced
727:feaabee15e72 728:2d64ff7e22e8
171 if [ $SYSINST -eq 1 -a "$UID" -ne 0 ] ; then 171 if [ $SYSINST -eq 1 -a "$UID" -ne 0 ] ; then
172 fatal "System wide installation requires root privileges!" 172 fatal "System wide installation requires root privileges!"
173 fi 173 fi
174 } 174 }
175 175
176 rm_empty_dirs()
177 {
178 # Args: $1 - DIRECTORY
179 #
180 # Recursively remove DIRECTORY and all it _parent_ directories as
181 # long as they are empty.
182 local directory="$1"
183 while [ "$directory" -a -z "$(ls -A "$directory")" ] ; do
184 echo "Deleting empty directory '$directory' ..."
185 rmdir "$directory"
186 directory=`dirname "$directory"`
187 done
188 }
189
176 deinstall_certs() 190 deinstall_certs()
177 { 191 {
178 local cinst="${oldinstcfg[PREFIX]}/bin/cinst" 192 local cinst="${oldinstcfg[PREFIX]}/bin/cinst"
179 local certlist=`ls -1 ${instdata_path}/list-*.txt | sort -nr | head -n 1` 193 local certlist=`ls -1 ${instdata_path}/list-*.txt | sort -nr | head -n 1`
180 194
181 echo "Uninstalling certificates ..." 195 echo "Uninstalling certificates ..."
182 196
183 if [ "$certlist" ] ; then 197 if [ "$certlist" ] ; then
184 echo "Using certificate list '$certlist'." 198 echo "Using certificate list '$certlist'."
185 if [ -x "$cinst" ] ; then 199 if [ -x "$cinst" ] ; then
186 "$cinst" "list=$certlist" "choices=uninstall" 200 "$cinst" "list=$certlist" "choices=uninstall"
187 else 201 else
203 for file in $BINNAMES ; do 217 for file in $BINNAMES ; do
204 local path="${deinstdir}/$file" 218 local path="${deinstdir}/$file"
205 echo "Deleting '$path' ..." 219 echo "Deleting '$path' ..."
206 rm "$path" || echo >&2 "WARNING: Could not delete: '$path'!" 220 rm "$path" || echo >&2 "WARNING: Could not delete: '$path'!"
207 done 221 done
208 while [ "$deinstdir" -a -z "$(ls -A "$deinstdir")" ] ; do 222 rm_empty_dirs "$deinstdir"
209 echo "Deleting empty directory '$deinstdir' ..."
210 rmdir "$deinstdir"
211 deinstdir=`dirname "$deinstdir"`
212 done
213 echo "Removing installation configuration from: $instcfg_file ..." 223 echo "Removing installation configuration from: $instcfg_file ..."
214 rm "$instcfg_file" 224 rm "$instcfg_file"
215 echo "Deinstallation finished." 225 echo "Deinstallation finished."
216 else 226 else
217 echo "No current installation found! No harm done." 227 echo "No current installation found! No harm done."

http://wald.intevation.org/projects/trustbridge/