Again rpm provides a great macro in this section, but you can use whatever scripts you want to move the files. The root directory for your fake filesystem is in the variable $RPM_BUILD_ROOT. Consider this a blank canvas. If you want to put a file in /usr/bin, you have to create $RPM_BUILD_ROOT/usr/bin in your %install section. In our example, we only need use the %makeinstall macro. This macro do a make install with appropriate options, including setting the prefix and installdir variables for you.
%install %makeinstallWhen we run rpmbuild this time, we should see the files being built, and then installed into $RPM_BUILD_ROOT.
[build@client11 SPECS]$ rpmbuild -bb tar.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.14568
+ umask 022
+ cd /home/build/rpmbuild/BUILD
+ cd /home/build/rpmbuild/BUILD
+ rm -rf tar-1.22
+ /usr/bin/bzip2 -dc /home/build/rpmbuild/SOURCES/tar-1.22.tar.bz2
...
+ ./configure --host=x86_64-redhat-linux-gnu --build=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/usr/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/usr/var --sharedstatedir=/usr/com --mandir=/usr/man --infodir=/usr/info
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
...
installing zh_TW.gmo as /tmp/tar-1.22/usr/share/locale/zh_TW/LC_MESSAGES/tar.mo
if test "tar" = "gettext-tools"; then \
/bin/mkdir -p /tmp/tar-1.22/usr/share/gettext/po; \
for file in Makefile.in.in remove-potcdate.sin quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot Makevars.template; do \
/usr/bin/install -c -m 644 ./$file \
/tmp/tar-1.22/usr/share/gettext/po/$file; \
done; \
for file in Makevars; do \
rm -f /tmp/tar-1.22/usr/share/gettext/po/$file; \
done; \
else \
: ; \
fi
make[1]: Leaving directory `/home/build/rpmbuild/BUILD/tar-1.22/po'
Making install in tests
make[1]: Entering directory `/home/build/rpmbuild/BUILD/tar-1.22/tests'
make[2]: Entering directory `/home/build/rpmbuild/BUILD/tar-1.22/tests'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/build/rpmbuild/BUILD/tar-1.22/tests'
make[1]: Leaving directory `/home/build/rpmbuild/BUILD/tar-1.22/tests'
make[1]: Entering directory `/home/build/rpmbuild/BUILD/tar-1.22'
make[2]: Entering directory `/home/build/rpmbuild/BUILD/tar-1.22'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/build/rpmbuild/BUILD/tar-1.22'
make[1]: Leaving directory `/home/build/rpmbuild/BUILD/tar-1.22'
+ exit 0
Checking for unpackaged file(s): /usr/lib/rpm/check-files /tmp/tar-1.22
error: Installed (but unpackaged) file(s) found:
/usr/bin/tar
/usr/info/tar.info
/usr/info/tar.info-1
/usr/info/tar.info-2
/usr/libexec/rmt
/usr/share/locale/bg/LC_MESSAGES/tar.mo
...
RPM build errors:
Installed (but unpackaged) file(s) found:
/usr/bin/tar
/usr/info/tar.info
/usr/info/tar.info-1
...
We haven't defined any files installed by this package, but our %install section created many files. We can look at them by looking in the BuildRoot directory.
[build@client11 SPECS]$ find /tmp/tar-1.22/ |head /tmp/tar-1.22/ /tmp/tar-1.22/usr /tmp/tar-1.22/usr/sbin /tmp/tar-1.22/usr/share /tmp/tar-1.22/usr/share/locale /tmp/tar-1.22/usr/share/locale/pl /tmp/tar-1.22/usr/share/locale/pl/LC_MESSAGES /tmp/tar-1.22/usr/share/locale/pl/LC_MESSAGES/tar.mo /tmp/tar-1.22/usr/share/locale/ky /tmp/tar-1.22/usr/share/locale/ky/LC_MESSAGESWe need to tell rpm what we want done with these files, we'll do that next.