summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/apatch.in27
-rw-r--r--scripts/patchfns.in51
-rwxr-xr-xscripts/rpatch.in21
3 files changed, 70 insertions, 29 deletions
diff --git a/scripts/apatch.in b/scripts/apatch.in
index bba756f..2ec69bc 100755
--- a/scripts/apatch.in
+++ b/scripts/apatch.in
@@ -44,15 +44,18 @@ apply_patch()
if [ "x${patch_file:(-3)}" = "x.gz" ]
then
gzip -cd $patch_file \
- | @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) --backup --prefix=".pc/$patch/" \
+ | @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) \
+ --backup --prefix="$QUILT_PC/$patch/" \
-E $silent $force_apply 2>&1
elif [ "x${patch_file:(-4)}" = "x.bz2" ]
then
bzip2 -cd $patch_file \
- | @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) --backup --prefix=".pc/$patch/" \
+ | @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) \
+ --backup --prefix="$QUILT_PC/$patch/" \
-E $silent $force_apply 2>&1
else
- @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) --backup --prefix=".pc/$patch/" \
+ @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) \
+ --backup --prefix="$QUILT_PC/$patch/" \
-E $silent $force_apply -i $patch_file 2>&1
fi
}
@@ -63,7 +66,8 @@ rollback_patch()
# FIXME backup_files should scan the directory hierarchy itself.
files_in_patch $patch > $pc_file
- @LIB@/backup-files $silent_unless_verbose -f $pc_file -B .pc/$patch/ -r
+ @LIB@/backup-files $silent_unless_verbose \
+ -f $pc_file -B $QUILT_PC/$patch/ -r
if [ -z "$opt_leave_rejects" ]
then
@SED@ -e 's/$/\.rej/' $pc_file | xargs rm -f
@@ -88,7 +92,8 @@ apatch()
then
# The reject files are removed in rollback_patch.
echo "$output" \
- | sed -e 's/-- saving rejects to file \(.\+\)\.rej/-- rejects in file \1/'
+ | sed -e \
+'s/-- saving rejects to file \(.\+\)\.rej/-- rejects in file \1/'
elif [ -n "$output" ]
then
echo "$output"
@@ -99,17 +104,17 @@ apatch()
add_to_db $patch
if [ $status -eq 0 ]
then
- rm -f .pc/$patch~refresh
+ rm -f $QUILT_PC/$patch~refresh
else
- touch .pc/$patch~refresh
+ touch $QUILT_PC/$patch~refresh
fi
- if [ -e ".pc/$patch" ]
+ if [ -e "$QUILT_PC/$patch" ]
then
- touch .pc/$patch/.timestamp
+ touch $QUILT_PC/$patch/.timestamp
fi
- if [ "$(shopt -s nullglob ; echo .pc/$patch/*)" = "" ]
+ if [ "$(shopt -s nullglob ; echo $QUILT_PC/$patch/*)" = "" ]
then
echo $"Patch $patch appears to be empty, applied"
elif [ $status -ne 0 ]
@@ -173,7 +178,7 @@ fi
patch=$(stripit $1)
top=$(top_patch)
-if [ -n "$top" -a -e .pc/$top~refresh ]
+if [ -n "$top" -a -e $QUILT_PC/$top~refresh ]
then
echo $"The topmost patch $top needs to be refreshed first."
exit 1
diff --git a/scripts/patchfns.in b/scripts/patchfns.in
index a715033..17275f6 100644
--- a/scripts/patchfns.in
+++ b/scripts/patchfns.in
@@ -9,17 +9,51 @@
export TEXTDOMAIN=quilt
-
if [ -e $HOME/.quiltrc ]
then
. $HOME/.quiltrc
fi
: ${QUILT_PATCHES:=patches}
+: ${QUILT_PC:=.pc}
-if [ -e .pc/series ]
+#
+# If the working directory does not contain a $QUILT_PATCHES directory,
+# quilt searches for its base directory up the directory tree. If no
+# $QUILT_PATCHES directory exists, the quilt operations that create
+# patches will create $QUILT_PATCHES in the current working directory.
+#
+# When quilt is invoked from a directory below the base directory, it
+# changes into the base directory, and sets $SUBDIR to the relative
+# path from the base directory to the directory in which it was
+# invoked. (e.g., if quilt is invoked in /usr/src/linux/drivers/net
+# and the base direcory is /usr/src/linux, $SUBDIR is set to
+# drivers/net/.
+
+unset SUBDIR
+if ! [ -d "$QUILT_PATCHES" ]
then
- SERIES=.pc/series
+ basedir=$PWD
+ while [ -n "$basedir" ]
+ do
+ basedir=${basedir%/*}
+ if [ -d "$basedir/$QUILT_PATCHES" ]
+ then
+ SUBDIR="${PWD#$basedir/}/"
+ if ! cd $basedir
+ then
+ echo "Cannot change into parent directory $basedir" >&2
+ exit 1
+ fi
+ break
+ fi
+ done
+ unset basedir
+fi
+
+if [ -e $QUILT_PC/series ]
+then
+ SERIES=$QUILT_PC/series
elif [ -e series ]
then
SERIES=series
@@ -27,7 +61,8 @@ else
SERIES=$QUILT_PATCHES/series
fi
-DB=".pc/applied-patches"
+DB="$QUILT_PC/applied-patches"
+
# Quote a string for use in a basic regular expression.
quote_bre()
@@ -239,7 +274,7 @@ backup_file_name()
local patch=$1
while [ $# -gt 1 ]
do
- echo ".pc/$patch/$2"
+ echo "$QUILT_PC/$patch/$2"
shift
done
}
@@ -391,13 +426,13 @@ stripit()
file_in_patch()
{
local file=$1 patch=$2
- [ -f ".pc/$patch/$file" ]
+ [ -f "$QUILT_PC/$patch/$file" ]
}
files_in_patch()
{
local patch="$1"
- local path=".pc/$patch"
+ local path="$QUILT_PC/$patch"
if [ -d "$path" ]
then
for file in $(find "$path" -type f \
@@ -585,7 +620,7 @@ first_modified_by()
fi
for patch in ${patches[@]}
do
- if [ -f ".pc/$patch/$file" ]
+ if [ -f "$QUILT_PC/$patch/$file" ]
then
echo $patch
return 0
diff --git a/scripts/rpatch.in b/scripts/rpatch.in
index eeb1363..e4dfefb 100755
--- a/scripts/rpatch.in
+++ b/scripts/rpatch.in
@@ -28,13 +28,14 @@ files_may_have_changed()
local patch=$1 file
local patch_file=$(patch_file_name $patch)
- if [ $? -ne 0 -o ! -e "$patch_file" -o ! -e ".pc/$patch/.timestamp" \
- -o ".pc/$patch/.timestamp" -ot "$patch_file" ]
+ if [ $? -ne 0 -o ! -e "$patch_file" \
+ -o ! -e "$QUILT_PC/$patch/.timestamp" \
+ -o "$QUILT_PC/$patch/.timestamp" -ot "$patch_file" ]
then
return 0
fi
- local apply_ts=$(date -r ".pc/$patch/.timestamp" '+%s') ts
+ local apply_ts=$(date -r "$QUILT_PC/$patch/.timestamp" '+%s') ts
for file in $(files_in_patch $patch)
do
ts=$(date -r $file '+%s' 2> /dev/null)
@@ -53,10 +54,10 @@ check_for_pending_changes()
local patch_args=$(patch_args $patch)
local workdir=$(gen_tempfile -d quilt) status=0
- if [ -d .pc/$patch ]
+ if [ -d $QUILT_PC/$patch ]
then
if ! rmdir $workdir || # note that this is racey...
- ! cp -rl .pc/$patch $workdir/
+ ! cp -rl $QUILT_PC/$patch $workdir/
then
echo $"Failed to copy files to temporary directory"
rm -rf $workdir
@@ -84,7 +85,7 @@ check_for_pending_changes()
# files won't succeed, either. So, ignore the error
# in that particular case.
- if ! [ -e .pc/$patch ]
+ if ! [ -e $QUILT_PC/$patch ]
then
echo $"Failed to patch temporary files"
rm -rf $workdir
@@ -133,11 +134,11 @@ rpatch()
if [ $status -eq 0 ]
then
echo $"Removing $patch"
- rm -f ".pc/$patch/.timestamp"
- @LIB@/backup-files $silent -f $pc_file -B .pc/$patch/ -r
+ rm -f "$QUILT_PC/$patch/.timestamp"
+ @LIB@/backup-files $silent -f $pc_file -B $QUILT_PC/$patch/ -r
status=$?
remove_from_db $patch
- rm -f .pc/$patch~refresh
+ rm -f $QUILT_PC/$patch~refresh
fi
rm -f $pc_file
trap - SIGINT
@@ -187,7 +188,7 @@ patch=$(stripit $1)
[ -z "$opt_verbose" ] && silent_unless_verbose=-s
top=$(top_patch)
-if [ -n "$top" -a -e .pc/$top~refresh -a -z "$opt_force" ]
+if [ -n "$top" -a -e $QUILT_PC/$top~refresh -a -z "$opt_force" ]
then
echo $"The topmost patch $top needs to be refreshed first."
exit 1