infrastructure: add scripts to build apt/yum repos

This commit is contained in:
Matthew Thomas 2022-05-21 13:45:58 -04:00
parent 3ec25f437b
commit 8915b7232b
4 changed files with 105 additions and 0 deletions

View File

@ -190,6 +190,12 @@ upload:
upload_github:
./bin/upload-github $(TAG)
repo_apt:
./bin/make_repo_apt.sh
repo_yum:
./bin/make_repo_yum.sh
cross: doc
go run bin/cross-compile.go -release current $(BUILD_FLAGS) $(BUILDTAGS) $(BUILD_ARGS) $(TAG)

View File

@ -31,6 +31,8 @@ This file describes how to make the various kinds of releases
* make upload
* make upload_website
* make upload_github
* make apt_repo
* make yum_repo
* make startdev # make startstable for stable branch
* # announce with forum post, twitter post, patreon post

53
bin/make_repo_apt.sh Executable file
View File

@ -0,0 +1,53 @@
#!/bin/bash
#
# Upload a release
#
# Requires reprepro from https://github.com/ionos-cloud/reprepro
set -e
FINGERPRINT=${1:-"FBF737ECE9F8AB18604BD2AC93935E02FF3B54FA"}
BUCKET_PATH=${2:-"/mnt/apt.rclone.org"}
# path for persistant files in bucket
LOCAL_PATH="$BUCKET_PATH/.local"
REPREPRO_PATH="$LOCAL_PATH/reprepro"
# if the bucket path does not exist, give error
if [[ ! -d $BUCKET_PATH ]]
then
echo "Bucket not mounted. Expected directory at ${BUCKET_PATH}."
exit 1
elif [[ ! -d $REPREPRO_PATH ]]
then
echo "Config dir not found. Performing first time setup."
mkdir -p "$REPREPRO_PATH/conf"; mkdir -p "$REPREPRO_PATH/db"; mkdir -p "$REPREPRO_PATH/log"
cat <<- EOF > "$REPREPRO_PATH/conf/options"
basedir $BUCKET_PATH
dbdir $REPREPRO_PATH/db
logdir $REPREPRO_PATH/log
EOF
cat <<- EOF > "$REPREPRO_PATH/conf/distributions"
Origin: apt.rclone.org
Label: Rclone
Codename: any
Architectures: amd64 i386 arm64 armhf armel mips mipsel
Components: main
Description: Apt repository for Rclone
SignWith: $FINGERPRINT
Limit: 20
EOF
fi
for build in build/*.deb; do
if [[ ${build} == *-arm.deb ]]
then
# do nothing because both arm and arm-v7 are armhf?
echo "Skipping ${build}."
else
reprepro --confdir "$REPREPRO_PATH/conf" includedeb any "${build}"
echo "Added ${build} to APT repo."
fi
done
echo "Done"

44
bin/make_repo_yum.sh Executable file
View File

@ -0,0 +1,44 @@
#!/usr/bin/env bash
#
# Upload a release
#
# Requires createrepo-c and rpm
set -e
FINGERPRINT=${1:-"FBF737ECE9F8AB18604BD2AC93935E02FF3B54FA"}
BUCKET_PATH=${2:-"/mnt/yum.rclone.org"}
if [[ ! -d $BUCKET_PATH ]]
then
echo "Bucket not mounted. Expected directory at ${BUCKET_PATH}."
exit 1
fi
update_rpm_repo() {
local RPM_FILE="$1"
local RPM_REPO_DIR="$2"
# query rpm version and package name
local RPM_FULLNAME=$(rpm -qp "${RPM_FILE}")
# query rpm arch separately
local RPM_ARCH=$(rpm -qp --qf "%{arch}" "${RPM_FILE}")
mkdir -p "${RPM_REPO_DIR}/${RPM_ARCH}/" &&
cp "${RPM_FILE}" "${RPM_REPO_DIR}/${RPM_ARCH}/${RPM_FULLNAME}.rpm"
echo "Copied ${RPM_FILE} to ${RPM_REPO_DIR}/${RPM_ARCH}/${RPM_FULLNAME}.rpm"
# remove and replace repodata
createrepo_c --update "${RPM_REPO_DIR}/${RPM_ARCH}"
rm -f "${RPM_REPO_DIR}/${RPM_ARCH}/repodata/repomd.xml.asc" &&
gpg --default-key "$3" -absq -o "${RPM_REPO_DIR}/${RPM_ARCH}/repodata/repomd.xml.asc" "${RPM_REPO_DIR}/${RPM_ARCH}/repodata/repomd.xml"
}
for build in build/*.rpm; do
update_rpm_repo "$build" "$BUCKET_PATH" "$FINGERPRINT"
echo "Added ${build} to YUM repo."
done
echo "Done"