Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[packaging] Prefer /usr/{,s}bin for binaries and symlinks.
Old /bin symlinks are preserved for compatibility. Move busybox and
busybox-static to /usr/bin.
  • Loading branch information
Tomin1 committed Aug 21, 2019
1 parent dc8726d commit cf9bc55
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 9 deletions.
77 changes: 77 additions & 0 deletions rpm/0002-applets-Busybox-in-usr-bin-instead-of-bin.patch
@@ -0,0 +1,77 @@
From 473e5c4022bc0e3c793063ed5002b40fca988ee3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomi=20Lepp=C3=A4nen?= <tomi.leppanen@jolla.com>
Date: Fri, 16 Aug 2019 11:51:33 +0300
Subject: [PATCH] applets: Busybox in /usr/bin instead of /bin

---
applets/install.sh | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/applets/install.sh b/applets/install.sh
index 415896893..2b73f1a02 100755
--- a/applets/install.sh
+++ b/applets/install.sh
@@ -60,8 +60,8 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ x"$DO_INSTALL_LIBS" != x"n" ]; then
done
fi

-if [ x"$cleanup" = x"1" ] && [ -e "$prefix/bin/busybox" ]; then
- inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'`
+if [ x"$cleanup" = x"1" ] && [ -e "$prefix/usr/bin/busybox" ]; then
+ inode=`ls -i "$prefix/usr/bin/busybox" | awk '{print $1}'`
sub_shell_it=`
cd "$prefix"
for d in usr/sbin usr/bin sbin bin; do
@@ -76,9 +76,9 @@ if [ x"$cleanup" = x"1" ] && [ -e "$prefix/bin/busybox" ]; then
exit 0
fi

-rm -f "$prefix/bin/busybox" || exit 1
-mkdir -p "$prefix/bin" || exit 1
-install -m 755 busybox "$prefix/bin/busybox" || exit 1
+rm -f "$prefix/usr/bin/busybox" || exit 1
+mkdir -p "$prefix/usr/bin" || exit 1
+install -m 755 busybox "$prefix/usr/bin/busybox" || exit 1

for i in $h; do
appdir=`dirname "$i"`
@@ -93,7 +93,7 @@ for i in $h; do
ln $linkopts busybox "$prefix/$i" || exit 1
else
rm -f "$prefix/$i"
- echo "#!/bin/busybox" >"$prefix/$i"
+ echo "#!/usr/bin/busybox" >"$prefix/$i"
chmod +x "$prefix/$i"
fi
echo " $prefix/$i"
@@ -108,20 +108,20 @@ for i in $h; do
fi
else
if [ x"$linkopts" = x"-f" ]; then
- bb_path="$prefix/bin/busybox"
+ bb_path="$prefix/usr/bin/busybox"
else
case "$appdir" in
/)
- bb_path="bin/busybox"
+ bb_path="usr/bin/busybox"
;;
- /bin)
+ /usr/bin)
bb_path="busybox"
;;
- /sbin)
- bb_path="../bin/busybox"
+ /usr/sbin)
+ bb_path="../bin/busybox"
;;
- /usr/bin | /usr/sbin)
- bb_path="../../bin/busybox"
+ /bin | /sbin)
+ bb_path="../usr/bin/busybox"
;;
*)
echo "Unknown installation directory: $appdir"
--
2.21.0

42 changes: 33 additions & 9 deletions rpm/busybox.spec
Expand Up @@ -9,6 +9,7 @@ Source1: rpm/udhcpd.service
Source2: busybox-static.config
Source3: busybox-sailfish.config
Patch0: 0001-Copy-extended-attributes-if-p-flag-is-provided-to-cp.patch
Patch1: 0002-applets-Busybox-in-usr-bin-instead-of-bin.patch
URL: https://git.sailfishos.org/mer-core/busybox

Obsoletes: time <= 1.7
Expand Down Expand Up @@ -174,6 +175,7 @@ is the symlink implementing which replacement.
%prep
%setup -q -n %{name}-%{version}/upstream
%patch0 -p1
%patch1 -p1

%build
# TODO: This config should be synced with the dynamic config at some point
Expand All @@ -193,42 +195,58 @@ cp %{SOURCE3} .config
yes "" | make oldconfig
make %{_smp_mflags}
make busybox.links
# /bin links are legacy, use /usr/bin whenever you can
cat >> busybox.links << EOF
/bin/busybox
%{_bindir}/ping
%{_bindir}/ping6
%{_sbindir}/mkdosfs
%{_sbindir}/mkfs.vfat
%{_bindir}/gzip
%{_bindir}/gunzip
/usr/sbin/udhcpc
%{_bindir}/zcat
%{_sbindir}/udhcpc
/bin/find
%{_bindir}/grep
%{_bindir}/egrep
%{_bindir}/fgrep
%{_bindir}/cpio
%{_bindir}/tar
EOF

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/bin
install -m 755 busybox %{buildroot}/bin/busybox
mkdir -p %{buildroot}/usr/bin
install -m 755 busybox %{buildroot}/usr/bin/busybox
install -m 644 -D %{SOURCE1} %{buildroot}/lib/systemd/system/udhcpd.service
applets/install.sh %{buildroot} --symlinks
rm -f %{buildroot}/sbin/udhcpc

install -m 755 busybox-static %{buildroot}/bin/busybox-static
install -m 755 busybox-static %{buildroot}/usr/bin/busybox-static
ln -s ../usr/bin/busybox-static %{buildroot}/bin/busybox-static
mkdir -p %{buildroot}/%{_docdir}/%{name}-%{version}
install -m 644 -t %{buildroot}/%{_docdir}/%{name}-%{version} \
docs/BusyBox.html docs/BusyBox.txt
docs/BusyBox.html docs/BusyBox.txt

%files
%defattr(-,root,root,-)
%license LICENSE
/bin/busybox
%{_bindir}/busybox
/bin/ping
%{_bindir}/ping
/bin/ping6
%{_bindir}/ping6
%{_bindir}/time
%{_bindir}/traceroute
%{_bindir}/traceroute6
/usr/sbin/arping
%{_sbindir}/arping

%files static
%defattr(-,root,root,-)
/bin/busybox-static
%{_bindir}/busybox-static

%files doc
%defattr(-,root,root,-)
Expand All @@ -237,7 +255,9 @@ install -m 644 -t %{buildroot}/%{_docdir}/%{name}-%{version} \
%files symlinks-dosfstools
%defattr(-,root,root,-)
/sbin/mkdosfs
%{_sbindir}/mkdosfs
/sbin/mkfs.vfat
%{_sbindir}/mkfs.vfat

%files symlinks-gzip
%defattr(-,root,root,-)
Expand All @@ -246,11 +266,12 @@ install -m 644 -t %{buildroot}/%{_docdir}/%{name}-%{version} \
/bin/gzip
%{_bindir}/gzip
/bin/zcat
%{_bindir}/zcat

%files symlinks-dhcp
%defattr(-,root,root,-)
/usr/sbin/udhcpc
/usr/sbin/udhcpd
%{_sbindir}/udhcpc
%{_sbindir}/udhcpd
/lib/systemd/system/udhcpd.service

%files symlinks-diffutils
Expand All @@ -267,18 +288,21 @@ install -m 644 -t %{buildroot}/%{_docdir}/%{name}-%{version} \
%files symlinks-grep
%defattr(-,root,root,-)
/bin/grep
%{_bindir}/grep
/bin/egrep
%{_bindir}/egrep
/bin/fgrep
%{_bindir}/fgrep

%files symlinks-cpio
%defattr(-,root,root,-)
%{_bindir}/cpio
/bin/cpio
%{_bindir}/cpio

%files symlinks-tar
%defattr(-,root,root,-)
%{_bindir}/tar
/bin/tar
%{_bindir}/tar

%files symlinks-which
%defattr(-,root,root,-)
Expand Down

0 comments on commit cf9bc55

Please sign in to comment.