Commit 16e4d11e authored by Scott J's avatar Scott J

added new commands: `pkg add` and `pkg remove`:

- `pkg add PKGNAME` is just an alias for `pkg get`, and works the same
- `pkg remove PKGNAME` uninstalls a package, and its unused, left over deps
- can also use `pkg rm PKGNAME` too
- updated help info, usage docs and example commands to match
- added some advanced example commands too
parent 1776d72d
......@@ -3,8 +3,10 @@ EXAMPLES="EXAMPLE COMMANDS:
$SELF s SEARCH # list pkgs in current repo matching SEARCH
$SELF sa SEARCH # list pkgs in all repos matching SEARCH
$SELF n SEARCH # search name only, list all matching pkgs
$SELF g filezilla # get & install filezilla and deps
$SELF -a g filezilla # ask to download filezilla and its deps
$SELF add freeciv # get and install Freeciv and deps
$SELF rm freeciv # uninstall Freeciv and all deps
$SELF -a la # ask to delete all downloaded packages
$SELF -a e PKGNAME # install deps of PKGNAME, ask each time
$SELF -a d qupzilla-1.2.0 # ask to download qupzilla-1.2.0
......@@ -13,12 +15,25 @@ EXAMPLES="EXAMPLE COMMANDS:
$SELF d qupzilla-1.3.1 # download qupzilla-1.3.1 no questions
$SELF l qupzilla-1.3.1 # delete the downloaded qupzilla-1.3.1
$SELF pb jwm # compile, build & install the 'jwm' package
$SELF la # delete all downloaded packages without asking!
$SELF la # delete all downloaded packages, asks to confirm
$SELF li vim | $SELF -ps - # Get info on all installed Vim pkgs
$SELF li vim | $SELF -wr - # Get repo of an installed Vim pkg
$SELF li | $SELF -a u - # Ask to uninstall installed pkgs one by one
$SELF get filezilla # same as '$SELF add filezilla'
$SELF -a g filezilla # same as above, but ask first
$SELF dir2pet /path/to/dir/ # convert a local dir to a .pet package
$SELF dir2sfs /path/to/dir/ # convert a local dir to a .sfs package
$SELF i /path/to/file.pet # install PET, include the extension!
$SELF tgz2pet /path/to/file # convert a local .tar.gz file to PET
$SELF unpack /path/to/file # extract the given pkg file contents"
$SELF unpack /path/to/file # extract the given pkg file contents
ADVANCED EXAMPLES:
Get info for all dependencies of Kodi:
$SELF list-deps kodi | $SELF status -
Remove all packages that depend on SDL:
$SELF what-needs libSDL | pkg rm -
Download and unzip all repo packages matching 'freeciv':
cd /root/pkg; $SELF na freeciv | pkg d -; pkg ld freeciv | pkg unpack -"
......@@ -14,41 +14,44 @@ COMMANDS:
The commands below can be used with the options above, but they can't be
used with each other:
get|g PKGNAME download & install matching package and deps
add|a PKGNAME download & install matching package and deps
remove|rm PKGNAME uninstall a package and any left over deps
get|g PKGNAME alias of add (see the command above)
get-only|go PKGNAME same as get, but don't install
download|d PKGNAME download a package from CURRENT repo
install|i PKGNAME install a downloaded package
install-all|ia install all downloaded packages
update|pu [PKGNAME] update all matching installed packages
extract|unpack PKGFILE extract package contents into folder
repack|pr PKG build a .pet package from an installed package
deps|e PKGNAME install dependencies of matching package
deps-download|ed PKGNAME only download dependencies, no install
deps-all|ea install dependencies of all installed packages
deps-check|ec prints message about missing dependencies
what-needs|wn PKGNAME lists pkgs that depend on PKGNAME
update|pu [PKGNAME] update all matching installed packages
uninstall|u PKGNAME uninstall a pet package
uninstall|u PKGNAME uninstall a package
uninstall-all|ua uninstall all installed packages
delete|l PKGNAME delete a downloaded package
delete-all|la delete ALL downloaded pet packages!
clean [PKGNAME] delete downloaded pkg files of installed pkgs
names|n [PKG] list package name matches in the CURRENT repo
names-all|na [PKG] list package name matches in ALL repos
names-exact|ne [PKG] list EXACT package name matches in CURRENT repo
names-exact-all|nea [PKG] list EXACT package name matches in ALL repos
list-downloaded|ld [PKG] list downloaded packages, PKGNAME is a filter
list-installed|li|LI [PKG] list installed packages, PKGNAME is a filter
list-deps|le|LE PKGNAME list the dependencies of PKGNAME
build|pb PKG build a PET package from source and install it
build-list|pbl [PKG] list all build scripts, PKGNAME is optional
status|ps|PS PKG show package status (name, size, deps, etc)
entry|pe PKG show package repo entry (if in current repo)
installed|pi PKG return true if package installed, false if not
repack|pr PKG build a .pet package from an installed package
pkg-combine|pc PKG build a new package containing PKGNAME + deps
sfs-combine|sc PKG build a new SFS file containing PKGNAME + deps
extract|unpack PKGFILE extract package contents into folder
status|ps|PS PKG show package status (name, size, deps, etc)
contents|c PKG list the contents of a downloaded package
entry|pe PKG show package repo entry (if in current repo)
installed|pi PKG return true if package installed, false if not
what-needs|wn PKGNAME lists pkgs that depend on PKGNAME
which|w FILENAME find out which pkg FILENAME comes from
which-repo|wr PKG find out which repo PKG comes from
......@@ -58,14 +61,21 @@ These commands cannot be used with any other options:
search|s [SEARCH] search all package info in CURRENT repo
search-all|sa [SEARCH] search all package info in ALL repos
names|n [PKG] list package name matches in the CURRENT repo
names-all|na [PKG] list package name matches in ALL repos
names-exact|ne [PKG] list EXACT package name matches in CURRENT repo
names-exact-all|nea [PKG] list EXACT package name matches in ALL repos
repo|r [REPONAME] set repo to use, show current repo if none given
repo-info|ri REPONAME display the name, and other info of CURRENT repo
repo-list|rl list names of all available repositories
repo-file-list|rfl list all available repository files
repo-update|ru [REPONAME] update the current repo package list
repo-convert|rc FILE convert repo files to pre/post Woof format
add-source add new repo (needs repo file in ~/.packages/)
update-sources update the list of available repos
repo-pkg-scope one|all search pkgs in current repo (one), or all (all)
repo-dep-scope one|all search deps in current repo (one), or all (all)
bleeding-edge no|yes if yes, get latest pkg versions, from ANY repo
......
USAGE="Usage: ${bold}pkg remove PKGNAME${endcolour}
Uninstall an installed package, and also uninstall
all it's left over dependencies."
remove
\ No newline at end of file
......@@ -4077,6 +4077,53 @@ pkg_uninstall(){ # remove an installed package FUNCLIST
}
pkg_remove(){ # remove pkg and its leftover deps FUNC_LIST
# quit if no valid options
[ ! "$1" -o "$1" = "-" ] && print_usage uninstall && exit 1
local PKGNAME
local PKGNAME_ONLY
local PKGFILE
local pkg_ext
# get pkg extension
pkg_ext=`get_pkg_ext "$1"`
#get pkg name with version, but no extension or path
PKGNAME="$(basename "$1" .$pkg_ext)"
PKGNAME=`get_pkg_name "$PKGNAME"`
# get pkg name only .. without versions or suffix
PKGNAME_ONLY="`get_pkg_name_only "$PKGNAME"`"
pkg_uninstall "$PKGNAME"
# now we will remove any left over dependencies
file="`find $TMPDIR -iname "${1}*_dep_list"`"
if [ -f "$file" ];then
# if we have a deps list file, go over it three times, uninstalling all deps
# that have no packages that depend on them ... fugly solution, but works ok..
for x in 1 2 3 4
do
cat "$file" | tr ' ' '\n' | while read user_installed_dep
do
[ "$user_installed_dep" = '' ] && continue
ASK=false pkg_uninstall $user_installed_dep &>/dev/null && \
echo -e "${green}Uninstalled:${endcolour} $(get_pkg_name $user_installed_dep)"
done
done
fi
return 0
}
pkg_get(){ # find, download and install packages and deps FUNCLIST
# The function `choose_pkg` is run just before this one. It gives us $TMPDIR/USRPKGLIST,
......@@ -4768,7 +4815,8 @@ clean_pkgs(){ # delete downloaded pkg files of installed pkgs
# dependency funcs
get_deps_entry(){
get_deps_entry(){ # $1 is PKGNAME, returns dep entry from repo db
[ "$1" = '' -o "$1" = "-" ] && print_usage list-deps && exit 1
# get current $REPOFILE, $DEPSEARCH
......@@ -4822,7 +4870,7 @@ get_deps_entry(){
}
list_all_installed_pkgs(){
list_all_installed_pkgs(){ # list inc builtins if HIDE_BUILTINS=false
# reset list of installed pkgs
echo -n '' > $TMPDIR/installed_pkgs
......@@ -5282,6 +5330,9 @@ get_deps(){ # find, get and install the deps of pkg FUNCLIS
# mark the pkg as done!
echo "$DEPNAME_ONLY" >> $TMPDIR/PKGSDONE
# add dep to list of user installed deps
add_to_user_installed_dep_list "$DEPNAME_ONLY"
else # if not installing,
# skip dep checking of the deps that dont get installed
continue
......@@ -6380,9 +6431,10 @@ while [ $# != 0 ]; do # get all options ($# means all options)
--download|-d|download|d) [ ! "$2" ] && pkg_download || for x in $opt; do [ "$x" -a "$x" != "-" ] && pkg_download "$x"; done;;
--install|-i|install|i) [ ! "$2" ] && pkg_install || for x in $opt; do [ "$x" -a "$x" != "-" ] && pkg_install "$x"; done;;
--uninstall|-u|uninstall|u) [ ! "$2" ] && pkg_uninstall|| for x in $opt; do [ "$x" -a "$x" != "-" ] && pkg_uninstall "$x"; done;;
--remove|-rm|remove|rm) [ ! "$2" ] && pkg_remove || for x in $opt; do [ "$x" -a "$x" != "-" ] && pkg_remove "$x"; done;;
--unpack|--extract|unpack|extract)[ ! "$2" ] && pkg_unpack || for x in $opt; do [ "$x" -a "$x" != "-" ] && pkg_unpack "$x"; done;;
--clean|clean) [ ! "$2" ] && clean_pkgs || for x in $opt; do [ "$x" -a "$x" != "-" ] && clean_pkgs "$x"; done;;
--get|-g|get|g) [ ! "$2" ] && pkg_get || for x in $opt; do [ "$x" -a "$x" != "-" ] && { choose_pkg "$x"; pkg_get "$x"; }; done ;;
--get|-g|get|g|--add|add|a) [ ! "$2" ] && pkg_get || for x in $opt; do [ "$x" -a "$x" != "-" ] && { choose_pkg "$x"; pkg_get "$x"; }; done ;;
--get-only|-go|get-only|go) [ ! "$2" ] && print_usage get-only || for x in $opt; do if [ "$x" -a "$x" != "-" ];then choose_pkg "$x"; NO_INSTALL=true pkg_get "$x"; fi; done ;;
--delete|-l|delete|l) [ ! "$2" ] && print_usage delete || for x in $opt; do [ "$x" = '-' ] && continue; if [ -f "${WORKDIR}/$(basename "$x")" ];then if [ "$ASK" = true ];then echo -n "Remove package `basename $x`$QTAG "; read -n 1 CONFIRM </dev/tty; echo; else CONFIRM=y; fi; [ "$CONFIRM" = "y" ] && rm -v "${WORKDIR}/$(basename "$x")"; else not_found "$x"; fi; done ;; #110213,0.9.1 renamed to --delete|-l
--delete-all|-la|delete-all|la) ASK=true; QTAG="? (y/N)"; if [ "$ASK" = true ];then echo -en "Remove all downloaded packages in ${lightblue}${WORKDIR}/${endcolour}$QTAG"; read -n 1 CONFIRM </dev/tty; echo; else CONFIRM=y; fi; [ "$CONFIRM" = "y" ] && rm -v ${WORKDIR}/*.pet ${WORKDIR}/*.pkg.* ${WORKDIR}/*.sfs ${WORKDIR}/*.tar.* ${WORKDIR}/*.tcz ${WORKDIR}/*.txz ${WORKDIR}/*.tgz ${WORKDIR}/*.deb ${WORKDIR}/*.rpm ${WORKDIR}/*.apk ${WORKDIR}/*.gz ${WORKDIR}/*.xz 2>/dev/null; exit 0;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment