Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 3db02dd

Browse files
committed
Implement backport-<commit> target
For packages with a GitHub repo configured in options.conf, allow downloading and applying backport patches via the 'backport-<commit>' target. If given an abbreviated commit ID, it will still create a backport-<commit>.patch file with the full commit hash, plus add it (if it does not already exist) to the end of the series file. Because this handles a single commit at a time, this should be wrappable by a future Makefile target that applies individual commits to catch up to a target tag, for example.
1 parent 5866d7a commit 3db02dd

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Makefile.common

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,36 @@ cloc: $(SRPMFILE)
582582
@$(MOCK) --clean --scrub=chroot --uniqueext=$(PKG_NAME)
583583
cat results/cloc.txt
584584

585+
#help backport-<commit>: Retrieve a commit from the upstream git repository and save it as a backport patch.
586+
#help Currently only works with GitHub repositories. The giturl is read from options.conf.
587+
backport-%:
588+
@commit=$*; \
589+
echo "Backporting commit: $${commit}"; \
590+
giturl=$$(grep -E '^giturl\s*=\s*https://github.com' options.conf | sed 's/giturl\s*=\s*//' | sed 's/\.git$$//' | sed 's/\/$$//' 2>/dev/null); \
591+
if [[ -z "$${giturl}" ]]; then \
592+
echo "Error: giturl not defined in options.conf"; \
593+
exit 1; \
594+
fi; \
595+
if ! curl -s -L -o $@.patch $${giturl}/commit/$*.patch || [[ "Not Found" == $$(< $@.patch) ]]; then \
596+
rm -f $@.patch; \
597+
echo "Error: Failed to download commit $*"; \
598+
exit 1; \
599+
fi; \
600+
patch=$@.patch; \
601+
full_commit=$$(head -1 $@.patch | grep -oE '\b$*\S+' 2>/dev/null); \
602+
if ! [[ -z "$${full_commit}" ]]; then \
603+
patch=backport-$${full_commit}.patch; \
604+
mv $@.patch $${patch}; \
605+
fi; \
606+
if [[ -s $${patch} ]]; then \
607+
echo "$${patch} created"; \
608+
grep -qE "^$${patch}$$" series 2>/dev/null || echo "$${patch}" >> series; \
609+
else \
610+
rm -f $${patch}; \
611+
echo "Error: Failed to create backport patch"; \
612+
exit 1; \
613+
fi \
614+
585615
.PHONY: whatrequires
586616
#help whatrequires: Output a list of packages that directly depend on this one,
587617
#help showing the subpackage-level breakdown. Each line of output has the format

0 commit comments

Comments
 (0)