45 lines
2.0 KiB
Bash
Executable File
45 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
REPO=${1:-"$ROOT/repository"}
|
|
DEBS=${2:-"$ROOT/dist"}
|
|
ARCH=${RUSTPROXY_REPO_ARCH:-$(dpkg --print-architecture)}
|
|
CODENAME=${RUSTPROXY_REPO_CODENAME:-stable}
|
|
COMPONENT=${RUSTPROXY_REPO_COMPONENT:-main}
|
|
|
|
for tool in dpkg-scanpackages apt-ftparchive gzip; do
|
|
command -v "$tool" >/dev/null 2>&1 || { echo "Missing repository tool: $tool" >&2; exit 2; }
|
|
done
|
|
|
|
POOL="$REPO/pool/$COMPONENT/r/rustproxy"
|
|
BINARY="$REPO/dists/$CODENAME/$COMPONENT/binary-$ARCH"
|
|
mkdir -p "$POOL" "$BINARY"
|
|
find "$DEBS" -maxdepth 1 -type f -name 'rustproxy_*.deb' -exec cp -f {} "$POOL/" \;
|
|
|
|
cd "$REPO"
|
|
dpkg-scanpackages --arch "$ARCH" "pool/$COMPONENT" /dev/null > "dists/$CODENAME/$COMPONENT/binary-$ARCH/Packages"
|
|
gzip -9 -n -c "dists/$CODENAME/$COMPONENT/binary-$ARCH/Packages" > "dists/$CODENAME/$COMPONENT/binary-$ARCH/Packages.gz"
|
|
apt-ftparchive \
|
|
-o APT::FTPArchive::Release::Origin=RustProxy \
|
|
-o APT::FTPArchive::Release::Label=RustProxy \
|
|
-o APT::FTPArchive::Release::Suite="$CODENAME" \
|
|
-o APT::FTPArchive::Release::Codename="$CODENAME" \
|
|
-o APT::FTPArchive::Release::Architectures="$ARCH" \
|
|
-o APT::FTPArchive::Release::Components="$COMPONENT" \
|
|
release "dists/$CODENAME" > "dists/$CODENAME/Release"
|
|
|
|
if [ -n "${RUSTPROXY_REPO_GPG_KEY:-}" ]; then
|
|
command -v gpg >/dev/null 2>&1 || { echo "RUSTPROXY_REPO_GPG_KEY is set but gpg is missing" >&2; exit 2; }
|
|
gpg --batch --yes --local-user "$RUSTPROXY_REPO_GPG_KEY" --armor --detach-sign \
|
|
--output "dists/$CODENAME/Release.gpg" "dists/$CODENAME/Release"
|
|
gpg --batch --yes --local-user "$RUSTPROXY_REPO_GPG_KEY" --clearsign \
|
|
--output "dists/$CODENAME/InRelease" "dists/$CODENAME/Release"
|
|
else
|
|
rm -f "dists/$CODENAME/Release.gpg" "dists/$CODENAME/InRelease"
|
|
echo "WARNING: repository is unsigned. Set RUSTPROXY_REPO_GPG_KEY for production." >&2
|
|
fi
|
|
|
|
echo "Repository ready: $REPO"
|
|
echo "Publish this directory as https://rustproxy.linuxiarz.pl/"
|