Compare commits

..

1 Commits

Author SHA1 Message Date
d3f1349838 distro specific prep 2023-05-08 11:08:25 +02:00
6 changed files with 83 additions and 52 deletions

View File

@ -2,6 +2,17 @@
A Debian repository management tool.
## Development
__Warning! This software is still under development and is not intended for stable use.__
### Todo
- [x] finish add feature
- [x] create del feature
- [ ] multiple repositories feature
- [ ] multiple archs feature
- [x] signing repositories using GPG
- [ ] make simple way to edit repository info in release file
## About
`Debrepo` is a software tool designed for creating and managing Debian repositories for `*.deb` packages, providing a lightweight and user-friendly alternative to more complex tools like `reprepo` or `aptly`. While these alternatives may offer more advanced features, Debrepo focuses on providing essential functionality and ease of use for repository management, allowing users to easily add, remove, and update packages within their repositories. With Debrepo, users can efficiently manage their Debian repositories without the unnecessary complexity of more advanced tools.
@ -9,13 +20,11 @@ A Debian repository management tool.
`sh` `dpkg` `gpg` `python3`
## Installation
### from source
- clone this repository to some folder inside your file system
- make symlink to `/bin/`
- now you should be able to use `debrepo`
### from deb package
- *Todo*
- Todo
### from source
- Todo
## How to use
```

48
debrepo
View File

@ -1,13 +1,10 @@
#!/bin/sh
VERSION="0.1.0"
#DIR="$(cd "$(dirname "$0")" && pwd)" # location of debrepo source path
SCRIPT_PATH=$(readlink -f "$0")
DIR=$(dirname "$SCRIPT_PATH")
VERSION="1.0.0"
DIR="$(cd "$(dirname "$0")" && pwd)" # location of debrepo source path
# set vars
index=1
for arg in $@; do
# set REPODIR variable
if [ $arg = "--repodir" ]; then
ARGID="$((index+1))"
eval "REPODIR=\$$ARGID"
@ -18,6 +15,11 @@ for arg in $@; do
eval "GPG=\$$ARGID"
fi
if [ $arg = "--distro" ]; then
ARGID="$((index+1))"
eval "DISTRO=\$$ARGID"
fi
index=$((index+1))
done
@ -33,32 +35,26 @@ if [ "$1" = "init" ] || [ "$1" = "-i" ] || [ "$1" = "--init" ]; then
fi
if [ "$1" = "add" ] || [ "$1" = "-a" ] || [ "$1" = "--add" ]; then
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"
# if distro specific package
if [ "$DISTRO" ]; then
echo "distro: $DISTRO"
mkdir -p "$REPODIR/apt-repo/pool/main/$FIRST_LETTER/$PKG_NAME/"
cp $PKG $PKG_PATH
exit
fi
exit
# 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/"
else
# 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"
cp "$2" "$REPODIR/apt-repo/pool/main/"
fi
# generate package and release file
$DIR/scripts/genPkgRel.sh $REPODIR && echo "debrepo: package $PKG_FULLNAME was successfully added"
$DIR/scripts/gpgSign.sh $REPODIR && echo "debrepo: repo was succesfully signed"
$DIR/scripts/genPkgRel.sh $REPODIR $2 $DISTRO && echo "debrepo: package $2 was successfully added"
$DIR/scripts/gpgSign.sh $REPODIR $GPG $DISTRO && echo "debrepo: repo was succesfully signed"
exit
fi

View File

@ -1,20 +1,22 @@
#!/bin/sh
#DIR="$(cd "$(dirname "$0")" && pwd)"
SCRIPT_PATH=$(readlink -f "$0")
DIR=$(dirname "$SCRIPT_PATH")
LS="$(which ls)" # this prevents bugs when aliasing ls to tools like exa
DIR="$(cd "$(dirname "$0")" && pwd)"
REPODIR="$1"
ARCHS="$($LS -l $REPODIR/apt-repo/dists/stable/main/ | awk '{print $9}' | awk NF | awk -F - '{print $2}')"
DISTRO="$3"
if [ !$DISTRO ]; then
DISTRO="stable"
fi
ARCHS="$($LS -l $REPODIR/apt-repo/dists/$DISTRO/main/ | awk '{print $9}' | awk NF | awk -F - '{print $2}')"
# generate Packages file
cd $REPODIR/apt-repo/
for ARCH in $ARCHS; do
dpkg-scanpackages --multiversion --arch $ARCH "pool/" > "dists/stable/main/binary-$ARCH/Packages"
dpkg-scanpackages --multiversion --arch $ARCH "$REPODIR/apt-repo/pool/" > "$REPODIR/apt-repo/dists/$DISTRO/main/binary-$ARCH/Packages"
# compress Packages file
cat "dists/stable/main/binary-$ARCH/Packages" | gzip -9 > "dists/stable/main/binary-$ARCH/Packages.gz"
cat "$REPODIR/apt-repo/dists/$DISTRO/main/binary-$ARCH/Packages" | gzip -9 > "$REPODIR/apt-repo/dists/$DISTRO/main/binary-$ARCH/Packages.gz"
done
# generate Release file
cd "dists/stable/"
$DIR/generate-release.sh > "Release"
cd "$REPODIR/apt-repo/dists/$DISTRO/"
$DIR/generate-release.sh $DISTRO > "Release"

View File

@ -2,6 +2,15 @@
set -e
. ../../config # this file is in /apt-repo/config
if [ ! $DISTRO ]; then
DISTRO="stable"
fi
if [ ! -f "../../config" ]; then
echo "error - config file does not exists"
exit 1;
fi
do_hash() {
HASH_NAME=$1
HASH_CMD=$2
@ -15,17 +24,11 @@ do_hash() {
done
}
if [ ! -f "../../config" ]; then
echo "error - config file does not exists"
exit 1;
fi
cat << EOF
Origin: $ORIGIN
Label: $LABEL
Suite: $SUITE
Codename: $CODENAME
Codename: $DISTRO
Version: $VERSION
Architectures: $ARCHITECTURES
Components: $COMPONENTS

View File

@ -1,17 +1,20 @@
#!/bin/sh
REPODIR="$1"
DISTRO="$3"
. $REPODIR/apt-repo/config
if [ ! $DISTRO ]; then
DISTRO="stable"
fi
if [ ! $DEFAULT_GPG ]; then
echo "error: no gpg key provided in config file"
exit 1
fi
KEY=$DEFAULT_GPG
echo "debrepo: signing using $KEY"
cat $REPODIR/apt-repo/dists/stable/Release | gpg --default-key $KEY -abs > $REPODIR/apt-repo/dists/stable/Release.gpg
cat $REPODIR/apt-repo/dists/stable/Release | gpg --default-key $KEY -abs --clearsign > $REPODIR/apt-repo/dists/stable/InRelease
cat $REPODIR/apt-repo/dists/$DISTRO/Release | gpg --default-key $KEY -abs > $REPODIR/apt-repo/dists/$DISTRO/Release.gpg
cat $REPODIR/apt-repo/dists/$DISTRO/Release | gpg --default-key $KEY -abs --clearsign > $REPODIR/apt-repo/dists/$DISTRO/InRelease

View File

@ -9,3 +9,21 @@ fi
mkdir -p $1/apt-repo/dists/stable/main/binary-amd64/
mkdir -p $1/apt-repo/pool/main/
# make config file
echo \
"#!/bin/sh
# Repository preferences
DEFAULT_GPG=\"\"
# Repository info
ORIGIN=\"example.com\"
LABEL=\"example repository\"
SUITE=\"stable\"
CODENAME=\"stable\"
VERSION=\"1.0\"
ARCHITECTURES=\"amd64\"
COMPONENTS=\"main\"
DESCRIPTION=\"example repository\"
" > $1/apt-repo/config