Skip to content

Commit

Permalink
[sb2-tools] Support the /usr merge. Contributes to JB#36606
Browse files Browse the repository at this point in the history
Remove  rpmlint-mini from the packages
Add a changes entry
Handle the /bin /lib /sbin symlinks properly

Signed-off-by: David Greaves <david.greaves@jolla.com>
  • Loading branch information
lbt committed Jan 22, 2020
1 parent f169245 commit b97dcd7
Show file tree
Hide file tree
Showing 10 changed files with 436 additions and 45 deletions.
53 changes: 48 additions & 5 deletions sb2-tools-aarch64.spec
@@ -1,14 +1,15 @@
# busybox is included because busybox-symlinks-which needs it
# busybox-symlinks-which provides which
# libselinux is needed by busybox
%define packages_in_tools autoconf automake bash binutils busybox busybox-symlinks-which bzip2 bzip2-libs ccache cmake coreutils cpio cpp db4 diffutils doxygen elfutils elfutils-libelf elfutils-libs expat fakeroot fdupes file file-libs filesystem findutils fontconfig freetype gawk gcc glib2 glibc glibc-common glibc-devel glibc-headers gmp grep gzip kernel-headers libacl libarchive libattr libblkid libcap libcap libcurl libgcc libgomp libicu libidn liblua libmount libsb2 libselinux libsmartcols libstdc++ libuuid libxml2 m4 make mpc mpfr ncurses-libs net-tools nspr nss nss-pem nss-softokn-freebl openssl-libs pam pcre perl perl-libs perl-Scalar-List-Utils perl-threads perl-threads-shared popt python python-libs qemu-usermode readline rpm rpm-build rpm-devel rpm-libs rpmlint-mini scratchbox2 sed setup sqlite-libs tar util-linux xz xz-libs zip zlib
%define packages_in_tools autoconf automake bash binutils busybox busybox-symlinks-which bzip2 bzip2-libs ccache cmake coreutils cpio cpp db4 diffutils doxygen elfutils elfutils-libelf elfutils-libs expat fakeroot fdupes file file-libs filesystem findutils fontconfig freetype gawk gcc glib2 glibc glibc-common glibc-devel glibc-headers gmp grep gzip kernel-headers libacl libarchive libattr libblkid libcap libcap libcurl libgcc libgomp libicu libidn liblua libmount libsb2 libselinux libsmartcols libstdc++ libuuid libxml2 m4 make mpc mpfr ncurses-libs net-tools nspr nss nss-pem nss-softokn-freebl openssl-libs pam pcre perl perl-libs perl-Scalar-List-Utils perl-threads perl-threads-shared popt python python-libs qemu-usermode readline rpm rpm-build rpm-devel rpm-libs scratchbox2 sed setup sqlite-libs tar util-linux xz xz-libs zip zlib

%define cross_compilers cross-aarch64-gcc cross-aarch64-binutils
%define _target_cpu aarch64
# Prevent stripping, python-bytecompiling etc. as this has been already done for the packages
%global __os_install_post %{nil}

Name: sb2-tools-aarch64-inject
Version: 1.0+git10
Version: 1.0+git11
Release: 1
AutoReqProv: 0
BuildRequires: rpm grep tar patchelf sed
Expand Down Expand Up @@ -37,14 +38,27 @@ Group: Development/Tools
This is a package providing %packages_in_tools %cross_compilers for SB2 tools directory
It is not intended to be used in a normal system!

%package -n sb2-tools-aarch64-filesystem-inject
Summary: Filesystem files for sb2 target
Group: Development/Tools

%description -n sb2-tools-aarch64-filesystem-inject
This is a package providing /bin /lib /sbin symlinks for SB2 tools directory
It is only intended to be used in the preinstall!

%prep

%build

%install

#set +x -e
mkdir -p %buildroot

# We must make the /usr/* dirs to avoid problems when /bin is a symlink to /usr/bin
mkdir -p %buildroot/usr/bin
mkdir -p %buildroot/usr/lib
mkdir -p %buildroot/usr/sbin

# Get a list of all the files in our rpms *according to the rpm DB*
rpm -ql %packages_in_tools %cross_compilers > filestoinclude1
#/var/log contains lots of random data we don't need
sed -i -e '/\/var\/log/d' filestoinclude1
Expand All @@ -66,8 +80,23 @@ cat > filestoignore << EOF
/sbin/unix_update
/var/lock
/var/lock/subsys
/usr/lib/pkgconfig/rpm.pc
/var/lib/rpm/
EOF
# Strip out the files we don't want (note at this point filenames are 'as per rpm DB')
grep -vf filestoignore filestoinclude1 | sort | uniq > filestoinclude2

# At this point the current project should have used a 'filesystem'
# package which runs the lua /usr merge in the post install. So the
# rpm DB doesn't represent on-disk... fix that now:
sed -i filestoinclude2 -e '
s,^/bin,/usr/bin/,
s,^/lib,/usr/lib/,
s,^/sbin,/usr/sbin,'

# Uncomment this to check :)
# cat filestoinclude2

# Copy files to buildroot and preserve permissions.
tar --no-recursion -T filestoinclude2 -cpf - | ( cd %buildroot && fakeroot tar -xvpf - ) > filesincluded
# Add back "/" prefix, add double quotes to protect file names with spaces, use %%dir directive for
Expand All @@ -82,7 +111,10 @@ sed -i filesincluded -e '
# Everything else
s,^.*$,"/&",
'
cat filesincluded
sort -u filesincluded > f.sorted
mv f.sorted filesincluded
# This can allow a check of the rpm DB vs the transformed/installed filelist
# cat filesincluded
sed 's|:.*$|:*:16229:0:99999:7:::|' < /etc/passwd > %{buildroot}/etc/shadow
sed 's|:.*$|:*::|' < /etc/group > %{buildroot}/etc/gshadow
chmod 0400 %buildroot/etc/shadow
Expand All @@ -99,6 +131,11 @@ cat > %{buildroot}/etc/hosts << EOF
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
EOF
touch %buildroot/etc/sb2-tools-template
# Make the symlinks needed for the preinstall to target
# Keep them relative - just in case
ln -s usr/bin %buildroot/bin
ln -s usr/lib %buildroot/lib
ln -s usr/sbin %buildroot/sbin

%clean
rm -rf $RPM_BUILD_ROOT
Expand All @@ -115,3 +152,9 @@ rm -rf $RPM_BUILD_ROOT
%files -n sb2-tools-aarch64-dependency-inject
%defattr(-,root,root)
/etc/sb2-tools-template

%files -n sb2-tools-aarch64-filesystem-inject
%defattr(-,root,root)
/bin
/lib
/sbin
53 changes: 48 additions & 5 deletions sb2-tools-armv6l.spec
@@ -1,14 +1,15 @@
# busybox is included because busybox-symlinks-which needs it
# busybox-symlinks-which provides which
# libselinux is needed by busybox
%define packages_in_tools autoconf automake bash binutils busybox busybox-symlinks-which bzip2 bzip2-libs ccache cmake coreutils cpio cpp db4 diffutils doxygen elfutils elfutils-libelf elfutils-libs expat fakeroot fdupes file file-libs filesystem findutils fontconfig freetype gawk gcc glib2 glibc glibc-common glibc-devel glibc-headers gmp grep gzip kernel-headers libacl libarchive libattr libblkid libcap libcap libcurl libgcc libgomp libicu libidn liblua libmount libsb2 libselinux libsmartcols libstdc++ libuuid libxml2 m4 make mpc mpfr ncurses-libs net-tools nspr nss nss-pem nss-softokn-freebl openssl-libs pam pcre perl perl-libs perl-Scalar-List-Utils perl-threads perl-threads-shared popt python python-libs qemu-usermode readline rpm rpm-build rpm-devel rpm-libs rpmlint-mini scratchbox2 sed setup sqlite-libs tar util-linux xz xz-libs zip zlib
%define packages_in_tools autoconf automake bash binutils busybox busybox-symlinks-which bzip2 bzip2-libs ccache cmake coreutils cpio cpp db4 diffutils doxygen elfutils elfutils-libelf elfutils-libs expat fakeroot fdupes file file-libs filesystem findutils fontconfig freetype gawk gcc glib2 glibc glibc-common glibc-devel glibc-headers gmp grep gzip kernel-headers libacl libarchive libattr libblkid libcap libcap libcurl libgcc libgomp libicu libidn liblua libmount libsb2 libselinux libsmartcols libstdc++ libuuid libxml2 m4 make mpc mpfr ncurses-libs net-tools nspr nss nss-pem nss-softokn-freebl openssl-libs pam pcre perl perl-libs perl-Scalar-List-Utils perl-threads perl-threads-shared popt python python-libs qemu-usermode readline rpm rpm-build rpm-devel rpm-libs scratchbox2 sed setup sqlite-libs tar util-linux xz xz-libs zip zlib

%define cross_compilers cross-armv6l-gcc cross-armv6l-binutils
%define _target_cpu armv6l
# Prevent stripping, python-bytecompiling etc. as this has been already done for the packages
%global __os_install_post %{nil}

Name: sb2-tools-armv6l-inject
Version: 1.0+git10
Version: 1.0+git11
Release: 1
AutoReqProv: 0
BuildRequires: rpm grep tar patchelf sed
Expand Down Expand Up @@ -37,14 +38,27 @@ Group: Development/Tools
This is a package providing %packages_in_tools %cross_compilers for SB2 tools directory
It is not intended to be used in a normal system!

%package -n sb2-tools-aarch64-filesystem-inject
Summary: Filesystem files for sb2 target
Group: Development/Tools

%description -n sb2-tools-aarch64-filesystem-inject
This is a package providing /bin /lib /sbin symlinks for SB2 tools directory
It is only intended to be used in the preinstall!

%prep

%build

%install

#set +x -e
mkdir -p %buildroot

# We must make the /usr/* dirs to avoid problems when /bin is a symlink to /usr/bin
mkdir -p %buildroot/usr/bin
mkdir -p %buildroot/usr/lib
mkdir -p %buildroot/usr/sbin

# Get a list of all the files in our rpms *according to the rpm DB*
rpm -ql %packages_in_tools %cross_compilers > filestoinclude1
#/var/log contains lots of random data we don't need
sed -i -e '/\/var\/log/d' filestoinclude1
Expand All @@ -66,8 +80,23 @@ cat > filestoignore << EOF
/sbin/unix_update
/var/lock
/var/lock/subsys
/usr/lib/pkgconfig/rpm.pc
/var/lib/rpm/
EOF
# Strip out the files we don't want (note at this point filenames are 'as per rpm DB')
grep -vf filestoignore filestoinclude1 | sort | uniq > filestoinclude2

# At this point the current project should have used a 'filesystem'
# package which runs the lua /usr merge in the post install. So the
# rpm DB doesn't represent on-disk... fix that now:
sed -i filestoinclude2 -e '
s,^/bin,/usr/bin/,
s,^/lib,/usr/lib/,
s,^/sbin,/usr/sbin,'

# Uncomment this to check :)
# cat filestoinclude2

# Copy files to buildroot and preserve permissions.
tar --no-recursion -T filestoinclude2 -cpf - | ( cd %buildroot && fakeroot tar -xvpf - ) > filesincluded
# Add back "/" prefix, add double quotes to protect file names with spaces, use %%dir directive for
Expand All @@ -82,7 +111,10 @@ sed -i filesincluded -e '
# Everything else
s,^.*$,"/&",
'
cat filesincluded
sort -u filesincluded > f.sorted
mv f.sorted filesincluded
# This can allow a check of the rpm DB vs the transformed/installed filelist
# cat filesincluded
sed 's|:.*$|:*:16229:0:99999:7:::|' < /etc/passwd > %{buildroot}/etc/shadow
sed 's|:.*$|:*::|' < /etc/group > %{buildroot}/etc/gshadow
chmod 0400 %buildroot/etc/shadow
Expand All @@ -99,6 +131,11 @@ cat > %{buildroot}/etc/hosts << EOF
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
EOF
touch %buildroot/etc/sb2-tools-template
# Make the symlinks needed for the preinstall to target
# Keep them relative - just in case
ln -s usr/bin %buildroot/bin
ln -s usr/lib %buildroot/lib
ln -s usr/sbin %buildroot/sbin

%clean
rm -rf $RPM_BUILD_ROOT
Expand All @@ -115,3 +152,9 @@ rm -rf $RPM_BUILD_ROOT
%files -n sb2-tools-armv6l-dependency-inject
%defattr(-,root,root)
/etc/sb2-tools-template

%files -n sb2-tools-aarch64-filesystem-inject
%defattr(-,root,root)
/bin
/lib
/sbin
53 changes: 48 additions & 5 deletions sb2-tools-armv7hl.spec
@@ -1,14 +1,15 @@
# busybox is included because busybox-symlinks-which needs it
# busybox-symlinks-which provides which
# libselinux is needed by busybox
%define packages_in_tools autoconf automake bash binutils busybox busybox-symlinks-which bzip2 bzip2-libs ccache cmake coreutils cpio cpp db4 diffutils doxygen elfutils elfutils-libelf elfutils-libs expat fakeroot fdupes file file-libs filesystem findutils fontconfig freetype gawk gcc glib2 glibc glibc-common glibc-devel glibc-headers gmp grep gzip kernel-headers libacl libarchive libattr libblkid libcap libcap libcurl libgcc libgomp libicu libidn liblua libmount libsb2 libselinux libsmartcols libstdc++ libuuid libxml2 m4 make mpc mpfr ncurses-libs net-tools nspr nss nss-pem nss-softokn-freebl openssl-libs pam pcre perl perl-libs perl-Scalar-List-Utils perl-threads perl-threads-shared popt python python-libs qemu-usermode readline rpm rpm-build rpm-devel rpm-libs rpmlint-mini scratchbox2 sed setup sqlite-libs tar util-linux xz xz-libs zip zlib
%define packages_in_tools autoconf automake bash binutils busybox busybox-symlinks-which bzip2 bzip2-libs ccache cmake coreutils cpio cpp db4 diffutils doxygen elfutils elfutils-libelf elfutils-libs expat fakeroot fdupes file file-libs filesystem findutils fontconfig freetype gawk gcc glib2 glibc glibc-common glibc-devel glibc-headers gmp grep gzip kernel-headers libacl libarchive libattr libblkid libcap libcap libcurl libgcc libgomp libicu libidn liblua libmount libsb2 libselinux libsmartcols libstdc++ libuuid libxml2 m4 make mpc mpfr ncurses-libs net-tools nspr nss nss-pem nss-softokn-freebl openssl-libs pam pcre perl perl-libs perl-Scalar-List-Utils perl-threads perl-threads-shared popt python python-libs qemu-usermode readline rpm rpm-build rpm-devel rpm-libs scratchbox2 sed setup sqlite-libs tar util-linux xz xz-libs zip zlib

%define cross_compilers cross-armv7hl-gcc cross-armv7hl-binutils
%define _target_cpu armv7hl
# Prevent stripping, python-bytecompiling etc. as this has been already done for the packages
%global __os_install_post %{nil}

Name: sb2-tools-armv7hl-inject
Version: 1.0+git10
Version: 1.0+git11
Release: 1
AutoReqProv: 0
BuildRequires: rpm grep tar patchelf sed
Expand Down Expand Up @@ -37,14 +38,27 @@ Group: Development/Tools
This is a package providing %packages_in_tools %cross_compilers for SB2 tools directory
It is not intended to be used in a normal system!

%package -n sb2-tools-aarch64-filesystem-inject
Summary: Filesystem files for sb2 target
Group: Development/Tools

%description -n sb2-tools-aarch64-filesystem-inject
This is a package providing /bin /lib /sbin symlinks for SB2 tools directory
It is only intended to be used in the preinstall!

%prep

%build

%install

#set +x -e
mkdir -p %buildroot

# We must make the /usr/* dirs to avoid problems when /bin is a symlink to /usr/bin
mkdir -p %buildroot/usr/bin
mkdir -p %buildroot/usr/lib
mkdir -p %buildroot/usr/sbin

# Get a list of all the files in our rpms *according to the rpm DB*
rpm -ql %packages_in_tools %cross_compilers > filestoinclude1
#/var/log contains lots of random data we don't need
sed -i -e '/\/var\/log/d' filestoinclude1
Expand All @@ -66,8 +80,23 @@ cat > filestoignore << EOF
/sbin/unix_update
/var/lock
/var/lock/subsys
/usr/lib/pkgconfig/rpm.pc
/var/lib/rpm/
EOF
# Strip out the files we don't want (note at this point filenames are 'as per rpm DB')
grep -vf filestoignore filestoinclude1 | sort | uniq > filestoinclude2

# At this point the current project should have used a 'filesystem'
# package which runs the lua /usr merge in the post install. So the
# rpm DB doesn't represent on-disk... fix that now:
sed -i filestoinclude2 -e '
s,^/bin,/usr/bin/,
s,^/lib,/usr/lib/,
s,^/sbin,/usr/sbin,'

# Uncomment this to check :)
# cat filestoinclude2

# Copy files to buildroot and preserve permissions.
tar --no-recursion -T filestoinclude2 -cpf - | ( cd %buildroot && fakeroot tar -xvpf - ) > filesincluded
# Add back "/" prefix, add double quotes to protect file names with spaces, use %%dir directive for
Expand All @@ -82,7 +111,10 @@ sed -i filesincluded -e '
# Everything else
s,^.*$,"/&",
'
cat filesincluded
sort -u filesincluded > f.sorted
mv f.sorted filesincluded
# This can allow a check of the rpm DB vs the transformed/installed filelist
# cat filesincluded
sed 's|:.*$|:*:16229:0:99999:7:::|' < /etc/passwd > %{buildroot}/etc/shadow
sed 's|:.*$|:*::|' < /etc/group > %{buildroot}/etc/gshadow
chmod 0400 %buildroot/etc/shadow
Expand All @@ -99,6 +131,11 @@ cat > %{buildroot}/etc/hosts << EOF
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
EOF
touch %buildroot/etc/sb2-tools-template
# Make the symlinks needed for the preinstall to target
# Keep them relative - just in case
ln -s usr/bin %buildroot/bin
ln -s usr/lib %buildroot/lib
ln -s usr/sbin %buildroot/sbin

%clean
rm -rf $RPM_BUILD_ROOT
Expand All @@ -115,3 +152,9 @@ rm -rf $RPM_BUILD_ROOT
%files -n sb2-tools-armv7hl-dependency-inject
%defattr(-,root,root)
/etc/sb2-tools-template

%files -n sb2-tools-aarch64-filesystem-inject
%defattr(-,root,root)
/bin
/lib
/sbin

0 comments on commit b97dcd7

Please sign in to comment.