Commit 32728bba authored by Daniel Brown's avatar Daniel Brown
Browse files

rpm packaging script

parent 45e94d6f
......@@ -6,6 +6,4 @@ RUN yum -y update
RUN yum -y install git rpm-build gcc gsl-devel make gcc-c++
RUN git clone
ADD . /host
ENTRYPOINT "python /root/finesse/packaging/rpm/"
\ No newline at end of file
CMD ["python", "/host/"]
\ No newline at end of file
......@@ -3,3 +3,5 @@ Builds an RPM package for the Finesse binary
Build docker image first:
docker build -t finesse/sl7 .
To create the rpm package:
docker run -it --volume=${PWD}:/host finesse/sl7
\ No newline at end of file
import os
from subprocess import call
import textwrap
from subprocess import call, check_output
from collections import defaultdict
import string
class SafeDict(dict):
def __missing__(self, key):
return '{' + key + '}'
call("git pull".split())
git_describe = str(check_output('git describe --tags'.split())).split("-")
call("./ --build".split())
call("mkdir -p rpmbuild/{RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp}".split())
for d in "RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp".split(","):
call("mkdir -p rpmbuild/{d}".format(d=d).split())
with open(".rpmmacros") as file:
%_topdir %(echo $HOME)/rpmbuild
%_tmppath %{_topdir}/tmp
with open("/root/.rpmmacros", "w") as f:
f.write("%_topdir /root/finesse/packaging/rpm/rpmbuild\n")
f.write("%_tmppath %{_topdir}/tmp\n")
# mkdir finesse-{version}
# mkdir -p finesse-{version}/usr/bin
# mkdir -p finesse-{version}/etc/finesse
# install -m 755 toybinprog toybinprog-1.0/usr/bin
# install -m 644 toybinprog.conf toybinprog-1.0/etc/toybinprog/
# tar -zcvf toybinprog-1.0.tar.gz toybinprog-1.0/
\ No newline at end of file
vals = {
"version": git_describe[0],
"release": git_describe[1],
call('mkdir -p finesse-{version}'.format(**vals).split())
call('mkdir -p finesse-{version}/usr/bin'.format(**vals).split())
call('mkdir -p finesse-{version}/etc/finesse'.format(**vals).split())
call('cp /root/finesse/kat /root/finesse/packaging/rpm/rpmbuild/finesse-{version}/usr/bin'.format(**vals).split())
call('cp /root/finesse/kat.ini /root/finesse/packaging/rpm/rpmbuild/finesse-{version}/etc/finesse'.format(**vals).split())
call('tar -zcvf ./SOURCES/finesse-{version}-{release}.tar.gz finesse-{version}/'.format(**vals).split())
with open("/root/finesse/packaging/rpm/rpmbuild/SPECS/finesse.spec", "w") as f:
s = string.Formatter().vformat(textwrap.dedent("""
%define __spec_install_post %{nil}
%define debug_package %{nil}
%define __os_install_post %{_dbpath}/brp-compress
Summary: FINESSE: Frequency domain INterfErometer Simulation SoftwarE
Name: finesse
Version: {version}
Release: {release}
License: GPL
Group: Development/Tools
SOURCE0 : %{name}-%{{version}}-%{{release}}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{{version}}-%{{release}}-root
%setup -q
# Empty section.
rm -rf %{buildroot}
mkdir -p %{buildroot}
# in builddir
cp -a * %{buildroot}
rm -rf %{buildroot}
"""), (), SafeDict(**vals))
call("rpmbuild -bb SPECS/finesse.spec".split())
call("cp RPMS/x86_64/finesse-2.2-16.x86_64.rpm /host".split())
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment