From patchwork Sat Sep 30 01:10:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 114527 Delivered-To: patch@linaro.org Received: by 10.140.104.133 with SMTP id a5csp1414859qgf; Fri, 29 Sep 2017 18:11:20 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDpnA3BgZsBb8r7ddOR0ve8AoD5rtOVWhABg2v71/oz2/cvPepM7VLYFnwX/xjqozR45xMV X-Received: by 10.98.163.153 with SMTP id q25mr9225263pfl.183.1506733880451; Fri, 29 Sep 2017 18:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506733880; cv=none; d=google.com; s=arc-20160816; b=wKP9dzSQJ1jrYPhL/RkHvvPTIYICtAvDzmBlHTMrbhf3BfS5Gst5ZAAxNjDWUOhLtj PwHsePeWLZCrkhPS2bOx7aFxsq/CujQOhY5gEHeI9/Ur0XZsy54jPHVAfCu/TNSf7aDs SKeeelOvFBmhKbX35Lu4hd1UZlqGM2NpZz9pUpAfvImqRbq/mQ/xHMAMDAaVb2Yt55Rw XVzcfX5Bxs+tHWiKyskt5W6uSoZniy07FTiHTFzE9wGqETuOgWfGfhpUfubQH1G4j+20 ph+dFhXTbWTG06BDX6H+V+aCDKwgMtffEF3+ZzArxB7oM2MaZhlBO3nsJ/13ghP82mgv MHbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=GYBBYdTghLjG/kB4kNKuO4VYuFcGO2pTgQDPWhaeyTc=; b=Bw5Rb/dTb5E5tIxhl+JnKG4qsHKlcTlghjaihtPJc1KWofLccQL/3/2XLTnT55QjIm rYRmRd681XftVRgtmNCLF5vn1zy9trL6nL1U7Csg6iNid2OzCDHE0RkGqS2MVyM0he+z Yr2jQyOhYV/d6UE1kRLGaSx9u7zmW/9RbYPdxSdV0BgeuGNwPPxHm7PYGyn2OlmEFjRP YjnlYCQE0K5Dwb7LagXUKpHURXSY9W91/jO4KpKNvCDJDomR47CkGC+WZ07+nPM4egPp JQZ+/U94VxPCLNeE8Xm1BbJlOTDCgBCHnjUPUOhQOLXgKomT/igar/zXZvj5XnMN+A1i BgEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=DOenzW++; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22si4020075pgn.561.2017.09.29.18.11.20; Fri, 29 Sep 2017 18:11:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=DOenzW++; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752855AbdI3BLR (ORCPT + 26 others); Fri, 29 Sep 2017 21:11:17 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:25322 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752731AbdI3BKf (ORCPT ); Fri, 29 Sep 2017 21:10:35 -0400 Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-07.nifty.com with ESMTP id v8U1AOK8030198; Sat, 30 Sep 2017 10:10:26 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v8U1AOK8030198 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1506733826; bh=GYBBYdTghLjG/kB4kNKuO4VYuFcGO2pTgQDPWhaeyTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DOenzW++PRemsLW4x3k9FjWgKRdo7xr7ZZFO725I+vGG2MhUb4r6dwqKhTQtDB0Yp xGryClELkALpD+OQoww8tC7Tq23ng3Lgq8mHI0ksKR28VwUfBcVluzMYaC6L9ZpSuF +XzO2odUnqTGleOOcg5iPe2/0wlBxpWeq5ATF7BFZLlmzuVq4oWxiddlzWEnIf9yxM taI66UaLKAbxC0Yi9NPdWKSdllxEQvPv2gTTGuW/CjMoVXx1IUDrqAwfUFcWFGE9KY h7AYianv7RTsVSrgeR115FK3ko9hkV+Yb06GfBwBUXis94dye5QKe1qiQRiAgR6Fab TNCoT7oeMcnUA== X-Nifty-SrcIP: [122.131.185.176] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 4/9] kbuild: rpm-pkg: refactor mkspec with here doc Date: Sat, 30 Sep 2017 10:10:06 +0900 Message-Id: <1506733811-24636-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506733811-24636-1-git-send-email-yamada.masahiro@socionext.com> References: <1506733811-24636-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 < --- scripts/package/mkspec | 218 ++++++++++++++++++++++++------------------------- 1 file changed, 105 insertions(+), 113 deletions(-) -- 2.7.4 diff --git a/scripts/package/mkspec b/scripts/package/mkspec index 97feb60..f34e3bf 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -11,9 +11,9 @@ # how we were called determines which rpms we build and how we build them if [ "$1" = prebuilt ]; then - PREBUILT=true + S=DEL else - PREBUILT=false + S= fi if grep -q CONFIG_DRM=y .config; then @@ -26,120 +26,112 @@ EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \ --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \ --exclude=.config.old --exclude=.missing-syscalls.d" -echo "Name: kernel" -echo "Summary: The Linux Kernel" -echo "Version: $__KERNELRELEASE" -echo "Release: $(cat .version 2>/dev/null || echo 1)" -echo "License: GPL" -echo "Group: System Environment/Kernel" -echo "Vendor: The Linux Community" -echo "URL: http://www.kernel.org" +# We can label the here-doc lines for conditional output to the spec file +# +# Labels: +# $S: this line is enabled only when building source package +sed -e '/^DEL/d' -e's/^\t*//' </dev/null || 1) + License: GPL + Group: System Environment/Kernel + Vendor: The Linux Community + URL: http://www.kernel.org +$S Source: kernel-$__KERNELRELEASE.tar.gz + Provides: $PROVIDES + %define __spec_install_post /usr/lib/rpm/brp-compress || : + %define debug_package %{nil} -if ! $PREBUILT; then -echo "Source: kernel-$__KERNELRELEASE.tar.gz" -fi + %description + The Linux Kernel, the operating system core itself -echo "Provides: $PROVIDES" -echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :" -echo "%define debug_package %{nil}" -echo "" -echo "%description" -echo "The Linux Kernel, the operating system core itself" -echo "" -echo "%package headers" -echo "Summary: Header files for the Linux kernel for use by glibc" -echo "Group: Development/System" -echo "Obsoletes: kernel-headers" -echo "Provides: kernel-headers = %{version}" -echo "%description headers" -echo "Kernel-headers includes the C header files that specify the interface" -echo "between the Linux kernel and userspace libraries and programs. The" -echo "header files define structures and constants that are needed for" -echo "building most standard programs and are also needed for rebuilding the" -echo "glibc package." -echo "" + %package headers + Summary: Header files for the Linux kernel for use by glibc + Group: Development/System + Obsoletes: kernel-headers + Provides: kernel-headers = %{version} + %description headers + Kernel-headers includes the C header files that specify the interface + between the Linux kernel and userspace libraries and programs. The + header files define structures and constants that are needed for + building most standard programs and are also needed for rebuilding the + glibc package. -if ! $PREBUILT; then -echo "%package devel" -echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel" -echo "Group: System Environment/Kernel" -echo "AutoReqProv: no" -echo "%description -n kernel-devel" -echo "This package provides kernel headers and makefiles sufficient to build modules" -echo "against the $__KERNELRELEASE kernel package." -echo "" -echo "%prep" -echo "%setup -q" -echo "" -echo "%build" -echo "make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}" -echo "" -fi +$S %package devel +$S Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel +$S Group: System Environment/Kernel +$S AutoReqProv: no +$S %description -n kernel-devel +$S This package provides kernel headers and makefiles sufficient to build modules +$S against the $__KERNELRELEASE kernel package. +$S +$S %prep +$S %setup -q +$S +$S %build +$S make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release} +$S + %install + mkdir -p \$RPM_BUILD_ROOT/boot + %ifarch ia64 + mkdir -p \$RPM_BUILD_ROOT/boot/efi + cp \$(make image_name) \$RPM_BUILD_ROOT/boot/efi/vmlinuz-$KERNELRELEASE + ln -s efi/vmlinuz-$KERNELRELEASE \$RPM_BUILD_ROOT/boot/ + %else + cp \$(make image_name) \$RPM_BUILD_ROOT/boot/vmlinuz-$KERNELRELEASE + %endif + make %{?_smp_mflags} INSTALL_MOD_PATH=\$RPM_BUILD_ROOT KBUILD_SRC= modules_install + make %{?_smp_mflags} INSTALL_HDR_PATH=\$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install + cp System.map \$RPM_BUILD_ROOT/boot/System.map-$KERNELRELEASE + cp .config \$RPM_BUILD_ROOT/boot/config-$KERNELRELEASE + bzip2 -9 --keep vmlinux + mv vmlinux.bz2 \$RPM_BUILD_ROOT/boot/vmlinux-$KERNELRELEASE.bz2 +$S rm -f \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE/build +$S rm -f \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE/source +$S mkdir -p \$RPM_BUILD_ROOT/usr/src/kernels/$KERNELRELEASE +$S tar cf - . $EXCLUDES | tar xf - -C \$RPM_BUILD_ROOT/usr/src/kernels/$KERNELRELEASE +$S cd \$RPM_BUILD_ROOT/lib/modules/$KERNELRELEASE +$S ln -sf /usr/src/kernels/$KERNELRELEASE build +$S ln -sf /usr/src/kernels/$KERNELRELEASE source -echo "%install" -echo 'mkdir -p $RPM_BUILD_ROOT/boot' -echo "%ifarch ia64" -echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi' -echo 'cp $(make image_name) $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" -echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" -echo "%else" -echo 'cp $(make image_name) $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" -echo "%endif" -echo 'make %{?_smp_mflags} INSTALL_MOD_PATH=$RPM_BUILD_ROOT KBUILD_SRC= modules_install' -echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install' -echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" -echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" -echo 'bzip2 -9 --keep vmlinux' -echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2" + %clean + rm -rf \$RPM_BUILD_ROOT -if ! $PREBUILT; then -echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/build" -echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/source" -echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" -echo "tar cf - . $EXCLUDES | tar xf - -C "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE" -echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE" -echo "ln -sf /usr/src/kernels/$KERNELRELEASE build" -echo "ln -sf /usr/src/kernels/$KERNELRELEASE source" -fi + %post + if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then + cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm + cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm + rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE + /sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm + rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm + fi -echo "" -echo "%clean" -echo 'rm -rf $RPM_BUILD_ROOT' -echo "" -echo "%post" -echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then" -echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm" -echo "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm" -echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE" -echo "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" -echo "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm" -echo "fi" -echo "" -echo "%preun" -echo "if [ -x /sbin/new-kernel-pkg ]; then" -echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img" -echo "fi" -echo "" -echo "%postun" -echo "if [ -x /sbin/update-bootloader ]; then" -echo "/sbin/update-bootloader --remove $KERNELRELEASE" -echo "fi" -echo "" -echo "%files" -echo '%defattr (-, root, root)' -echo "/lib/modules/$KERNELRELEASE" -echo "%exclude /lib/modules/$KERNELRELEASE/build" -echo "%exclude /lib/modules/$KERNELRELEASE/source" -echo "/boot/*" -echo "" -echo "%files headers" -echo '%defattr (-, root, root)' -echo "/usr/include" -if ! $PREBUILT; then -echo "" -echo "%files devel" -echo '%defattr (-, root, root)' -echo "/usr/src/kernels/$KERNELRELEASE" -echo "/lib/modules/$KERNELRELEASE/build" -echo "/lib/modules/$KERNELRELEASE/source" -fi + %preun + if [ -x /sbin/new-kernel-pkg ]; then + new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img + fi + + %postun + if [ -x /sbin/update-bootloader ]; then + /sbin/update-bootloader --remove $KERNELRELEASE + fi + + %files + %defattr (-, root, root) + /lib/modules/$KERNELRELEASE + %exclude /lib/modules/$KERNELRELEASE/build + %exclude /lib/modules/$KERNELRELEASE/source + /boot/* + + %files headers + %defattr (-, root, root) + /usr/include +$S +$S %files devel +$S %defattr (-, root, root) +$S /usr/src/kernels/$KERNELRELEASE +$S /lib/modules/$KERNELRELEASE/build +$S /lib/modules/$KERNELRELEASE/source +EOF