diff options
-rw-r--r-- | config/setup/Kconfig | 10 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_world_patchin.sh | 72 |
2 files changed, 81 insertions, 1 deletions
diff --git a/config/setup/Kconfig b/config/setup/Kconfig index 3a15c6df9..608f6a30d 100644 --- a/config/setup/Kconfig +++ b/config/setup/Kconfig @@ -233,6 +233,16 @@ config SETUP_CCACHE the same compile is being done again. +config SETUP_PATCHIN_GIT + bool "use git to apply patches" + help + + Activating this option, ptxdist will use "git" instead of + quilt to apply patches. + + _NOTE_: this is an experimental feature + + config SETUP_HOST_CC prompt "host CC" string diff --git a/scripts/lib/ptxd_make_world_patchin.sh b/scripts/lib/ptxd_make_world_patchin.sh index a1356075e..d9453b826 100644 --- a/scripts/lib/ptxd_make_world_patchin.sh +++ b/scripts/lib/ptxd_make_world_patchin.sh @@ -59,7 +59,9 @@ ptxd_make_world_patchin_apply_init() fi # decide which tool to use - if which quilt > /dev/null 2>&1; then + if [ "${PTXCONF_SETUP_PATCHIN_GIT}" ] && which git > /dev/null 2>&1; then + pkg_patch_tool=git + elif which quilt > /dev/null 2>&1; then pkg_patch_tool=quilt else pkg_patch_tool=patch @@ -69,6 +71,70 @@ export -f ptxd_make_world_patchin_apply_init # +# initialize git database in $pkg_patchin_dir and do initial commit +# +ptxd_make_world_patchin_apply_git_init() +{ + local git_dir + git_dir="$(git rev-parse --git-dir 2> /dev/null)" || true + + # is already git repo? + if [ "${git_dir}" != ".git" ]; then + git init -q "${pkg_patchin_dir}" && + git add -f . && + git commit -q -m "initial commit" --author="ptxdist-${PTXDIST_VERSION_FULL} <ptxdist@pengutronix.de>" && + git tag "${pkg_pkg}" + git tag base + fi +} +export -f ptxd_make_world_patchin_apply_git_init + + +# +# create a directory containing the patches and the selected series +# file. name that file "series" +# +ptxd_make_world_patchin_apply_git_compat() +{ + mv "${pkg_patchin_dir}/.ptxdist/patches" "${pkg_patchin_dir}/.ptxdist/patches.orig" && + mkdir "${pkg_patchin_dir}/.ptxdist/patches" && + + # FIXME use lndir? + + while read patch para; do + case "${patch}" in + ""|"#"*) continue ;; # skip empty lines and comments + *) + # FIXME take care about subdirs + ln -s "../patches.orig/${patch}" "${pkg_patchin_dir}/.ptxdist/patches" || return + ;; + esac + done < "${pkg_patchin_dir}/.ptxdist/series" && + + ln -sf "../series" "${pkg_patchin_dir}/.ptxdist/patches" +} +export -f ptxd_make_world_patchin_apply_git_compat + + +# +# apply patch series with git +# +ptxd_make_world_patchin_apply_git() +{ + # + # git quiltimport has uses a hardcoded "series" + # for now we cannot use git with series files not names "series" + # + if [ -n "${pkg_patch_series}" -a "${pkg_patch_series##*/}" != "series" ]; then + ptxd_make_world_patchin_apply_git_compat || return + fi + + git quiltimport --patches "${pkg_patchin_dir}/.ptxdist/patches" --author "unknown author <unknown.author@example.com>" +} +export -f ptxd_make_world_patchin_apply_git + + +# # apply patch series with quilt # ptxd_make_world_patchin_apply_quilt() @@ -127,6 +193,10 @@ ptxd_make_world_patchin_apply() return fi && + if [ "${pkg_patch_tool}" = "git" ]; then + ptxd_make_world_patchin_apply_git_init || return + fi && + # # the primary reference is the ".ptxdist" folder in the pkg_patchin_dir: # these files might be existent: |