Maintenance will be performed on git.ligo.org, chat.ligo.org, containers.ligo.org, and docs.ligo.org on the morning of Tuesday 11th August 2020, starting at approximately 9am PDT. It is expected to take around 20 minutes and there will be a short period of downtime (less than five minutes) towards the end of the maintenance window. Please direct any comments, questions, or concerns to computing-help@ligo.org.

build.py 2.77 KB
Newer Older
Daniel Brown's avatar
Daniel Brown committed
1
import os
Daniel Brown's avatar
Daniel Brown committed
2 3 4 5 6 7 8 9 10 11
import textwrap

from subprocess import call, check_output

from collections import defaultdict
import string

class SafeDict(dict):
    def __missing__(self, key):
        return '{' + key + '}'
Daniel Brown's avatar
Daniel Brown committed
12 13 14 15

os.chdir("/root/finesse")

call("git pull".split())
Daniel Brown's avatar
Daniel Brown committed
16 17 18

git_describe = str(check_output('git describe --tags'.split())).split("-")

Daniel Brown's avatar
Daniel Brown committed
19 20 21 22
call("./finesse.sh --build".split())

os.chdir("/root/finesse/packaging/rpm")

Daniel Brown's avatar
Daniel Brown committed
23 24
for d in "RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp".split(","):
    call("mkdir -p rpmbuild/{d}".format(d=d).split())
Daniel Brown's avatar
Daniel Brown committed
25

Daniel Brown's avatar
Daniel Brown committed
26 27 28
with open("/root/.rpmmacros", "w") as f:
    f.write("%_topdir   /root/finesse/packaging/rpm/rpmbuild\n")
    f.write("%_tmppath  %{_topdir}/tmp\n")
Daniel Brown's avatar
Daniel Brown committed
29 30 31

os.chdir("/root/finesse/packaging/rpm/rpmbuild")

Daniel Brown's avatar
Daniel Brown committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
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}
Daniel Brown's avatar
Daniel Brown committed
56
            Requires: gsl
Daniel Brown's avatar
Daniel Brown committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
            License: GPL
            Group: Development/Tools
            SOURCE0 : %{name}-%{{version}}-%{{release}}.tar.gz
            URL: http://gwoptics.org/finesse

            BuildRoot: %{_tmppath}/%{name}-%{{version}}-%{{release}}-root

            %description
            %{summary}

            %prep
            %setup -q

            %build
            # Empty section.

            %install
            rm -rf %{buildroot}
            mkdir -p  %{buildroot}

            # in builddir
            cp -a * %{buildroot}


            %clean
            rm -rf %{buildroot}


            %files
            %defattr(-,root,root,-)
            %{_sysconfdir}/%{name}/kat.ini
            %{_bindir}/*

            %changelog
            """), (), SafeDict(**vals))
            
    f.write(s)
            
call("rpmbuild -bb SPECS/finesse.spec".split())

Daniel Brown's avatar
Daniel Brown committed
97
call("cp /root/finesse/packaging/rpm/rpmbuild/RPMS/x86_64/finesse-{version}-{release}.x86_64.rpm /host".format(**vals).split())