diff --git a/bin/shpkg b/bin/shpkg
index 37e5a3a..8edd3c2 100755
--- a/bin/shpkg
+++ b/bin/shpkg
@@ -7,110 +7,103 @@ set -e
: ${SHPKG_DIR:=~/shpkg}
SHPKG_SHARE_DIR="${SHPKG_DIR}/share/shpkg"
-# SHPKG
+# shpkg
. ${SHPKG_SHARE_DIR}/shpkg.subr
+# Usage
+usage () {
+ echo "Usage: shpkg OPERATION PKG ...
+
+Source directory operations :
+ clone shortcut for git clone
+ fetch shortcut for git fetch
+ pull shortcut for git pull
+ clean-sources remove source directory
+
+Compilation operations :
+ autogen shortcut for ./autogen
+ configure shortcut for ./configure
+ build shortcut for make
+ clean-configure remove configured and object files
+ clean-build remove object files
+
+Package operations :
+ fake install compiled sources into fake directory
+ package build package from sources
+ install install package
+ upgrade pull sources, build package and install
+ uninstall uninstall package
+ clean-fake remove fake installation directory
+ clean-package remove built packages
+" >&2
+ exit "$1"
+}
+
# CLI
if [ "x$1" = "xbuild" ]; then
shift
verbose 2 shpkg_build "$@"
- exit
elif [ "x$1" = "xclean-all" ]; then
shift
verbose 2 shpkg_clean_all "$@"
- exit
elif [ "x$1" = "xclean-sources" ]; then
shift
verbose 2 shpkg_clean_sources "$@"
- exit
elif [ "x$1" = "xclean-build" ]; then
shift
verbose 2 shpkg_clean_build "$@"
- exit
elif [ "x$1" = "xclean-configure" ]; then
shift
verbose 2 shpkg_clean_configure "$@"
- exit
elif [ "x$1" = "xclean-fake" ]; then
shift
verbose 2 shpkg_clean_fake "$@"
- exit
elif [ "x$1" = "xclean-package" ]; then
shift
verbose 2 shpkg_clean_package "$@"
- exit
elif [ "x$1" = "xclean-sources" ]; then
shift
verbose 2 shpkg_clean_sources "$@"
- exit
elif [ "x$1" = "xclone" ]; then
shift
verbose 2 shpkg_clone "$@"
- exit
elif [ "x$1" = "xconfigure" ]; then
shift
verbose 2 shpkg_configure "$@"
- exit
elif [ "x$1" = "xfake" ]; then
shift
verbose 2 shpkg_fake "$@"
- exit
elif [ "x$1" = "xfetch" ] ||
[ "x$1" = "xf" ]; then
shift
verbose 2 shpkg_fetch "$@"
- exit
+elif [ "x$1" = "xhelp" ] ||
+ [ "x$1" = "xh" ] ||
+ [ "x$1" = "x--help" ] ||
+ [ "x$1" = "x-h" ]; then
+ usage 1
elif [ "x$1" = "xinstall" ] ||
[ "x$1" = "xi" ]; then
shift
verbose 2 shpkg_install "$@"
- exit
+elif [ "x$1" = "xlist" ] ||
+ [ "x$1" = "xl" ]; then
+ shift
+ verbose 2 shpkg_list
elif [ "x$1" = "xpackage" ] ||
[ "x$1" = "xpkg" ]; then
shift
verbose 2 shpkg_package "$@"
- exit
elif [ "x$1" = "xpull" ] ||
[ "x$1" = "xp" ]; then
shift
verbose 2 shpkg_pull "$@"
- exit
elif [ "x$1" = "xuninstall" ]; then
shift
verbose 2 shpkg_uninstall "$@"
- exit
elif [ "x$1" = "xupdate" ]; then
verbose 2 shpkg_update
- exit
elif [ "x$1" = "xupgrade" ]; then
shift
verbose 2 shpkg_upgrade "$@"
- exit
fi
-
-echo "Usage: shpkg OPERATION PKG ...
-
-Source directory operations :
- clone shortcut for git clone
- fetch shortcut for git fetch
- pull shortcut for git pull
- clean-sources remove source directory
-
-Compilation operations :
- autogen shortcut for ./autogen
- configure shortcut for ./configure
- build shortcut for make
- clean-configure remove configured and object files
- clean-build remove object files
-
-Package operations :
- fake install compiled sources into fake directory
- package build package from sources
- install install package
- upgrade pull sources, build package and install
- uninstall uninstall package
- clean-fake remove fake installation directory
- clean-package remove built packages
-" >&2
-
-exit 1
diff --git a/bin/shpkg_bootstrap b/bin/shpkg_bootstrap
index 5d5474e..e4519c9 100755
--- a/bin/shpkg_bootstrap
+++ b/bin/shpkg_bootstrap
@@ -1,9 +1,60 @@
#!/bin/sh
+
+usage () {
+ {
+ echo 'Usage :'
+ echo ' shpkg_bootstrap [-f] [SHPKG_DIR]'
+ echo ' SHPKG_DIR="$HOME/shpkg" shpkg_bootstrap [-f]'
+ echo ' Installs shpkg into SHPKG_DIR.'
+ echo 'Options :'
+ echo ' -f Clear SHPKG_DIR before installing.'
+ echo 'Environment variables :'
+ echo ' PATH Binaries path.'
+ echo ' SHPKG_DIR Target installation directory.'
+ } >&2
+ exit 1
+}
+
set -e
-if [ "x$1" = "x" ]; then
- SHPKG_DIR=~/shpkg
+
+# config
+FORCE=No
+while [ $# -gt 0 ]; do
+ if [ "x$1" = "x-h" ]; then
+ usage
+ elif [ "x$1" = "x-f" ]; then
+ FORCE=Yes
+ shift
+ else
+ SHPKG_DIR="$1"
+ shift
+ fi
+done
+
+if [ "x${SHPKG_DIR}" = "x" ]; then
+ if [ "x${HOME}" = "x" ]; then
+ echo "HOME is not set" >&2
+ exit 1
+ fi
+ SHPKG_DIR="${HOME}/shpkg"
+fi
+
+# clone
+if [ -d "${SHPKG_DIR}" ]; then
+ if [ "x$FORCE" = "xYes" ]; then
+ rm -rf "${SHPKG_DIR}"
+ fi
else
- SHPKG_DIR="$1"
+ git clone https://git.kmx.io/kmx.io/shpkg.git "${SHPKG_DIR}"
fi
-git clone https://git.kmx.io/kmx.io/shpkg.git "${SHPKG_DIR}" >&2
+
+# profile
+{
+ echo "export SHPKG_DIR='${SHPKG_DIR}'"
+ echo "export PATH='${SHPKG_DIR}/bin:${PATH}'"
+ echo "export LD_LIBRARY_PATH='${SHPKG_DIR}/lib'"
+} > "${SHPKG_DIR}/etc/shpkg/profile"
+
+# source profile
echo ". ${SHPKG_DIR}/etc/shpkg/profile"
+. "${SHPKG_DIR}/etc/shpkg/profile"
diff --git a/share/shpkg/shpkg.subr b/share/shpkg/shpkg.subr
index e76c441..aa6b080 100644
--- a/share/shpkg/shpkg.subr
+++ b/share/shpkg/shpkg.subr
@@ -455,14 +455,8 @@ shpkg_upgrade () {
fi
}
-shpkg_upgrade_shpkg () {
- ( verbose 1 cd "${SHPKG_DIR}" &&
- verbose 1 git pull &&
- verbose 1 . "${SHPKG_DIR}/share/shpkg/shpkg.subr"; )
-}
-
-# Clean
-shpkg_clean_all() {
+# Misc
+shpkg_clean_all () {
for SHPKG_REPO; do
SHPKG_REPO_DIR="$(shpkg_dir "${SHPKG_REPO}")"
SHPKG_REPO_FAKE_DIR="$(shpkg_fake_dir "${SHPKG_REPO}")"
@@ -477,3 +471,26 @@ shpkg_clean_all() {
verbose 1 rm -rf "${SHPKG_REPO_TAG_DIR}"
done
}
+
+shpkg_list () {
+ grep -Eo '^[^#]*' "${SHPKG_REPO_INDEX}" |
+ grep -Ev '\s+#' |
+ while read SHPKG_REPO SHPKG_REPO_DIR REST; do
+ echo "${SHPKG_REPO}"
+ SHPKG_REPO_SRC_DIR="${SHPKG_SRC_DIR}/${SHPKG_REPO_DIR}"
+ if [ -d "${SHPKG_REPO_SRC_DIR}" ]; then
+ echo " Sources: ${SHPKG_REPO_SRC_DIR}"
+ fi
+ SHPKG_REPO_INSTALLED="${SHPKG_VAR_DB_DIR}/installed/${SHPKG_REPO_DIR}"
+ if [ -f "${SHPKG_REPO_INSTALLED}" ]; then
+ head -n 1 "${SHPKG_REPO_INSTALLED}" | \
+ sed -e 's/^Version: / Installed: /'
+ fi
+ done
+}
+
+shpkg_upgrade_shpkg () {
+ ( verbose 1 cd "${SHPKG_DIR}" &&
+ verbose 1 git pull &&
+ verbose 1 . "${SHPKG_DIR}/share/shpkg/shpkg.subr"; )
+}