-
2 months ago1 month ago1 month ago
-
3 weeks ago
-
Local "build" test successful
-
This is what I came up with:
macros.platform
%_native_arch x86_64 %_native_os linux %_native_libc glibc %_native_platform %{_native_arch}-%{_native_os}-%{_native_libc} %_native_prefix /usr/%{_native_arch}/%{_native_os}/%{_native_libc}platforms.list
x86_64-linux-glibc aarch64-linux-glibc x86_64-linux-musl riscv64-linux-glibc x86_64-win-mingwfilesystem.spec
Name: filesystem Version: 1.0 Release: 1%{?dist} Summary: Base filesystem layout and native symlinks License: MIT BuildArch: noarch Source0: macros.platform Source1: platforms.list Requires: filesystem-%{_native_platform} %description Base directories and short-path symlinks that always point to the native platform. Foreign platform trees are available as separate subpackages generated from platforms.list. %prep %setup -q -c -T cp -p %{SOURCE0} %{SOURCE1} . # -------------------------------------------------- # Automatically generate subpackage definitions # from platforms.list # -------------------------------------------------- cat > subpackages.inc << 'EOF' # Generated file – do not edit EOF while read -r platform; do # Skip empty lines and comments [[ -z "$platform" || "$platform" =~ ^[[:space:]]*# ]] && continue cat >> subpackages.inc << EOF %package -n filesystem-${platform} Summary: Filesystem tree for ${platform} BuildArch: noarch %description -n filesystem-${platform} Directory hierarchy for the ${platform} target. Safe to install on any host for cross-compilation or emulation. Does not modify short paths (/bin, /usr/lib, …). %files -n filesystem-${platform} %dir /usr/${platform} %dir /usr/${platform}/bin %dir /usr/${platform}/sbin %dir /usr/${platform}/lib %dir /usr/${platform}/libexec %dir /usr/${platform}/include %dir /usr/${platform}/share EOF done < platforms.list %install install -D -m 644 macros.platform \ %{buildroot}%{_rpmconfigdir}/macros.d/macros.platform # ABI-independent base directories mkdir -p %{buildroot}/{etc,var,boot,home,mnt,opt,root,run,srv,tmp} mkdir -p %{buildroot}/usr/{share,src,local,include} mkdir -p %{buildroot}/var/{cache,log,lib,spool,tmp} # Create every platform tree while read -r platform; do [[ -z "$platform" || "$platform" =~ ^[[:space:]]*# ]] && continue mkdir -p %{buildroot}/usr/${platform}/{bin,sbin,lib,libexec,include,share} done < platforms.list %post # Short paths always point to the native platform ln -sfn %{_native_prefix}/bin /bin ln -sfn %{_native_prefix}/lib /lib ln -sfn %{_native_prefix}/sbin /sbin ln -sfn %{_native_prefix}/bin /usr/bin ln -sfn %{_native_prefix}/lib /usr/lib ln -sfn %{_native_prefix}/sbin /usr/sbin ln -sfn %{_native_prefix} /usr/native mkdir -p /usr/include %files %{_rpmconfigdir}/macros.d/macros.platform %dir /usr/include %dir /usr/share %dir /usr/src %dir /usr/local %dir /etc %dir /var %dir /boot %dir /home %dir /mnt %dir /opt %dir /root %dir /run %dir /srv %dir /tmp # Pull in all the generated subpackages %include subpackages.inc -
Wouldn't it make sense to just build all the platform packages in one shot? Technically, the package "build" is
noarchbecause it doesn't compile anything. -
Yes, absolutely. The only package that shouldn't be
noarchis the one that selects the native platform package automatically. -
Yes, absolutely. The only package that shouldn't be
noarchis the one that selects the native platform package automatically.It was meant as a general statement as there are no libraries or executables being built. I think the package should therefore create all the arch based packages on the first build pass and not do any autodetection. If the spec is doing that, it's not needed.
-
The spec file as written should indeed do that, but honestly I didn't test it yet. If you did and it doesn't result in all packages being built, that's unintended behavior.
-
I guess, I am confused what
macros.platformdoes. It supplies%{_native_prefix}later on, but that shouldn't really need to happen. First, it's hard defined from what I can tell, and second it should be building all the platform packages so knowing the native prefix isn't really relevant. There just needs to be a substitution based on the platform for the package, which already seems to be taken care of. What am I missing? -
macros.platformis just a concept and it allows to test the spec file, I should've clarified that. In the final form we'll have one macros file per platform, with substitution in place. -
We probably shouldn't include it as a source, then. It should be sufficient to add the test logic to
%checkif you are trying to apply a test that should error out a build. -
We'll probably have it as a template that is then used as the base for the actual macros file(s).
-
Why not just iterate over the
platforms.listfile and create a macro from the results, then?
| Submitter | zeroability |
| Target | master |
| Source | refac-drop-compat32 |
WIP - do not merge without approval