#!/bin/bash # $Id$ # Magic script to make branch pulls from KDE SVN. Invoke it from a # toplevel dir (i.e., debian/ exists) and let it figure out what to do. # (C) 2005, Adeodato Simó # GPL'ed code follows. # TODO # 1/ it does not work for arts # (since it thinks kde is kde 1.4.0 instead of 3.4.0 ...) set -e # ensure same behavior independently of language used export LANG=C KDE_SVN=svn://anonsvn.kde.org/home/kde dh_testdir # Find out module and version dpkg-parsechangelog | awk ' /^Source/ { printf("%s ", $2) } /^Version/ { sub(/^[0-9]+:/, "", $2) sub(/-[^-]+$/, "", $2) printf("%s ", $2) sub(/\.[0-9]+$/, "", $2) print $2 } ' | { read MODULE VERSION MAJOR_VERSION # Determine the revision of the latest pull # (empty string if there has been none) shopt -s nullglob LATEST_PULL=$( echo debian/patches/*_${MODULE}_branch_r*.diff | tail -1 | sed -re 's/.*_branch_r([0-9]+).*/\1/' ) TOPLEVEL=KDE if [ "$MODULE" = "koffice" ]; then TOPLEVEL=koffice fi if [ -z "$LATEST_PULL" ]; then echo "This is the first pull for $MODULE $VERSION." ARG1="$KDE_SVN/tags/$TOPLEVEL/$VERSION/$MODULE" ARG2="$KDE_SVN/branches/$TOPLEVEL/$MAJOR_VERSION/$MODULE" else echo "Patch until revision $LATEST_PULL exists." ARG1="-r$LATEST_PULL:HEAD" ARG2="$KDE_SVN/branches/$TOPLEVEL/$MAJOR_VERSION/$MODULE" fi # Get branch from the repo TMP_PATCH=$(mktemp debian/patches/branch.XXXXXX) trap "rm -f $TMP_PATCH" EXIT echo "Getting diff file from server..." svn diff "$ARG1" "$ARG2" | filterdiff -x 'debian/*' | filterdiff >${TMP_PATCH} # Find out the revision of this new pull, unless empty # Gross hack coming... if [ ! -s ${TMP_PATCH} ]; then echo "Diff file was empty, no patch created." exit else NEW_REVISION=$(sed -rne '2s/.*revision ([0-9]+).*/\1/p' ${TMP_PATCH}) fi # Move patch to its final destination DEST="debian/patches/01_${MODULE}_branch_r$NEW_REVISION.diff" { echo "#DPATCHLEVEL=0"; cat ${TMP_PATCH}; } > ${DEST} echo "Created patch ${DEST}." exit # ensure traps get executed }