[opensuse-kernel] [RFC] dtb-*: Generate the filelists during build
This allows us to share the mkspec-dtb script among slightly different branches. Nonexistent dtbs will result in empty RPM packages. --- rpm/dtb.spec.in.in | 42 +++++++++++++++++++++++++++++++++--------- rpm/mkspec-dtb | 25 +++++-------------------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/rpm/dtb.spec.in.in b/rpm/dtb.spec.in.in index 0ea9b4639d8b..11e9bae5ec8e 100644 --- a/rpm/dtb.spec.in.in +++ b/rpm/dtb.spec.in.in @@ -75,6 +75,9 @@ DTC_FLAGS="$DTC_FLAGS -@" cd $source/$DTS_folder for dts in $ALL_SUPPORTED_DTB; do + if test ! -e "$dts"; then + continue + fi target=${dts%*.dts} mkdir -p $PPDIR/$(dirname $target) cpp -x assembler-with-cpp -undef -D__DTS__ -nostdinc -I. -I$SRCDIR/include/ -I$SRCDIR/scripts/dtc/include-prefixes/ -P $target.dts -o $PPDIR/$target.dts @@ -85,18 +88,39 @@ done %install +cat >boilerplate.list <<EOF +%%defattr(-,root,root) +%%doc COPYING +%%ghost /boot/dtb +%%dir %{dtbdir} +EOF + cd pp -for dts in $ALL_SUPPORTED_DTB; do - target=${dts%*.dts} - install -m 700 -d %{buildroot}%{dtbdir}/$(dirname $target) - install -m 644 $target.dtb %{buildroot}%{dtbdir}/$(dirname $target) +for spec in $ALL_SUPPORTED_PKG_DTB; do + pkg=${spec%:*} + glob=${spec#*:} + : >../$pkg.list + for dts in $glob; do + if test ! -e "$dts"; then + continue + fi + if test ! -s ../$pkg.list; then + cp ../boilerplate.list ../$pkg.list + fi + target=${dts%*.dts} + install -m 700 -d %{buildroot}%{dtbdir}/$(dirname $target) + install -m 644 $target.dtb %{buildroot}%{dtbdir}/$(dirname $target) + echo "%%{dtbdir}/$target.dtb" >>../$pkg.list + if test "$(dirname $target)" != "."; then + echo "%%dir %%{dtbdir}/$(dirname $target)" >>../$pkg.list + fi %ifarch aarch64 - # HACK: work around U-Boot ignoring vendor dir - baselink=%{dtbdir}/$(basename $target).dtb - vendordir=$(basename $(dirname $target)) - ln -s $target.dtb %{buildroot}$baselink - echo $baselink >> ../dtb-$vendordir.list + # HACK: work around U-Boot ignoring vendor dir + baselink=%{dtbdir}/$(basename $target).dtb + ln -s $target.dtb %{buildroot}$baselink + echo $baselink >> ../$pkg.list %endif + done done cd - diff --git a/rpm/mkspec-dtb b/rpm/mkspec-dtb index 09c7126f3c59..d96ce76892cc 100755 --- a/rpm/mkspec-dtb +++ b/rpm/mkspec-dtb @@ -100,6 +100,7 @@ sub generate_spec($$$) my $subpkg_post = ""; my $subpkg_files = ""; my $all_supported_dtb = ""; + my $all_supported_pkg_dtb = ""; my $DTS_folder = "arch/arm/boot/dts"; if ($exclusive_arch =~ /aarch64/) { $DTS_folder = "arch/arm64/boot/dts"; @@ -146,31 +147,14 @@ sub generate_spec($$$) "# Unless /boot/dtb exists as real directory, create a symlink.\n" . "[ -d dtb ] || ln -sf dtb-%kernelrelease dtb\n\n"; - my $bin_supported_dtb = $SUPPORTED_DTB; - $bin_supported_dtb =~ s/\.dts/\.dtb/g; - - my $dtb_subdir = ""; - if ($bin_supported_dtb =~ /(.*)\/[^\/]+$/) { - $dtb_subdir = "%dir %{dtbdir}/$1\n"; - } - $subpkg_files .= - "%ifarch aarch64\n" . - "%files -n $PKG_NAME -f $PKG_NAME.list\n" . - "%else\n" . - "%files -n $PKG_NAME\n" . - "%endif\n" . - "%defattr(-,root,root)\n" . - "%doc COPYING\n" . - "%ghost /boot/dtb\n" . - "%dir %{dtbdir}\n" . - $dtb_subdir . - "%{dtbdir}/$bin_supported_dtb\n" . - "\n"; + "%files -n $PKG_NAME -f $PKG_NAME.list\n\n"; $all_supported_dtb .= "$SUPPORTED_DTB "; + $all_supported_pkg_dtb .= "$PKG_NAME:$SUPPORTED_DTB "; } chomp($all_supported_dtb); + chomp($all_supported_pkg_dtb); # spec file generation while(<TEMPLATE>){ @@ -179,6 +163,7 @@ sub generate_spec($$$) $_ =~ s/\$DTS_folder/$DTS_folder/g; $_ =~ s/\$SUBPKG_DESC/$subpkg_desc/g; $_ =~ s/\$ALL_SUPPORTED_DTB/$all_supported_dtb/g; + $_ =~ s/\$ALL_SUPPORTED_PKG_DTB/$all_supported_pkg_dtb/g; $_ =~ s/\$SUBPKG_POST\n?/$subpkg_post/g; $_ =~ s/\$SUBPKG_FILES\n?/$subpkg_files/g; print SPEC $_; -- 2.10.2 -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-kernel+owner@opensuse.org
On Jun 05 2017, Michal Marek <mmarek@suse.com> wrote:
@@ -85,18 +88,39 @@ done
%install
+cat >boilerplate.list <<EOF +%%defattr(-,root,root) +%%doc COPYING +%%ghost /boot/dtb +%%dir %{dtbdir} +EOF + cd pp -for dts in $ALL_SUPPORTED_DTB; do - target=${dts%*.dts} - install -m 700 -d %{buildroot}%{dtbdir}/$(dirname $target) - install -m 644 $target.dtb %{buildroot}%{dtbdir}/$(dirname $target) + pkg=${spec%:*}
% should be doubled.
+ glob=${spec#*:} + : >../$pkg.list + for dts in $glob; do + if test ! -e "$dts"; then + continue + fi + if test ! -s ../$pkg.list; then + cp ../boilerplate.list ../$pkg.list + fi + target=${dts%*.dts}
Likewise. Andreas. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different." -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-kernel+owner@opensuse.org
On 2017-06-06 09:32, Andreas Schwab wrote:
On Jun 05 2017, Michal Marek <mmarek@suse.com> wrote:
+ pkg=${spec%:*}
% should be doubled.
Good catch, fixed both. Michal -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-kernel+owner@opensuse.org
On Tuesday, 6 June 2017 9:32 Andreas Schwab wrote:
% should be doubled.
+ glob=${spec#*:} + : >../$pkg.list + for dts in $glob; do + if test ! -e "$dts"; then + continue + fi + if test ! -s ../$pkg.list; then + cp ../boilerplate.list ../$pkg.list + fi + target=${dts%*.dts}
Likewise.
I may be missing something but wouldn't ${dts%%*.dts} expand to empty string whenever $dts ends with ".dts"? Is this what we wan't here? Michal Kubeček -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-kernel+owner@opensuse.org
On 2017-06-06 09:54, Michal Kubecek wrote:
On Tuesday, 6 June 2017 9:32 Andreas Schwab wrote:
% should be doubled.
+ glob=${spec#*:} + : >../$pkg.list + for dts in $glob; do + if test ! -e "$dts"; then + continue + fi + if test ! -s ../$pkg.list; then + cp ../boilerplate.list ../$pkg.list + fi + target=${dts%*.dts}
Likewise.
I may be missing something but wouldn't ${dts%%*.dts} expand to empty string whenever $dts ends with ".dts"? Is this what we wan't here?
The % removes the shortest matching pattern, so this correctly removes the .dts suffix. But I agree that it is extremely confusing, I will remove the redundant '*'. Michal -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-kernel+owner@opensuse.org
On Tuesday, 6 June 2017 10:03 Michal Marek wrote:
On 2017-06-06 09:54, Michal Kubecek wrote:
On Tuesday, 6 June 2017 9:32 Andreas Schwab wrote:
% should be doubled.
+ glob=${spec#*:} + : >../$pkg.list + for dts in $glob; do + if test ! -e "$dts"; then + continue + fi + if test ! -s ../$pkg.list; then + cp ../boilerplate.list ../$pkg.list + fi + target=${dts%*.dts}
Likewise.
I may be missing something but wouldn't ${dts%%*.dts} expand to empty string whenever $dts ends with ".dts"? Is this what we wan't here?
The % removes the shortest matching pattern, so this correctly removes the .dts suffix. But I agree that it is extremely confusing, I will remove the redundant '*'.
One '%' does (so that ${dts%*.dts} is indeed equivalent to ${dts%.dts}). But Andreas suggested to replace it with '%%' which would cut off the longest match - and that would be the whole string whenever it ends with ".dts". Michal -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-kernel+owner@opensuse.org
On 2017-06-06 10:09, Michal Kubecek wrote:
On Tuesday, 6 June 2017 10:03 Michal Marek wrote:
On 2017-06-06 09:54, Michal Kubecek wrote:
On Tuesday, 6 June 2017 9:32 Andreas Schwab wrote:
% should be doubled.
+ glob=${spec#*:} + : >../$pkg.list + for dts in $glob; do + if test ! -e "$dts"; then + continue + fi + if test ! -s ../$pkg.list; then + cp ../boilerplate.list ../$pkg.list + fi + target=${dts%*.dts}
Likewise.
I may be missing something but wouldn't ${dts%%*.dts} expand to empty string whenever $dts ends with ".dts"? Is this what we wan't here?
The % removes the shortest matching pattern, so this correctly removes the .dts suffix. But I agree that it is extremely confusing, I will remove the redundant '*'.
One '%' does (so that ${dts%*.dts} is indeed equivalent to ${dts%.dts}). But Andreas suggested to replace it with '%%' which would cut off the longest match - and that would be the whole string whenever it ends with ".dts".
And that is precisely why I called it extremely confusing: The double % is there because of the rpm specfile parser, bash gets a single %. Oh, and for the real connoisseurs, we also have a quadruple % in rpm/kernel-binary.spec.in ;). Anyway, we drifted away from the topic a bit. I posted the RFC to ask if it is an acceptable trade off to have a shared mkspec-dtb script at the cost of occasionally having empty dtb-* packages. Michal -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-kernel+owner@opensuse.org
Hi Michal, Am 06.06.2017 um 10:33 schrieb Michal Marek:
Anyway, we drifted away from the topic a bit. I posted the RFC to ask if it is an acceptable trade off to have a shared mkspec-dtb script at the cost of occasionally having empty dtb-* packages.
Could you give us a verbose explanation of what the RFC is doing? For arm64 I would be fine with an auto-generated list of sub-packages: Every vendor directory arch/arm64/boot/dts/foo/ should get its own dtb-foo subpackage. That requires access to an expanded source tree, which I miss in mkspec-dtb. Lua script in the .spec might be a solution? For ARMv7 and ARMv6 things are more complicated, so I don't see how we could automate them... Even the soc-board.dts convention has exceptions. Regards, Andreas -- SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-kernel+owner@opensuse.org
Dne 6.6.2017 v 20:06 Andreas Färber napsal(a):
Hi Michal,
Am 06.06.2017 um 10:33 schrieb Michal Marek:
Anyway, we drifted away from the topic a bit. I posted the RFC to ask if it is an acceptable trade off to have a shared mkspec-dtb script at the cost of occasionally having empty dtb-* packages.
Could you give us a verbose explanation of what the RFC is doing?
It generates the %files sections for subpackages during rpm build, as opposed to the mkspec-dtb script generating them. So the mkspec-dtb can live in the packaging branch and contain the union of all the dtb subpackage definitions from master, linux-next, vanilla, SLE15 and the spec file will produce empty subpackages if the kernel does not have a given dts file.
For arm64 I would be fine with an auto-generated list of sub-packages: Every vendor directory arch/arm64/boot/dts/foo/ should get its own dtb-foo subpackage. That requires access to an expanded source tree, which I miss in mkspec-dtb. Lua script in the .spec might be a solution?
This sounds interesting, but the RFC patch is not doing this. And I'm afraid not even lua will help, because the spec file is parsed and all macros evaluated before any of the build scriptlets is executed. We would have to unpack the linux tarball and apply all patches inside the lua script. Michal -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-kernel+owner@opensuse.org
On Jun 06 2017, Michal Kubecek <mkubecek@suse.cz> wrote:
One '%' does (so that ${dts%*.dts} is indeed equivalent to ${dts%.dts}). But Andreas suggested to replace it with '%%' which would cut off the
% is an rpm special character. To insert a literal % in a specfile you need to double it. You should not depend on rpm leaving it alone when followed by a random character. Andreas. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different." -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-kernel+owner@opensuse.org
participants (4)
-
Andreas Färber
-
Andreas Schwab
-
Michal Kubecek
-
Michal Marek