diff --git a/debrepo b/debrepo index 1a45ea8..8aa3fbd 100755 --- a/debrepo +++ b/debrepo @@ -1,5 +1,5 @@ #!/bin/sh -VERSION="1.0.0" +VERSION="0.1.0" DIR="$(cd "$(dirname "$0")" && pwd)" # location of debrepo source path # set vars @@ -31,19 +31,32 @@ if [ "$1" = "init" ] || [ "$1" = "-i" ] || [ "$1" = "--init" ]; then fi if [ "$1" = "add" ] || [ "$1" = "-a" ] || [ "$1" = "--add" ]; then - # copy deb file to repo folder structure - if [ "$2" = "--letter-based-structure" ] || [ "$2" = "-l" ];then - first_letter=$(echo "$3" | sed 's/.*\///' | cut -c 1 | tr '[:upper:]' '[:lower:]') - pkg_name=$(echo "$3" | sed 's/.*\///' | awk -F "_" '{print $1}') - mkdir -p "$REPODIR/apt-repo/pool/main/$first_letter/$pkg_name/" - cp "$3" "$REPODIR/apt-repo/pool/main/$first_letter/$pkg_name/" + if [ "$2" = "--letter-based-structure" ] || [ "$2" = "-l" ]; then + # generate package file name and copy deb file + PKG=$3 + PKG_ARCH=$(dpkg -I $PKG | grep "Architecture" | sed 's/ Architecture: //') + PKG_VERSION=$(dpkg -I $PKG | grep "Version" | sed 's/ Version: //') + PKG_NAME=$(echo "$PKG" | sed 's/.*\///' | awk -F "_" '{print $1}') + PKG_FULLNAME="${PKG_NAME}_${PKG_VERSION}_${PKG_ARCH}.deb" + FIRST_LETTER=$(echo "$PKG" | sed 's/.*\///' | cut -c 1 | tr '[:upper:]' '[:lower:]') + PKG_PATH="$REPODIR/apt-repo/pool/main/$FIRST_LETTER/$PKG_NAME/$PKG_FULLNAME" + + mkdir -p "$REPODIR/apt-repo/pool/main/$FIRST_LETTER/$PKG_NAME/" + cp $PKG $PKG_PATH else - cp "$2" "$REPODIR/apt-repo/pool/main/" + # generate package file name and copy deb file + PKG=$2 + PKG_ARCH=$(dpkg -i $PKG | grep "Architecture" | sed 's/ Architecture: //') + PKG_VERSION=$(dpkg -I $PKG | grep "Version" | sed 's/ Version: //') + PKG_NAME=$(echo "$PKG" | sed 's/.*\///' | awk -F "_" '{print $1}') + PKG_FULLNAME="${$PKG_NAME}_${PKG_VERSION}_${PKG_ARCH}.deb" + + cp $PKG "$REPODIR/apt-repo/pool/main/$PKG_FULNAME" fi # generate package and release file - $DIR/scripts/genPkgRel.sh $REPODIR $2 && echo "debrepo: package $2 was successfully added" - $DIR/scripts/gpgSign.sh $REPODIR $GPG && echo "debrepo: repo was succesfully signed" + $DIR/scripts/genPkgRel.sh $REPODIR && echo "debrepo: package $PKG_FULLNAME was successfully added" + $DIR/scripts/gpgSign.sh $REPODIR && echo "debrepo: repo was succesfully signed" exit fi diff --git a/scripts/genPkgRel.sh b/scripts/genPkgRel.sh index 190d6ca..37a98bb 100755 --- a/scripts/genPkgRel.sh +++ b/scripts/genPkgRel.sh @@ -6,9 +6,10 @@ ARCHS="$($LS -l $REPODIR/apt-repo/dists/stable/main/ | awk '{print $9}' | awk NF # generate Packages file for ARCH in $ARCHS; do - dpkg-scanpackages --multiversion --arch $ARCH "$REPODIR/apt-repo/pool/" > "$REPODIR/apt-repo/dists/stable/main/binary-$ARCH/Packages" + cd $REPODIR/apt-repo/ + dpkg-scanpackages --multiversion --arch $ARCH "pool/" > "dists/stable/main/binary-$ARCH/Packages" # compress Packages file - cat "$REPODIR/apt-repo/dists/stable/main/binary-$ARCH/Packages" | gzip -9 > "$REPODIR/apt-repo/dists/stable/main/binary-$ARCH/Packages.gz" + cat "dists/stable/main/binary-$ARCH/Packages" | gzip -9 > "dists/stable/main/binary-$ARCH/Packages.gz" done # generate Release file diff --git a/scripts/gpgSign.sh b/scripts/gpgSign.sh index c7e03af..af57703 100755 --- a/scripts/gpgSign.sh +++ b/scripts/gpgSign.sh @@ -2,21 +2,6 @@ REPODIR="$1" . $REPODIR/apt-repo/config -#KEY="$2" -#echo $KEY -#if [ $KEY = "--repodir" ]; then -# KEY="" -#fi -# -#if [ $KEY ]; then -# continue -#elif [ $DEFAULT_GPG ]; then -# KEY="$DEFAULT_GPG" -#else -# echo "error: no gpg key provided" -# exit 1 -#fi - if [ ! $DEFAULT_GPG ]; then echo "error: no gpg key provided in config file" exit 1