diff options
author | Bryan Drewery <bryan@shatow.net> | 2020-04-20 00:22:06 +0300 |
---|---|---|
committer | Bryan Drewery <bryan@shatow.net> | 2020-04-27 19:35:47 +0300 |
commit | 456b632b821a75342fb2ab5804a6f1d6c0676732 (patch) | |
tree | 6f769928f06f5c9e298c0afaf171ed52e90d04e3 /test-ports | |
parent | 1f4f998b368481289cbdde0e8ac034009059b288 (diff) |
Test ports update script
Diffstat (limited to 'test-ports')
-rw-r--r-- | test-ports/update-ports.sh | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/test-ports/update-ports.sh b/test-ports/update-ports.sh new file mode 100644 index 00000000..86050792 --- /dev/null +++ b/test-ports/update-ports.sh @@ -0,0 +1,106 @@ +#! /bin/sh +set -e +export __MAKE_CONF=/dev/null +export PORT_DBDIR=/dev/null + +: ${SVN_URL:=https://svn.freebsd.org/ports/head} +: ${DESTDIR:=$(realpath "${0%/*}/default")} +cd "${DESTDIR}" +export PORTSDIR="${DESTDIR}" + +if [ -f .svn_rev ]; then + read SVN_REV < .svn_rev +fi +: ${SVN_REV:=$(svn info "${SVN_URL}" | grep 'Last Changed Rev' | sed -e 's,.*: ,,')} + +py3=$(make -f Mk/bsd.port.mk -V PYTHON3_DEFAULT:S,.,,) +perl5=$(make -f Mk/bsd.port.mk -V PERL5_DEFAULT) + +# Minimum for a partial tree (and their deps) +DIRS=" +Mk +Templates +Tools +Keywords +devel/gettext +devel/gettext-runtime +devel/gettext-tools +lang/perl${perl5} +lang/python +lang/python2 +lang/python27 +lang/python3 +lang/python${py3} +security/openssl +" + +update_dir() { + local dir="$1" + + echo "Fetching ${dir}" >&2 + git rm -rf "${dir}" || : + rm -rf "${dir}" + svn export "${SVN_URL}/${dir}" "${dir}" || return $? + git add -f "${dir}" + find "${dir}" -name Makefile -exec git add -f {} + +} + +get_deps() { + local dir="$1" + + echo "Getting deps: ${dir}" >&2 + make -C "${dir}" \ + _PDEPS='${PKG_DEPENDS} ${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}' \ + -V '${_PDEPS:C,([^:]*):([^:]*):?.*,\2,:C,^${PORTSDIR}/,,:O:u}' | + grep -v '^make:' +} + +recurse_deps() { + local port dep + + for port in "$@"; do + [ -f "${port}/.deps" ] && continue + get_deps "${port}" + touch "${port}/.deps" + done | tr ' ' '\n' | sort -u | + ( + updated_dir=0 + while read dep; do + [ -z "${dep}" ] && continue + [ -e "${dep}/Makefile" ] && continue + update_dir "${dep}" && + updated_dir=1 + done + exit "${updated_dir}" + ) && { + find . -name .deps -size 0 -delete + return 0 + } + recurse_deps_all +} + +recurse_deps_all() { + local allports + + allports=$(find . -type d -name '[a-z]*' -depth 1 | xargs -J % find % -type d -depth 1 | sed -e 's,^\./,,') + recurse_deps ${allports} +} + +git rm -rf * + +for dir in ${DIRS}; do + update_dir "${dir}" +done + +recurse_deps_all + +find -s . -type d -name '[a-z]*' -depth 1 | while read cat; do + find -s "${cat}" -type d -depth 1 | sed -e "s,^${cat}/,SUBDIR += ," > \ + "${cat}/Makefile" + git add -f "${cat}/Makefile" + echo "SUBDIR += ${cat#*/}" +done > Makefile +git add -f Makefile + +echo "${SVN_REV}" > .svn_rev +git add .svn_rev |