瀏覽代碼

update-patches-git: Fix for package without patches folder

Without the folder, 'patch' target would not initialize the git repo and
thus update-patches was not possible.

To fix this, force calling the patch script for package/<foo>/patches
directory even if it doesn't exist. Standard patch.sh handles this
sanely, patch_git.sh is adjusted to initialize the repo then.

Also adjust update-patches-git accordingly to not create empty patch
directories if there are no commits to export there.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Phil Sutter 3 周之前
父節點
當前提交
dc76e7ff93
共有 3 個文件被更改,包括 21 次插入11 次删除
  1. 1 1
      mk/buildhlp.mk
  2. 19 10
      scripts/patch_git.sh
  3. 1 0
      scripts/update-patches-git

+ 1 - 1
mk/buildhlp.mk

@@ -78,7 +78,7 @@ ${WRKDIST}/.prepared: ${WRKDIST}/.extract_done
 	@find $(WRKDIST)/ -name \*.rej -delete
 	[ ! -d ./patches/${PKG_VERSION} ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches/${PKG_VERSION} \
 	    '{patch-!(*.orig),*.patch,*.${ADK_TARGET_ARCH},*.${ADK_TARGET_LIBC}}' $(MAKE_TRACE)
-	[ ! -d ./patches ] || ${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches \
+	${PREVENT_PATCH} ${PATCH} ${WRKDIST} ./patches \
 	    '{patch-!(*.orig),*.patch,*.${ADK_TARGET_ARCH},*.${ADK_TARGET_LIBC}}' $(MAKE_TRACE)
 	[ ! -d ./src ] || (cd src; $(PREVENT_PATCH) cp -Rp . ${WRKDIST}/) \
 		$(MAKE_TRACE)

+ 19 - 10
scripts/patch_git.sh

@@ -14,17 +14,20 @@
 
 # Set directories from arguments, or use defaults.
 targetdir=${1-.}
-patchdir=${2-../patches}
+patchdir=$(realpath ${2-../patches})
 patchpattern=${3-*}
 
+git_commit_marker() { # (num)
+	git commit --allow-empty --no-signoff --no-gpg-sign \
+		--author="OpenADK <wbx@openadk.org>" \
+		-m "OpenADK patch marker: $1"
+}
+
+
 if [ ! -d "${targetdir}" ] ; then
     echo "Aborting.  '${targetdir}' is not a directory."
     exit 1
 fi
-if [ ! -d "${patchdir}" ] ; then
-    echo "Aborting.  '${patchdir}' is not a directory."
-    exit 0
-fi
 
 wd=$(pwd)
 
@@ -36,6 +39,7 @@ if [ ! -d .git ]; then
     find . -name .gitignore -delete
     git init
     git add .
+    git_commit_marker $(printf "%04d" 0)
 elif [ -e .git/rebase-apply ]; then
     git am --abort
 fi
@@ -49,9 +53,16 @@ done
 mkdir -p $patch_tmp
 patch_series=$(printf "%04d" $i)
 
-git commit --allow-empty --no-signoff --no-gpg-sign \
-    --author="OpenADK <wbx@openadk.org>" \
-    -m "OpenADK patch marker: $patch_series"
+if [ $i -gt 0 ]; then
+	git_commit_marker $patch_series
+fi
+
+echo "$patchdir" >${targetdir}/${patch_tmp}/__patchdir__
+
+if [ ! -d "${patchdir}" ] ; then
+    echo "Aborting.  '${patchdir}' is not a directory."
+    exit 0
+fi
 
 cd $wd
 cd $patchdir
@@ -97,8 +108,6 @@ done
 # XXX: this is unsafe and should be dropped at some point
 am_opts="-C1"
 
-cd ${wd}
-realpath $patchdir >${targetdir}/${patch_tmp}/__patchdir__
 cd ${targetdir}
 git am $am_opts ${patch_tmp}/*.patch
 if [ $? != 0 ] ; then

+ 1 - 0
scripts/update-patches-git

@@ -12,6 +12,7 @@ cd "$wrkdist"
 top="HEAD"
 git log --grep='^OpenADK patch marker:' --format='%H %s'$logopt | \
 		while read hash o p m series; do
+	[ -n "$(git log --oneline ${hash}..${top})" ] || continue
 	patchdir=$(<.git/patch_tmp/${series}/__patchdir__)
 	while read patchfile; do
 		rm ${patchdir}/$patchfile