fix: adding and removing package from random dir

This commit is contained in:
Filip Rojek 2023-05-03 18:41:57 +02:00
parent 49833a67cb
commit 89dd681fc6

12
debrepo
View File

@ -33,12 +33,12 @@ fi
if [ "$1" = "add" ] || [ "$1" = "-a" ] || [ "$1" = "--add" ]; then 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/.*\///' | cut -c 1 | tr '[:upper:]' '[:lower:]')
pkg_name=$(echo "$3" | awk -F "_" '{print $1}') pkg_name=$(echo "$3" | sed 's/.*\///' | awk -F "_" '{print $1}')
mkdir -p "$REPODIR/apt-repo/pool/main/$first_letter/$pkg_name/" mkdir -p "$REPODIR/apt-repo/pool/main/$first_letter/$pkg_name/"
cp "./$3" "$REPODIR/apt-repo/pool/main/$first_letter/$pkg_name/$3" cp "$3" "$REPODIR/apt-repo/pool/main/$first_letter/$pkg_name/"
else else
cp "./$2" "$REPODIR/apt-repo/pool/main/" cp "$2" "$REPODIR/apt-repo/pool/main/"
fi fi
# generate package and release file # generate package and release file
@ -48,8 +48,8 @@ if [ "$1" = "add" ] || [ "$1" = "-a" ] || [ "$1" = "--add" ]; then
fi 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/.*\///' | cut -c 1 | tr '[:upper:]' '[:lower:]')
pkg_name=$(echo "$2" | awk -F "_" '{print $1}') pkg_name=$(echo "$2" | sed 's/.*\///' | awk -F "_" '{print $1}')
if [ -f "$REPODIR/apt-repo/pool/main/$first_letter/$pkg_name/$2" ]; then if [ -f "$REPODIR/apt-repo/pool/main/$first_letter/$pkg_name/$2" ]; then
# remove package # remove package