Skip to content

Commit

Permalink
Do not fail on files that exist in RPM DB but not on filesystem
Browse files Browse the repository at this point in the history
Files that are recorded in the RPM package with the %ghost directive.

Also utilize the %dir directive to fix the "File listed twice" warnings
which in turn requires to prevent python-bytecompiling and other
__os_install_post actions that would produce new files leading to
"Installed (but unpackaged) file(s) found" error.
  • Loading branch information
martyone authored and lbt committed Jul 5, 2018
1 parent dc8f06f commit ec263ff
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions sb2-tools-template.spec
@@ -1,8 +1,8 @@
%define __strip /bin/true
%define packages_in_tools autoconf automake bash binutils 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 groff gzip kernel-headers libacl libarchive libattr libblkid libcap libcap libcurl libgcc libgomp libicu52 libidn liblua libmount libsb2 libsmartcols libstdc++ libuuid libxml2 m4 make mpc mpfr ncurses-libs net-tools nspr nss 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 tar util-linux xz xz-libs zip zlib
%define cross_compilers cross-@ARCH@-gcc cross-@ARCH@-binutils
%global _python_bytecompile_errors_terminate_build 0
%define _target_cpu @ARCH@
# Prevent stripping, python-bytecompiling etc. as this has been already done for the packages
%global __os_install_post %{nil}

Name: sb2-tools-@ARCH@-inject
Version: 1.0+git3
Expand Down Expand Up @@ -67,10 +67,20 @@ cat > filestoignore << EOF
EOF
grep -vf filestoignore filestoinclude1 | sort | uniq > filestoinclude2
# Copy files to buildroot and preserve permissions.
tar --no-recursion -T filestoinclude2 -cpf - | ( cd %buildroot && fakeroot tar -xvpf - )
# Add quotas around the lines as filenames contain spaces.
sed -i "s/^\(.*\)$/\"\1\"/g" filestoinclude2
cat filestoinclude2
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
# directories to prevent "File listed twice" warnings.
sed -i filesincluded -e '
# First line is special - it is the root directory
1s,^\./$,%%dir /,
t
# Lines ending with / are special - they are directory paths
s,^\(.*\)/$,%%dir "/\1",
t
# Everything else
s,^.*$,"/&",
'
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 @@ -92,7 +102,7 @@ touch %buildroot/etc/sb2-tools-template
%clean
rm -rf $RPM_BUILD_ROOT

%files -f filestoinclude2
%files -f filesincluded
%defattr(-,root,root)
%dir /var/log
%dir /root/
Expand Down

0 comments on commit ec263ff

Please sign in to comment.