squidpm

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

commit 923a7ffce53f18ff31a1a15a6537d6b2e1c0ce5a
parent b633da4f6e0b68a9cf1e2fdc745b99575f633497
Author: Josh Moore <jxm5210@rit.edu>
Date:   Tue, 14 Jan 2020 15:03:48 -0500

Add basic package management and example package

Diffstat:
Apackages/example | 31+++++++++++++++++++++++++++++++
Msquidpm.sh | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+), 0 deletions(-)

diff --git a/packages/example b/packages/example @@ -0,0 +1,31 @@ +#!/bin/sh + +# set this to the public git url of the package +GITURL= + +# the name of this package +me=$(basename "$0") +mydir=$(dirname "$0") + +# create a repo dir for this package if it doesn't exist +mkdir -p $mydir/../repos/$me +cd $mydir/../repos/$me + +if [ $1 == "install" ]; then + # clone the repo + #git clone $GITURL . + + # installation behavior for this package + # make, make install, etc + echo "Installed example package!" +elif [ $1 == "uninstall" ]; then + # uninstallation behavior for this package + + cd .. + rm -rf $me + + echo "Uninstalled example package!" +elif [ $1 == "update" ]; then + # update behavior for this package + echo "Updated example package!" +fi diff --git a/squidpm.sh b/squidpm.sh @@ -1 +1,80 @@ +# The Squid Package Manager +# Copyright (C) 2020 Joshua Moore +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 only of the GNU Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +if [ "$#" -eq 0 ]; then + #\TODO detailed usage message + echo "Squid Package Manager" + echo "usage: squidpm <operation> <package>" + exit +fi + +if [ "$#" -ne 2 ]; then + echo "$0: Invalid number of arguments." + exit +fi + +# make sure the user is root +if [[ $EUID > 0 ]]; then + echo "$0: This operation requires root." + exit +fi + + +# resolve the actual squidpm directory +SPMDIR=$(dirname $(readlink -f "$0")) + +# make sure the package exists +if [ ! -f $SPMDIR/packages/$2 ]; then + echo "$0: Unrecognized package '$2'." + exit +fi + +# create the repos/ directory (if it doesn't exist) +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." + exit + fi + + # if not, install the package + /bin/sh $SPMDIR/packages/$2 install +elif [ $1 == "uninstall" ]; then + # verify that the package is installed + if [ ! -d $SPMDIR/repos/$2 ]; then + echo "$0: Package '$2' is not installed." + exit + fi + + # if so, uninstall the package + /bin/sh $SPMDIR/packages/$2 uninstall +elif [ $1 == "update" ]; then + # verify that the package is installed + if [ ! -d $SPMDIR/repos/$2 ]; then + echo "$0: Package '$2' is not installed." + exit + fi + + # if so, update the package + /bin/sh $SPMDIR/packages/$2 update +else + echo "$0: Invalid operation '$1'." + exit +fi