diff --git a/scripts/git-import-srpm b/scripts/git-import-srpm index 6bd3cf3..6be714d 100755 --- a/scripts/git-import-srpm +++ b/scripts/git-import-srpm @@ -35,11 +35,11 @@ set -o pipefail THIS_SCRIPT="$(readlink -f "$0")" function usage() { - echo "Usage: $(basename "${THIS_SCRIPT}") [-c CODE_REPO_PATH] [-s SRPM_REPO_PATH] [-f] REVISION" + echo "Usage: $(basename "${THIS_SCRIPT}") [-c CODE_REPO_PATH] [-s SRPM_REPO_PATH] [-f] [-d] [-D] [-N] -a|REVISION" exit "${1}" } -while getopts ":ac:s:dDfh" opt; do +while getopts ":ac:dDfhNs:" opt; do case "${opt}" in a) IMPORT_ALL=true @@ -47,9 +47,6 @@ while getopts ":ac:s:dDfh" opt; do c) CODE_REPO_PATH="$(realpath "${OPTARG}")" ;; - s) - SRPM_REPO_PATH="$(realpath "${OPTARG}")" - ;; d) OOT_DRIVER_IMPORT=true ;; @@ -59,6 +56,12 @@ while getopts ":ac:s:dDfh" opt; do f) FORCE_IMPORT=1 ;; + N) + NO_MANUAL_PATCHES=1 + ;; + s) + SRPM_REPO_PATH="$(realpath "${OPTARG}")" + ;; h|*) if [ "${opt}" = "h" ]; then usage 0; else usage 1; fi ;; @@ -184,19 +187,20 @@ function get_base_version() { function get_source_commit() { local worktree="$1" local revision="$2" + local source_commit check_spec_file "${worktree}" "${revision}" - if [[ ${PRODUCT} = "edk2" ]]; then - local source_commit + + if git -C "${worktree}" show "${revision}:${SPEC_FILE}" | awk '/package_srccommit/{found=1} END{exit !found}'; then + source_commit=$(git -C "${worktree}" show "${revision}:${SPEC_FILE}" | \ + awk '$1 == "%global" && $2 == "package_srccommit" { print $3; exit }' + ) + echo "${source_commit}" + elif [[ ${PRODUCT} = "edk2" ]]; then source_commit=$(git -C "${worktree}" show "${revision}:${SPEC_FILE}" | \ - awk '$1 == "%global" && $2 == "package_srccommit" { print $3; exit }' - ) - if [[ -z ${source_commit} ]]; then - source_commit=$(git -C "${worktree}" show "${revision}:${SPEC_FILE}" | \ - awk '$1 == "%global" && $2 == "edk2_githash" { print $3; exit }' - ) - fi + awk '$1 == "%global" && $2 == "edk2_githash" { print $3; exit }' + ) if [[ -z ${source_commit} ]]; then echo "${SPEC_FILE} does not define package_srccommit" 1>&2 exit 1 @@ -597,7 +601,7 @@ rpmbuild --nodeps \ -bp "${SRPM_REPO_WORKTREE}/${SPEC_FILE}" |& sed 's/^/(rpmbuild)/' >> "${COMMAND_LOGS}" & RPMBUILD_PID=$! -if [[ -z "${OOT_DRIVER_IMPORT}" ]]; then +if [[ -z "${OOT_DRIVER_IMPORT}" ]] && [[ -z "${NO_MANUAL_PATCHES:-}" ]]; then cd "${SRPM_REPO_WORKTREE}" while IFS= read -r l; do