Files
mpbb/mpbb-gather-archives
T

75 lines
2.5 KiB
Bash
Raw Normal View History

2016-03-17 08:06:27 +00:00
#!/bin/bash
# -*- coding: utf-8; mode: sh; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=sh:et:sw=4:ts=4:sts=4
2016-03-17 08:06:27 +00:00
# Note:
2016-08-05 19:06:18 +00:00
# This script is sourced by the mpbb wrapper script.
2016-03-17 08:06:27 +00:00
# Do not execute this directly!
2016-09-12 01:59:04 +00:00
gather-archives-usage() {
# "prog" is defined in mpbb-help.
# shellcheck disable=SC2154
cat <<EOF
usage: $prog [<global opts>] gather-archives [<opts>]
2016-03-17 08:06:27 +00:00
2016-09-12 01:59:04 +00:00
Copy unpublished, distributable archives of active ports into a staging
directory for uploading.
Options:
--archive-site=<URL>
URL to check for preexisting public archives. Defaults to
2016-09-12 01:59:04 +00:00
\`https://packages.macports.org'.
--archive-site-private=<URL>
URL to check for preexisting private archives. Defaults to
\`https://packages-private.macports.org'.
2016-09-12 01:59:04 +00:00
--staging-dir=<path>
A directory for storing archives before deployment. Defaults to the
\`archive-staging' subdirectory of the \`--work-dir' working directory.
2016-09-12 01:59:04 +00:00
Run \`$prog help' for global options and a list of other subcommands.
EOF
2016-03-17 08:06:27 +00:00
}
device-of-path() {
df -P -- "$1" | awk 'NR==2 {print $1}'
}
2016-03-17 08:06:27 +00:00
gather-archives() {
local args
parseopt archive-site:,archive-site-private:,staging-dir: "$@" || return
# $option_archive_site is set by parseopt
# shellcheck disable=SC2154
: "${option_archive_site=https://packages.macports.org}"
# $option_archive_site_private is set by parseopt
# shellcheck disable=SC2154
: "${option_archive_site_private=https://packages-private.macports.org}"
# $option_staging_dir is set by parseopt
# shellcheck disable=SC2154
: "${option_staging_dir=${option_work_dir}/archive-staging}"
# shellcheck disable=SC2086
set -- ${args+"${args[@]}"}
# $option_prefix is set in mpbb
# shellcheck disable=SC2154
2025-04-29 22:45:18 +10:00
tclsh="${option_prefix}/bin/port-tclsh"
if [ -d "${option_staging_dir}" ]; then
find "${option_staging_dir}" -type f -delete -print | sed -E -e "s|^.*/||" -e 's/^/Deleting previously staged archive: /'
rm -rf "${option_staging_dir}"
echo
fi
mkdir -p "${option_staging_dir}"/public "${option_staging_dir}"/private || return
chmod -R a+rX "${option_staging_dir}"
2016-03-17 08:06:27 +00:00
# $thisdir is set in mpbb
# shellcheck disable=SC2154
"${tclsh}" "${thisdir}/tools/gather-archives.tcl" --archive_site_private "${option_archive_site_private}" \
--archive_site_public "${option_archive_site}" --jobs_dir "${option_jobs_dir}" \
--license_db_dir "${option_license_db_dir}" --staging_dir "${option_staging_dir}" \
"${option_work_dir}/requested_port"
return $?
2016-03-17 08:06:27 +00:00
}