From fd11b5b9bedb5ebe28bae4694934d1798ca4a97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 7 Apr 2024 17:33:09 +0200 Subject: [PATCH] Merge /usr/sbin and /usr/bin https://fedoraproject.org/wiki/Changes/Unify_bin_and_sbin /usr/sbin is now created via a scriptlet. In a pristine installation, we'll end up with merged sbin. On upgrades, symlink creation will fail and the existing /usr/sbin directory will remain. The updated package means that if we build packages, they'll see merged sbin in the filesystem. If additionally rpm defines %{_sbindir} as /usr/sbin, those packages will get files in the merged location. A separate pull request will be filed for rpm. For building rpms, the change in rpm is more important, because what really matters is the path specified in %files, so even if the buildroot has merged-sbin, if %_sbindir says otherwise, package will use the unmerged path. For installation on disk, the change here is more important, because even if packages specify unmerged paths, if the directory on disk is a symlink, that symlink will be followed, so the installation will end up with merged sbin. We want to build packages in a chroot where /usr/sbin is a symlink to /usr/bin, so that packages get files in the merged location. But on user systems, especially when the transition is in progress, we will have packages with files in /usr/sbin, so we accept that /usr/sbin in a separate directory. --- filesystem.spec | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/filesystem.spec b/filesystem.spec index 49a0e80..5cf89eb 100644 --- a/filesystem.spec +++ b/filesystem.spec @@ -48,7 +48,7 @@ Paths=( afs boot dev \ etc/{X11/{applnk,fontpath.d,xinit/{xinitrc,xinput}.d},xdg/autostart,opt,pm/{config.d,power.d,sleep.d},skel,sysconfig,keys/ima,pki,bash_completion.d,rwtab.d,statetab.d} \ home media mnt opt root run srv tmp \ - usr/{bin,games,include,%{_lib}/{bpf,games,X11,pm-utils/{module.d,power.d,sleep.d}},lib/{debug/{.dwz,usr},games,locale,modules,sysimage,systemd/{system,user},sysusers.d,tmpfiles.d},libexec,local/{bin,etc,games,lib,%{_lib}/bpf,sbin,src,share/{applications,man/man{1,2,3,4,5,6,7,8,9,n,1x,2x,3x,4x,5x,6x,7x,8x,9x},info},libexec,include,},sbin,share/{aclocal,appdata,applications,augeas/lenses,backgrounds,bash-completion{,/completions,/helpers},desktop-directories,dict,doc,empty,fish/vendor_completions.d,games,gnome,help,icons,idl,info,licenses,man/man{1,2,3,4,5,6,7,8,9,n,1x,2x,3x,4x,5x,6x,7x,8x,9x,0p,1p,3p},metainfo,mime-info,misc,modulefiles,omf,pixmaps,sounds,themes,xsessions,X11/fonts,wayland-sessions,zsh/site-functions},src,src/kernels,src/debug} \ + usr/{bin,games,include,%{_lib}/{bpf,games,X11,pm-utils/{module.d,power.d,sleep.d}},lib/{debug/{.dwz,usr},games,locale,modules,sysimage,systemd/{system,user},sysusers.d,tmpfiles.d},libexec,local/{bin,etc,games,lib,%{_lib}/bpf,src,share/{applications,man/man{1,2,3,4,5,6,7,8,9,n,1x,2x,3x,4x,5x,6x,7x,8x,9x},info},libexec,include,},share/{aclocal,appdata,applications,augeas/lenses,backgrounds,bash-completion{,/completions,/helpers},desktop-directories,dict,doc,empty,fish/vendor_completions.d,games,gnome,help,icons,idl,info,licenses,man/man{1,2,3,4,5,6,7,8,9,n,1x,2x,3x,4x,5x,6x,7x,8x,9x,0p,1p,3p},metainfo,mime-info,misc,modulefiles,omf,pixmaps,sounds,themes,xsessions,X11/fonts,wayland-sessions,zsh/site-functions},src,src/kernels,src/debug} \ var/{adm,empty,ftp,lib/{games,misc,rpm-state},local,log,nis,preserve,spool/{mail,lpd},tmp,db,cache/bpf,opt,games,yp} ) for i in "${Paths[@]}"; do @@ -59,6 +59,7 @@ ln -snf ../var/tmp usr/tmp ln -snf spool/mail var/mail ln -snf usr/bin bin ln -snf usr/sbin sbin +ln -snf bin usr/sbin ln -snf usr/lib lib ln -snf usr/%{_lib} %{_lib} ln -snf ../run var/run @@ -68,6 +69,7 @@ ln -snf usr/lib usr/lib/debug/lib ln -snf usr/%{_lib} usr/lib/debug/%{_lib} ln -snf ../.dwz usr/lib/debug/usr/.dwz ln -snf usr/sbin usr/lib/debug/sbin +ln -snf bin usr/local/sbin sed -n -f %{buildroot}/iso_639.sed /usr/share/xml/iso-codes/iso_639.xml \ >%{buildroot}/iso_639.tab @@ -138,14 +140,15 @@ find %{buildroot} -mindepth 0 | sed -e 's|%{buildroot}|/|' -e 's|//|/|' \ --# later. posix.mkdir("/usr") posix.mkdir("/usr/bin") -posix.mkdir("/usr/sbin") +posix.symlink("bin", "/usr/sbin") posix.mkdir("/usr/lib") posix.mkdir("/usr/lib/debug") posix.mkdir("/usr/lib/debug/usr/") posix.mkdir("/usr/lib/debug/usr/bin") -posix.mkdir("/usr/lib/debug/usr/sbin") +posix.symlink("bin", "/usr/lib/debug/usr/sbin") posix.mkdir("/usr/lib/debug/usr/lib") posix.mkdir("/usr/lib/debug/usr/%{_lib}") +posix.symlink("bin", "/usr/local/sbin") posix.mkdir("/usr/%{_lib}") posix.symlink("usr/bin", "/bin") posix.symlink("usr/sbin", "/sbin") @@ -187,6 +190,7 @@ end %defattr(0755,root,root,0755) %dir %attr(555,root,root) / /bin +/sbin %attr(555,root,root) /boot %attr(555,root,root) /afs /dev @@ -213,12 +217,12 @@ end %ghost %attr(555,root,root) /proc %attr(550,root,root) /root /run -/sbin /srv %ghost %attr(555,root,root) /sys %attr(1777,root,root) /tmp %dir /usr %attr(555,root,root) /usr/bin +%ghost /usr/sbin /usr/games /usr/include %dir %attr(555,root,root) /usr/lib @@ -251,8 +255,14 @@ end %attr(555,root,root) /usr/lib/pm-utils %endif /usr/libexec -/usr/local -%attr(555,root,root) /usr/sbin +%dir /usr/local +%ghost /usr/local/sbin +/usr/local/etc +/usr/local/games +/usr/local/include +/usr/local/lib* +/usr/local/share +/usr/local/src %dir /usr/share /usr/share/aclocal /usr/share/appdata