Tuesday, 9 October 2018

Apt Indexer

#!/bin/bash

dpkg-scanpackages -m pool >  dists/trusty/main/binary-armhf/Packages
cat dists/trusty/main/binary-armhf/Packages | gzip -9c > dists/trusty/main/binary-armhf/Packages.gz

PKGS=$(wc -c dists/trusty/main/binary-armhf/Packages)
PKGS_GZ=$(wc -c  dists/trusty/main/binary-armhf/Packages.gz)
cat > dists/trusty/Release << EOF
Suite: trusty
Architectures: all
Date: $(date -Ru)
MD5Sum:
 $(md5sum dists/trusty/main/binary-armhf/Packages  | cut -d" " -f1) $PKGS
 $(md5sum dists/trusty/main/binary-armhf/Packages.gz  | cut -d" " -f1) $PKGS_GZ
SHA256:
 $(sha256sum dists/trusty/main/binary-armhf/Packages | cut -d" " -f1) $PKGS
 $(sha256sum dists/trusty/main/binary-armhf/Packages.gz | cut -d" " -f1) $PKGS_GZ
EOF

sleep 3s

cd dists/trusty

gpg --yes -abs -o Release.gpg Release

# Sign!
gpg --yes --batch --passphrase mypassword --digest-algo SHA256 --armor --output Release.gpg --detach-sign Release
gpg --yes --batch --passphrase mypasword --digest-algo SHA256 --clearsign --output InRelease Release

cd -

Automating the repo signing:

#!/bin/sh

dir1="/var/www/raspbian-stretch/staging/"
dir2="/var/www/raspbian-stretch/unstable/"
dir3="/var/www/raspbian-stretch/legacy/"
dir4="/var/www/raspbian-stretch/stable/"

monitor() {
while inotifywait -qqe modify,move,create,delete,delete_self "$1"; do
    cd "$1"
    ./indexer.sh 2>&1>/dev/null
    cd -
done 2>&1>/dev/null
}

monitor "$dir1" &
monitor "$dir2" &
monitor "$dir3" &
monitor "$dir4" &

No comments:

Post a Comment