@@ -865,16 +865,28 @@ if [[ ${#PATCH_LIST[@]} -eq 0 ]]; then
865865fi
866866
867867trace_on
868+ # Don't check external file.
869+ # shellcheck disable=SC1090
870+ if [[ -z " $USERSRCDIR " ]] && [[ -f " $RELEASE_FILE " ]]; then
871+ source " $RELEASE_FILE "
872+ DISTRO=" $ID "
873+ fi
874+
868875
869876if [[ -n " $SRCRPM " ]]; then
870877 if [[ -n " $ARCHVERSION " ]]; then
871878 warn " --archversion is incompatible with --sourcerpm"
872879 exit 1
873880 fi
874881 rpmname=" $( basename " $SRCRPM " ) "
875- ARCHVERSION=" ${rpmname% .src.rpm} .$( uname -m) "
882+ if [[ " $DISTRO " = photon ]]; then
883+ ARCHVERSION=" ${rpmname% .src.rpm} "
884+ else
885+ ARCHVERSION=" ${rpmname% .src.rpm} .$( uname -m) "
886+ fi
876887 ARCHVERSION=" ${ARCHVERSION# kernel-} "
877888 ARCHVERSION=" ${ARCHVERSION# alt-} "
889+ ARCHVERSION=" ${ARCHVERSION# linux-} "
878890fi
879891
880892if [[ -n " $OOT_MODULE " ]] && [[ -z " $OOT_MODULE_SRCDIR " ]]; then
924936
925937[[ " $SKIPCLEANUP " -eq 0 ]] && trap cleanup EXIT INT TERM HUP
926938
927- # Don't check external file.
928- # shellcheck disable=SC1090
929- if [[ -z " $USERSRCDIR " ]] && [[ -f " $RELEASE_FILE " ]]; then
930- source " $RELEASE_FILE "
931- DISTRO=" $ID "
932- fi
933-
934939KVER=" ${ARCHVERSION%% -* } "
935940if [[ " $ARCHVERSION " =~ - ]]; then
936941 # handle flavor extension on Photon ex) -rt, -esx
@@ -942,12 +947,12 @@ if [[ "$ARCHVERSION" =~ - ]]; then
942947 KREL=" ${KREL% -* } "
943948 KREL=" ${KREL#* -} "
944949
945- PH_TAG=" ${ ARCHVERSION##* .} "
946- PH_FLAVOR= " ${PH_TAG ##* -} "
947- PH_TAG =" ${PH_TAG %% - * } "
948-
949- # if no flavor, these will be the same
950- [[ " $PH_FLAVOR " = " $PH_TAG " ]] && PH_FLAVOR= " "
950+ PH_TAG=$( echo " $ ARCHVERSION" | grep -oE ' ph[0-9]+ ' )
951+ if [[ " $ARCHVERSION " =~ (^ | [- \. ])(rt | esx | aws)($ | [- \. ]) ]] ; then
952+ PH_FLAVOR =" ${BASH_REMATCH[2] } "
953+ else
954+ PH_FLAVOR= " "
955+ fi
951956 else
952957 KREL=" ${ARCHVERSION##* -} "
953958 fi
@@ -1025,11 +1030,9 @@ else
10251030 if [ -z " $SRCRPM " ]; then
10261031 SRCRPM=" $TEMPDIR /kernel$ALT -$KVER -$KREL .src.rpm"
10271032 fi
1028-
10291033 fi
10301034
10311035 echo " Unpacking kernel source"
1032-
10331036 if [[ " $DISTRO " = photon ]]; then
10341037 [[ -n " $PH_FLAVOR " ]] && SPECNAME=" linux-$PH_FLAVOR .spec" || SPECNAME=" linux.spec"
10351038 else
@@ -1040,7 +1043,7 @@ else
10401043
10411044 # Define dist tag to handle rpmbuild of the linux src rpm in Photon
10421045 if [[ " $DISTRO " = photon ]] && [ " $( rpm -E %dist) " = " %dist" ]; then
1043- sed -i " 1s/^/ %define dist .$PH_TAG / " " $RPMTOPDIR " /SPECS/" $SPECNAME "
1046+ sed -i " 1s|^| %define dist .$PH_TAG \n\n| " " $RPMTOPDIR " /SPECS/" $SPECNAME "
10441047 fi
10451048
10461049 rpmbuild -D " _topdir $RPMTOPDIR " -bp --nodeps " --target=$( uname -m) " " $RPMTOPDIR " /SPECS/" $SPECNAME " 2>&1 | logger || die " rpmbuild -bp failed. you may need to run 'yum-builddep kernel' first."
@@ -1052,19 +1055,6 @@ else
10521055 elif [[ " $DISTRO " = opencloudos ]]; then
10531056 mv " $RPMTOPDIR " /BUILD/kernel-* /kernel-* " $KERNEL_SRCDIR " 2>&1 | logger || die
10541057 elif [[ " $DISTRO " = photon ]]; then
1055- # Photon has some files that are copied over during the build section of the spec file (instead of prep)
1056- # These change occasionally, so check they exist before copying
1057- ls " $RPMTOPDIR " /BUILD/fips* canister* & > /dev/null && ( cp -rT " $RPMTOPDIR " /BUILD/fips* canister* " $RPMTOPDIR " /BUILD/linux-" $KVER " /crypto | logger || die )
1058- [[ -f " $RPMTOPDIR " /SOURCES/fips_canister-kallsyms ]] && ( cp " $RPMTOPDIR " /SOURCES/fips_canister-kallsyms rpmbuild/BUILD/linux-" $KVER " /crypto | logger || die )
1059-
1060- if [[ -z " $CONFIGFILE " ]]; then
1061- # Photon has multiple config files per src rpm sometimes, and naming is not consistent.
1062- # So do our best to find the right one by parsing the spec file
1063- SRC_CFG=$( rpmspec -P -D " _topdir $RPMTOPDIR " " $RPMTOPDIR " /SPECS/" $SPECNAME " | awk ' /^cp .*\/SOURCES\/config.* \.config$/{print $2}' )
1064- [[ -z " $SRC_CFG " ]] && die " Failed to locate kernel config file"
1065- SRC_CFG=" ${SRC_CFG##*/ } "
1066- cp " $RPMTOPDIR " /SOURCES/" $SRC_CFG " " $RPMTOPDIR " /BUILD/linux-" $KVER " | logger || die
1067- fi
10681058 mv " $RPMTOPDIR " /BUILD/linux-" $KVER " " $KERNEL_SRCDIR " 2>&1 | logger || die
10691059 else
10701060 mv " $RPMTOPDIR " /BUILD/kernel-* /linux-* " $KERNEL_SRCDIR " 2>&1 | logger || die
@@ -1082,20 +1072,14 @@ else
10821072 if [[ " $DISTRO " = openEuler ]] || [[ " $DISTRO " = opencloudos ]]; then
10831073 [[ -z " $CONFIGFILE " ]] && CONFIGFILE=" /boot/config-${ARCHVERSION} "
10841074 elif [[ " $DISTRO " = photon ]]; then
1085- [[ -z " $CONFIGFILE " ]] && CONFIGFILE=" $KERNEL_SRCDIR /$SRC_CFG "
1086-
1087- # modify config file here to get the right vermagic, as Photon does not always listen to localversion file
1088- if [[ -z " $PH_FLAVOR " ]]; then
1089- sed -i s/^CONFIG_LOCALVERSION=\" .* \" /CONFIG_LOCALVERSION=\" -" $KREL " ." $PH_TAG " \" /g " $CONFIGFILE " || die
1090- else
1091- sed -i s/^CONFIG_LOCALVERSION=\" .* \" /CONFIG_LOCALVERSION=\" -" $KREL " ." $PH_TAG " -" $PH_FLAVOR " \" /g " $CONFIGFILE " || die
1092- fi
1093-
1075+ [[ -z " $CONFIGFILE " ]] && CONFIGFILE=" $KERNEL_SRCDIR " /.config
10941076 else
10951077 [[ -z " $CONFIGFILE " ]] && CONFIGFILE=" $KERNEL_SRCDIR /configs/kernel$ALT -$KVER -$ARCH .config"
10961078 fi
1079+ if [[ ! " $DISTRO " = photon ]]; then
1080+ (cd " $KERNEL_SRCDIR " && make mrproper 2>&1 | logger) || die
1081+ fi
10971082
1098- (cd " $KERNEL_SRCDIR " && make mrproper 2>&1 | logger) || die
10991083
11001084 elif is_supported_deb_distro " $DISTRO " ; then
11011085
0 commit comments