From f9e5472515ed2a43af847c4ccfc188fc4a59982b Mon Sep 17 00:00:00 2001 From: Peter Mosmans Date: Mon, 29 Aug 2016 21:42:59 +0200 Subject: [PATCH] Added script to pull framework changes into clones --- pull_upstream_changes.sh | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 pull_upstream_changes.sh diff --git a/pull_upstream_changes.sh b/pull_upstream_changes.sh new file mode 100644 index 0000000..0629431 --- /dev/null +++ b/pull_upstream_changes.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# pull_upstream_changes - Updates repo and applies upstream changes +# +# Copyright (C) 2016 Peter Mosmans [Radically Open Security] +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + + +# File which has to exist in the target directory to qualify as target +FINGERPRINT="dtd" +# List of files and directories that need to be updated +SOURCEFILES="dtd xslt" +# Root directory within source repo +SOURCEROOT="xml" + + +## Don't change anything below this line +VERSION=0.6 + +source=$(dirname $(readlink -f $0)) +target=$1 + +if [ -z "$target" ]; then + target=$(readlink -f .) + if [ "${target}" == "${source}" ]; then + echo "Usage: pull_upstream_changes [TARGET]" + echo " or run from within target directory" + exit + fi +fi + +# Check if the target actually contains the repository +if [ ! -z ${FINGERPRINT} ] && [ ! -d $target/dtd ]; then + echo "[-] ${target} does not contain the correct repository" + exit +fi + +# Update repository +echo "[*] Updating source repository (${source})..." +pushd "$source" >/dev/null && git pull && popd >/dev/null + +# Only update newer files +echo "[*] Applying changes (if any)..." +for sourcefile in ${SOURCEFILES}; do + if [ -d "${source}/${SOURCEROOT}/${sourcefile}" ]; then + cp -prv ${source}/${SOURCEROOT}/${sourcefile} $target/ + else + cp -pv ${source}/${SOURCEROOT}/${sourcefile} $target/${sourcefile} + fi +done +echo "[+] Done" +