Commit 19755d21 authored by PoroCYon's avatar PoroCYon
Browse files

added some switches, other stuff

parent a7388635
...@@ -18,7 +18,7 @@ packages to happen. ...@@ -18,7 +18,7 @@ packages to happen.
* `coreutils` * `coreutils`
* `bash` * `bash`
* `strace` * [`strace`](https://gitlab.com/PoroCYon/sspt/blob/master/local/libexec/sspt/sspt-strace)
### Optional ### Optional
...@@ -172,7 +172,7 @@ I'm ***NOT*** open to adding dependency management and other fancy stuff. ...@@ -172,7 +172,7 @@ I'm ***NOT*** open to adding dependency management and other fancy stuff.
I'm ***NOT*** open to rewriting it in `<insert language here>` because I'm ***NOT*** open to rewriting it in `<insert language here>` because
shell scritps are slow/ugly/not even a real language/... . sspt isn't meant shell scritps are slow/ugly/not even a real language/... . sspt isn't meant
to be professional, or look like something 'real'. to be professional, or pretend to.
## License ## License
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
print_help() { print_help() {
(>&2 cat <<EOF (>&2 cat <<EOF
Autogenerate an .sspt file for a package. Autogenerate an .sspt file for a package.
Usage: $0 [-h|-?|--help] Usage: sspt autogen [-h|-?|--help]
Print this help text and exit. Print this help text and exit.
- $0 <package-name> - sspt autogen {-e|--edit} <package-name>
Generate the .sspt file for this package. Generate the .sspt file for this package and optionally edit
it afterwards.
Supported VCSes: git, hg, svn, cvs, bzr, mtn, darcs Supported VCSes: git, hg, svn, cvs, bzr, mtn, darcs
Supported build systems: npm, cargo, setuptools, idris, xbuild, stack, Supported build systems: npm, cargo, setuptools, idris, xbuild, stack,
cabal, scons, gradle, sbt, bazel, meson, ninja, ant, mvn, cmake, cabal, scons, gradle, sbt, bazel, meson, ninja, ant, mvn, cmake,
...@@ -125,8 +126,8 @@ autogen_vcs() { ...@@ -125,8 +126,8 @@ autogen_vcs() {
elif [ -d "_darcs/" ]; then elif [ -d "_darcs/" ]; then
autogen_darcs autogen_darcs
else else
(>&2 echo "NOTE: could not detect repository type, add the .sspt" \ (>&2 echo "NOTE: could not detect repository type of package" \
"file to make updating this pacakge possible.") "'$1', add the .sspt file to make updating this pacakge possible.")
# no upstream? # no upstream?
cat >> ".sspt" <<EOF cat >> ".sspt" <<EOF
sspt_pull() { sspt_pull() {
...@@ -563,7 +564,7 @@ EOF ...@@ -563,7 +564,7 @@ EOF
DONT_LOOK_INTO_BUILD=1 autogen_buildsys DONT_LOOK_INTO_BUILD=1 autogen_buildsys
return $? return $?
else else
(>&2 echo "Could not detect how to compile the package. ") (>&2 echo "Could not detect how to compile package '$1'.")
return 1 return 1
fi fi
...@@ -575,8 +576,8 @@ EOF ...@@ -575,8 +576,8 @@ EOF
autogen_cwd() { autogen_cwd() {
touch ".sspt" touch ".sspt"
#echo "name=\"$(basename `pwd`)\"" >> ".sspt" #echo "name=\"$(basename `pwd`)\"" >> ".sspt"
autogen_vcs autogen_vcs "$1"
autogen_buildsys autogen_buildsys "$1"
return $? return $?
} }
...@@ -587,6 +588,15 @@ main() { ...@@ -587,6 +588,15 @@ main() {
-h|-?|--help) -h|-?|--help)
print_help print_help
;; ;;
-e|--edit)
if [ -z "$2" ]; then
print_help
exit
fi
main "$2"
exec_subcommand edit "$2"
;;
*) *)
if ! exec_subcommand src-db exists "$1"; then if ! exec_subcommand src-db exists "$1"; then
(>&2 echo "Package '$1' doesn't exist.") (>&2 echo "Package '$1' doesn't exist.")
...@@ -596,7 +606,7 @@ main() { ...@@ -596,7 +606,7 @@ main() {
local PACKAGE_DIR="$SSPT_DL_DIR/$ESCAPED_PKG" local PACKAGE_DIR="$SSPT_DL_DIR/$ESCAPED_PKG"
pushd "$PACKAGE_DIR" >/dev/null pushd "$PACKAGE_DIR" >/dev/null
autogen_cwd autogen_cwd "$1"
local RETVAL=$? local RETVAL=$?
popd >/dev/null popd >/dev/null
exit $RETVAL exit $RETVAL
......
...@@ -3,15 +3,15 @@ ...@@ -3,15 +3,15 @@
print_help() { print_help() {
(>&2 cat <<EOF (>&2 cat <<EOF
Modify the database of installed binaries. Modify the database of installed binaries.
Usage: $0 -h|-?|--help Usage: sspt bin-db -h|-?|--help
Print this help text and exit. Print this help text and exit.
- $0 exists <package-name> - sspt bin-db exists <package-name>
Check whether the package has been installed. The exit code Check whether the package has been installed. The exit code
is set to 0 if the package exists, and 1 otherwise. is set to 0 if the package exists, and 1 otherwise.
- $0 reg(ister) <package-name> <file containing the list of files the package owns> - sspt bin-db reg(ister) <package-name> <file containing the list of files the package owns>
Add the package to the list of registered packages. Add the package to the list of registered packages.
Use \`sspt add\` to actually install the package. Use \`sspt add\` to actually install the package.
- $0 unreg(ister) <package-name> - sspt bin-db unreg(ister) <package-name>
Remove the package from the list of registered packages. Remove the package from the list of registered packages.
NOTE: this subcommand is supposed to be used only by ssbt internally. NOTE: this subcommand is supposed to be used only by ssbt internally.
Proceed with caution. Proceed with caution.
......
...@@ -3,26 +3,37 @@ ...@@ -3,26 +3,37 @@
print_help() { print_help() {
(>&2 cat <<EOF (>&2 cat <<EOF
Build a package. Build a package.
Usage: $0 [-h|-?|--help] Usage: sspt build [-h|-?|--help]
Print this help text and exit. Print this help text and exit.
- $0 <package-name> - sspt build {-c|--configure} <package-name>
Build the package. Build the package. Optionally configure it as well.
EOF EOF
) )
} }
DO_CONFIG='auto'
main() { main() {
case $1 in case $1 in
-h|-?|--help) -h|-?|--help)
print_help print_help
;; ;;
-c|--configure)
DO_CONFIG='y'
local ALLARGS=("$@")
main "${ALLARGS[@]:1}"
;;
*) *)
if ! exec_subcommand src-db exists "$1"; then if ! exec_subcommand src-db exists "$1"; then
# TODO: download if URL specified # TODO: download if URL specified
(>&2 echo "This package doesn't exist.") (>&2 echo "Package '$1' doesn't exist.")
exit 1 exit 1
fi fi
# assume it is already configured
if [ "$DO_CONFIG" = "y" ]; then
exec_subcommand pkgcmd configure "$1"
fi
exec_subcommand pkgcmd build "$1" exec_subcommand pkgcmd build "$1"
;; ;;
esac esac
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
print_help() { print_help() {
(>&2 cat <<EOF (>&2 cat <<EOF
Clean a package. Clean a package.
Usage: $0 [-h|-?|--help] Usage: sspt clean [-h|-?|--help]
Print this help text and exit. Print this help text and exit.
- $0 <package-name> - sspt clean <package-name>
Clean the package. Clean the package.
EOF EOF
) )
...@@ -18,7 +18,7 @@ main() { ...@@ -18,7 +18,7 @@ main() {
;; ;;
*) *)
if ! exec_subcommand src-db exists "$1"; then if ! exec_subcommand src-db exists "$1"; then
(>&2 echo "This package doesn't exist.") (>&2 echo "Package '$1' doesn't exist.")
exit 1 exit 1
fi fi
exec_subcommand pkgcmd clean "$1" exec_subcommand pkgcmd clean "$1"
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
print_help() { print_help() {
(>&2 cat <<EOF (>&2 cat <<EOF
Clean a package, including all configuration files. Clean a package, including all configuration files.
Usage: $0 [-h|-?|--help] Usage: sspt clean-config [-h|-?|--help]
Print this help text and exit. Print this help text and exit.
- $0 <package-name> - sspt clean-config <package-name>
Clean the package. Clean the package.
EOF EOF
) )
...@@ -18,7 +18,7 @@ main() { ...@@ -18,7 +18,7 @@ main() {
;; ;;
*) *)
if ! exec_subcommand src-db exists "$1"; then if ! exec_subcommand src-db exists "$1"; then
(>&2 echo "This package doesn't exist.") (>&2 echo "Package '$1' package doesn't exist.")
exit 1 exit 1
fi fi
exec_subcommand pkgcmd clean_config "$1" exec_subcommand pkgcmd clean_config "$1"
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
print_help() { print_help() {
(>&2 cat <<EOF (>&2 cat <<EOF
Configure a pacakge. Configure a pacakge.
Usage: $0 [-h|-?|--help] Usage: sspt configure [-h|-?|--help]
Print this help text and exit. Print this help text and exit.
- $0 <package-name> - sspt configure <package-name>
Configure the package. Configure the package.
EOF EOF
) )
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
print_help() { print_help() {
(>&2 cat <<EOF (>&2 cat <<EOF
Edit the .sspt file of a package. Edit the .sspt file of a package.
Usage: $0 [-h|-?|--help] Usage: sspt edit [-h|-?|--help]
Print this help text and exit. Print this help text and exit.
- $0 <package-name> - sspt edit <package-name>
Edit the .sspt file of the package using \$EDITOR. Edit the .sspt file of the package using \$EDITOR.
EOF EOF
) )
......
...@@ -3,22 +3,66 @@ ...@@ -3,22 +3,66 @@
print_help() { print_help() {
(>&2 cat <<EOF (>&2 cat <<EOF
Install a package's binary files. Install a package's binary files.
Usage: $0 [-h|-?|--help] Usage: sspt install [-h|-?|--help]
Print this help text and exit. Print this help text and exit.
- $0 <package-name> - sspt install {-f|--configure} {-b|--build } {-c|--clean}
Install the binary files of this package. {-C|--clean-cfg} <package-name>
Install the binary files of this package. Optionally configure,
build or clean it as well. (-C implies -c.)
EOF EOF
) )
} }
DO_CONF='auto'
DO_BUILD='auto'
DO_CLEAN='auto'
DO_CCFG='auto'
main() { main() {
local ALLARGS=("$@")
case $1 in case $1 in
-h|-?|--help) -h|-?|--help)
print_help print_help
;; ;;
-f|--configure)
DO_CONF='y'
main "${ALLARGS[@]:1}"
;;
-b|--build)
DO_BUILD='y'
main "${ALLARGS[@]:1}"
;;
-c|--clean)
DO_CLEAN='y'
main "${ALLARGS[@]:1}"
;;
-C|--clean-cfg)
DO_CLEAN='y'
DO_CCFG='y'
main "${ALLARGS[@]:1}"
;;
*) *)
# TODO: other stuff if ! exec_subcommand src-db exists "$1"; then
(>&2 echo "Package '$1' doesn't exist.")
exit 1
fi
if [ "$DO_CONF" = "y" ]; then
exec_subcommand pkgcmd config "$1"
fi
if [ "$DO_BUILD" = "y" ]; then
exec_subcommand pkgcmd build "$1"
fi
exec_subcommand strace "$1" exec_subcommand strace "$1"
if [ "$DO_CLEAN" = "y" ]; then
exec_subcommand pkgcmd clean "$1"
fi
if [ "$DO_CCFG" = "y" ]; then
exec_subcommand pkgcmd clean_config "$1"
fi
;; ;;
esac esac
} }
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
print_help() { print_help() {
(>&2 cat <<EOF (>&2 cat <<EOF
List pulled and installed pacakges. List pulled and installed pacakges.
Usage: $0 [-h|-?|--help] Usage: sspt list [-h|-?|--help]
Print this help text and exit. Print this help text and exit.
- $0 - sspt list {-i|--installed-only|--only-installed}
List all packages. List all packages, optionally only displaying those that
- $0 [-i|--installed-only] are installed through \`sspt install\`.
EOF EOF
) )
} }
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
print_help() { print_help() {
(>&2 cat <<EOF (>&2 cat <<EOF
Purge a package without deleting the installed binaries. Purge a package without deleting the installed binaries.
Usage: $0 [-h|-?|--help] Usage: sspt orphanize [-h|-?|--help]
Print this help text and exit. Print this help text and exit.
- $0 <package-name> - sspt orphanize <package-name>
Orphanize the package. Orphanize the package.
EOF EOF
) )
...@@ -25,7 +25,7 @@ main() { ...@@ -25,7 +25,7 @@ main() {
;; ;;
*) *)
if ! exec_subcommand src-db exists "$1"; then if ! exec_subcommand src-db exists "$1"; then
(>&2 echo "This package doesn't exist.") (>&2 echo "Package '$1' doesn't exist.")
exit 1 exit 1
fi fi
...@@ -33,7 +33,7 @@ main() { ...@@ -33,7 +33,7 @@ main() {
if exec_subcommand bin-db exists "$1"; then if exec_subcommand bin-db exists "$1"; then
exec_subcommand bin-db unreg "$1" exec_subcommand bin-db unreg "$1"
else else
(>&2 echo "This package isn't installed.") (>&2 echo "Package '$1' isn't installed.")
exit 1 exit 1
fi fi
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
print_help() { print_help() {
(>&2 cat <<EOF (>&2 cat <<EOF
Directly execute a command from a package's .sspt file. Directly execute a command from a package's .sspt file.
Usage: $0 [-h|-?|--help] Usage: sspt pkgcmd [-h|-?|--help]
Print this help text and exit. Print this help text and exit.
- $0 <command> <package-name> - sspt pkgcmd <command> <package-name>
Run <command> on the specified package. Run <command> on the specified package.
NOTE: this subcommand is supposed to be used only by ssbt internally. NOTE: this subcommand is supposed to be used only by ssbt internally.
Proceed with caution. Proceed with caution.
...@@ -27,7 +27,7 @@ main() { ...@@ -27,7 +27,7 @@ main() {
;; ;;
*) *)
if ! exec_subcommand src-db exists "$2"; then if ! exec_subcommand src-db exists "$2"; then
(>&2 echo "This package doesn't exist.") (>&2 echo "Package '$2' doesn't exist.")
exit 1 exit 1
fi fi
......
...@@ -3,11 +3,17 @@ ...@@ -3,11 +3,17 @@
print_help() { print_help() {
(>&2 cat <<EOF (>&2 cat <<EOF
Pull the source code of a package from a remote location. Pull the source code of a package from a remote location.
Usage: $0 [-h|-?|--help] Usage: sspt pull [-h|-?|--help]
Print this help text and exit. Print this help text and exit.
- $0 {--<vcs>} <repo url> - sspt pull {-n|--no-autogen} {-f|--force-autogen} {-e|--edit}
{-b|--build} {-i|--install} {--<vcs>} <repo url>
Add the repo to the database and download the source code. Add the repo to the database and download the source code.
Optionally, the VCS type can be specified. Optionally, the VCS type, whether to autogenerate the
.sspt file (-n, -f, defaults to generate if none exists),
whether to edit the .sspt file afterwards (-e, defaults to
edit if autogeneration failed) and whether to build or install
the package afterwards (resp. -b and -i, default to false, -i
implies -b) can be specified.
Supported VCSes: git, hg, svn, cvs, bzr, mtn, darcs, http(s), rsync Supported VCSes: git, hg, svn, cvs, bzr, mtn, darcs, http(s), rsync
(Those last two aren't VCSes, but you can get tarballs over them.) (Those last two aren't VCSes, but you can get tarballs over them.)
EOF EOF
...@@ -78,11 +84,49 @@ pull_with_vcs() { ...@@ -78,11 +84,49 @@ pull_with_vcs() {
esac esac
} }
DO_AUTOGEN='auto'
DO_EDIT='auto'
DO_BUILD='auto'
DO_INSTALL='auto'
main() { main() {
local ALL_ARGS=("$@")
if [ $# -eq 0 ]; then
print_help
exit
fi
case $1 in case $1 in
-h|-?|--help) -h|-?|--help)
print_help print_help
;; ;;
-n|--no-autogen)
DO_AUTOGEN='n'
main "${ALL_ARGS[@]:1}"
exit
;;
-f|--force-autogen)
DO_AUTOGEN='y'
main "${ALL_ARGS[@]:1}"
exit
;;
-e|--edit)
DO_EDIT='y'
main "${ALL_ARGS[@]:1}"
exit
;;
-b|--build)
DO_BUILD='y'
main "${ALL_ARGS[@]:1}"
exit
;;
-i|--install)
DO_BUILD='y'
DO_INSTALL='y'
main "${ALL_ARGS[@]:1}"
exit
;;
--*) --*)
pull_with_vcs "${1:2}" "$2" pull_with_vcs "${1:2}" "$2"
;; ;;
...@@ -121,15 +165,34 @@ main() { ...@@ -121,15 +165,34 @@ main() {
# need to register it before we can autogen the .sspt file # need to register it before we can autogen the .sspt file
exec_subcommand src-db reg "$PKG_NAME" dummy_revision exec_subcommand src-db reg "$PKG_NAME" dummy_revision
if ! [ -f "$SSPT_DL_DIR/$PKG_NAME/.sspt" ]; then
if [ "$DO_AUTOGEN" = "auto" ] && ! [ -f "{SSPT_DL_DIR:?}/$PKG_NAME/.sspt" ]; then
DO_AUTOGEN='y'
fi
if [ "$DO_AUTOGEN" = "y" ]; then
if ! exec_subcommand autogen "$PKG_NAME"; then if ! exec_subcommand autogen "$PKG_NAME"; then
# autogen failed -> resorting to manual edit DO_EDIT='y'
exec_subcommand edit "$PKG_NAME"
fi fi
fi fi
if [ "$DO_EDIT" = "y" ]; then
exec_subcommand edit "$PKG_NAME"
# assume the .sspt file exists and is well-formed
fi
# now set the version of the package in the DB # now set the version of the package in the DB
# (this is only possible because the .sspt file is generated) # (this is only possible because the .sspt file is generated)
exec_subcommand src-db reg "$PKG_NAME" "$(exec_subcommand pkgcmd version "$PKG_NAME")" exec_subcommand src-db reg "$PKG_NAME" "$(exec_subcommand pkgcmd version "$PKG_NAME")"
if [ "$DO_BUILD" = "y" ]; then
exec_subcommand pkgcmd config "$PKG_NAME"
exec_subcommand pkgcmd build "$PKG_NAME"
fi
if [ "$DO_INSTALL" = "y" ]; then
exec_subcommand strace "$PKG_NAME"
fi
} }
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
print_help() { print_help() {