diff --git a/src/pm b/src/pm index e461b4b..e777caf 100755 --- a/src/pm +++ b/src/pm @@ -76,6 +76,7 @@ checknonroot() { #----------------- add(install) package function ------------------------ add() { + checkroot [[ "$packages" == "" ]] \ && help \ && exit 0 @@ -92,6 +93,7 @@ a() { #-------------------- download package without install function --------- down() { + checkroot [[ "$packages" == "" ]] \ && help \ && exit 0 @@ -131,6 +133,7 @@ download() { #-------------------- unpack local package archive ---------------------- unpack() { + checkroot [[ "$archives" == "" ]] \ && printf "${BBLUE}**${BWHITE} Specify package name [${BRED} ERROR ${BWHITE}]\n${RESET}" \ && exit 1 @@ -205,6 +208,7 @@ u() { #------------------ delete package function ----------------------------- del() { + checkroot printf "${YELLOW}**${GREEN} deleting\n${RESET}" for i in $packages; do printf "${YELLOW}**${GREEN} deleting $i\n${RESET}" @@ -345,6 +349,7 @@ ${RESET}" #------------------- sync repo function --------------------------------- sync() { + checkroot servers=$(/usr/bin/cat $repofile) for i in $servers; do printf "${YELLOW}**${GREEN} Sync ${BWHITE}$i\n${RESET}" @@ -408,6 +413,7 @@ ss() { #------------------- clear cached packages directory -------------------- clear() { + checkroot printf "${YELLOW}**${BWHITE} clearing cached packages directory " rm -rf $cachedpkgdir/* printf "[${GREEN} OK${BWHITE} ]\n${RESET}" @@ -422,6 +428,7 @@ c() { #--- show package dependencies function --- deps() { + checkroot if [[ "$packages" == "" ]]; then for i in $(/usr/bin/cat $packagesqueryfile); do cd $installedpackagesdir @@ -462,6 +469,7 @@ deps() { #--- build package uses PMBUILD file function --- buildpkg() { + checknonroot if [ ! -f ./PMBUILD ]; then if [ "$1" != "" ]; then source $1 @@ -553,6 +561,7 @@ buildpkg() { # upgrade system packages function upgrade() { + checkroot total_updates=0 for i in $(cat $packagesqueryfile); do package=$(search $(get_pkgname $i) | awk -F' ' '{ for (i=2; i<=NF; i++) { print $i } }') @@ -624,6 +633,7 @@ v() { # install pm to some rootfs directory function selfinstall() { + checkroot [ -z "$destdir" ] && destdir="rootfs" printf "${BGREEN}Installing pm to ${BWHITE}$destdir ${BGREEN}directory\n${RESET}" printf "${YELLOW}Creating directories... ${RESET}"