2
2
I have a basic RPM question. I don't know very much about RPM building, besides the basic .rpmmacros file, the build directory etc. I work at a company where there is a continuous build server (Jenkins) where the Ops department wants self contained RPMs to be dropped for deployment. This is the first time I've been exposed to this methodology, and so now I need to understand the "nitty gritty" of building an RPM. I feel like if I understand the most basic spirit of the rpmbuild logic, I can take it from there, but have had a difficult time finding tutorials or documentation that elucidate the process.
So, basically I have boiled it down to a simple how do I do these three simple things type question that I think will lift the veil on RPM building.
The starting point is a .spec file, and a couple of files to be deployed.
Name: my-ws
Version: 0.1.0
Release: 1
Summary: A web service to do cool stuff
URL: http://my.ws/
BuildRoot: %{_tmppath}/my-ws-build-root
Requires: some-web-server-such-as-Jetty
%description
my-ws war file and data update script
%prep
%build
%install
%pre
%preun
%postun
%clean
%files
%defattr(-,www-data,www-data,-)
%doc
Now the web service is really comprised of 3 pieces of code: A python script that updates a data file, a .war file that defines the routes and does some calculations in Java, and a cronjob to run the python script once daily and restart a server, possibly Jetty.
So somewhere in this spec file I think i need to code the following logic:
To install this rpm
copy the python script my-ws-update.py to /opt/my-ws/bin and chown it to www-data
copy the war file my-ws.war to /opt/webapps
install a cronjob for www-data to run my-ws-update.py and restart some server
To uninstall this rpm
undo install steps
Starting with an empty spec file I have no idea where to go next. I've tried a few tutorials but none seem to be aimed at this kind of simple, fundamental level. I have a feeling the %files directive is one key to all this, but when I look at other peoples examples, all I see is a list of directories, and its not clear to me how the rpm knows to put file x from path y to file w in path z.
Can anyone help me understand the basic nuts and bolts of doing this? This will be something I need to do many times at least over the next year so help is much appreciated!
A more advanced version of this will eventually be to install the cronjobs at staggered times across servers, to avoid downtime.
Hi, thanks for chiming in. This is helping get closer to the finish line. I'm on Mac OSX btw. so I added to my .spec
Source: myapp.tar.gz
and%setup -q
and%install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_DIR/opt/webapps mkdir -p $RPM_BUILD_DIR/opt/myapp cp -a myapp.war $RPM_BUILD_DIR/opt/webapps cp -a Datafile1.txt $RPM_BUILD_DIR/opt/chrome cp -a Datafile2.txt $RPM_BUILD_DIR/opt/chrome
– David Williams – 2013-05-31T17:51:58.953Then in the %files section
%files %defattr(-,www-data,www-data,-) /opt/webapps/myapp.war /opt/myapp/Datafile1.txt /opt/myapp/Datafile2.txt
– David Williams – 2013-05-31T17:52:44.223I also needed to put the tar.gz in
rpmbuild/SOURCES/myapp.tar.gz
and I tried putting my .spec inrpmbuild/SPECS/myapp.spec
Then I ran$ rpmbuild SPECS/myapp.spec
But it appears that nothing happend: `$ ls rpmbuild/SRPMS/ rpmbuild/RPMS/ rpmbuild/RPMS/:rpmbuild/SRPMS/:` I also dont see a BUILDROOT dir. What am I doing wrong? – David Williams – 2013-05-31T17:56:50.257
Tell rpmbuild what to do via parameters, e.g.
rpmbuild -ba
– ptr – 2013-06-02T07:36:04.413You missed the "-ba" between rpmbuild and the spec file. Did you succeed since your last comment? – ptr – 2013-06-10T13:54:54.570