summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2022-05-10 20:24:40 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2022-05-10 20:35:34 -0400
commit08c9f03073da8ff8a95fcc094c72cfb5da280dee (patch)
tree522a282f11d1026a14f1f16a0f41ef2f7c820dc2
parent10b44e4ac376af1b351e98f83517c902c33c000f (diff)
wip - refactor metedata script
-rw-r--r--parabolaiso/TORRENT_METADATA.sample27
-rwxr-xr-xparabolaiso/mkmetadata36
2 files changed, 33 insertions, 30 deletions
diff --git a/parabolaiso/TORRENT_METADATA.sample b/parabolaiso/TORRENT_METADATA.sample
index f920958..c60220c 100644
--- a/parabolaiso/TORRENT_METADATA.sample
+++ b/parabolaiso/TORRENT_METADATA.sample
@@ -12,29 +12,28 @@
# if this is not defined, then no .torrent file will be created
readonly TORRENT_ANNOUNCE_URL="http://torrent.resonatingmedia.com:6969/announce" # distrowatch
-# TORRENT_WEBSEED_URLS (newline-separated list of strings)
+
+# MIRRORLIST_URL (string)
+# will be downloaded and parsed to generate the .torrent web-seed URLs
+readonly MIRRORLIST_URL=https://repo.parabola.nu/mirrorlist.txt
+
+
+# TORRENT_WEBSEED_URLS (array of strings)
# will be embedded into the .torrent file
-readonly TORRENT_WEBSEED_URLS="
-https://mirrors.dotsrc.org/parabola/iso
+readonly TORRENT_WEBSEED_URLS=(
https://mirror.cyberbits.eu/parabola/iso
-https://mirror.grapentin.org/parabola/iso
-https://parabola.isacdaavid.info/iso
-https://jeweet.net/repo/parabola/iso
-https://mirror.csclub.uwaterloo.ca/parabola/iso
-https://mirror.yandex.ru/mirrors/parabola/iso
-https://ftpmirror1.infania.net/parabola/iso
-https://mirror.linux.pizza/parabola/iso
-https://ftp.acc.umu.se/mirror/parabola.nu/iso
-https://mirror.fsf.org/parabola/iso
-https://mirror.freedif.org/Parabola/iso
-"
+https://mirrors.dotsrc.org/parabola/iso
+)
+
# TORRENT_COMMENT (string)
# will be embedded into the .torrent file
+# _RELEASE_ will be replaced with a version parsed from the ISO filename
# if ISOS_URL is defined below, a URL will be appended to this, pointing
# to where the GPG signature of the ISO will be expected to be hosted
readonly TORRENT_COMMENT="Parabola GNU/Linux-libre _RELEASE_ Release"
+
# ISOS_URL (string)
# is used to make a URL to the master repo where the ISO will be hosted
# the torrent comment will indicate this as the location of the canonical GPG signature
diff --git a/parabolaiso/mkmetadata b/parabolaiso/mkmetadata
index 01ab721..a13f5f1 100755
--- a/parabolaiso/mkmetadata
+++ b/parabolaiso/mkmetadata
@@ -1,29 +1,33 @@
#!/bin/bash
-readonly OUT_DIR=$1
-readonly IMG_NAME=$2
+# mkmetadata - copy package lists from work directory to output directory
+# and create checksums/torrent files
+
+
+readonly OUT_DIR="$1" # eg: ./out/x86_64-systemd-cli-2022.04
+readonly ISO_FILENAME=$2 # eg: parabola-x86_64-systemd-cli-2022.04-netinstall.iso
readonly PKGLIST="$( readlink -f $3 2> /dev/null)"
readonly THIS_DIR="$(readlink -f "$(dirname $0)")"
# if a .torrent file is desired, see ./TORRENT_METADATA.sample
-[[ -f "$THIS_DIR/TORRENT_METADATA" ]] && source "$THIS_DIR/TORRENT_METADATA"
+[[ -f "${THIS_DIR}/TORRENT_METADATA" ]] && source "${THIS_DIR}/TORRENT_METADATA"
which mktorrent &> /dev/null && readonly HAS_MKTORRENT=1 || readonly HAS_MKTORRENT=0
which rhash &> /dev/null && readonly HAS_RHASH=1 || readonly HAS_RHASH=0
[[ -n "${TORRENT_ANNOUNCE_URL}" ]] && readonly SHOULD_MKTORRENT=${HAS_MKTORRENT} || \
readonly SHOULD_MKTORRENT=0
-[[ -n "${ISOS_URL}" ]] && readonly IMG_URL="${ISOS_URL}/$(basename ${OUT_DIR})/${IMG_NAME}"
+[[ -n "${ISOS_URL}" ]] && readonly IMG_URL="${ISOS_URL}/$(basename ${OUT_DIR})/${ISO_FILENAME}"
[[ -n "${ISOS_URL}" ]] && readonly PUBLISH_MSG="The directory: '${OUT_DIR}' should be copied to the repo server entirely, preserving the directory name; such that it is accessible via the URL:\n\t${IMG_URL}/\nThe GPG signature of the ISO should be added to that directory; such that it is accessible at the URL:\n\t${IMG_URL}.sig"
-readonly ISO_HOST_PATH=$(echo "$(basename ${OUT_DIR})/${IMG_NAME}" | sed 's|\s|%20|')
-readonly WEBSEEDS_CSV=$(echo ${TORRENT_WEBSEED_URLS} | sed -E "s|([^ ]+)|\1${ISO_HOST_PATH}|g" | tr ' ' ',')
-readonly RELEASE_DEV_CMD='s|[^-]*-\(.*\)-\(.*\)-\(.*\)-\(.*\)-\(.*\)\.iso|\L\1 \u\2/\U\3 \4 \L\5|'
+readonly ISO_HOST_PATH=$(echo "$(basename ${OUT_DIR})/${ISO_FILENAME}" | sed 's|\s|%20|')
+readonly WEBSEEDS_CSV=$(sed -E "s|([^ ]+)|\1/${ISO_HOST_PATH}|g" <<<"${TORRENT_WEBSEED_URLS[@]}" | tr ' ' ',')
+readonly RELEASE_SED_RX='s|[^-]*-\(.*\)-\(.*\)-\(.*\)-\(.*\)-\(.*\)\.iso|\L\1 \u\2/\U\3 \4 \L\5|'
readonly PKGLIST_SUCCESS_MSG="\t=> copied $(basename ${PKGLIST} 2> /dev/null)"
readonly SHA512SUMS_SUCCESS_MSG="\t=> SHA512SUMS $( [[ -f "${OUT_DIR}/SHA512SUMS" ]] && echo 'appended' || echo 'generated' )"
-readonly MAGNET_SUCCESS_MSG="\t=> ${IMG_NAME}.magnet generated"
-readonly TORRENT_SUCCESS_MSG="\t=> ${IMG_NAME}.torrent generated"
+readonly MAGNET_SUCCESS_MSG="\t=> ${ISO_FILENAME}.magnet generated"
+readonly TORRENT_SUCCESS_MSG="\t=> ${ISO_FILENAME}.torrent generated"
readonly RHASH_NOT_FOUND_MSG="[mkmetadata]: 'rhash' is not installed - metadata files will not be generated"
readonly MAKE_METADATA_MSG="[mkmetadata]: preparing metadata"
@@ -31,17 +35,17 @@ readonly MAKE_METADATA_MSG="[mkmetadata]: preparing metadata"
MakeMetadata()
{
# copy package lists and generate checksums and optional torrent file
- (( ${SHOULD_MKTORRENT} )) && MakeTorrent && echo -e ${TORRENT_SUCCESS_MSG}
- [[ -f "${PKGLIST}" ]] && cp ${PKGLIST} . && echo -e ${PKGLIST_SUCCESS_MSG}
- rhash --sha512 "${IMG_NAME}" >> SHA512SUMS && echo -e ${SHA512SUMS_SUCCESS_MSG}
- rhash --magnet "${IMG_NAME}" > "${IMG_NAME}.magnet" && echo -e ${MAGNET_SUCCESS_MSG}
+ (( ${SHOULD_MKTORRENT} )) && MakeTorrent && echo -e ${TORRENT_SUCCESS_MSG}
+ [[ -f "${PKGLIST}" ]] && cp ${PKGLIST} . && echo -e ${PKGLIST_SUCCESS_MSG}
+ rhash --sha512 "${ISO_FILENAME}" >> SHA512SUMS && echo -e ${SHA512SUMS_SUCCESS_MSG}
+ rhash --magnet "${ISO_FILENAME}" > "${ISO_FILENAME}.magnet" && echo -e ${MAGNET_SUCCESS_MSG}
sort SHA512SUMS --key=2 --output=SHA512SUMS
}
MakeTorrent()
{
- local release=$( sed "${RELEASE_DEV_CMD}" <<<${IMG_NAME})
+ local release=$( sed "${RELEASE_SED_RX}" <<<${ISO_FILENAME})
local sig="$( [[ -n "${ISOS_URL}" ]] && echo "GPG signature: '${IMG_URL}.sig")"
local comment="$(sed 's|_RELEASE_|'"${release}"'|' <<<${TORRENT_COMMENT})\n${sig}"
@@ -50,12 +54,12 @@ MakeTorrent()
--comment="${comment}" \
$([[ -n "${WEBSEEDS_CSV}" ]] && echo "--web-seed=${WEBSEEDS_CSV}") \
--piece-length=20 --no-date --verbose \
- "${IMG_NAME}"
+ "${ISO_FILENAME}"
}
if ! (( ${HAS_RHASH} ))
then echo "$RHASH_NOT_FOUND_MSG"
-elif [[ -d "${OUT_DIR}" ]] && [[ -f "${OUT_DIR}/${IMG_NAME}" ]]
+elif [[ -d "${OUT_DIR}" ]] && [[ -f "${OUT_DIR}/${ISO_FILENAME}" ]]
then echo "$MAKE_METADATA_MSG"
pushd ${OUT_DIR} > /dev/null