From: Andreas Gruenbacher Date: Thu, 1 Dec 2016 11:15:48 +0100 Subject: patch-wrapper: Make the patch names that quilt shows more convenient Git-commit: 1cde19389bc5805da713361ac32869388e42f592 Patch-mainline: yes When operating on an rpm package, create links to the rpm sources and build directories and make patch names relative to these links. This is more convenient than using ugly absolute paths. --- a/bin/patch-wrapper.in +++ b/bin/patch-wrapper.in @@ -28,7 +28,7 @@ fi backup_files() { - declare dir=${QUILT_PC:-.pc}/$patch + declare dir=${QUILT_PC:-.pc}/$name if [ "$backup_mode" = --backup-if-mismatch ] then @@ -201,39 +201,56 @@ then fi quilt_patches=${QUILT_PATCHES:-patches} -dir=$(dirname "$quilt_patches/$patch") -mkdir -p "$dir" -if [ -e "$patch" ] + +if [ "${patch#$RPM_SOURCE_DIR}" != "$patch" ] +then + name=SOURCES/${patch#$RPM_SOURCE_DIR/} + if [ ! -e "$quilt_patches/SOURCES" ] + then + mkdir -p "$quilt_patches" + ln -s $RPM_SOURCE_DIR "$quilt_patches/SOURCES" + fi +elif [ "${patch#$RPM_BUILD_DIR}" != "$patch" ] then + name=BUILD/${patch#$RPM_BUILD_DIR/} + if [ ! -e "$quilt_patches/BUILD" ] + then + mkdir -p "$quilt_patches" + ln -s $RPM_BUILD_DIR "$quilt_patches/BUILD" + fi +else + name=${patch#/} + dir=$(dirname "$quilt_patches/$name") + mkdir -p "$dir" + if [ "${patch:0:1}" = / ] then - ln -s "$patch" "$quilt_patches$patch" - patch=${patch#/} + ln -s "$patch" "$quilt_patches/${name#/}" else - while ! [ "$dir/$updir$patch" -ef "$patch" ] + while ! [ "$dir/$updir$name" -ef "$patch" ] do updir=$updir../ [ ${#updir} -gt 96 ] && break done - if [ "$dir/$updir$patch" -ef "$patch" ] + if [ "$dir/$updir$name" -ef "$patch" ] then - ln -s "$updir$patch" "$quilt_patches/$patch" + ln -s "$updir$patch" "$quilt_patches/$name" fi fi fi if [ "$opt_strip" = -p1 ]; then - echo "$patch" + echo "$name" else - echo "$patch $opt_strip" + echo "$name $opt_strip" fi >> $quilt_patches/series -$PATCH "${new_options[@]}" --backup --prefix "${QUILT_PC:-.pc}/$patch/" \ +$PATCH "${new_options[@]}" --backup --prefix "${QUILT_PC:-.pc}/$name/" \ | backup_files status=${PIPESTATUS[0]} if [ $status -eq 0 ] then - dir=${QUILT_PC:-.pc}/$patch + dir=${QUILT_PC:-.pc}/$name if [ ! -e "$dir" ] then mkdir -p "$dir" @@ -243,6 +260,6 @@ then then echo 2 > ${QUILT_PC:-.pc}/.version fi - echo "$patch" >> "${QUILT_PC:-.pc}/applied-patches" + echo "$name" >> "${QUILT_PC:-.pc}/applied-patches" fi exit $status