Skip to content

Commit

Permalink
improved loggin, prevent uninstalling as user when was installed as root
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapis committed Dec 18, 2011
1 parent 856112e commit b85da8f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg-install
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,23 @@ __pkg_uninstall_pkg()
do
if ! pkgutil --file-info "${_file}" | grep "^pkgid: " | grep -v ${_package} >/dev/null
then
rm -rf "${_file}"
printf "."
rm -rf "${_file}" && printf "." || {
printf "E"
printf "Can not remove ${_file}\n" >> uninstall_${_package}.log
}
fi
done < <(pkgutil --files ${_package})
printf "\n"
pkgutil --forget ${_package}
printf " done.\n"
}

__pkg_build_uninstaller()
{
{
printf "#!/usr/bin/env bash\n\n"
if ! (( UID ))
then printf "if (( UID )) ; then printf \"pkg_uninstaller: Must be run as root to uninstall this package.\\\n\"; exit 1; fi";
fi
__pkg_extract_function __pkg_uninstall_pkg
printf "\nprintf 'Uninstalling $1\\\n'\n\n"
awk '{print "__pkg_uninstall_pkg "$1;}' < ${pkg_list_prefix}_new
Expand Down

0 comments on commit b85da8f

Please sign in to comment.