mirror of
https://github.com/chocolate-doom/chocpkg.git
synced 2024-11-30 16:01:10 +00:00
Add extra package info commands.
The new commands are: info, packages and dependencies. The main one is 'chocpkg info' which allows a description of a package (or of all packages) to be shown, along with its status.
This commit is contained in:
parent
128a9d35fd
commit
724eedad45
2 changed files with 113 additions and 18 deletions
124
chocpkg/chocpkg
124
chocpkg/chocpkg
|
@ -172,29 +172,117 @@ cmd_install() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $# -lt 2 ]; then
|
cmd_packages() {
|
||||||
echo "Usage: $0 [fetch|build|install|installed] <package name>"
|
for sh_file in $CHOCPKG_ROOT/pkgdef/*.sh; do
|
||||||
exit -1
|
basename "${sh_file/%.sh/}"
|
||||||
fi
|
done
|
||||||
|
}
|
||||||
|
|
||||||
cmd=$1; package=$2
|
cmd_info() {
|
||||||
configure_for_package "$package"
|
# If a specific package name is not provided, list info on
|
||||||
|
# all packages.
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
for package in $(chocpkg packages); do
|
||||||
|
chocpkg info "$package"
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
case "$cmd" in
|
configure_for_package "$2"
|
||||||
installed)
|
printf "package: %s\n" "$PACKAGE_NAME"
|
||||||
cmd_installed
|
printf "description: %s\n" "$PACKAGE_DESCRIPTION"
|
||||||
|
printf "type: %s\n" "$PACKAGE_TYPE"
|
||||||
|
|
||||||
|
printf "installed: "
|
||||||
|
if chocpkg installed "$PACKAGE_NAME"; then
|
||||||
|
printf "true\n"
|
||||||
|
else
|
||||||
|
printf "false\n"
|
||||||
|
fi
|
||||||
|
local deps=$(chocpkg dependencies "$PACKAGE_NAME")
|
||||||
|
|
||||||
|
printf "dependencies:"
|
||||||
|
for dep in $(chocpkg dependencies "$PACKAGE_NAME"); do
|
||||||
|
printf " %s" "$dep"
|
||||||
|
done
|
||||||
|
printf "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_dependencies() {
|
||||||
|
for dep in $DEPENDENCIES; do
|
||||||
|
echo "$dep"
|
||||||
|
chocpkg dependencies "$dep"
|
||||||
|
done | sort | uniq
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<END
|
||||||
|
Usage:
|
||||||
|
$0 packages
|
||||||
|
- List the names of all known packages.
|
||||||
|
|
||||||
|
$0 info [package]
|
||||||
|
- Display a description of the specified package, or all packages.
|
||||||
|
|
||||||
|
$0 install <package>
|
||||||
|
- Build and install the specified package, if not already installed.
|
||||||
|
|
||||||
|
$0 reinstall <package>
|
||||||
|
- Rebuild and reinstall the specified package, even if installed.
|
||||||
|
|
||||||
|
$0 build <package>
|
||||||
|
- Fetch and build the specified package, but do not install it.
|
||||||
|
|
||||||
|
$0 fetch <package>
|
||||||
|
- Download the specified package but do not build it.
|
||||||
|
|
||||||
|
END
|
||||||
|
}
|
||||||
|
|
||||||
|
# "Package" commands operate on a specific package named on the command line.
|
||||||
|
package_command() {
|
||||||
|
local cmd="$1" package="$2"
|
||||||
|
configure_for_package "$package"
|
||||||
|
|
||||||
|
case "$cmd" in
|
||||||
|
fetch)
|
||||||
|
cmd_fetch
|
||||||
|
;;
|
||||||
|
build)
|
||||||
|
cmd_build
|
||||||
|
;;
|
||||||
|
reinstall)
|
||||||
|
cmd_reinstall
|
||||||
|
;;
|
||||||
|
install)
|
||||||
|
cmd_install
|
||||||
|
;;
|
||||||
|
info)
|
||||||
|
cmd_info
|
||||||
|
;;
|
||||||
|
dependencies)
|
||||||
|
cmd_dependencies
|
||||||
|
;;
|
||||||
|
installed)
|
||||||
|
cmd_installed
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
case "${1:-NONE}" in
|
||||||
|
packages)
|
||||||
|
cmd_packages
|
||||||
;;
|
;;
|
||||||
fetch)
|
info)
|
||||||
cmd_fetch
|
cmd_info "$@"
|
||||||
;;
|
;;
|
||||||
build)
|
fetch|build|reinstall|install|dependencies|installed)
|
||||||
cmd_build
|
package_command "$@"
|
||||||
;;
|
;;
|
||||||
reinstall)
|
*)
|
||||||
cmd_reinstall
|
usage
|
||||||
;;
|
exit 1
|
||||||
install)
|
|
||||||
cmd_install
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -36,3 +36,10 @@ cmd_reinstall() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd_dependencies() {
|
||||||
|
for package in $PKGGRP_PACKAGES; do
|
||||||
|
echo "$package"
|
||||||
|
chocpkg dependencies "$package"
|
||||||
|
done | sort | uniq
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue