summaryrefslogtreecommitdiff
path: root/pwx
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2018-05-29 08:07:21 +0200
committerSven Eden <yamakuzure@gmx.net>2018-05-29 08:07:21 +0200
commit58f295bc1a9c802160929cdd5e6ee7556ed5232e (patch)
tree1c16acce10613e43f106a584b3d56b1df53288ef /pwx
parent3e53473a26ff176e0b52039330903299bed6380d (diff)
Cleanup now obsolete pwx tools.
Diffstat (limited to 'pwx')
-rw-r--r--pwx/pwx_exchange_list.txt1
-rwxr-xr-xpwx/pwx_git_applier.sh426
-rw-r--r--pwx/pwx_git_funcs.sh170
-rwxr-xr-xpwx/pwx_git_getter.sh528
-rwxr-xr-xpwx/pwx_git_patch_formatter.sh186
-rw-r--r--pwx/pwx_last_mutual_commits.txt13
6 files changed, 0 insertions, 1324 deletions
diff --git a/pwx/pwx_exchange_list.txt b/pwx/pwx_exchange_list.txt
deleted file mode 100644
index ec1085904..000000000
--- a/pwx/pwx_exchange_list.txt
+++ /dev/null
@@ -1 +0,0 @@
--e libelogind:libsystemd -e elogind.xml:systemd-logind.service.xml -e elogind:systemd
diff --git a/pwx/pwx_git_applier.sh b/pwx/pwx_git_applier.sh
deleted file mode 100755
index 5db015373..000000000
--- a/pwx/pwx_git_applier.sh
+++ /dev/null
@@ -1,426 +0,0 @@
-#!/bin/bash
-#
-# (c) 2012 - 2016 PrydeWorX
-# Sven Eden, PrydeWorX - Bardowick, Germany
-# yamakuzure@users.sourceforge.net
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# History and ChangePWX_ERR_LOG:
-# Version Date Maintainer Change(s)
-# 0.0.1 2012-12-29 sed, PrydeWorX First Design.
-# 0.0.2 2013-01-08 sed, PrydeWorX First working version.
-# 0.1.0 2013-01-10 sed, PrydeWorX Initial private release.
-# 0.1.1 2013-06-01 sed, PrydeWorX Use functions from pwx_git_funcs.sh.
-# 0.2.0 2014-09-02 sed, PrydeWorX Use GNU enhanced getopt for command
-# line parsing.
-# 0.3.0 2016-11-18 sed, PrydeWorX Added option -T|--theirs to force
-# merge errors to be resolved by
-# throwing away all local changes.
-# 0.3.1 2017-03-22 sed, PrydeWorX Show full part of a patch that is to be
-# deleted after manually fixing merge
-# conflicts.
-# Show tried command if we fail with
-# full rejects.
-# 0.4.0 2017-04-24 sed, PrydeWorX Remove some remote-is-right-automatisms
-# 0.5.0 2017-07-04 sed, PrydeWorX If normal processing fails, use
-# check_tree.pl to generate diffs for the
-# specific commit, and apply them after
-# letting the user have a look.
-
-# Common functions
-PROGDIR="$(readlink -f $(dirname $0))"
-source ${PROGDIR}/pwx_git_funcs.sh
-
-# Version, please keep this current
-VERSION="0.5.0"
-
-
-# Global values to be filled in:
-PATCH_DIR="${PROGDIR}/patches"
-TAG_TO_USE=""
-
-
-# Editor to edit individual patches when needed
-PWX_EDIT=/usr/bin/kate
-
-
-# The options for the git am command:
-GIT_AM_OPTS="--committer-date-is-author-date"
-
-
-# Options and the corresponding help text
-OPT_SHORT=hi:T
-OPT_LONG=help,input:,theirs
-
-HELP_TEXT="Usage: $0 [OPTIONS] <source dir> <tag>
-
- Take all commit patches from the input directory and
- apply them to the local tree.
- They are assumed to be from tag <tag> of some source
- tree.
-
-OPTIONS:
- -h|--help Show this help and exit.
- -i|--input <path> : Path to where to patches are.
- The default is to read from the
- subdirectory 'patches' of the
- current directory.
-Notes:
- - When the script succeeds, it adds a line to the commit
- - file \"${PWX_COMMIT_FILE}\" of the form:
- <tag>-merged <last used commit>
-"
-
-
-# =========================================
-# === Use getopt (GNU enhanced version) ===
-# =========================================
-
-# Check the version first, so we do not run into trouble
-getopt --test > /dev/null
-if [[ $? -ne 4 ]]; then
- echo "ERROR: getopt is not the GNU enhanced version."
- exit 1
-fi
-
-# Store the output so we can check for errors.
-OPT_PARSED=$(getopt --options $OPT_SHORT --longoptions $OPT_LONG --name "$0" -- "$@")
-
-if [[ $? -ne 0 ]]; then
- # getopt has already complained about wrong arguments to stdout
- exit 2
-fi
-
-# Use eval with "$OPT_PARSED" to properly handle the quoting
-eval set -- "$OPT_PARSED"
-
-# --------------------
-# --- Handle input ---
-# --------------------
-while true; do
- case "$1" in
- -h|--help)
- echo "$HELP_TEXT"
- exit 0
- ;;
- -i|--input)
- PATCH_DIR="$2"
- shift 2
- ;;
- --)
- shift
- break
- ;;
- *)
- echo "Something went mysteriously wrong."
- exit 3
- ;;
- esac
-done
-
-# At this point we must have <source dir> and <tag> left
-if [[ $# -ne 2 ]]; then
- echo "$HELP_TEXT"
- exit 4
-fi
-
-# So these must be it:
-SOURCE_DIR="$1"
-TAG_TO_USE="$2"
-
-if [[ ! -d "$SOURCE_DIR" ]]; then
- echo "$SOURCE_DIR does not exist"
- echo
- echo "$HELP_TEXT"
- exit 5
-fi
-
-
-# ===========================================
-# === The PATCH_DIR directory must exist. ===
-# ===========================================
-if [[ -n "$PATCH_DIR" ]]; then
- if [[ ! -d "$PATCH_DIR" ]]; then
- echo "ERROR: $PATCH_DIR does not exist"
- exit 4
- fi
-else
- echo "You have set the patch directory to be"
- echo "an empty string. Where should I find the"
- echo "patches, then?"
- exit 5
-fi
-
-
-# =============================================================
-# === We need two file lists. ===
-# === A) The list of root files. ===
-# === These have not been used to generate commit ===
-# === patches and must be ignored by 'git am'. ===
-# === B) The patches to work with. ===
-# =============================================================
-echo -n "Building file lists ..."
-
-# --- File list a) Root files
-declare -a root_files=( $(find ./ -mindepth 1 -maxdepth 1 -type f \
- -not -name '*~' -and \
- -not -name '*.diff' -and \
- -not -name '*.orig' -and \
- -not -name '*.bak' -printf "%f ") )
-
-# --- File list b) Patch files
-# --- Here we might find patches that failed for single files. Those
-# --- must not clutter the list, they wouldn't apply anyway.
-declare -a patch_files=( $(find "$PATCH_DIR"/ -mindepth 1 -maxdepth 1 -type f \
- -name '????-*.patch' -and -not -name '*-failed_patch_for-*' \
- -printf "%f\n" | sort -n) )
-echo " done"
-
-# --- Add an error log file to the list of temp files
-PWX_ERR_LOG="/tmp/pwx_git_applier_$$.log"
-add_temp "$PWX_ERR_LOG"
-touch $PWX_ERR_LOG || die "Unable to create $PWX_ERR_LOG"
-
-
-# ===================================================
-# === Build a basic exclude string to begin with. ===
-# ===================================================
-basic_excludes=""
-for e in "${root_files[@]}" ; do
- if [[ "" = "$(echo -n "$basic_excludes" | \
- grep -P "^\sexclude=$e")" ]]; then
- basic_excludes+=" --exclude=$e"
- fi
-done
-
-
-# ============================================
-# === Main loop over the found patch files ===
-# ============================================
-for p in "${patch_files[@]}" ; do
-
- # For further processing the number and the full path
- # are needed.
- pnum=${p%%-*}
- psrc="${PATCH_DIR}/${p}"
-
- # We start with normal 3-way-patching
- GIT_USE_TWP="-3 "
-
-
- # ====================================================
- # === Step 1) Reset the exclude list of root files ===
- # ====================================================
- excludes="$basic_excludes"
-
-
- # ==============================================
- # === Step 2) Start applying the patch as is ===
- # ==============================================
- echo -n "Applying $p ..."
- git am $GIT_USE_TWP$GIT_AM_OPTS$excludes < $psrc 1>/dev/null 2>$PWX_ERR_LOG
- res=$?
- echo " done [$res]"
-
-
- # ===========================================================
- # === Step 3) Look for reasons to not use 3-way patching ===
- # === Symptom : "could not build fake ancestor" ===
- # === Reason : No common root can be built ===
- # === Resolution: Do not use "-3" option ===
- # ===========================================================
- if [[ 0 -ne $res ]] && \
- [[ $(grep -c "could not build fake ancestor" $PWX_ERR_LOG) -gt 0 ]];
- then
- echo -n "Trying again without 3-way-patching ..."
- GIT_USE_TWP=""
- git am --abort 1>/dev/null 2>&1
- git am $GIT_USE_TWP$GIT_AM_OPTS$excludes < $psrc 1>/dev/null 2>$PWX_ERR_LOG
- res=$?
- echo " done [$res]"
- fi
-
-
- # ====================================================================
- # === Step 4) Look for more files to exclude ===
- # === Symptom : "error: <file>: does not exist in index" ===
- # === Reason : The file to patch isn't there ===
- # === Resolution: Exclude the offending file(s) ===
- # ====================================================================
- if [[ 0 -ne $res ]] && \
- [[ $(grep -c "does not exist in index" $PWX_ERR_LOG) -gt 0 ]];
- then
- declare -a nff_files=( $( \
- grep "does not exist in index" $PWX_ERR_LOG | \
- cut -d ':' -f 2) )
-
- for nff in "${nff_files[@]}" ; do
- echo "Excluding $nff ..."
- excludes+=" --exclude=$nff"
-
- # A special an evil case is a rename copy of something non-existent.
- # git am then needs *two* excludes, one for the (non-existing)
- # source and one for the still not existing target.
- nff_tgt="$(grep -A 1 "copy from $nff" $psrc | \
- grep "copy to " | \
- cut -d ' ' -f 3)"
- if [[ "x" != "x$nff_tgt" ]]; then
- echo "Excluding $nff_tgt ..."
- excludes+=" --exclude=$nff_tgt"
- fi
- done
-
- echo -n "Trying again without non-existing files ..."
- git am --abort 1>/dev/null 2>&1
- git am $GIT_USE_TWP$GIT_AM_OPTS$excludes < $psrc 1>/dev/null 2>$PWX_ERR_LOG
- res=$?
- echo " done [$res]"
- unset nff_files
- fi
-
-
- # ====================================================================
- # === Step 5) If this still doesn't work, let check_tree.pl check ===
- # === out the commit and build diffs for the touched files ===
- # === against the tree. Then let the user have a chance to ===
- # === decide what to apply before continuing. ===
- # ====================================================================
- if [[ 0 -ne $res ]] && \
- [[ $(grep -c "patch does not apply" $PWX_ERR_LOG) -gt 0 ]];
- then
- res=0
- xCommit="$(head -n 1 $psrc | cut -d ' ' -f 2)"
- echo "git am failed to apply the patch automatically:"
- echo -e "\n--------"
- cat $PWX_ERR_LOG
- echo -e "--------\n"
- echo "Building patch diffs for commit $xCommit ..."
-
- # We need to know which files are relevant:
- xFiles=""
- xPatches=""
- for pF in $(grep "^diff \--git" $psrc | cut -d ' ' -f 3,4 | \
- while read a b ; do \
- echo -e "$a\n$b" | cut -d '/' -f 2- ; \
- done | sort -u) ; do
- xFiles+="-f $pF "
- xPatches+="${PROGDIR}/patches/${pF//\//_}.patch "
- done
-
- # If we have our lists, do it:
- if [[ "x" != "x$xFiles" ]] && [[ "x" != "x$xPatches" ]]; then
- $(PROGDIR)/check_tree.pl -c $xCommit $xFiles "$SOURCE_DIR"
-
- # Let's see which patches got built
- xResult=""
- for xP in $xPatches ; do
- echo -n "Checkin $xP : "
- if [[ -f "$xP" ]]; then
- echo "present"
- xResult+="$xP "
- else
- echo "missing"
- fi
- done
-
- # So, if no patches have been found, this whole thing
- # can be skipped.
- if [[ "x" = "x$xResult" ]]; then
- echo "No relevant patches found."
- echo -n "Skipping $psrc"
- git am --skip
- else
- # Okay, something to do found.
- echo "Please edit/delete the diffs as they are"
- echo "and then close $PWX_EDIT to continue"
- echo " ... to skip, just delete all patches"
- $PWX_EDIT $xResult 1>/dev/null 2>&1
-
- # Apply patch-by-patch and add to git.
- have_patch=0
- for xP in $xResult ; do
- while [[ -f "$xP" ]]; do
- have_patch=1
- echo "Applying $xP ..."
- patch -p 1 -i $xP
- if [[ 0 -ne $? ]]; then
- echo "Something is wrong with $xP"
- $PWX_EDIT $xP 1>/dev/null 2>&1
- else
- rm -f $xP
- fi
- done
- done
-
- if [[ 0 -eq $have_patch ]]; then
- echo "All patches deleted."
- git am --skip
- else
- git add man src
-
- git status
- echo "Patch: $psrc"
- echo -e -n "\nDoes this look in order to you? [Y/n]"
- read answer
- if [[ "xn" = "x$answer" ]]; then
- echo "Okay, then see what you can do"
- exit 0
- fi
-
- echo -n "Finishing $psrc ..."
- git am --continue 1>/dev/null 2>$PWX_ERR_LOG
- res=$?
- echo " done [$res]"
- fi
- fi
- else
- echo "ERROR: Could not get file list from $psrc"
- echo
- echo "You have to do this by hand. Sorry."
- exit 1
- fi
- fi
-
-
- # ===========================================
- # === Step 6) Exit if we couldn't help it ===
- # ===========================================
- if [[ $res -ne 0 ]]; then
- echo -e "\n ==> $psrc can not be applied"
- echo " ==> The command that failed was:"
- echo "git am $GIT_USE_TWP$GIT_AM_OPTS$excludes < $psrc"
- echo -e " ==> The Error message is:\n"
- cat $PWX_ERR_LOG
- echo -e "\nPlease try to apply the remaining parts by hand"
- echo "and then finish with 'git am --continue'"
- cleanup
- exit $res
- fi
-
-
- # ==================================
- # === Step 7) Clean up behind us ===
- # ==================================
-
- # The patch is applied or irrelevant, remove it.
- rm -f $psrc
-
- # Remove merge debris
- find -iname '*.orig' | xargs rm -f
-
- # Remove temp files
- cleanup
-done
-
diff --git a/pwx/pwx_git_funcs.sh b/pwx/pwx_git_funcs.sh
deleted file mode 100644
index 30bcebe69..000000000
--- a/pwx/pwx_git_funcs.sh
+++ /dev/null
@@ -1,170 +0,0 @@
-#!/bin/bash
-#
-# (c) 2013 - 2016 PrydeWorX
-# Sven Eden, PrydeWorX - Bardowick, Germany
-# yamakuzure@users.sourceforge.net
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# History and Changelog:
-# Version Date Maintainer Change(s)
-# 0.1.0 2013-06-01 sed, PrydeWorX First common function for
-# pwx_git_getter and pwx_git_applier.
-# 0.2.0 2016-11-18 sed, PrydeWorX Added exchanges array and
-# add_exchange() function.
-#
-
-# Make sure a known output is generated:
-export LC_ALL="C"
-
-
-# Error out if an unset variable or function is used
-set -u
-
-
-# Save IFS so it can be restored if someone ctrl+c's while IFS is patched
-declare PWX_OLD_IFS="$IFS"
-
-
-# @VARIABLE: PWX_EXCHANGES
-# @DESCRIPTION:
-# Array of <t:s> strings used by pwx_git_getter to substitute path names when
-# searching for files, and after generating commit patches.
-# This is put here as there might be a need for it in pwx_git_applier, too.
-declare -a PWX_EXCHANGES=()
-
-
-# @VARIABLE: PWX_TEMP_FILES
-# @DESCRIPTION:
-# Array of temporary files that get deleted when calling cleanup().
-declare -a PWX_TEMP_FILES=()
-
-
-# @VARIABLE: PWX_ERR_LOG
-# @DESCRIPTION:
-# Path to a file that gets dumped on the console when calling die().
-declare PWX_ERR_LOG=""
-
-
-# @VARIABLE: HERE
-# @DESCRIPTION:
-# Simple full path of the current working directory.
-declare HERE="$(pwd -P)"
-
-
-# @VARIABLE: PWX_COMMIT_FILE
-# @DESCRIPTION
-# The name of the file that stores mutual commit information.
-declare PWX_COMMIT_FILE="${PROGDIR}/pwx_last_mutual_commits.txt"
-
-
-# @VARIABLE: PWX_IS_PUSHD
-# @DESCRIPTION
-# If set to 1, the die() function knows that it has to perform a popd.
-declare PWX_IS_PUSHD=0
-
-
-# FUNCTION: add_exchange
-# @USAGE: <string>
-# @DESCRIPTION:
-# Add <string> to the PWX_EXCHANGES array
-add_exchange() {
- local f x present
- for f in "$@" ; do
- present=0
- for x in "${PWX_EXCHANGES[@]}" ; do
- if [[ "x$f" = "x$x" ]]; then
- present=1
- break
- fi
- done
- if [[ 0 -eq $present ]]; then
- PWX_EXCHANGES[${#PWX_EXCHANGES[@]}]="$f"
- fi
- done
-}
-
-
-# FUNCTION: add_temp
-# @USAGE: <file [...]>
-# @DESCRIPTION:
-# Add 1..n files to the PWX_TEMP_FILES array
-add_temp() {
- local f x present
- for f in "$@" ; do
- present=0
- for x in "${PWX_TEMP_FILES[@]}" ; do
- if [[ "x$f" = "x$x" ]]; then
- present=1
- break
- fi
- done
- if [[ 0 -eq $present ]]; then
- PWX_TEMP_FILES[${#PWX_TEMP_FILES[@]}]="$f"
- fi
- done
-}
-
-
-# FUNCTION: cleanup
-# @USAGE:
-# @DESCRIPTION:
-# Remove all (present) files in the PWX_TEMP_FILES array
-cleanup() {
- for f in "${PWX_TEMP_FILES[@]}" ; do
- [[ -f "$f" ]] && rm -f $f
- done
-}
-
-
-# @FUNCTION: die
-# @USAGE: [message]
-# @DESCRIPTION:
-# print out [message], cat error log if not empty,
-# delete all files listed in PWX_TEMP_FILES and exit
-# with error code 255.
-# If we are in pushd state, popd back before exiting
-die() {
- local f msg="$@"
-
- # Reset IFS
- export IFS="$PWX_OLD_IFS"
-
- # Get the message out
- if [[ -n "$msg" ]]; then
- echo -e "\n$msg\n"
- else
- echo -e "\nDIE\n"
- fi
-
- if [[ -n "$PWX_ERR_LOG" ]] \
- && [[ 0 -lt $(wc -l $PWX_ERR_LOG | cut -d ' ' -f 1) ]]; then
- echo -e "Last error log:\n========"
- cat $PWX_ERR_LOG
- echo "========"
- fi
-
- cleanup
-
- if [[ 0 -ne $PWX_IS_PUSHD ]]; then
- popd 1>/dev/null 2>&1
- fi
-
- exit 255
-}
-
-
-trap die SIGINT SIGKILL SIGTERM
-
-return 0
diff --git a/pwx/pwx_git_getter.sh b/pwx/pwx_git_getter.sh
deleted file mode 100755
index 183cb1259..000000000
--- a/pwx/pwx_git_getter.sh
+++ /dev/null
@@ -1,528 +0,0 @@
-#!/bin/bash
-#
-# (c) 2012 - 2016 PrydeWorX
-# Sven Eden, PrydeWorX - Bardowick, Germany
-# yamakuzure@users.sourceforge.net
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# History and Changelog:
-# Version Date Maintainer Change(s)
-# 0.0.1 2012-12-21 sed, PrydeWorX First Design.
-# 0.0.2 2012-12-29 sed, PrydeWorX First working version.
-# 0.0.3 2013-01-07 sed, PrydeWorX Force LC_ALL=C
-# 0.1.0 2013-01-09 sed, PrydeWorX Initial private release.
-# 0.1.1 2013-01-13 sed, PrydeWorX Added logging and error handling.
-# 0.1.2 2013-02-17 sed, PrydeWorX Cleanup on trapped signals added.
-# 0.1.3 2013-05-22 sed, PrydeWorX Use function descriptions like in
-# Gentoo eclasses.
-# 0.1.4 2013-06-01 sed, PrydeWorX Put functions into pwx_git_funcs.sh
-# for shared use with pwx_git_applier.
-# 0.2.0 2014-09-02 sed, PrydeWorX Use GNU enhanced getopt for command
-# line parsing.
-# 0.2.1 2015-03-07 sed, PrydeWorX Make <source path> and <tag> mandatory
-# positional arguments.
-# 0.3.0 2016-11-18 sed, PrydeWorX Added -w|--exchange option for
-# word/path substitutions. (elogind)
-# 0.3.1 2016-11-25 sed, PrydeWorX Add generated *.<tag>[.diff] files to
-# the targets .gitignore.
-# 0.3.2 2017-05-23 sed, PrydeWorX It is not fatal if the source dir has
-# no 'master' branch.
-# 0.3.3 2017-07-25 sed, PrydeWorX Do not build root file diffs, use
-# include the workings of
-# ./get_build_file_diff.sh instead.
-# 0.4.0 2017-08-08 sed, PrydeWorX Include meson build files in normal
-# file list.
-
-# Common functions
-PROGDIR="$(readlink -f $(dirname $0))"
-source ${PROGDIR}/pwx_git_funcs.sh
-
-# Version, please keep this current
-VERSION="0.4.0"
-
-# Global values to be filled in:
-SOURCE_TREE=""
-TAG_TO_USE=""
-LAST_MUTUAL_COMMIT=""
-OUTPUT="${PROGDIR}/patches"
-EXTRA_GIT_OPTS=""
-
-
-# The options for the git format-patch command:
-GIT_FP_OPTS="-1 -C --find-copies-harder -n"
-
-
-# Options and the corresponding help text
-OPT_SHORT=c:e:ho:
-OPT_LONG=commit:,exchange:,help,output:
-
-HELP_TEXT="Usage: $0 [OPTIONS] <source path> <tag>
-
- Reset the git tree in <source path> to the <tag>. Then
- search its history since the last mutual commit for any
- commit that touches at least one file in any subdirectory
- of the directory this script was called from.
- The root files, like Makefile.am or configure.ac, are not
- used by the search, but copied with the tag as a postfix
- if these files where changed. A diff file is created as
- well.
-
-OPTIONS:
- -c|--commit <hash> : The mutual commit to use. If this
- option is not used, the script looks
- into \"${PWX_COMMIT_FILE}\"
- and uses the commit noted for <tag>.
- -e|--exchange <t:s>: Exchanges t for s when searching for
- commits and replaces s with t in the
- formatted patches.
- 't' is the [t]arget string. (HERE)
- 's' is the [s]ource string. (THERE)
- This option can be used more than
- once. Substitutions are performed in
- the same order as given on the
- command line.
- -h|--help Show this help and exit.
- -o|--output <path> : Path to where to write the patches.
- The default is to write into the
- subdirectory 'patches' of the
- current directory.
-
-Notes:
- - The source tree is not reset and kept in detached state
- after the script finishes.
- - When the script succeeds, it adds a line to the commit
- - file \"${PWX_COMMIT_FILE}\" of the form:
- <tag>-last <newest found commit>
- You can use that line for the next tag you wish to
- migrate.
-"
-
-
-# =========================================
-# === Use getopt (GNU enhanced version) ===
-# =========================================
-
-# Check the version first, so we do not run into trouble
-getopt --test > /dev/null
-if [[ $? -ne 4 ]]; then
- echo "ERROR: getopt is not the GNU enhanced version."
- exit 1
-fi
-
-# Store the output so we can check for errors.
-OPT_PARSED=$(getopt --options $OPT_SHORT --longoptions $OPT_LONG --name "$0" -- "$@")
-
-if [[ $? -ne 0 ]]; then
- # getopt has already complained about wrong arguments to stdout
- exit 2
-fi
-
-# Use eval with "$OPT_PARSED" to properly handle the quoting
-eval set -- "$OPT_PARSED"
-
-# --------------------
-# --- Handle input ---
-# --------------------
-while true; do
- case "$1" in
- -c|--commit)
- LAST_MUTUAL_COMMIT="$2"
- shift 2
- ;;
- -e|--exchange)
- add_exchange "$2"
- shift 2
- ;;
- -h|--help)
- echo "$HELP_TEXT"
- exit 0
- ;;
- -o|--output)
- OUTPUT="$2"
- shift 2
- ;;
- --)
- shift
- break
- ;;
- *)
- echo "Something went mysteriously wrong."
- exit 3
- ;;
- esac
-done
-
-# At this point we must have <source path> and <tag> left
-if [[ $# -ne 2 ]]; then
- echo "$HELP_TEXT"
- exit 4
-fi
-
-# So these must be it:
-SOURCE_TREE="$1"
-TAG_TO_USE="$2"
-
-
-
-# ======================================================
-# === The directory to analyse must exist of course. ===
-# ======================================================
-THERE="$(readlink -f "$SOURCE_TREE")"
-if [[ ! -d "$THERE" ]]; then
- echo "The directory \"$SOURCE_TREE\""
- if [[ -n "$THERE" ]] \
- && [[ "x$THERE" != "x$SOURCE_TREE" ]]; then
- echo " aka \"$THERE\""
- fi
- echo -e "could not be found"
- exit 1
-fi
-
-
-# ==============================================
-# === It is futile to analyze this directory ===
-# ==============================================
-if [[ "x$HERE" = "x$THERE" ]]; then
- echo "No. Please use another directory."
- exit 1
-fi
-
-
-# =======================================================
-# === If no last mutual commit was given, try to load ===
-# === it from commit list. ===
-# =======================================================
-if [[ -z "$LAST_MUTUAL_COMMIT" ]]; then
- if [[ -f "${PWX_COMMIT_FILE}" ]]; then
- LAST_MUTUAL_COMMIT="$( \
- grep -s -P "^$TAG_TO_USE " $PWX_COMMIT_FILE 2>/dev/null | \
- cut -d ' ' -f 2)"
- else
- echo "ERROR: ${PWX_COMMIT_FILE} does not exist."
- echo " Please provide a last mutual commit"
- echo " to use."
- echo -e "\n$HELP_TEXT"
- exit 2
- fi
-
- # If the tag was not found in the commit file,
- # error out. Analysing the trees by this script is
- # almost guaranteed to go wrong.
- if [[ -z "$LAST_MUTUAL_COMMIT" ]] ; then
- echo "ERROR: $PWX_COMMIT_FILE does not contain"
- echo " \"$TAG_TO_USE\" Please provide a last mutual"
- echo " commit to use."
- echo -e "\n$HELP_TEXT"
- exit 3
- fi
-fi
-echo "Last mutual commit: $LAST_MUTUAL_COMMIT"
-
-
-# ================================================================
-# === The PWX_EXCHANGES array may consist of "t:s" strings which ===
-# === must be split. The first part is needed to rename paths ===
-# === for the source tree history search, the second to rename ===
-# === those paths in the patch files back into what can be ===
-# === used here. ===
-# ================================================================
-declare -a ex_src=()
-declare -a ex_tgt=()
-for x in "${!PWX_EXCHANGES[@]}" ; do
- exstr=${PWX_EXCHANGES[$x]}
- src=${exstr##*:}
- tgt=${exstr%%:*}
- if [[ "x$src" = "x$tgt" ]]; then
- echo "ERROR: The exchange string \"$exstr\" is invalid"
- exit 4
- fi
- # The reason we go by using two indexed arrays instead
- # of associative arrays is, that the output of
- # ${!ex_src[@]} and ${!ex_tgt[@]} would be sorted
- # alphanumerical. But to be able to do chained substitutions
- # as defined by the order on the command line, that sorting
- # is counterproductive.
- # An argument chain like:
- # --exchange foobar:baz --exchange bar:foo
- # would result in the wrong order for the target to source
- # substitutions, as 'bar' would be given before 'foobar'.
- ex_src[$x]="$src"
- ex_tgt[$x]="$tgt"
-done
-
-
-# ==========================================================
-# === The OUTPUT directory must exist and must be empty. ===
-# ==========================================================
-if [[ -n "$OUTPUT" ]]; then
- if [[ ! -d "$OUTPUT" ]]; then
- mkdir -p "$OUTPUT" || die "Can not create $OUTPUT [$?]"
- fi
-
- if [[ -n "$(ls "$OUTPUT"/????-*.patch 2>/dev/null)" ]]; then
- echo "ERROR: $OUTPUT already contains patches"
- exit 4
- fi
-else
- echo "You have set the output directory to be"
- echo "an empty string. Where should I put the"
- echo "patches, then?"
- exit 5
-fi
-
-
-# =============================================================
-# === We need two file lists. ===
-# === A) The list of root files. ===
-# === These are not analyzed beyond the question whether ===
-# === they differ from our version or not. If they ===
-# === differ, we'll copy them with the used tag becoming ===
-# === a postfix. They are further analyzed later. ===
-# === B) All files in the used subdirectories. We need all ===
-# === commits that change these files. ===
-# =============================================================
-echo -n "Building file lists ..."
-
-# If this is a meson+ninja build, there might be a "build" subdirectory,
-# that we surely do not want to get analyzed.
-if [[ -d ./build ]]; then
- rm -rf ./build
-fi
-
-# --- File list a) Root files
-declare -a root_files=( $(find ./ -mindepth 1 -maxdepth 1 -type f \
- -not -name '*~' -and \
- -not -name '*.diff' -and \
- -not -name '*.orig' -and \
- -not -name '*.bak' -and \
- -not -name '*meson*' -printf "%f ") )
-
-# --- File list b) Core files
-declare -a core_files=( $(find ./ -mindepth 2 -type f \
- -not -name '*~' -and \
- -not -name '*.diff' -and \
- -not -name '*.orig' -and \
- -not -name '*.bak') )
-echo " done"
-
-# --- Add root meson files to the core list
-core_files+=( $(find ./ -mindepth 1 -maxdepth 1 -type f \
- -not -name '*~' -and \
- -not -name '*.diff' -and \
- -not -name '*.orig' -and \
- -not -name '*.bak' -and \
- -name '*meson*') )
-
-# --- Add an error log file to the list of temp files
-PWX_ERR_LOG="/tmp/pwx_git_getter_$$.log"
-add_temp "$PWX_ERR_LOG"
-touch $PWX_ERR_LOG || die "Unable to create $PWX_ERR_LOG"
-
-
-# ===============================================
-# === Step 1: pushd into the source directory ===
-# === and check out the tag to use. ===
-# ===============================================
-pushd $THERE 1>/dev/null 2>$PWX_ERR_LOG || die "Can't pushd into \"$THERE\""
-PWX_IS_PUSHD=1
-
-# Reset to master first, to see whether this is clean
-git checkout master 1>/dev/null 2>&1
-git checkout $TAG_TO_USE 1>/dev/null 2>$PWX_ERR_LOG
-res=$?
-if [ 0 -ne $res ] ; then
- die "ERROR: tag \"$TAG_TO_USE\" is unknown [$res]"
-fi
-
-
-# ======================================
-# === Step 2: Now that we are THERE, ===
-# === copy the root files. ===
-# ======================================
-echo -n "Copying root files that differ ..."
-
-# Go through the files.
-for f in "${root_files[@]}" ; do
- if [[ -f "$THERE/$f" ]] \
- && [[ -n "$(diff -dqw "$HERE/$f" "$THERE/$f")" ]] ; then
-
- cp -uf "$THERE/$f" "$HERE/${f}.$TAG_TO_USE" 2>$PWX_ERR_LOG || \
- die "cp \"$THERE/$f\" \"$HERE/${f}.$TAG_TO_USE\" failed"
- fi
-done
-
-echo " done"
-
-
-# =========================================
-# === Step 3: Build the list of commits ===
-# =========================================
-echo -n "Building commit list..."
-
-# lst_a is for the raw list of commits with time stamps
-lst_a=/tmp/git_list_a_$$.lst
-touch "$lst_a" || die "Can not create $lst_a"
-truncate -s 0 $lst_a
-add_temp "$lst_a"
-
-# lst_b is for the ordered (by timestamp) and unified list
-lst_b=/tmp/git_list_b_$$.lst
-touch "$lst_b" || die "Can not create $lst_b"
-truncate -s 0 $lst_b
-add_temp "$lst_b"
-
-for f in "${core_files[@]}" ; do
- # Before using that file to find log entries that match,
- # all target->source substitutions must be used.
- fsrc="$f"
- for i in "${!ex_tgt[@]}" ; do
- src="${ex_src[$i]//\//\\\/}"
- tgt="${ex_tgt[$i]//\//\\\/}"
- fsrc="${fsrc//$tgt/$src}"
- done
-
- # Now go looking what we've got
- git log ${LAST_MUTUAL_COMMIT}..HEAD $fsrc 2>/dev/null | \
- grep -P "^commit\s+" | \
- cut -d ' ' -f 2 >> $lst_a
- # Note: No PWX_ERR_LOG here. If we check a file, that ONLY
- # exists in the target, git log will error out.
-done
-sort -u $lst_a > $lst_b
-truncate -s 0 $lst_a
-
-c_cnt=$(wc -l $lst_b | cut -d ' ' -f 1)
-echo " $c_cnt commits found"
-
-
-# ==============================================================
-# === Step 4: Get a full list of all commits since the last ===
-# === mutual commit. These are tac'd and then used ===
-# === to build the final list of commits, now in the ===
-# === correct order. ===
-# ==============================================================
-echo -n "Ordering by commit time..."
-for c in $(git log ${LAST_MUTUAL_COMMIT}..HEAD 2>/dev/null | \
- grep -P "^commit\s+" | \
- cut -d ' ' -f 2 | tac) ; do
- grep "$c" $lst_b >> $lst_a
-done
-echo " done"
-
-
-# ================================================================
-# === Step 5: Now that we have a lst_b file with a list of all ===
-# === relevant commits for all files found in the ===
-# === target, the commit patches can be build. ===
-# ================================================================
-echo -n "Creating patches ..."
-
-# To be able to apply the patches in the correct order, they need
-# to be numbered. However, as git will only create one patch at a
-# time, we have to provide the numbering by ourselves.
-n=0
-LAST_COMMIT=""
-for c in $(cut -d ' ' -f 2 $lst_a) ; do
- n=$((n+1))
- n_str="$(printf "%04d" $n)"
- git format-patch $GIT_FP_OPTS -o $OUTPUT --start-number=$n $c \
- 1>/dev/null 2>$PWX_ERR_LOG || die "git format-patch failed on $c"
-
- # Again we have to apply the exchange substitutions, now in
- # reverse order. If we didn't do that, the patches would
- # try to modify files, that do not exist in the target.
- # Or worse, are different files.
- for i in "${!ex_src[@]}" ; do
- src="${ex_src[$i]//,/\\,}"
- tgt="${ex_tgt[$i]//,/\\,}"
- perl -p -i -e "s,$src,$tgt,g" $OUTPUT/${n_str}-*.patch
- done
-
- # Store commit so the last is known when the loop ends
- LAST_COMMIT="$c"
-done
-echo " done"
-
-
-# =============================================
-# === Step 6: Get the real root files diffs ===
-# =============================================
-echo -n "Building root file diffs ..."
-git checkout ${LAST_MUTUAL_COMMIT} 1>/dev/null 2>$PWX_ERR_LOG
-res=$?
-if [ 0 -ne $res ] ; then
- die "ERROR: tag \"${LAST_MUTUAL_COMMIT}\" is unknown [$res]"
-fi
-
-# The work is done HERE
-popd 1>/dev/null 2>&1
-PWX_IS_PUSHD=0
-
-# Now go through the files:
-for t in "${root_files[@]}"; do
- f="${t}.${TAG_TO_USE}"
- if [[ ! -f "${f}" ]]; then
- continue
- fi
-
- case "$t" in
- autogen.sh|Makefile-man.am|README)
- rm -f "$f"
- ;;
- CODING_STYLE|NEWS|TODO|.dir-locals.el|.mailmap|.vimrc|.ymc_extra_conf.py)
- mv "$f" "$t"
- ;;
- .gitignore|configure.ac|Makefile.am|configure|Makefile)
- diff -dwu $THERE/$t "$f" | \
- sed -e "s,$THERE/$t,a/$t," \
- -e "s,$f,b/$t," > ${t}.diff
- rm -f "${f}"
- ;;
- *)
- echo "WHAT the hell should I do with \"$f\" -> \"$t\" ?"
- ;;
- esac
-done
-
-# Get upstream back THERE
-pushd $THERE 1>/dev/null 2>$PWX_ERR_LOG || die "Can't pushd into \"$THERE\""
-PWX_IS_PUSHD=1
-git checkout $TAG_TO_USE 1>/dev/null 2>&1
-
-
-# ======================================================
-# === Step 7: Make the last commit found to be known ===
-# ======================================================
-popd 1>/dev/null 2>&1
-PWX_IS_PUSHD=0
-if [[ -n "$LAST_COMMIT" ]]; then
- m="${TAG_TO_USE}-last"
- if [[ -f $PWX_COMMIT_FILE ]] \
- && [[ 0 -lt $(grep -c "$m" $PWX_COMMIT_FILE) ]]; then
- echo "Substituting $m with $LAST_COMMIT"
- perl -p -i -e "s,^$m\s+\S+$,$m $LAST_COMMIT," $PWX_COMMIT_FILE
- else
- echo "Setting $m to $LAST_COMMIT"
- echo "$m $LAST_COMMIT" >> $PWX_COMMIT_FILE
- fi
-fi
-
-
-# ========================================
-# === Cleanup : Remove temporary files ===
-# ========================================
-cleanup
-echo "All finished"
-
diff --git a/pwx/pwx_git_patch_formatter.sh b/pwx/pwx_git_patch_formatter.sh
deleted file mode 100755
index 54ba4e404..000000000
--- a/pwx/pwx_git_patch_formatter.sh
+++ /dev/null
@@ -1,186 +0,0 @@
-#!/bin/bash
-#
-# (c) 2012 - 2017 PrydeWorX
-# Sven Eden, PrydeWorX - Bardowick, Germany
-# yamakuzure@users.sourceforge.net
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# History and Changelog:
-# Version Date Maintainer Change(s)
-# 0.0.1 2017-07-27 sed, PrydeWorX First Design, forked off pwx_git_getter.sh
-#
-
-# Common functions
-source pwx_git_funcs.sh
-
-# Version, please keep this current
-VERSION="0.0.1"
-
-# Global values to be filled in:
-SINCE_WHEN=""
-OUTPUT="${HERE}/patches"
-EXTRA_GIT_OPTS=""
-
-
-# The options for the git format-patch command:
-GIT_FP_OPTS="-1 -C --find-copies-harder -n"
-
-
-# Options and the corresponding help text
-OPT_SHORT=ho:
-OPT_LONG=help,output:
-
-HELP_TEXT="Usage: $0 [OPTIONS] <commit>
-
- Build formatted patches for all commits *after* <commit>
- up to HEAD.
-
-OPTIONS:
- -h|--help Show this help and exit.
- -o|--output <path> : Path to where to write the patches.
- The default is to write into the
- subdirectory 'patches' of the
- current directory.
-"
-
-
-# =========================================
-# === Use getopt (GNU enhanced version) ===
-# =========================================
-
-# Check the version first, so we do not run into trouble
-getopt --test > /dev/null
-if [[ $? -ne 4 ]]; then
- echo "ERROR: getopt is not the GNU enhanced version."
- exit 1
-fi
-
-# Store the output so we can check for errors.
-OPT_PARSED=$(getopt --options $OPT_SHORT --longoptions $OPT_LONG --name "$0" -- "$@")
-
-if [[ $? -ne 0 ]]; then
- # getopt has already complained about wrong arguments to stdout
- exit 2
-fi
-
-# Use eval with "$OPT_PARSED" to properly handle the quoting
-eval set -- "$OPT_PARSED"
-
-# --------------------
-# --- Handle input ---
-# --------------------
-while true; do
- case "$1" in
- -h|--help)
- echo "$HELP_TEXT"
- exit 0
- ;;
- -o|--output)
- OUTPUT="$2"
- shift 2
- ;;
- --)
- shift
- break
- ;;
- *)
- echo "Something went mysteriously wrong."
- exit 3
- ;;
- esac
-done
-
-# At this point we must have <commit> left
-if [[ $# -ne 1 ]]; then
- echo "$HELP_TEXT"
- exit 4
-fi
-
-# So these must be it:
-SINCE_WHEN="$1"
-
-
-# ==========================================================
-# === The OUTPUT directory must exist and must be empty. ===
-# ==========================================================
-if [[ -n "$OUTPUT" ]]; then
- if [[ ! -d "$OUTPUT" ]]; then
- mkdir -p "$OUTPUT" || die "Can not create $OUTPUT [$?]"
- fi
-
- if [[ -n "$(ls "$OUTPUT"/????-*.patch 2>/dev/null)" ]]; then
- echo "ERROR: $OUTPUT already contains patches"
- exit 4
- fi
-else
- echo "You have set the output directory to be"
- echo "an empty string. Where should I put the"
- echo "patches, then?"
- exit 5
-fi
-
-
-# --- Add an error log file to the list of temp files
-PWX_ERR_LOG="/tmp/pwx_git_getter_$$.log"
-add_temp "$PWX_ERR_LOG"
-touch $PWX_ERR_LOG || die "Unable to create $PWX_ERR_LOG"
-
-
-# =========================================
-# === Step 1: Build the list of commits ===
-# =========================================
-echo -n "Building commit list..."
-
-# lst_a is for the list of commits in reverse order
-lst_a=/tmp/git_list_a_$$.lst
-touch "$lst_a" || die "Can not create $lst_a"
-truncate -s 0 $lst_a
-add_temp "$lst_a"
-
-git log ${SINCE_WHEN}..HEAD 2>/dev/null | \
- grep -P "^commit\s+" | \
- cut -d ' ' -f 2 | \
- tac > $lst_a
-
-c_cnt=$(wc -l $lst_a | cut -d ' ' -f 1)
-echo " $c_cnt commits found"
-
-
-# ================================================================
-# === Step 2: Now that we have a lst_b file with a list of all ===
-# === relevant commits for all files found in the ===
-# === target, the commit patches can be build. ===
-# ================================================================
-echo -n "Creating patches ..."
-
-# To be able to apply the patches in the correct order, they need
-# to be numbered. However, as git will only create one patch at a
-# time, we have to provide the numbering by ourselves.
-n=0
-for c in $(cut -d ' ' -f 2 $lst_a) ; do
- n=$((n+1))
- n_str="$(printf "%04d" $n)"
- git format-patch $GIT_FP_OPTS -o $OUTPUT --start-number=$n $c \
- 1>/dev/null 2>$PWX_ERR_LOG || die "git format-patch failed on $c"
-done
-echo " done"
-
-
-# ========================================
-# === Cleanup : Remove temporary files ===
-# ========================================
-cleanup
-echo "All finished"
-
diff --git a/pwx/pwx_last_mutual_commits.txt b/pwx/pwx_last_mutual_commits.txt
deleted file mode 100644
index 7401aa5dd..000000000
--- a/pwx/pwx_last_mutual_commits.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-v234 d6d0473dc9688dbfcd9e9b6ed005de26dd1131b7
-v234-last 782c925f7fa2e6e716ca9ac901954f3349d07ad8
-v234-stable 782c925f7fa2e6e716ca9ac901954f3349d07ad8
-v229-stable c7f5a7d897491ceea90138d412a641b3225a1936
-v231-stable 33628598ef1af73f8f50f96b4ce18f8a95733913
-v232-stable 79a5d862a7abe903f456a75d6d1ca3c11adfa379
-v233-stable 589fa9087a49e4250099bb6a4cf00358379fa3a4
-master 265710c2055254a98ed6dcd6aa172ca509a33553
-master-last efaa3176ad0e763a0fafd4519d4391813a88ba0e
-v236-stable 590171d1c956ac3b073bc73a7ca1f5529b01ab83
-v236 83fefc8888620ce27ba39d906bd879bbcb6bc84e
-v236-last f78a88beca362e62ca242499950a097fbcdb10d2
-v235-stable b3e823e43c45b6233405d62e5f095c11130e638f