update: add and rm -l option updated

This commit is contained in:
Filip Rojek 2023-05-03 17:35:26 +02:00
parent ce0b37cabe
commit 49833a67cb

10
debrepo
View File

@ -34,8 +34,9 @@ if [ "$1" = "add" ] || [ "$1" = "-a" ] || [ "$1" = "--add" ]; then
# copy deb file to repo folder structure # copy deb file to repo folder structure
if [ "$2" = "--letter-based-structure" ] || [ "$2" = "-l" ];then if [ "$2" = "--letter-based-structure" ] || [ "$2" = "-l" ];then
first_letter=$(echo "$3" | sed 's/[.\/]//g' | cut -c 1 | tr '[:upper:]' '[:lower:]') first_letter=$(echo "$3" | sed 's/[.\/]//g' | cut -c 1 | tr '[:upper:]' '[:lower:]')
mkdir "$REPODIR/apt-repo/pool/main/$first_letter/" pkg_name=$(echo "$3" | awk -F "_" '{print $1}')
cp "./$3" "$REPODIR/apt-repo/pool/main/$first_letter/$3" mkdir -p "$REPODIR/apt-repo/pool/main/$first_letter/$pkg_name/"
cp "./$3" "$REPODIR/apt-repo/pool/main/$first_letter/$pkg_name/$3"
else else
cp "./$2" "$REPODIR/apt-repo/pool/main/" cp "./$2" "$REPODIR/apt-repo/pool/main/"
fi fi
@ -48,10 +49,11 @@ fi
if [ "$1" = "del" ] || [ "$1" = "-d" ] || [ "$1" = "--del" ]; then if [ "$1" = "del" ] || [ "$1" = "-d" ] || [ "$1" = "--del" ]; then
first_letter=$(echo "$2" | sed 's/[.\/]//g' | cut -c 1 | tr '[:upper:]' '[:lower:]') first_letter=$(echo "$2" | sed 's/[.\/]//g' | cut -c 1 | tr '[:upper:]' '[:lower:]')
pkg_name=$(echo "$2" | awk -F "_" '{print $1}')
if [ -f "$REPODIR/apt-repo/pool/main/$first_letter/$2" ]; then if [ -f "$REPODIR/apt-repo/pool/main/$first_letter/$pkg_name/$2" ]; then
# remove package # remove package
rm -i "$REPODIR/apt-repo/pool/main/$first_letter/$2" && echo "debrepo: package $2 was successfully removed" rm -i "$REPODIR/apt-repo/pool/main/$first_letter/$pkg_name/$2" && echo "debrepo: package $2 was successfully removed"
elif [ -f "$REPODIR/apt-repo/pool/main/$2" ]; then elif [ -f "$REPODIR/apt-repo/pool/main/$2" ]; then
# remove package # remove package
rm -i "$REPODIR/apt-repo/pool/main/$2" && echo "debrepo: package $2 was successfully removed" rm -i "$REPODIR/apt-repo/pool/main/$2" && echo "debrepo: package $2 was successfully removed"