diff --git a/anolis/Makefile b/anolis/Makefile index 5346c50c96369dbd392166c3391befea42bfd43a..069ceab2c498663811dbdfd4dbf9933a3f94aa5e 100644 --- a/anolis/Makefile +++ b/anolis/Makefile @@ -1,17 +1,29 @@ include Makefile.variables -all: help +all: help examples + +dist-check: + @if [ "${DIST_BUILD_MODE}" == "official" ]; then \ + if [ "$(shell git describe --tags --exact-match HEAD 2>/dev/null)" != "${DIST_ANOLIS_VERSION}" ]; then \ + echo "Error: For official build, the tag ${DIST_ANOLIS_VERSION} should point to HEAD"; \ + exit 1; \ + fi \ + fi + @if [ "${DIST_BUILD_MODE}" == "diy" ] && [ -z "${DIST_DIY}" ]; then \ + echo "Error: For diy build, the variable DIST_DIY should not be empty"; \ + exit 1; \ + fi dist-genlog: sh genlog.sh -dist-genspec: +dist-genspec: dist-check sh genspec.sh -dist-genrpmtree: +dist-genrpmtree: dist-check sh genrpmtree.sh -dist-rpms: dist-genrpmtree +dist-rpms: dist-genrpmtree dist-check sh buildpkg.sh clean: @@ -20,9 +32,35 @@ clean: dist-version: @echo $(DIST_ANOLIS_VERSION) +examples: + @echo '' + @echo 'Build Examples:' + @echo '- *RECOMMEND* devel build with basic rpm packages' + @echo ' DIST_BUILD_MODE=devel DIST_BUILD_EXTRA=base make dist-rpms' + @echo '- *RECOMMEND* devel build with full rpm packages' + @echo ' DIST_BUILD_MODE=devel make dist-rpms' + @echo '- *RECOMMEND* nightly build with full rpm packages' + @echo ' DIST_BUILD_MODE=nightly make dist-rpms' + @echo '- diy build with basic rpm packages' + @echo ' DIST_BUILD_MODE=diy BUILD_DIY="your_diy_name" DIST_BUILD_EXTRA=base make dist-rpms' + @echo '' + @echo 'Kernel Version Examples:' + @echo '- show the kernel version of devel mode' + @echo ' DIST_BUILD_MODE=devel make dist-version' + @echo '- show the kernel version of diy mode' + @echo ' DIST_BUILD_MODE=diy BUILD_DIY="your_diy_name" make dist-version' + @echo '' + @echo 'Other Examples:' + @echo '- only generate rpm tree in devel mode, but do not build rpm packages' + @echo ' DIST_BUILD_MODE=devel make dist-genrpmtree' + @echo '- cleanup' + @echo ' make clean' + help: @echo 'For anolis release' @echo '' + @echo 'RUN `make examples` for some examples' + @echo '--------------------------------' @echo 'generic commands:' @echo ' dist-genspec - generate kernel spec file through kernel.spec.template and changelog files' @echo ' dist-genlog - generate changelogs' @@ -30,18 +68,20 @@ help: @echo ' dist-rpms - build kernel rpm package, it will auto generated in $(DIST_SHORT_OUTPUT)' @echo ' dist-version - show dist version' @echo ' clean - cleanup output dir' + @echo ' examples - show some examples' @echo '' @echo '-------------------------------' @echo 'the environment variables that could override:' @echo ' DIST - the distribution suffix, eg: .an7, .an8, .an23' - @echo ' DIST_DO_SIGNMODULES - should sign kernel modules. optional: 0/1, default: 0' @echo ' DIST_OUTPUT - the output directory, default: $(DIST_SHORT_OUTPUT)' - @echo ' DIST_BUILD_MODE - the build mode. optional: official/nightly/devel' + @echo ' DIST_BUILD_MODE - the build mode. optional: official/nightly/devel/diy' @echo ' !!! NOTE: BE CAUTIOUS ABOUT USING official BUILD !!!' @echo ' - official build. kernel version: $(DIST_KERNELVERSION)-$(DIST_OFFICIAL_PKGRELEASEVERION), with srpm' @echo ' - nightly build. kernel version: $(DIST_KERNELVERSION)-$(DIST_UNOFFICIAL_PKGRELEASEVERION), with srpm' @echo ' - devel build. kernel version: $(DIST_KERNELVERSION)-$(DIST_UNOFFICIAL_PKGRELEASEVERION), without srpm' + @echo ' - diy build. kernel version: $(DIST_KERNELVERSION)-$(DIST_DIY_PKGRELEASEVERION), with srpm' @echo ' DIST_BUILD_NUMBER - the build number for unofficial build, eg: 1/2' + @echo ' DIST_DIY - the kernel version for diy build' @echo ' DIST_BUILD_VARIANT & DIST_BUILD_EXTRA - see comments in buildpkg.sh' export \ No newline at end of file diff --git a/anolis/Makefile.variables b/anolis/Makefile.variables index 318df6a83df61efda0dfbc3d42cb4a92d24c596e..ca2243be42bc4f8d37a965fbcc14ac5a2be83568 100644 --- a/anolis/Makefile.variables +++ b/anolis/Makefile.variables @@ -29,9 +29,6 @@ DIST_SPECIAL_VERSION_MINOR = # build number DIST_BUILD_NUMBER ?= 1 -# need to sign modules? -DIST_DO_SIGNMODULES ?= 0 - # the kernel root DIST_SRCROOT = $(shell realpath ..)/ DIST_SOURCES = $(DIST_SRCROOT)anolis/ @@ -63,9 +60,14 @@ DIST_GIT_HEAD_SHORT_COMMIT_ID = $(shell git rev-parse --short HEAD) DIST_GIT_HEAD_FULL_COMMIT_ID = $(shell git rev-parse HEAD) DIST_UNOFFICIAL_PKGRELEASEVERION = ${DIST_BUILD_NUMBER}.git.$(DIST_GIT_HEAD_SHORT_COMMIT_ID) +# kernel version for diy build +DIST_DIY_PKGRELEASEVERION = ${DIST_DIY}.diy + # final kernel version ifeq ("${DIST_BUILD_MODE}", "official") DIST_PKGRELEASEVERION = $(DIST_OFFICIAL_PKGRELEASEVERION) +else ifeq ("${DIST_BUILD_MODE}", "diy") +DIST_PKGRELEASEVERION = $(DIST_DIY_PKGRELEASEVERION) else DIST_PKGRELEASEVERION = $(DIST_UNOFFICIAL_PKGRELEASEVERION) endif diff --git a/anolis/buildpkg.sh b/anolis/buildpkg.sh index 0219208cb315a1b3637c32fd61af9e991f22c505..34ff6a929f1de8d54b58b543457f9fb0f772bf2a 100644 --- a/anolis/buildpkg.sh +++ b/anolis/buildpkg.sh @@ -1,7 +1,9 @@ set -xe function do_rpmbuild() { - if [ "$DIST_BUILD_MODE" == "official" ] || [ "$DIST_BUILD_MODE" == "nightly" ]; then + if [ "$DIST_BUILD_MODE" == "official" ] || \ + [ "$DIST_BUILD_MODE" == "nightly" ] || \ + [ "$DIST_BUILD_MODE" == "diy" ]; then CMD="-ba" else CMD="-bb" diff --git a/anolis/genspec.sh b/anolis/genspec.sh index 513a9921587851fe15a8e27e100f9033baed35f0..15797b876560c5f6ff5238a8d611b0231e40dea1 100644 --- a/anolis/genspec.sh +++ b/anolis/genspec.sh @@ -11,7 +11,6 @@ do done sed -i -e " - s/%%DIST_DO_SIGNMODULES%%/$DIST_DO_SIGNMODULES/ s/%%DIST%%/$DIST/ s/%%DIST_KERNELVERSION%%/$DIST_KERNELVERSION/ s/%%DIST_PKGRELEASEVERION%%/$DIST_PKGRELEASEVERION/" ${DIST_OUTPUT}/${DIST_SPEC_FILE} \ No newline at end of file diff --git a/anolis/rpm/kernel.spec.template b/anolis/rpm/kernel.spec.template index 221468bcd4c9f58118d6dd1efd14c6dd89189463..d441638f87122fd8108cf3c2f82f9b150a520045 100644 --- a/anolis/rpm/kernel.spec.template +++ b/anolis/rpm/kernel.spec.template @@ -5,9 +5,6 @@ # For internal testing builds during development, it should be 0. %global released_kernel 1 -# Sign modules on all arches -%global signmodules %%DIST_DO_SIGNMODULES%% - # define buildid .local %global dist %%DIST%% @@ -254,8 +251,6 @@ BuildRequires: rpm-build, elfutils %global _no_recompute_build_ids 1 %endif -BuildRequires: openssl openssl-devel - # These below are required to build man pages %if %{with_perf} BuildRequires: xmlto @@ -875,11 +870,6 @@ BuildKernel() { %{make} -s %{?_smp_mflags} mrproper cp configs/$Config .config - %if %{signmodules} - cp %{SOURCE11} certs/. - cp %{SOURCE12} certs/. - %endif - Arch=`head -1 .config | cut -b 3-` echo USING ARCH=$Arch @@ -1184,14 +1174,6 @@ BuildKernel() { rm -f $RPM_BUILD_ROOT/mod-extra.list rm -f $RPM_BUILD_ROOT/mod-internal.list -%if %{signmodules} - if [ $DoModules -eq 1 ]; then - # Save the signing keys so we can sign the modules in __modsign_install_post - cp certs/signing_key.pem certs/signing_key.pem.sign${Flav} - cp certs/signing_key.x509 certs/signing_key.x509.sign${Flav} - fi -%endif - # Move the devel headers out of the root file system mkdir -p $RPM_BUILD_ROOT/usr/src/kernels mv $RPM_BUILD_ROOT/lib/modules/$KernelVer/build $RPM_BUILD_ROOT/$DevelDir @@ -1312,28 +1294,6 @@ chmod -R a=rX Documentation find Documentation -type d | xargs chmod u+w %endif -# In the modsign case, we do 3 things. 1) We check the "flavour" and hard -# code the value in the following invocations. This is somewhat sub-optimal -# but we're doing this inside of an RPM macro and it isn't as easy as it -# could be because of that. 2) We restore the .tmp_versions/ directory from -# the one we saved off in BuildKernel above. This is to make sure we're -# signing the modules we actually built/installed in that flavour. 3) We -# grab the arch and invoke mod-sign.sh command to actually sign the modules. -# -# We have to do all of those things _after_ find-debuginfo runs, otherwise -# that will strip the signature off of the modules. - -%define __modsign_install_post \ - if [ "%{signmodules}" -eq "1" ]; then \ - if [ "%{with_debug}" -ne "0" ]; then \ - %{modsign_cmd} certs/signing_key.pem.sign+debug certs/signing_key.x509.sign+debug $RPM_BUILD_ROOT/lib/modules/%{KVERREL}+debug/ \ - fi \ - if [ "%{with_up}" -ne "0" ]; then \ - %{modsign_cmd} certs/signing_key.pem.sign certs/signing_key.x509.sign $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/ \ - fi \ - fi \ -%{nil} - ### ### Special hacks for debuginfo subpackages. ### @@ -1359,8 +1319,7 @@ find Documentation -type d | xargs chmod u+w %define __spec_install_post \ %{?__debug_package:%{__debug_install_post}}\ %{__arch_install_post}\ - %{__os_install_post}\ - %{__modsign_install_post} + %{__os_install_post} ### ### install