summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2018-11-20 15:33:22 -0500
committerbill-auger <mr.j.spam.me@gmail.com>2019-05-07 09:23:28 -0400
commitf087cdd8b0026777ac754af4a8608128d82e1b88 (patch)
tree63d0623ec9de3f7119e65568a3407ed85444b78a
parent3fd439f9822d5c0f78817aad5bf4af1c4bd8864f (diff)
squashme - mkmetadata
-rw-r--r--parabolaiso/TORRENT_METADATA.sample4
-rwxr-xr-xparabolaiso/mkmetadata36
2 files changed, 26 insertions, 14 deletions
diff --git a/parabolaiso/TORRENT_METADATA.sample b/parabolaiso/TORRENT_METADATA.sample
index ad4427a..40ba4a8 100644
--- a/parabolaiso/TORRENT_METADATA.sample
+++ b/parabolaiso/TORRENT_METADATA.sample
@@ -1,3 +1,5 @@
+# metadata requisites: 'mktorrent', 'rhash'
+# if these are not installed, then no .torrent, magnet, or checksum files will be created
# TORRENT_ANNOUNCE_URL (string)
# will be embedded into the .torrent file
@@ -23,5 +25,5 @@ http://ftp.acc.umu.se/mirror/parabola.nu/iso/
readonly TORRENT_COMMENT="Parabola GNU/Linux-libre Official Release - GPG signature: "
# ISOS_URL (string)
-# is used to make a URL to where the ISO and GPG signature will be hosted
+# is used to make a URL to the master repo where the ISO and GPG signature will be hosted
readonly ISOS_URL=https://repo.parabola.nu/iso
diff --git a/parabolaiso/mkmetadata b/parabolaiso/mkmetadata
index c00b98c..1724765 100755
--- a/parabolaiso/mkmetadata
+++ b/parabolaiso/mkmetadata
@@ -2,35 +2,42 @@
readonly OUT_DIR=$1
readonly IMG_NAME=$2
-readonly PKGLIST=$(readlink -f $3)
+readonly PKGLIST="$(readlink -f $3 2> /dev/null)"
+readonly THIS_DIR="$(readlink -f "$(dirname $0)")"
# if an optional .torrent file is desired, see ./TORRENT_METADATA.sample
-[[ -f ./TORRENT_METADATA ]] && source ./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 SIG_URL=${ISOS_URL}/$(basename ${OUT_DIR})/${IMG_NAME}.sig
-[[ -n "${ISOS_URL}" ]] && readonly SIGURL_MSG="GPG signature is expected to be at: ${SIG_URL}"
+
+[[ -n "${ISOS_URL}" ]] && readonly PUBLIC_URL="${ISOS_URL}/$(basename ${OUT_DIR})"
+[[ -n "${ISOS_URL}" ]] && readonly SIG_URL="${PUBLIC_URL}/${IMG_NAME}.sig"
+[[ -n "${ISOS_URL}" ]] && readonly PUBLISH_MSG="The directory: '${OUT_DIR}' should be copied in tact to the repo server such that it is accessible via the URL: ${PUBLIC_URL}/"
+[[ -n "${ISOS_URL}" ]] && (( ${SHOULD_MKTORRENT} )) && SIG_MSG="The torrent expects the GPG signature to be accessible at: ${SIG_URL}"
+
readonly ISO_HOST_PATH=$(echo "$(basename ${OUT_DIR})/${IMG_NAME}" | sed 's|\s|%20|')
readonly WEBSEEDS_CSV=$(echo $urls | sed -E "s|([^ ]+)|\1${ISO_HOST_PATH}|g" | tr ' ' ',')
-readonly PKGLIST_SUCCESS_MSG="\t=> copied $(basename ${PKGLIST})"
+readonly PKGLIST_SUCCESS_MSG="\t=> copied $(basename ${PKGLIST} 2> /dev/null)"
readonly SHA512SUMS_SUCCESS_MSG="\t=> SHA512SUMS appended"
readonly WHIIRLPOOLSUMS_SUCCESS_MSG="\t=> WHIRLPOOLSUMS appended"
readonly MAGNET_SUCCESS_MSG="\t=> ${IMG_NAME}.magnet saved"
-readonly TORRENT_SUCCESS_MSG="\t=> ${IMG_NAME}.torrent saved\n${SIGURL_MSG}"
+readonly TORRENT_SUCCESS_MSG="\t=> ${IMG_NAME}.torrent saved"
+readonly RHASH_NOT_FOUND_MSG="[mkmetadata]: 'rhash' is not installed - metadata files will not be created"
+readonly MAKE_METADATA_MSG="[mkmetadata]: preparing metadata"
MakeMetadata()
{
- # copy package lists and create checksums and optional torrent file
- cp ${PKGLIST} . && echo -e ${PKGLIST_SUCCESS_MSG}
+ # 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 --whirlpool "${IMG_NAME}" >> WHIRLPOOLSUMS && echo -e ${WHIIRLPOOLSUMS_SUCCESS_MSG}
rhash --magnet "${IMG_NAME}" > "${IMG_NAME}.magnet" && echo -e ${MAGNET_SUCCESS_MSG}
- (( ${SHOULD_MKTORRENT} )) && MakeTorrent && echo -e ${TORRENT_SUCCESS_MSG}
sort SHA512SUMS --key=2 --output=SHA512SUMS
sort WHIRLPOOLSUMS --key=2 --output=WHIRLPOOLSUMS
@@ -38,7 +45,7 @@ MakeMetadata()
MakeTorrent()
{
- # create torrent file
+ # generate torrent file
mktorrent --announce=${TORRENT_ANNOUNCE_URL} \
--comment="${TORRENT_COMMENT}${SIG_URL}" \
$([[ -n "${WEBSEEDS_CSV}" ]] && echo "--web-seed=${WEBSEEDS_CSV}") \
@@ -46,11 +53,14 @@ MakeTorrent()
"${IMG_NAME}"
}
-
-if (( ${HAS_RHASH} )) && (( $# == 3 ))
-then echo "[mkmetadata]: preparing metadata"
+if ! (( ${HAS_RHASH} ))
+then echo "$RHASH_NOT_FOUND_MSG"
+elif [[ -d "${OUT_DIR}" ]] && [[ -f "${OUT_DIR}/${IMG_NAME}" ]]
+then echo "$MAKE_METADATA_MSG"
pushd ${OUT_DIR} > /dev/null
MakeMetadata
popd > /dev/null
fi
+
+[[ -n "${ISOS_URL}" ]] && echo "\n${PUBLISH_MSG}\n${SIG_MSG}"