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

rpm packaging script

parent 45e94d6f
...@@ -6,6 +6,4 @@ RUN yum -y update ...@@ -6,6 +6,4 @@ RUN yum -y update
RUN yum -y install git rpm-build gcc gsl-devel make gcc-c++ RUN yum -y install git rpm-build gcc gsl-devel make gcc-c++
RUN git clone RUN git clone
ADD . /host CMD ["python", "/host/"]
\ No newline at end of file
ENTRYPOINT "python /root/finesse/packaging/rpm/"
\ No newline at end of file
...@@ -3,3 +3,5 @@ Builds an RPM package for the Finesse binary ...@@ -3,3 +3,5 @@ Builds an RPM package for the Finesse binary
Build docker image first: Build docker image first:
docker build -t finesse/sl7 . 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 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 + '}'
os.chdir("/root/finesse") os.chdir("/root/finesse")
call("git pull".split()) call("git pull".split())
git_describe = str(check_output('git describe --tags'.split())).split("-")
call("./ --build".split()) call("./ --build".split())
os.chdir("/root/finesse/packaging/rpm") os.chdir("/root/finesse/packaging/rpm")
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: with open("/root/.rpmmacros", "w") as f:
file.write(""" f.write("%_topdir /root/finesse/packaging/rpm/rpmbuild\n")
%_topdir %(echo $HOME)/rpmbuild f.write("%_tmppath %{_topdir}/tmp\n")
%_tmppath %{_topdir}/tmp
os.chdir("/root/finesse/packaging/rpm/rpmbuild") os.chdir("/root/finesse/packaging/rpm/rpmbuild")
# mkdir finesse-{version} vals = {
# mkdir -p finesse-{version}/usr/bin "version": git_describe[0],
# mkdir -p finesse-{version}/etc/finesse "release": git_describe[1],
# 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/ call('mkdir -p finesse-{version}'.format(**vals).split())
\ No newline at end of file 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