2024-01-27 00:10:58 +03:00
|
|
|
#!/bin/zsh
|
|
|
|
|
2024-07-05 13:18:16 +03:00
|
|
|
z-quilt() { command quilt "$@" ; }
|
|
|
|
|
2024-01-27 00:10:58 +03:00
|
|
|
quilt-series-strip-comments() {
|
|
|
|
sed -E '/^[[:space:]]*(#|$)/d' "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
quilt-series-auto() {
|
2024-03-04 15:35:55 +03:00
|
|
|
[ -n "${1:?}" ]
|
2024-07-05 13:18:16 +03:00
|
|
|
[ -d "$1" ] || return 1
|
2024-01-27 00:10:58 +03:00
|
|
|
|
|
|
|
find "$1/" -follow -type f -printf '%P\0' \
|
|
|
|
| sed -zEn '/\.(diff|patch)$/p' \
|
2024-07-05 13:18:16 +03:00
|
|
|
| sort -zuV \
|
|
|
|
| xargs -0r printf '%s\n'
|
2024-01-27 00:10:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
krd-quilt() {
|
2024-03-04 15:35:55 +03:00
|
|
|
(( $+commands[quilt] )) || return 127
|
2024-01-27 00:10:58 +03:00
|
|
|
|
2024-03-04 15:35:55 +03:00
|
|
|
[ -n "${1:?}" ]
|
2024-01-27 00:10:58 +03:00
|
|
|
|
|
|
|
local patchdir series tmp_series
|
|
|
|
|
|
|
|
if [ -d "$1" ] ; then
|
|
|
|
patchdir="$1/debian/patches"
|
|
|
|
if [ -d "${patchdir}" ] ; then
|
2024-03-04 15:35:55 +03:00
|
|
|
[ -f "${patchdir}/series" ] || return 1
|
2024-01-27 00:10:58 +03:00
|
|
|
else
|
|
|
|
patchdir="$1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
series="${patchdir}/series"
|
|
|
|
if ! [ -f "${series}" ] ; then
|
2024-07-05 13:18:16 +03:00
|
|
|
mkdir -p "$1/.pc" || return 1
|
|
|
|
series="$1/.pc/krd-quilt-series"
|
|
|
|
touch "${series}" || return 1
|
2024-01-27 00:10:58 +03:00
|
|
|
quilt-series-auto "${patchdir}" > "${series}"
|
|
|
|
fi
|
|
|
|
elif [ -f "$1" ] ; then
|
2024-07-05 13:18:16 +03:00
|
|
|
[ -s "$1" ] || return 1
|
2024-01-27 00:10:58 +03:00
|
|
|
|
|
|
|
series="$1"
|
|
|
|
patchdir=${series:h}
|
|
|
|
else
|
2024-07-05 13:18:16 +03:00
|
|
|
return 1
|
2024-01-27 00:10:58 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
local r
|
|
|
|
(
|
|
|
|
z-quilt-default-env
|
|
|
|
set -a
|
|
|
|
QUILT_SERIES="${series}"
|
|
|
|
QUILT_PATCHES="${patchdir}"
|
|
|
|
set +a
|
|
|
|
|
|
|
|
r=0
|
2024-03-04 15:35:55 +03:00
|
|
|
while read -rs i ; do
|
2024-01-27 00:10:58 +03:00
|
|
|
[ -n "$i" ] || continue
|
|
|
|
|
2024-07-05 13:42:31 +03:00
|
|
|
z-quilt --fuzz=0 push "$i"
|
2024-01-27 00:10:58 +03:00
|
|
|
r=$? ; [ $r -eq 0 ] || exit $r
|
2024-07-05 13:42:31 +03:00
|
|
|
z-quilt refresh "$i"
|
2024-01-27 00:10:58 +03:00
|
|
|
r=$? ; [ $r -eq 0 ] || exit $r
|
|
|
|
|
|
|
|
sed -E -i \
|
|
|
|
-e 's#^(-{3} )[^/][^/]*/(.*)$#\1a/\2#;' \
|
|
|
|
-e 's#^(\+{3} )[^/][^/]*/(.*)$#\1b/\2#' \
|
2024-07-05 13:42:31 +03:00
|
|
|
"$i"
|
2024-01-27 00:10:58 +03:00
|
|
|
|
2024-07-05 13:42:31 +03:00
|
|
|
rm -f "$i"'~'
|
2024-07-05 13:18:16 +03:00
|
|
|
done <<< $(
|
2024-07-05 13:42:31 +03:00
|
|
|
if ! z-quilt unapplied ; then
|
|
|
|
quilt-series-strip-comments "${series}" \
|
|
|
|
| sed -E "s${ZSHU_XSED}^${ZSHU_XSED}${patchdir}/${ZSHU_XSED}"
|
2024-07-05 13:18:16 +03:00
|
|
|
fi
|
|
|
|
)
|
2024-01-27 00:10:58 +03:00
|
|
|
exit $r
|
|
|
|
)
|
|
|
|
r=$?
|
|
|
|
|
|
|
|
return $r
|
|
|
|
}
|