how ${buildroot} is created automatically during rpmbuild? - centos6

I want to create the binary rpm files from generated binary packages in centos 6.4 and noticed in one of my build system the ${buildroot} is created automatically, I want to know how it can be achieved.
The sample wget.spec looks like below. detail spec is in my gist https://gist.github.com/larrycai/1ffe134bce1860f1cf87
%install
tar xf ~/wget.tar.gz -C %{buildroot}/
%files
%defattr(-,root,root)
/usr/bin/wget
The wget.tar.gz can be created tar -zcvf ~/wget.tar.gz /usr/bin/wget
When I build it using rpmbuild -bb wget.spec, I got the
+ rpmbuild -bb wget.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.VNDZg4
+ umask 022
+ cd /home/larry/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.S8koPW
+ umask 022
+ cd /home/larry/rpmbuild/BUILD
+ '[' /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64 '!=' / ']'
+ rm -rf /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64
++ dirname /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64
+ mkdir -p /home/larry/rpmbuild/BUILDROOT
+ mkdir /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64
+ LANG=C
+ export LANG
+ unset DISPLAY
+ tar xf /home/larry/wget.tar.gz -C /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64/
+ /usr/lib/rpm/check-buildroot
... (it is successful)
I wonder why line mkdir /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64 is executed automatically.
Are there any script or rpmmacros is enabled for this ?

The main reason is that build machines installed redhat-rpm-config package, the detail list below
This macro setting is in /usr/lib/rpm/redhat/macros
%__spec_install_pre %{___build_pre}\
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\
mkdir -p `dirname "$RPM_BUILD_ROOT"`\
mkdir "$RPM_BUILD_ROOT"\
%{nil}
We can either install this package or put this macros into ~/.rpmmacros
I find it by running command rpmbuild --showrc can see that mkdir code segment is there, so I start to check whether there is special package is installed.

Related

How to skip elf checks when packing AppImage?

I have an AppImage file and want to package it in an rpm package.
Here is my .spec file:
%prep
%clean
rm -rf $RPM_BUILD_ROOT
%install
mkdir -p $RPM_BUILD_ROOT/opt/Movavi/
cp ~/RPM/SOURCES/MyProduct.AppImage $RPM_BUILD_ROOT/opt/MyCompany/
%files
# %doc
/opt/MyCompany/MyProduct.AppImage
When i call rpmbuild -ba ~/RPM/SPECS/MyProduct.spec it throws an error on ELF validation step
Whole output:
Executing(%prep): /bin/sh -e /tmp/rpm-tmp.71228
+ umask 022
+ /bin/mkdir -p /home/user/RPM/BUILD
+ cd /home/user/RPM/BUILD
+ exit 0
Executing(%install): /bin/sh -e /tmp/rpm-tmp.95497
+ umask 022
+ /bin/mkdir -p /home/user/RPM/BUILD
+ cd /home/user/RPM/BUILD
+ /bin/chmod -Rf u+rwX -- /tmp/MyProduct-buildroot
+ /bin/rm -rf -- /tmp/MyProduct-buildroot
+ mkdir -p /tmp/MyProduct-buildroot/opt/MyCompany/
+ cp /home/user/RPM/SOURCES/MyProduct.AppImage /tmp/MyProduct-buildroot/opt/MyCompany/
+ /usr/lib/rpm/brp-alt
Cleaning files in /tmp/MyProduct-buildroot (auto)
Verifying and fixing files in /tmp/MyProduct-buildroot (binconfig,pkgconfig,libtool,desktop)
Checking contents of files in /tmp/MyProduct-buildroot/ (default)
Compressing files in /tmp/MyProduct-buildroot (auto)
056-debuginfo.brp: WARNING: You have 1 stripped ELF objects. Please compile with debugging information!
056-debuginfo.brp: WARNING: An excerpt from the list of affected files follows:
./opt/MyCompany/MyProduct.AppImage
Verifying ELF objects in /tmp/MyProduct-buildroot (arch=normal,fhs=normal,lfs=relaxed,lint=relaxed,rpath=normal,stack=normal,textrel=normal,unresolved=normal)
unsupported ABI version e_ident[8] == 65
e_ident[9] is not zero
e_ident[10] is not zero
verify-elf: WARNING: ./opt/MyCompany/MyProduct.AppImage: eu-elflint failed
ldd: ERROR: ./opt/MyCompany/MyProduct.AppImage: failed to find the program interpreter
verify-elf: ERROR: ./opt/MyCompany/MyProduct.AppImage: ldd failed
error: Bad exit status from /tmp/rpm-tmp.95497 (%install)
RPM build errors:
Bad exit status from /tmp/rpm-tmp.95497 (%install)
Fixed the problem adding %set_verify_elf_method skip at the bottom of the spec file

rpmbuild %install section removes buildroot code. How do I keep rpmbuild from doing this

I am creating a new rpm for a rails app. However the default behavior of the %install section removes the BUILDROOT directory. I assumed that the %install section would install the files from buildroot. I must be doing something wrong because the buildroot is getting removed in the %install section. What is the proper way to do this?
This is the spec file
Summary: Rails APP API (replaces railsapp rpm)
Name: railsapp-api
Version: 6.0.0
Release: 1
License: GPL
URL: http://www.both.org
Group: System
Packager: Tommie Jones
Requires: bash
BuildRoot: ~/rpmbuild/
%description
A rewrite of railsapp from the HTML version to a Http API version
%prep
echo "BUILDROOT = $RPM_BUILD_ROOT"
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/local/veex/railsapp
unzip /home/realworx/rpmbuild/SOURCES/rwx-master.zip -d $RPM_BUILD_ROOT/usr/local/veex/
pushd $RPM_BUILD_ROOT/usr/local/veex/
rm -rf railsapp
mv rwx-master railsapp
pushd $RPM_BUILD_ROOT/usr/local/veex/railsapp
rm Gemfile.lock
bundle install
PWD=`pwd`
cat > gemrc <<EOGEMRC
gemhome: $PWD/vendor/bundle/ruby/1.8
gempath:
- $PWD/vendor/bundle/ruby/1.8
EOGEMRC
gem --config-file ./gemrc install bundler
# Don't need the gemrc any more...
rm ./gemrc
%files
%attr(0744, root, root) /usr/local/veex/railsapp/*
%install
echo %{buildroot}
echo "HELLO"
%clean
echo NOOP
Below is the log where the %install removes the buildroot.
(%install): /bin/sh -e /var/tmp/rpm-tmp.aX3U0b
+ umask 022
+ cd /home/railsapp-api/rpmbuild/BUILD
+ '[' /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch '!=' / ']'
+ rm -rf /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
++ dirname /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
+ mkdir -p /home/railsapp-api/rpmbuild/BUILDROOT
+ mkdir /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
+ echo /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
/home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
+ echo HELLO
HELLO
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-ldconfig
/sbin/ldconfig: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf: No such file or directory
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip /usr/bin/strip
+ /usr/lib/rpm/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/brp-python-bytecompile 1
+ /usr/lib/rpm/brp-python-hardlink
+ PYTHON3=/usr/libexec/platform-python
+ /usr/lib/rpm/redhat/brp-mangle-shebangs
Processing files: railsapp-api-6.0.0-1.noarch
error: File not found: /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch/usr/local/veex/railsapp/*
How do I keep %install from removing my buildroot?
you are misusing the %prep section. In very short how you should use those sections:
%prep: to extract your sources, apply patches etc.
%build: to compile or build your application (if you need to)
%install: to copy the files into $RPM_BUILD_ROOT
So it is logical that $RPM_BUILD_ROOT is emptied at the start of the %isntall section.
Change your code to extract your zip file in %prep, and use the %install section to put the files inside $RPM_BUILD_ROOT.

(WP-CLI) Wordpress-Tests_Lib files not being created

I'm trying to do WordPress Plugin Testing on Ubuntu 14.04 and I'm going through the setup of WP-CLI but I'm not able to download the necessary files (includes/functions.php).
This is the command I'm using:
bash bin/install-wp-tests.sh wordpress_test root '' localhost latest
This is the output:
+ install_wp
+ '[' -d /tmp/wordpress/ ']'
+ return
+ install_test_suite
++ uname -s
+ [[ Linux == \D\a\r\w\i\n ]]
+ local ioption=-i
+ '[' '!' -d /tmp/wordpress-tests-lib ']'
+ cd /tmp/wordpress-tests-lib
+ '[' '!' -f wp-tests-config.php ']'
+ download https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php /tmp/wordpress-tests-lib/wp-tests-config.php
++ which curl
+ '[' /opt/lampp/bin/curl ']'
+ curl -s https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
+ sed -i 's:dirname( __FILE__ ) . '\''/src/'\'':'\''/tmp/wordpress/'\'':' /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i s/youremptytestdbnamehere/wordpress_test/ /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i s/yourusernamehere/root/ /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i s/yourpasswordhere// /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i 's|localhost|localhost|' /tmp/wordpress-tests-lib/wp-tests-config.php
+ install_db
+ PARTS=(${DB_HOST//\:/ })
+ local PARTS
+ local DB_HOSTNAME=localhost
+ local DB_SOCK_OR_PORT=
+ local EXTRA=
+ '[' -z localhost ']'
++ echo
++ grep -e '^[0-9]\{1,\}$'
+ '[' ']'
+ '[' -z ']'
+ '[' -z localhost ']'
+ EXTRA=' --host=localhost --protocol=tcp'
+ mysqladmin create wordpress_test --user=root --password= --host=localhost --protocol=tcp
Warning: Using a password on the command line interface can be insecure.
On using the phpunit command it throws an error:
Fatal error: require_once(): Failed opening required '/tmp/wordpress-tests-lib/includes/functions.php' (include_path='.:/opt/lampp/lib/php')
I'm at the office so I think the firewall could be blocking this command, though I have set a proxy in /etc/environment.
Help is appreciated.
I had this problem and here is what you might try:
Confirm that /tmp/wordpress-tests-lib is missing the includes directory.
Confirm that you have svn installed on the machine. If not run sudo apt-get install subversion
Delete the /tmp/wordpress-tests-lib folder
Inside your plugin directory open up the bin/install-wp-tests.sh file and remove the quiet flag on the Subversion call. Change this line:
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
to
svn co https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
Run the install shell script command again.
You should now be able to run PHPUnit and see the one default test passes.
I was having the same issue; resolved it by following the instructions here: https://github.com/wp-cli/wp-cli/wiki/Plugin-Unit-Tests . Specifically, I needed to initialize the testing environment.
bash bin/install-wp-tests.sh wordpress_test root '' localhost latest
where wordpress_test is test database, root is DB user and '' contains password.
Further Resources:
http://dlh01.info/wcto2014/#/
https://pippinsplugins.com/series/unit-tests-wordpress-plugins/
http://code.tutsplus.com/tutorials/the-beginners-guide-to-unit-testing-what-is-unit-testing--wp-25728

RPMBUILD //SOURCES

I'm trying to build a RPM for barnyard2-1.9, but when I attempt it I receive this error. These are the last few lines of the rpmbuild output:
+ /usr/bin/install -d -p /home/snort/rpm/barnyard2-1.9/tmp/barnyard2-1.9-root/usr/share/doc/barnyard2-1.9/contrib
+ /usr/bin/install -d -p /home/snort/rpm/barnyard2-1.9/tmp/barnyard2-1.9-root/usr/share/man/man8
+ /usr/bin/install -d -p /home/snort/rpm/barnyard2-1.9/tmp/barnyard2-1.9-root/usr/share/doc/barnyard2-1.9/doc
+ /usr/bin/install -m 644 etc/barnyard2.conf /home/snort/rpm/barnyard2-1.9/tmp/barnyard2-1.9-root/etc/snort/
+ /usr/bin/install -m 644 /home/snort/rpm/barnyard2-1.9//SOURCES/barnyard2.config /home/snort/rpm/barnyard2-1.9/tmp/barnyard2-1.9-root/etc/sysconfig/barnyard2
/usr/bin/install: cannot stat `/home/snort/rpm/barnyard2-1.9//SOURCES/barnyard2.config': No such file or directory
error: Bad exit status from /home/snort/rpm/barnyard2-1.9/tmp/rpm-tmp.66176 (%install)
RPM build errors:
Bad exit status from /home/snort/rpm/barnyard2-1.9/tmp/rpm-tmp.66176 (%install)
I'm not sure where it's getting the "//" in "/home/snort/rpm/barnyard2-1.9//SOURCES/barnyard2.config" line.
Here are the top few lines from rpm-tmp.66176 file:
RPM_SOURCE_DIR="/home/snort/rpm/barnyard2-1.9//SOURCES"
RPM_BUILD_DIR="/home/snort/rpm/barnyard2-1.9//BUILD"
RPM_OPT_FLAGS="-O2 -g -m64 -mtune=generic"
RPM_ARCH="x86_64"
RPM_OS="linux"
export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
RPM_DOC_DIR="/usr/share/doc"
export RPM_DOC_DIR
RPM_PACKAGE_NAME="barnyard2"
RPM_PACKAGE_VERSION="1.9"
RPM_PACKAGE_RELEASE="1"
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
RPM_BUILD_ROOT="/home/snort/rpm/barnyard2-1.9/tmp/barnyard2-1.9-root"
export RPM_BUILD_ROOT
PKG_CONFIG_PATH="/usr/lib64/pkgconfig:/usr/share/pkgconfig"
export PKG_CONFIG_PATH
set -x
umask 022
cd "/home/snort/rpm/barnyard2-1.9//BUILD"
Any ideas?
I got it.
In my .rpmmacros file, I had:
%_topdir /home/snort/rpm/barnyard2-1.9/
The last / caused it. I'm not sure how RPM_SOURCE_DIR and %_topdir got connected, but whatever. It's working now.

Newbie rpmbuild error

I'm trying to build my first RPM, but getting an error. My .rpmmarcos files looks like this:
%packager Your Name
%_topdir /home/snort/test
%_tmppath /home/snort/test/tmp
%_smp_mflags -j3
%__arch_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot
When I run: "rpmbuild -v -bb SPECS/test.spec" I receive this error:
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd test-1
/home/snort/test/tmp/rpm-tmp.55712: line 36: cd: test-1: No such file or directory
error: Bad exit status from /home/snort/test/tmp/rpm-tmp.55712 (%prep)
File rpm-tmp.55712 ends with this:
cd '/home/snort/test/BUILD'
rm -rf 'test-1'
/bin/gzip -dc '/home/snort/test/SOURCES/test-1.c55.tar.gz' | tar -xvvf -
STATUS=$?
if [ $STATUS -ne 0 ]; then
exit $STATUS
fi
cd 'test-1'
I'm guessing rpmbuild does the "rm -rf 'test-1'" to remove any old/un-needed directories, then it untar's the test-1.c55.tar.gz file, then tries to "cd test-1" but the untar command doesn't make the directory so the scripts errors out. I'm not sure what to do now.
My spec file: more SPECS/test.spec
Name: test
Version: 1
Release: .c55
Summary: Just a Test
Group: MyJunk
License: GPL
URL: http://www.somesite.com
Source0: test-1.c55.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
This is just a test
<br>
%prep
%setup BUILD
%build<br>
%configure<br>
make %{?_smp_mflags}<br>
%install<br>
rm -rf $RPM_BUILD_ROOT<br>
make install DESTDIR=$RPM_BUILD_ROOT
<br>
%clean<br>
rm -rf $RPM_BUILD_ROOT<br>
%files
%defattr(-,root,root,-)
%doc
%changelog
Any ideas?
Thanks for the Help
Gary
RPM (or, to be exact, %setup macro) expects your source tarbal test-1.c55.... to contain the directory test-1.
If the directory there is different, you can fix that by using
%setup -n yourdir
See http://www.rpm.org/max-rpm/s1-rpm-inside-macros.html for more details.

Resources