summaryrefslogtreecommitdiff
path: root/scripts/package/mkspec
AgeCommit message (Collapse)Author
2023-10-03kbuild: rpm-pkg: generate kernel.spec in rpmbuild/SPECS/Masahiro Yamada
kernel.spec is the last piece that resides outside the rpmbuild/ directory. Move all the RPM-related files to rpmbuild/ consistently. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org>
2023-07-25kbuild: rpm-pkg: refactor *rpm-pkg targetsMasahiro Yamada
Merge the similar build targets. Also, make the output location consistent. Previously, source packages were created in the build directory, while binary packages under ~/rpmbuild/RPMS/. Now, Kbuild creates the rpmbuild/ directory in the build directory, and saves all packages under it. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: split out the body of spec fileMasahiro Yamada
Most of the lines in the spec file are independent of any build condition. Split the body of the spec file into scripts/package/kernel.spec. scripts/package/mkspec will prepend some env-dependent variables. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: introduce %{with_devel} switch to select devel packageMasahiro Yamada
scripts/package/mkspec preprocesses the spec file by sed, but it is unreadable. This commit removes the last portion of the sed scripting. Remove the $S$M prefixes from the conditionally generated lines. Instead, surround the code with %if %{with_devel} ... %endif. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: run modules_install for non-modular kernelMasahiro Yamada
For the same reason as commit 4243afdb9326 ("kbuild: builddeb: always make modules_install, to install modules.builtin*"), run modules_install even when CONFIG_MODULES=n to install modules.builtin*. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: invoke the kernel build from rpmbuild for binrpm-pkgMasahiro Yamada
To reduce the preprocess of the spec file, invoke the kernel build from rpmbuild. Run init/build-version to increment the release number not only for binrpm-pkg but also for srcrpm-pkg and rpm-pkg. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: use a dummy string for _arch when undefinedMasahiro Yamada
If this affects only %{buildroot}, it should be enough to use a fixed string for _arch when it is undefined. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: derive the Version from %{KERNELRELEASE}Masahiro Yamada
Avoid hard-coding the Version field in the generated spec file. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: refactor kernel-devel RPM package and linux-headers Deb packageMasahiro Yamada
The kernel-devel RPM package and the linux-headers Debian package provide headers and scripts needed for building external modules. They copy the necessary files in slightly different ways - the RPM copies almost everything except some exclude patterns, while the Debian copies less number of files. There is no need to maintain different code to do the same thing. Split the Debian code out to scripts/package/install-extmod-build, which is called from both of the packages. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: replace $KERNELRELEASE in spec file with %{KERNELRELEASE}Masahiro Yamada
Avoid hard-coding the value of KERNELRELEASE in the generated spec file. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: replace $__KERNELRELEASE in spec file with %{version}Masahiro Yamada
${version} will be replaced with the value of the Version field. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: record ARCH option in spec fileMasahiro Yamada
Currently, we rely on the top Makefile defining ARCH option when we run 'make rpm-pkg' or 'make binrpm-pkg'. It does not apply when we run 'make srcrpm-pkg', and separately run 'rpmbuild' for the generated SRPM. This is a problem for cross-build. Just like the Debian package, save the value of ARCH in the spec file. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: use %{makeflags} to pass common Make optionsMasahiro Yamada
This is useful to pass more common Make options. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: do not hard-code $MAKE in spec fileMasahiro Yamada
Currently, $MAKE will expand to the GNU Make program that created the source RPM. This is problematic if you carry it to a different build host to run 'rpmbuild' there. Consider this command: $ /path/to/my/custom/make srcrpm-pkg The spec file in the SRPM will record '/path/to/my/custom/make', which exists only on that build environment. To create a portable SRPM, the spec file should avoid hard-coding $MAKE. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: remove unneeded '-f $srctree/Makefile' in spec fileMasahiro Yamada
This is unneeded because the Makefile in the output directory wraps the top-level Makefile in the srctree. Just run $MAKE irrespective of the build location. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-07-25kbuild: rpm-pkg: define _arch conditionallyMasahiro Yamada
Commit 3089b2be0cce ("kbuild: rpm-pkg: fix build error when _arch is undefined") does not work as intended; _arch is always defined as $UTS_MACHINE. The intention was to define _arch to $UTS_MACHINE only when it is not defined. Fixes: 3089b2be0cce ("kbuild: rpm-pkg: fix build error when _arch is undefined") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-04-25kbuild: rpm-pkg: remove kernel-drm PROVIDESMasahiro Yamada
This code was added more than 20 years ago. [1] I checked the kernel spec files in Fedora and OpenSUSE, but did not see 'kernel-drm'. I do not know if there exists a distro that uses it in RPM dependency. Remove this, and let's see if somebody complains about it. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=6d956df7d6b716b28c910c4f5b360c4d44d96c4d Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
2023-04-11kbuild: give up untracked files for source package buildsMasahiro Yamada
When the source tree is dirty and contains untracked files, package builds may fail, for example, when a broken symlink exists, a file path contains whitespaces, etc. Since commit 05e96e96a315 ("kbuild: use git-archive for source package creation"), the source tarball only contains committed files because it is created by 'git archive'. scripts/package/gen-diff-patch tries to address the diff from HEAD, but including untracked files by the hand-crafted script introduces more complexity. I wrote a patch [1] to make it work in most cases, but still wonder if this is what we should aim for. To simplify the code, this patch just gives up untracked files. Going forward, it is your responsibility to do 'git add' for what you want in the source package. The script shows a warning just in case you forgot to do so. It should be checked only when building source packages. [1]: https://lore.kernel.org/all/CAK7LNAShbZ56gSh9PrbLnBDYKnjtTkHMoCXeGrhcxMvqXGq9=g@mail.gmail.com/2-0001-kbuild-make-package-builds-more-robust.patch Fixes: 05e96e96a315 ("kbuild: use git-archive for source package creation") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
2023-03-16kbuild: use git-archive for source package creationMasahiro Yamada
Commit 5c3d1d0abb12 ("kbuild: add a tool to list files ignored by git") added a new tool, scripts/list-gitignored. My intention was to create source packages without cleaning the source tree, without relying on git. Linus strongly objected to it, and suggested using 'git archive' instead. [1] [2] [3] This commit goes in that direction - Remove scripts/list-gitignored.c and rewrites Makefiles and scripts to use 'git archive' for building Debian and RPM source packages. It also makes 'make perf-tar*-src-pkg' use 'git archive' again. Going forward, building source packages is only possible in a git-managed tree. Building binary packages does not require git. [1]: https://lore.kernel.org/lkml/CAHk-=wi49sMaC7vY1yMagk7eqLK=1jHeHQ=yZ_k45P=xBccnmA@mail.gmail.com/ [2]: https://lore.kernel.org/lkml/CAHk-=wh5AixGsLeT0qH2oZHKq0FLUTbyTw4qY921L=PwYgoGVw@mail.gmail.com/ [3]: https://lore.kernel.org/lkml/CAHk-=wgM-W6Fu==EoAVCabxyX8eYBz9kNC88-tm9ExRQwA79UQ@mail.gmail.com/ Fixes: 5c3d1d0abb12 ("kbuild: add a tool to list files ignored by git") Fixes: e0ca16749ac3 ("kbuild: make perf-tar*-src-pkg work without relying on git") Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-03-16kbuild: rpm-pkg: move source components to rpmbuild/SOURCESMasahiro Yamada
Prepare to add more files to the source RPM. Also, fix the build error when KCONFIG_CONFIG is set: error: Bad file: ./.config: No such file or directory Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-02-26kbuild: rpm-pkg: remove unneeded KERNELRELEASE from modules/headers_installMasahiro Yamada
This is a temporary workaround added by commit f6e09b07cc12 ("kbuild: do not put .scmversion into the source tarball"). Since commit 1cb86b6c3136 ("kbuild: save overridden KERNELRELEASE in include/config/kernel.release"), the user-supplied KERNELRELEASE is saved in include/config/kernel.release. Remove it again. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
2023-02-26kbuild: srcrpm-pkg: create source package without cleaningMasahiro Yamada
If you run 'make (src)rpm-pkg', all objects are lost due to 'make clean', which makes the incremental builds impossible. Instead of cleaning, pass the exclude list to tar's --exclude-from option. Previously, the .config was contained in the source tarball. With this commit, the source rpm consists of separate linux.tar.gz and .config. Remove stale comments. Now, 'make (src)rpm-pkg' works with O= option. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2023-01-30kbuild: do not put .scmversion into the source tarballMasahiro Yamada
.scmversion is used by (src)rpm-pkg and deb-pkg to carry KERNELRELEASE. In fact, deb-pkg does not rely on it any more because the generated debian/rules specifies KERNELRELEASE from the command line. Do likwise for (src)rpm-pkg, and remove this feature. For the same reason, you do not need to save LOCALVERSION in the spec file. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
2023-01-11scripts: rpm: make clear that mkspec script contains 4.13 featureArend van Spriel
A fix was made in the mkspec script that uses a feature, ie. the OR expression, which requires RPM 4.13. However, the script indicates another minimum version. Lower versions may have success by using the --no-deps option as suggested, but feels like bumping the version to 4.13 is reasonable as it put me on the wrong track at first with RPM 4.11 on my Centos7 machine. Fixes: 02a893bc9975 ("kbuild: rpm-pkg: add libelf-devel as alternative for BuildRequires") Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2022-12-30kbuild: rpm-pkg: add libelf-devel as alternative for BuildRequiresMasahiro Yamada
Guoqing Jiang reports that openSUSE cannot compile the kernel rpm due to "BuildRequires: elfutils-libelf-devel" added by commit 8818039f959b ("kbuild: add ability to make source rpm buildable using koji"). The relevant package name in openSUSE is libelf-devel. Add it as an alternative package. BTW, if it is impossible to solve the build requirement, the final resort would be: $ make RPMOPTS=--nodeps rpm-pkg This passes --nodeps to the rpmbuild command so it will not verify build dependencies. This is useful to test rpm builds on non-rpm system. On Debian/Ubuntu, for example, you can install rpmbuild by 'apt-get install rpm'. NOTE1: Likewise, it is possible to bypass the build dependency check for debian package builds: $ make DPKG_FLAGS=-d deb-pkg NOTE2: The 'or' operator is supported since RPM 4.13. So, old distros such as CentOS 7 will break. I suggest installing newer rpmbuild in such cases. Link: https://lore.kernel.org/linux-kbuild/ee227d24-9c94-bfa3-166a-4ee6b5dfea09@linux.dev/T/#u Fixes: 8818039f959b ("kbuild: add ability to make source rpm buildable using koji") Reported-by: Guoqing Jiang <guoqing.jiang@linux.dev> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Guoqing Jiang <guoqing.jiang@linux.dev> Acked-by: Jonathan Toppins <jtoppins@redhat.com>
2022-11-24kbuild: add ability to make source rpm buildable using kojiIvan Vecera
Changes: - added new target 'srcrpm-pkg' to generate source rpm - added required build tools to spec file - removed locally compiled host tools to force their re-compile Signed-off-by: Ivan Vecera <ivecera@redhat.com> Signed-off-by: Jonathan Toppins <jtoppins@redhat.com> Acked-by: Íñigo Huguet <ihuguet@redhat.com> Tested-by: Ivan Vecera <ivecera@redhat.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2022-10-13kbuild: Stop including vmlinux.bz2 in the rpm'sZack Rusin
vmlinux.bz2 was added to the rpm packages in 2009 in the fc370ecfdb37 ("kbuild: add vmlinux to kernel rpm") but seemingly hasn't been used since. Originally this should have been split up in a seperate debugging package because it massively increases the size of the generated rpm's e.g. kernel rpm built using binrpm-pkg on Fedora 36 default 5.19.8 kernel config and localmodconfig is ~255MB with vmlinux.bz2 and only ~65MB without it. Make the kernel built rpms about 4x smaller by not including the unused vmlinux.bz2 in them. Signed-off-by: Zack Rusin <zackr@vmware.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2022-09-29kbuild: rpm-pkg: fix breakage when V=1 is usedJanis Schoetterl-Glausch
Doing make V=1 binrpm-pkg results in: Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.EgV6qJ + umask 022 + cd . + /bin/rm -rf /home/scgl/rpmbuild/BUILDROOT/kernel-6.0.0_rc5+-1.s390x + /bin/mkdir -p /home/scgl/rpmbuild/BUILDROOT + /bin/mkdir /home/scgl/rpmbuild/BUILDROOT/kernel-6.0.0_rc5+-1.s390x + mkdir -p /home/scgl/rpmbuild/BUILDROOT/kernel-6.0.0_rc5+-1.s390x/boot + make -f ./Makefile image_name + cp test -e include/generated/autoconf.h -a -e include/config/auto.conf || ( \ echo >&2; \ echo >&2 " ERROR: Kernel configuration is invalid."; \ echo >&2 " include/generated/autoconf.h or include/config/auto.conf are missing.";\ echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ echo >&2 ; \ /bin/false) arch/s390/boot/bzImage /home/scgl/rpmbuild/BUILDROOT/kernel-6.0.0_rc5+-1.s390x/boot/vmlinuz-6.0.0-rc5+ cp: invalid option -- 'e' Try 'cp --help' for more information. error: Bad exit status from /var/tmp/rpm-tmp.EgV6qJ (%install) Because the make call to get the image name is verbose and prints additional information. Fixes: 993bdde94547 ("kbuild: add image_name to no-sync-config-targets") Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2022-07-27kbuild: rpm-pkg: fix build error when _arch is undefinedMasahiro Yamada
Cross-building (bin)rpm-pkg fails on several architectures. For example, 'make ARCH=arm binrpm-pkg' fails like follows: sh ./scripts/package/mkspec prebuilt > ./binkernel.spec rpmbuild --define "_builddir ." --target \ arm -bb ./binkernel.spec Building target platforms: arm Building for target arm warning: line 19: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.0S8t2F + umask 022 + cd . + mkdir -p /home/masahiro/rpmbuild/BUILDROOT/kernel-5.19.0_rc6-19.%{_arch}/boot + make -f ./Makefile image_name + cp arch/arm/boot/zImage /home/masahiro/rpmbuild/BUILDROOT/kernel-5.19.0_rc6-19.%{_arch}/boot/vmlinuz-5.19.0-rc6 + make -f ./Makefile INSTALL_MOD_PATH=/home/masahiro/rpmbuild/BUILDROOT/kernel-5.19.0_rc6-19.%{_arch} modules_install make[3]: *** No rule to make target '/home/masahiro/rpmbuild/BUILDROOT/kernel-5.19.0_rc6-19.arch/arm/crypto/aes-arm-bs.ko{_arch}/lib/modules/5.19.0-rc6/kernel/%', needed by '__modinst'. Stop. make[2]: *** [Makefile:1768: modules_install] Error 2 error: Bad exit status from /var/tmp/rpm-tmp.0S8t2F (%install) By default, 'buildroot' contains %{_arch} (see /usr/lib/rpm/macros). _arch is generally defined in /usr/lib/rpm/platforms/*/macros, where the platform sub-directory is specified by --target= option for cross builds. If the given arch does not exist, %{_arch} is not expanded. In the example above, --target=arm is passed to rpmbuild, but /usr/lib/rpm/platforms/arm-linux/ does not exist. The '%' character in the path confuses GNU make and rpmbuild. The same occurs for such architectures as csky, microblaze, nios2, etc. Define _arch if it has not been defined. Reported-by: Jason Self <jason@bluehome.net> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2020-08-10kbuild: Replace HTTP links with HTTPS onesAlexander A. Klimov
Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2019-07-18kbuild: create *.mod with full directory path and remove MODVERDIRMasahiro Yamada
While descending directories, Kbuild produces objects for modules, but do not link final *.ko files; it is done in the modpost. To keep track of modules, Kbuild creates a *.mod file in $(MODVERDIR) for every module it is building. Some post-processing steps read the necessary information from *.mod files. This avoids descending into directories again. This mechanism was introduced in 2003 or so. Later, commit 551559e13af1 ("kbuild: implement modules.order") added modules.order. So, we can simply read it out to know all the modules with directory paths. This is easier than parsing the first line of *.mod files. $(MODVERDIR) has a flat directory structure, that is, *.mod files are named only with base names. This is based on the assumption that the module name is unique across the tree. This assumption is really fragile. Stephen Rothwell reported a race condition caused by a module name conflict: https://lkml.org/lkml/2019/5/13/991 In parallel building, two different threads could write to the same $(MODVERDIR)/*.mod simultaneously. Non-unique module names are the source of all kind of troubles, hence commit 3a48a91901c5 ("kbuild: check uniqueness of module names") introduced a new checker script. However, it is still fragile in the build system point of view because this race happens before scripts/modules-check.sh is invoked. If it happens again, the modpost will emit unclear error messages. To fix this issue completely, create *.mod with full directory path so that two threads never attempt to write to the same file. $(MODVERDIR) is no longer needed. Since modules with directory paths are listed in modules.order, Kbuild is still able to find *.mod files without additional descending. I also killed cmd_secanalysis; scripts/mod/sumversion.c computes MD4 hash for modules with MODULE_VERSION(). When CONFIG_DEBUG_SECTION_MISMATCH=y, it occurs not only in the modpost stage, but also during directory descending, where sumversion.c may parse stale *.mod files. It would emit 'No such file or directory' warning when an object consisting a module is renamed, or when a single-obj module is turned into a multi-obj module or vice versa. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Nicolas Pitre <nico@fluxnic.net>
2019-07-09kbuild: do not create wrappers for header-test-yMasahiro Yamada
header-test-y does not work with headers in sub-directories. For example, you may want to write a Makefile, like this: include/linux/Kbuild: header-test-y += mtd/nand.h This entry will create a wrapper include/linux/mtd/nand.hdrtest.c with the following content: #include "mtd/nand.h" To make this work, we need to add $(srctree)/include/linux to the header search path. It would be tedious to add ccflags-y. Instead, we could change the *.hdrtest.c rule to wrap: #include "nand.h" This works for in-tree build since #include "..." searches in the relative path from the header with this directive. For O=... build, we need to add $(srctree)/include/linux/mtd to the header search path, which will be even more tedious. After all, I thought it would be handier to compile headers directly without creating wrappers. I added a new build rule to compile %.h into %.h.s The target is %.h.s instead of %.h.o because it is slightly faster. Also, as for GCC, an empty assembly is smaller than an empty object. I wrote the build rule: $(CC) $(c_flags) -S -o $@ -x c /dev/null -include $< instead of: $(CC) $(c_flags) -S -o $@ -x c $< Both work fine with GCC, but the latter is bad for Clang. This comes down to the difference in the -Wunused-function policy. GCC does not warn about unused 'static inline' functions at all. Clang does not warn about the ones in included headers, but does about the ones in the source. So, we should handle headers as headers, not as source files. In fact, this has been hidden since commit abb2ea7dfd82 ("compiler, clang: suppress warning for unused static inline functions"), but we should not rely on that. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Jani Nikula <jani.nikula@intel.com> Tested-by: Jani Nikula <jani.nikula@intel.com>
2018-11-06kbuild: rpm-pkg: fix binrpm-pkg breakage when O= is usedMasahiro Yamada
Zhenzhong Duan reported that running 'make O=/build/kernel binrpm-pkg' failed with the following errors: Running 'make O=/build/kernel binrpm-pkg' failed with below two errors. Makefile:600: include/config/auto.conf: No such file or directory + cp make -C /mnt/root/kernel O=/build/kernel image_name make -f /mnt/root/kernel/Makefile ... cp: invalid option -- 'C' Try 'cp --help' for more information. Prior to commit 80463f1b7bf9 ("kbuild: add --include-dir flag only for out-of-tree build"), both srctree and objtree were added to --include-dir redundantly, and the wrong code 'make image_name' was working by relying on that. Now, the potential issue that had previously been hidden just showed up. 'make image_name' recurses to the generated $(objtree)/Makefile and ends up with running in srctree, which is incorrect. It should be invoked with '-f $srctree/Makefile' (or KBUILD_SRC=) to be executed in objtree. Fixes: 80463f1b7bf9 ("kbuild: add --include-dir flag only for out-of-tree build") Reported-by: Zhenzhong Duan <zhenzhong.duan@oracle.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-04-13kbuild: rpm-pkg: use kernel-install as a fallback for new-kernel-pkgJavier Martinez Canillas
The new-kernel-pkg script is only present when grubby is installed, but it may not always be the case. So if the script isn't present, attempt to use the kernel-install script as a fallback instead. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-03-28kbuild: rpm-pkg: Support GNU tar >= 1.29Jason Gunthorpe
There is a change in how command line parsing is done in this version. Excludes and includes are now ordered with the file list. Since the spec file puts the file list before the exclude list it means newer tar ignores the excludes and packs all the build output into the kernel-devel RPM resulting in a huge package. Simple argument re-ordering fixes the problem. Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-11-14kbuild: rpm-pkg: replace $RPM_BUILD_ROOT with %{buildroot}Masahiro Yamada
$RPM_BUILD_ROOT must be escaped to prevent shell from expanding it when generating the spec file. %{build_root} is more readable than \$RPM_BUILD_ROOT. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-11-14kbuild: rpm-pkg: fix build error when CONFIG_MODULES is disabledMasahiro Yamada
When CONFIG_MODULES is disabled, make rpm-pkg / binrpm-pkg fails with the following message: The present kernel configuration has modules disabled. Type 'make config' and enable loadable module support. Then build a kernel with module support enabled. Do not install modules in the case. Also, omit the devel package. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-11-14kbuild: rpm-pkg: refactor mkspec with here docMasahiro Yamada
The repeat of echo is unreadable. The here-document is a well-known device for such scripts. One difficulty is we have a bunch of PREBUILT conditionals that would split the here-document. My idea is to add "$S" annotatation to lines only for the source package spec file, then post-process it by sed. I hope it will make our life easier than repeat of "cat <<EOF ..." I confirmed this commit still produced the same (bin)kernel.spec as before. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-10-09kbuild: rpm-pkg: clean up mkspecMasahiro Yamada
Clean up the mkspec without changing the behavior. - grep CONFIG_DRM=y more simply - move "EXCLUDE" out of the "%install" section because it can be computed when the spec file is generated - remove "BuildRoot:" field, which is now redundant - do not mkdir $RPM_BUILD_ROOT/lib/modules explicitly because it is automatically created by "make modules_install" - exclude "%package devel" from source package spec file because it does not make sense where "%files devel" is already excluded - exclude "%build" from source package spec file - remove unneeded "make clean" because we had already cleaned before making tar file - merge two %ifarch ia64 conditionals - replace KBUILD_IMAGE with direct use of $(make image_name) - remove trailing empty line from the spec file Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-10-09kbuild: rpm-pkg: install vmlinux.bz2 unconditionallyMasahiro Yamada
This conditional was added by commit fc370ecfdb37 ("kbuild: add vmlinux to kernel rpm"). Its git-log mentioned vmlinux.bz2 was necessary for debugging, but did not explain why ppc64 was an exception. I see no problem to copy vmlinux.bz2 all the time. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-10-09kbuild: rpm-pkg: remove ppc64 specific image handlingMasahiro Yamada
This conditional was added by commit 1a0f3d422bb9 ("kbuild: fix make rpm for powerpc"). Its git-log explains the default kernel image is zImage, but obviously the current arch/powerpc/Makefile does not set KBUILD_IMAGE, so the image file is actually vmlinux. Moreover, since commit 09549aa1baa9 ("deb-pkg: Remove the KBUILD_IMAGE workaround"), all architectures are supposed to set the full path to the image in KBUILD_IMAGE. I see no good reason to differentiate ppc64 from others. Rip off the conditional. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-09-21kbuild: rpm-pkg: fix version number handlingMasahiro Yamada
The "Release:" field of the spec file is determined based on the .version file. However, the .version file is not copied to the source tar file. So, when we build the kernel from the source package, the UTS_VERSION always indicates #1. This does not match with "rpm -q". The kernel UTS_VERSION and "rpm -q" do not agree for binrpm-pkg, either. Please note the kernel has already been built before the spec file is created. Currently, mkspec invokes mkversion. This script returns an incremented version. So, the "Release:" field of the spec file is greater than the version in the kernel by one. For the source package build (where .version file is missing), we can give KBUILD_BUILD_VERSION=%{release} to the build command. For the binary package build, we can simply read out the .version file because it contains the version number that was used for building the kernel image. We can remove scripts/mkversion because scripts/package/Makefile need not touch the .version file. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-09-21kbuild: rpm-pkg: delete firmware_install to fix build errorMasahiro Yamada
Commit 5620a0d1aacd ("firmware: delete in-kernel firmware") deleted in-kernel firmware support, including "make firmware_install". Since then, "make rpm-pkg" / "make binrpm-pkg" fails to build with the error: make[2]: *** No rule to make target `firmware_install'. Stop. Commit df85b2d767aa ("firmware: Restore support for built-in firmware") restored the build infrastructure for CONFIG_EXTRA_FIRMWARE, but this is out of the scope of "make firmware_install". So, the right thing to do is to kill the use of "make firmware_install". Fixes: 5620a0d1aacd ("firmware: delete in-kernel firmware") Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-12-11kbuild/mkspec: avoid using brace expansionAnton Tikhomirov
Brace expansion might not work properly if _buildshell RPM macro points to a shell other than bash. Particularly, with _bulidshell defined to /bin/dash it leads to broken build and source symlinks. Signed-off-by: Anton Tikhomirov <anton.tikhomirov@cdnetworks.com> Signed-off-by: Michal Marek <mmarek@suse.com>
2016-04-20kbuild/mkspec: support 'update-bootloader'-based systemsJiri Kosina
When uninstalling kernel RPM, we're unconditionally calling "new-kernel-pkg --remove". This is useless on systems which are based on 'update-bootloader' script instead. Support update-bootloader removal method as well in case the script is present; contrary to new-kernel-pkg, this needs to be done in %postun, otherwise update-bootloader will refuse to remove entry for kernel for which the binary still exists. Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Michal Marek <mmarek@suse.com>
2016-03-04kbuild/mkspec: clean boot loader configuration on rpm removalPaolo Abeni
This patch add a rpm preuninstall scriptlet to cleanup the boot loader configuration on kernel package uninstall. The initrd for the to-be-removed kernel is deleted, too. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Michal Marek <mmarek@suse.com>
2016-02-26kbuild/mkspec: fix grub2 installkernel issueJiri Kosina
mkspec is copying built kernel to temporrary location /boot/vmlinuz-$KERNELRELEASE-rpm and runs installkernel on it. This however directly leads to grub2 menuentry for this suffixed binary being generated as well during the run of installkernel script. Later in the process the temporary -rpm suffixed files are removed, and therefore we end up with spurious (and non-functional) grub2 menu entries for each installed kernel RPM. Fix that by using a different temporary name (prefixed by '.'), so that the binary is not recognized as an actual kernel binary and no menuentry is created for it. Signed-off-by: Jiri Kosina <jkosina@suse.cz> Fixes: 3c9c7a14b627 ("rpm-pkg: add %post section to create initramfs and grub hooks") Signed-off-by: Michal Marek <mmarek@suse.com>
2015-08-26kbuild: avoid listing /lib/modules in kernel spec fileMike Marciniszyn
This causes conflicts when using multiple kernels built with this mechanism. Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: Michal Marek <mmarek@suse.com>
2015-04-27kbuild/mkspec: Simplify vmlinux.bz2 creationBorislav Petkov
No need for the intermediary vmlinux.orig - bzip2 can keep the original files used for compression with --keep. Signed-off-by: Borislav Petkov <bp@suse.de> Signed-off-by: Michal Marek <mmarek@suse.cz>
2014-12-08scripts/package: binrpm-pkg do not create source and devel packageJérôme Glisse
When doing make binrpm-pkg we only want to build the binary and header package as the documentation of binrpm-pkg target claims. Hence this patch avoid building the source and devel package. This makes binrpm-pkg target lot faster and way more usefull. Signed-off-by: Jérôme Glisse <jglisse@redhat.com> Cc: Michal Marek <mmarek@suse.cz> [mmarek: used subject line from v3] Signed-off-by: Michal Marek <mmarek@suse.cz>