squidpm

the squid package manager
git clone git://squid-tech.com/squidpm.git
Log | Files | Refs | README | LICENSE

commit c0e0ea79322bf80053e588a3c5c99706cfcb37d8
parent ae52eb1b286e121a9ccafbf312cdaa5208b308e8
Author: Josh Moore <jxm5210@rit.edu>
Date:   Tue, 14 Jan 2020 15:58:23 -0500

Add package: squidpm

Diffstat:
Apackages/squidpm | 31+++++++++++++++++++++++++++++++
Msquidpm.sh | 36++++++++++++++++--------------------
2 files changed, 47 insertions(+), 20 deletions(-)

diff --git a/packages/squidpm b/packages/squidpm @@ -0,0 +1,31 @@ +#!/bin/sh + +# set this to the public git url of the package +GITURL=https://github.com/joshiemoore/squidpm.git + +# the name of this package +me=$(basename "$0") +# the directory of this package +mydir=$(dirname "$0") + +cd $mydir/../ + +if [ $1 == "install" ]; then + # installation behavior for this package + # create symlinks + ln -s $PWD/squidpm.sh /usr/bin/squidpm + ln -s $PWD $PWD/repos/squidpm + + echo "Installed squidpm!" +elif [ $1 == "uninstall" ]; then + # uninstallation behavior for this package + + # remove symlinks + rm /usr/bin/squidpm + rm $PWD/repos/squidpm + + echo "Uninstalled squidpm." +elif [ $1 == "update" ]; then + # update behavior for this package + git pull +fi diff --git a/squidpm.sh b/squidpm.sh @@ -23,29 +23,34 @@ if [ "$#" -eq 0 ]; then fi if [ "$#" -gt 2 ]; then - echo "$0: Invalid number of arguments." + echo "Invalid number of arguments." exit fi # make sure the user is root if [[ $EUID > 0 ]]; then - echo "$0: This operation requires root." + echo "This operation requires root." exit fi # resolve the actual squidpm directory SPMDIR=$(dirname $(readlink -f "$0")) -if [ $1 == "list" ]; then - # list all installed packages - ls -1 $SPMDIR/repos/ - exit +if [ "$#" -eq 1 ]; then + if [ $1 == "list" ]; then + # list all installed packages + ls -1 $SPMDIR/repos/ + exit + else + echo "Invalid operation '$1'." + exit + fi fi # make sure the package exists if [ ! -f $SPMDIR/packages/$2 ]; then - echo "$0: Unrecognized package '$2'." + echo "Unrecognized package '$2'." exit fi @@ -56,7 +61,7 @@ mkdir -p $SPMDIR/repos/ if [ $1 == "install" ]; then # verify the package isn't already installed if [ -d $SPMDIR/repos/$2 ]; then - echo "$0: Package '$2' already installed." + echo "Package '$2' already installed." exit fi @@ -65,7 +70,7 @@ if [ $1 == "install" ]; then elif [ $1 == "uninstall" ]; then # verify that the package is installed if [ ! -d $SPMDIR/repos/$2 ]; then - echo "$0: Package '$2' is not installed." + echo "Package '$2' is not installed." exit fi @@ -74,26 +79,17 @@ elif [ $1 == "uninstall" ]; then elif [ $1 == "update" ]; then # verify that the package is installed if [ ! -d $SPMDIR/repos/$2 ]; then - echo "$0: Package '$2' is not installed." + echo "Package '$2' is not installed." exit fi # if so, update the package # check whether the package needs to be updated cd $SPMDIR/repos/$2 - git remote update - - LOCAL=$(git rev-parse @) - REMOTE=$(git rev-parse $(git rev-parse --abbrev-ref HEAD)) - - if [ LOCAL == REMOTE ]; then - echo "$0: Package '$2' is up-to-date." - exit - fi # remote and local are different, update the packages /bin/sh $SPMDIR/packages/$2 update else - echo "$0: Invalid operation '$1'." + echo "Invalid operation '$1'." exit fi