debrepo/debrepo

73 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
VERSION="1.0.0"
DIR="$(cd "$(dirname "$0")" && pwd)"
if [ "$1" = "init" ] || [ "$1" = "-i" ] || [ "$1" = "--init" ]; then
$DIR/scripts/repoinit.sh && echo "debrepo: repository folders have been successfully created"
exit
fi
if [ "$1" = "add" ] || [ "$1" = "-a" ] || [ "$1" = "--add" ]; then
# copy deb file to repo folder structure
cp "./$2" "./apt-repo/pool/main/"
# generate package and release file
$DIR/scripts/genPkgRel.sh $2 && echo "debrepo: package $2 was successfully added"
exit
fi
if [ "$1" = "del" ] || [ "$1" = "-d" ] || [ "$1" = "--del" ]; then
rm -i "./apt-repo/pool/main/$2" && echo "debrepo: package $2 was successfully removed"
# generate package and release file
$DIR/scripts/genPkgRel.sh $2 && echo "debrepo: repository was successfully updated"
exit
fi
if [ "$1" = "list" ] || [ "$1" = "-l" ] || [ "$1" = "--list" ]; then
echo "debrepo: list of packages"
ls -l "./apt-repo/pool/main/"
exit
fi
if [ "$1" = "serve" ] || [ "$1" = "-s" ] ||[ "$1" = "--serve" ]; then
python3 -m http.server
exit
fi
if [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
echo "debrepo $VERSION"
exit
fi
#if [ "$1" = "help" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
if [ 1 ]; then
HELPMESSAGE="
debrepo $VERSION
A Debian repository management tool.
USAGE:
debrepo [OPTIONS] [DEB]
OPTIONS:
init, -i, --init
create repository folder structure
add, -a, --add
add deb package to repository
del, -d, --del
delete deb package from repository
serve, -s, --serve
serve repository using python built in http module
help, -h, --help
print help message
-v, --version
print version of debrepo package
ARGS:
<DEB>...
*.deb package to add or delete from repository.
"
printf "%s\n" "$HELPMESSAGE"
fi