aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-09-21 21:04:06 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-09-21 21:04:06 -0300
commit155a47c8b763aedf2a5394650c2df9298badd8c6 (patch)
tree9c11d2ef33c3462fd29455295cfa6f13670ab143
parent1e8dd05a04e3d4faf48bc4507c17bcbd85f352f8 (diff)
downloadstowpkg-155a47c8b763aedf2a5394650c2df9298badd8c6.tar.gz
stowpkg-155a47c8b763aedf2a5394650c2df9298badd8c6.tar.bz2
Implement other actions
-rw-r--r--README.md25
-rw-r--r--ports/net/luakit/env10
-rwxr-xr-xstowpkg172
3 files changed, 181 insertions, 26 deletions
diff --git a/README.md b/README.md
index aeadff9..eed9d05 100644
--- a/README.md
+++ b/README.md
@@ -31,12 +31,18 @@ installed using
Usage
-----
- stowpkg search # list packages available on ports
- stowpkg install <package> # install packages from source
- stowpkg build # simple package builder (./configure && make && make install)
- stowpkg list # list packages installed
- stowpkg sources # list program sources available
- stowpkg binaries # list program binaries available
+ stowpkg install <package> # install packages from source
+ stowpkg switch <package> <version> # switch a package to another available version
+ stowpkg remove <package> # remove packages
+ stowpkg reinstall <package> # reinstall packages
+ stowpkg build # simple package builder (./configure && make && make install)
+ stowpkg search # list packages available on ports
+ stowpkg list # list packages installed
+ stowpkg sources # list program sources available
+ stowpkg binaries # list program binaries available
+ stowpkg purge <package> # purge packages
+ stowpkg upgrade <package> # upgrade packages
+ stowpkg update # update ports repository
Running installed applications
------------------------------
@@ -82,12 +88,7 @@ Further development
Other commands can easily be implemented:
- stowpkg remove <package> # remove packages
- stowpkg purge <package> # purge packages
- stowpkg update # update ports repository
- stowpkg upgrade [package] # upgrade packages
- stowpkg upstream <package> # check packages versions at upstream
- stowpkg switch <package> <version> # switch a package to another available version
+ stowpkg upstream <package> # check packages versions at upstream
Also, per-architecture binary package support might be implemented using
git-annex and GnuPG signatures, giving us commands like
diff --git a/ports/net/luakit/env b/ports/net/luakit/env
index 5efa547..77d81cb 100644
--- a/ports/net/luakit/env
+++ b/ports/net/luakit/env
@@ -1,5 +1,13 @@
+# Latest upstream version
#version="master"
-version="23f2af889da9eab5b8209cb1ea86e35f5c3662f4"
+
+# Arbitrary upstream version
+#version="23f2af889da9eab5b8209cb1ea86e35f5c3662f4"
+
+# Latest stable version - Luakit 2017.08.10
+version="c5328c2260bccd074d7650931ef09081bb0f2eb1"
+
+# Other parameters
source_format="git"
url="https://github.com/luakit/luakit"
dependencies_stowpkg=""
diff --git a/stowpkg b/stowpkg
index f182bd0..7778f00 100755
--- a/stowpkg
+++ b/stowpkg
@@ -18,10 +18,22 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Parameters
+PROGRAM="$0"
VERSION="0.0.1"
-DIRNAME="$(cd `dirname $0` && pwd)"
-BASENAME="`basename $0`"
+DIRNAME="$(cd `dirname $PROGRAM` && pwd)"
+BASENAME="`basename $PROGRAM`"
ACTION="$1"
+CWD="`pwd`"
+
+__stowpkg_cd () {
+ if [ -z "$1" ]; then
+ cd $CWD > /dev/null 2>&1
+ else
+ if [ -d "$1" ]; then
+ cd $1 > /dev/null 2>&1
+ fi
+ fi
+}
__stowpkg_initialize () {
# Check for stow
@@ -77,7 +89,7 @@ stowpkg_usage () {
echo ""
echo "available actions:"
echo ""
- grep "^stowpkg_" $0 | cut -d ' ' -f 1 | sed -e 's/stowpkg_//' | sort | xargs -L 6 | column -t -c 6 | sed -e 's/^/\t/'
+ grep "^stowpkg_" $PROGRAM | cut -d ' ' -f 1 | sed -e 's/stowpkg_//' | sort | xargs -L 6 | column -t -c 6 | sed -e 's/^/\t/'
echo ""
exit 1
@@ -89,7 +101,7 @@ stowpkg_search () {
if [ ! -z "$package" ]; then
stowpkg_search | grep "$package$"
else
- ( cd $PORTS && find -name 'desc' | sed -e 's|^\./||' -e 's|/desc||' )
+ ( __stowpkg_cd $PORTS && find -name 'desc' | sed -e 's|^\./||' -e 's|/desc||' )
fi
}
@@ -101,7 +113,7 @@ stowpkg_install () {
fi
# Find package on ports
- local location="$PORTS/`$0 search $package`"
+ local location="$PORTS/`$PROGRAM search $package`"
if [ "$location" = "${PORTS}/" ]; then
echo "$BASENAME: package not found: $package"
@@ -113,6 +125,14 @@ stowpkg_install () {
exit 1
fi
+ local installed="`stowpkg_list $package-`"
+
+ if [ ! -z "$installed" ]; then
+ echo "$BASENAME: package $package already installed"
+ echo "to reinstall, use '$BASENAME reinstall $package'"
+ exit 1
+ fi
+
# Source environment
if [ -e "$location/env" ]; then
. $location/env
@@ -132,7 +152,7 @@ stowpkg_install () {
# Resolve default dependencies
if [ ! -z "$dependencies_stowpkg" ]; then
for dependency in $dependencies_stowpkg; do
- $0 install $dependency
+ $PROGRAM install $dependency
done
fi
@@ -144,7 +164,7 @@ stowpkg_install () {
fi
# Go to sources folder
- cd $SOURCES
+ __stowpkg_cd $SOURCES
# Download sources if needed
if [ ! -d "${package}-${source_version}" ]; then
@@ -160,7 +180,7 @@ stowpkg_install () {
fi
# Go to source folder
- cd ${package}-${source_version}
+ __stowpkg_cd ${package}-${source_version}
if [ "$source_format" = "git" ]; then
git fetch --all
@@ -171,6 +191,17 @@ stowpkg_install () {
stowpkg_build $package $version
}
+stowpkg_reinstall () {
+ local package="$1"
+
+ if [ -z "$package" ]; then
+ echo "usage: $BASENAME reinstall <package>"
+ exit 1
+ fi
+
+ stowpkg_remove $package && stowpkg_install $package
+}
+
stowpkg_build () {
local package="$1"
local version="$2"
@@ -205,7 +236,7 @@ stowpkg_build () {
fi
fi
- cd $BINARIES
+ __stowpkg_cd $BINARIES
if [ -d "${package}-${version}" ]; then
stow ${package}-${version} || exit 1
@@ -213,13 +244,15 @@ stowpkg_build () {
echo "$BASENAME: error building $package"
exit 1
fi
+
+ __stowpkg_cd
}
stowpkg_list () {
local pattern="$1"
if [ ! -z "$pattern" ]; then
- local name="-name \'*$pattern*\'"
+ local name="-name \'$pattern*\'"
fi
find $BASE -type l | while read file; do
@@ -232,15 +265,128 @@ stowpkg_list () {
}
stowpkg_binaries () {
- ls $BINARIES
+ ls -1 $BINARIES
}
stowpkg_sources () {
- ls $SOURCES
+ ls -1 $SOURCES
+}
+
+stowpkg_switch () {
+ local package="$1"
+ local version="$2"
+
+ if [ -z "$version" ]; then
+ echo "usage: $BASENAME switch <package> <version>"
+ exit 1
+ fi
+
+ if [ ! -d "$BINARIES/${package}-${version}" ]; then
+ echo "$BASENAME: binaries not found for ${package}-${version}"
+ exit 1
+ fi
+
+ local installed="`stowpkg_list $package | sed -e "s/$package-//"`"
+
+ if [ "$version" = "$installed" ]; then
+ echo "$BASENAME: package $version already installed"
+ exit
+ fi
+
+ __stowpkg_cd $BINARIES
+
+ echo "Removing currently installed ${package}-${installed}..."
+ stow --delete ${package}-${installed}
+
+ echo "Switching to ${package}-${version}..."
+ stow ${package}-${version}
+
+ __stowpkg_cd
+}
+
+stowpkg_remove () {
+ local package="$1"
+
+ if [ -z "$package" ]; then
+ echo "usage: $BASENAME remove <package>"
+ exit 1
+ fi
+
+ local installed="`stowpkg_list $package-`"
+
+ if [ -z "$installed" ]; then
+ echo "$BASENAME: package $package not installed"
+ exit 1
+ fi
+
+ __stowpkg_cd $BINARIES
+ echo "Removing currently installed ${installed}..."
+ stow --delete $installed
+ __stowpkg_cd
+}
+
+stowpkg_purge () {
+ local package="$1"
+
+ if [ -z "$package" ]; then
+ echo "usage: $BASENAME purge <package>"
+ exit 1
+ fi
+
+ local installed="`stowpkg_list $package-`"
+
+ if [ ! -z "$installed" ]; then
+ stowpkg_remove $package
+ fi
+
+ echo "Removing all sources and binaries that matches $package..."
+ rm -rf $BINARIES/$package-*
+ rm -rf $SOURCES/$package-*
+}
+
+stowpkg_upgrade () {
+ local package="$1"
+
+ if [ -z "$package" ]; then
+ echo "usage: $BASENAME upgrade <package>"
+ exit 1
+ fi
+
+ local location="$PORTS/`$PROGRAM search $package`"
+
+ if [ "$location" = "${PORTS}/" ]; then
+ echo "$BASENAME: package not found: $package"
+ exit 1
+ fi
+
+ local installed="`stowpkg_list $package-`"
+
+ if [ -z "$installed" ]; then
+ echo "$BASENAME: package $package not installed"
+ exit 1
+ fi
+
+ if [ -e "$location/env" ]; then
+ . $location/env
+ fi
+
+ local current="`stowpkg_list $package | sed -e "s/$package-//"`"
+
+ if [ "$version" = "$current" ]; then
+ echo "$BASENAME: current package $version already installed"
+ exit
+ fi
+
+ stowpkg_remove $package && stowpkg_install $package
+}
+
+stowpkg_update () {
+ __stowpkg_cd $DIRNAME && git pull
+ __stowpkg_cd
}
# Dispatch
-if grep -q "^stowpkg_$ACTION () {$" $0; then
+if grep -q "^stowpkg_$ACTION () {$" $PROGRAM; then
__stowpkg_initialize
shift
stowpkg_$ACTION $*