This commit is contained in:
emmett1
2017-11-12 23:15:14 +08:00
parent d6302d372f
commit 9715efd331
5 changed files with 64 additions and 47 deletions

View File

@@ -81,16 +81,7 @@ getsource() {
downloadsource $sources
fi
done
}
checkforwget() {
if [ ! -e /usr/bin/wget ]; then
msgerr "Wget not installed."
exitscript1
fi
}
}
downloadsource(){
@@ -114,7 +105,7 @@ downloadsource(){
if [ -f $SOURCE_DIR/$tarballname ]; then
msg "Source file ${color_green}$tarballname${color_reset} found."
else
checkforwget
checktool wget
if [ -f $SOURCE_DIR/$tarballname.partial ]; then
msg "Resuming ${color_green}$1${color_reset}."
$WGETRESUME $tarballurl && mv $SOURCE_DIR/$tarballname.partial $SOURCE_DIR/$tarballname || exitscript1

View File

@@ -74,6 +74,28 @@ rm_silent() {
command rm "$@" 2> /dev/null
}
needroot() {
if [ $UID != 0 ]; then
if [ "$#" -eq 0 ]; then
needroot "This operation"
else
msgerr "$@ need root access!"
fi
exit 1
fi
}
checktool() {
if ! type -pa $1 &>/dev/null; then
msgerr "$1 not exist in your system!"
exit 1
fi
}
updmimedb() {
# msg2 "Update mime database..."

View File

@@ -449,7 +449,7 @@ parse_options() {
NO_ORPHAN_CHECK=yes
;;
*.spkg.txz)
[ -f "$1" ] && PKGNAME="$1" || msg "${color_red}$1${color_reset} not exist."
PKGNAME="$1"
;;
-h|--help)
SHOW_HELP=yes
@@ -470,6 +470,18 @@ main() {
parse_options "$@"
### NOT STATED PACKAGE ###
if [ -z $PKGNAME ]; then
msgerr "Please state the package to install."
exit 1
fi
### CHECK EXISTANT OF PACKAGE FILE ###
if [ ! -f $PKGNAME ]; then
msgerr "Package ${color_red}$1${color_reset} not exist!"
exit 1
fi
### DISABLE COLOR ###
if [ "$NO_COLOR" ]; then
nocolor
@@ -481,12 +493,7 @@ main() {
exit 0
fi
### CHECK FOR ROOT ACCESS ###
if [ "$UID" != "0" ]; then
msgerr "${color_red}Installing package need root access!${color_reset}"
exit 1
fi
needroot "Installing package"
check_directory
### CHECK FOR LOCK FILE ###
@@ -496,12 +503,6 @@ main() {
exit 1
fi
### NOT STATED PACKAGE ###
if [ -z $PKGNAME ]; then
msgerr "${color_red}Please state the package to install.${color_reset}"
exit 1
fi
### GET NAME, VERSION, RELEASE FROM PACKAGE ###
getname # get info from package

View File

@@ -108,18 +108,6 @@ run_postremove() {
}
updateinfopages() {
pushd /usr/share/info
if [ -f dir ]; then
rm dir
fi
for f in *; do
install-info $f dir 2>/dev/null
done
popd
}
getoldname() {
iname=$(cat $INDEX_DIR/$1/.pkginfo | grep ^name | cut -d " " -f3)
@@ -254,17 +242,13 @@ main() {
nocolor
fi
needroot "Removing package"
if [ -z $RMNAME ]; then
msgerr "Please state package name for remove."
exit 1
fi
### CHECK FOR ROOT ACCESS ###
if [ "$UID" != "0" ]; then
msgerr "Removing package need root access."
exit 1
fi
check_directory
### CHECK FOR LOCK FILE ###

29
scratch
View File

@@ -382,11 +382,7 @@ pkgcache() {
clearpkgcache() {
### CHECK FOR ROOT ACCESS ###
if [ "$UID" != "0" ]; then
msgerr "${color_red}Removing package & source cache need root access!${color_reset}"
exit 1
fi
needroot "Removing package & source cache"
getpkgcache
@@ -404,6 +400,20 @@ clearpkgcache() {
}
updports() {
needroot "Updating ports"
for repo in ${PORT_REPO[@]}; do
portname=$(basename $(echo $repo))
if [ -f /etc/ports/$portname.httpup ]; then
. /etc/ports/$portname.httpup
httpup sync $URL $repo
fi
done
}
interrupted() {
exit 1
}
@@ -512,6 +522,9 @@ parse_options() {
--clear-cache)
CLEAR_PKG_CACHE=yes
;;
-up|--update-ports)
UPD_PORTS=yes
;;
-c|--cat-port)
if [ ! "$2" ]; then
msg "Option '$1' require an argument (package to show its port script)"
@@ -637,6 +650,12 @@ main() {
nocolor
fi
### UPDATE PORTS ###
if [ $UPD_PORTS ]; then
updports
exit 0
fi
### LIST PACKAGES & SOURCE CACHE ###
if [ $PKG_CACHE ]; then
pkgcache