#!/bin/sh # $UFP$ # Copyright © 2019-2021 Trond Endrestøl # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. #set -x #set -eu -o pipefail #set -u -o pipefail set -o pipefail ## Kids, remember the simplicity of running Subversion through GNU Parallel. #parallel svn update --accept=theirs-full --non-interactive ::: /usr/ports /usr/src ## Now, compare that to what follows. INDEX_FILE="/usr/ports/INDEX-14" # Determine which git executable to run. GIT_CANDIDATES="/usr/local/bin/git /usr/bin/git /usr/bin/gitlite" readonly GIT_CANDIDATES for cand in ${GIT_CANDIDATES}; do if [ -x ${cand} ]; then GIT=${cand} break fi done if [ -z "${GIT}" ]; then echo "${0}: neither of ${GIT_CANDIDATES} are useable" >/dev/stderr exit 69 fi readonly GIT ncpu=`sysctl -n hw.ncpu` readonly ncpu # Usage: update_git_wc # # E.g.: update_git_wc /usr/src main main+local # update_git_wc /usr/src stable/13 stable/13+local # update_git_wc /usr/ports main main+local # update_git_wc () { if [ ${#} -ne 3 ]; then echo "Usage: ${0} " >/dev/stderr return 69 fi date || return echo "Updating Git WC in ${1} ..." || return local BASENAME=`basename ${1}` local FSTYPE=`df -T ${1} | tail -1 | awk '{print $2;exit}'` local FSDEV=`df ${1} | tail -1 | awk '{print $1;exit}'` local TIMESTAMP=`date +%Y%m%d-%H%M%S` if [ "${FSTYPE}" = zfs ]; then zfs snapshot -r ${FSDEV}/.git@${TIMESTAMP} || return fi ${GIT} -C ${1} diff ${2}..${3} > /var/backups/git-diff-${BASENAME}-${TIMESTAMP}.diff || return ${GIT} -C ${1} stash || return ${GIT} -C ${1} checkout ${2} || return ${GIT} -C ${1} pull -j ${ncpu} --no-edit --no-ff -p || { ${GIT} -C ${1} prune -v || return ${GIT} -C ${1} remote prune freebsd || return ${GIT} -C ${1} gc --auto || return ${GIT} -C ${1} pull -j ${ncpu} --no-edit --no-ff -p || return } ${GIT} -C ${1} rebase ${2} ${3} || return [ -n "`${GIT} -C ${1} stash list`" ] && { ${GIT} -C ${1} stash pop || return; } || true echo || return } date || exit echo "${0}: Inquiring Git about the commit count prior to updating the ports tree ..." || exit GIT_COMMIT_COUNT_PORTS_PRE=`${GIT} -C /usr/ports rev-list --first-parent --count HEAD` if [ -z "${GIT_COMMIT_COUNT_PORTS_PRE}" ]; then echo "${0}: zero length GIT_COMMIT_COUNT_PORTS_PRE" >/dev/stderr exit 69 fi echo "${0}: ... done." || exit echo || exit update_git_wc /usr/src main main+local || exit update_git_wc /usr/ports main main+local || exit #update_git_wc /usr/zstd-19.src main main+local || exit #update_git_wc /usr/zstd-19.ports main main+local || exit date || exit echo "${0}: Inquiring Git about the commit count after updating the ports tree ..." || exit GIT_COMMIT_COUNT_PORTS_POST=`${GIT} -C /usr/ports rev-list --first-parent --count HEAD` if [ -z "${GIT_COMMIT_COUNT_PORTS_POST}" ]; then echo "${0}: zero length GIT_COMMIT_COUNT_PORTS_POST" >/dev/stderr exit 69 fi echo "${0}: ... done." || exit echo || exit date || exit if [ "${GIT_COMMIT_COUNT_PORTS_PRE}" != "${GIT_COMMIT_COUNT_PORTS_POST}" ] || [ ! -e "${INDEX_FILE}" ] || [ ! -s "${INDEX_FILE}" ]; then echo "${0}: Ports tree commit count ${GIT_COMMIT_COUNT_PORTS_PRE} vs ${GIT_COMMIT_COUNT_PORTS_POST}" || exit echo || exit date || exit # make[5]: "/usr/ports/Mk/Uses/fpc.mk" line 45: warning: "/usr/local/bin/fpc -iV" exited on a signal # exec_new_vmspace: mapping stack size 0x20000000 prot 0x7 failed mach error 2 errno 13 # Also, running elfctl -e +wxneeded /usr/local/bin/fpc and getting the desired result is impossible. # elfctl: NT_FREEBSD_FEATURE_CTL note not found /sbin/sysctl kern.elf64.allow_wx=1 || exit make -C /usr/ports index || exit echo || exit date || exit synth status local/E590T-localbase || exit cp -p /var/synth/synth_status_results.txt /var/synth/synth_status_results_metaport.txt || exit /sbin/sysctl kern.elf64.allow_wx=0 || exit else echo "${0}: no change in the commit count for the ports tree, currently at ${GIT_COMMIT_COUNT_PORTS_POST}" || exit fi echo || exit date || exit echo "${0}: Origins from index:" || exit pkg version -ovIL= || exit echo || exit date || exit echo "${0}: Package names from index:" || exit pkg version -vIL= || exit echo || exit date || exit echo "${0}: Vulnerable ports:" || exit pkg audit -Fr || exit echo || exit date || exit # EOF