Skip to content

Commit 38a451c

Browse files
committed
trivial commit
Signed-off-by: Vanessa Sochat <[email protected]>
1 parent 935fe52 commit 38a451c

File tree

5 files changed

+321
-24
lines changed

5 files changed

+321
-24
lines changed

setup.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
import codecs
2323
import os
2424

25-
##########################################################################################
26-
# HELPER FUNCTIONS #######################################################################
27-
##########################################################################################
25+
################################################################################
26+
# HELPER FUNCTIONS #############################################################
27+
################################################################################
2828

2929
def get_lookup():
3030
'''get version by way of singularity.version, returns a
31-
lookup dictionary with several global variables without
32-
needing to import singularity
31+
lookup dictionary with several global variables without
32+
needing to import singularity
3333
'''
3434
lookup = dict()
3535
version_file = os.path.join('singularity', 'version.py')
@@ -41,7 +41,8 @@ def get_lookup():
4141
# Read in requirements
4242
def get_reqs(lookup=None, key='INSTALL_REQUIRES'):
4343
'''get requirements, mean reading in requirements and versions from
44-
the lookup obtained with get_lookup'''
44+
the lookup obtained with get_lookup
45+
'''
4546

4647
if lookup == None:
4748
lookup = get_lookup()
@@ -76,12 +77,10 @@ def get_reqs(lookup=None, key='INSTALL_REQUIRES'):
7677
KEYWORDS = lookup['KEYWORDS']
7778
DESCRIPTION = lookup['DESCRIPTION']
7879
LICENSE = lookup['LICENSE']
79-
with open('README.md') as filey:
80-
LONG_DESCRIPTION = filey.read()
8180

82-
##########################################################################################
83-
# MAIN ###################################################################################
84-
##########################################################################################
81+
################################################################################
82+
# MAIN #########################################################################
83+
################################################################################
8584

8685

8786
if __name__ == "__main__":
@@ -106,7 +105,6 @@ def get_reqs(lookup=None, key='INSTALL_REQUIRES'):
106105
url=PACKAGE_URL,
107106
license=LICENSE,
108107
description=DESCRIPTION,
109-
long_description=LONG_DESCRIPTION,
110108
keywords=KEYWORDS,
111109
install_requires = INSTALL_REQUIRES,
112110
extras_require={
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
################################################################################
4+
# Build Latest, only runs build without updating software
5+
# For Google cloud, Stackdriver/logging should have Write,
6+
# Google Storage should have Full
7+
# All other APIs None,
8+
#
9+
#
10+
# Copyright (C) 2016-2019 Vanessa Sochat.
11+
#
12+
# This program is free software: you can redistribute it and/or modify it
13+
# under the terms of the GNU Affero General Public License as published by
14+
# the Free Software Foundation, either version 3 of the License, or (at your
15+
# option) any later version.
16+
#
17+
# This program is distributed in the hope that it will be useful, but WITHOUT
18+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
20+
# License for more details.
21+
#
22+
# You should have received a copy of the GNU Affero General Public License
23+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
24+
#
25+
################################################################################
26+
27+
echo "Start Time: $(date)." > /tmp/.shub-log 2>&1
28+
timeout -s KILL 2h sudo python3 -c "from singularity.build.google import run_build; run_build()" >> /tmp/.shub-log 2>&1
29+
ret=$?
30+
31+
echo "Return value of ${ret}." >> /tmp/.shub-log 2>&1
32+
33+
if [ $ret -eq 137 ]
34+
then
35+
echo "Killed: $(date)." >> /tmp/.shub-log 2>&1
36+
else
37+
echo "End Time: $(date)." >> /tmp/.shub-log 2>&1
38+
fi
39+
40+
# Finish by sending log
41+
sudo python3 -c "from singularity.build.google import finish_build; finish_build()"

singularity/build/scripts/singularity-build-latest.sh

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,134 @@
2424
#
2525
################################################################################
2626

27+
SINGULARITY_libexecdir="/usr/local/libexec/singularity"
28+
SINGULARITY_PATH="/usr/local/bin"
29+
SECBUILD_IMAGE="$SINGULARITY_libexecdir/singularity/secure-build/secbuild.sif"
30+
31+
# Set the isolated root
32+
if [ -z "${SINGULARITY_ISOLATED_ROOT:-}" ]; then
33+
BUILDDEF_DIR_NAME=$(dirname ${SINGULARITY_BUILDDEF:-})
34+
else
35+
BUILDDEF_DIR_NAME=$(readlink -f ${SINGULARITY_ISOLATED_ROOT:-})
36+
fi
37+
BUILDDEF_DIR=$(readlink -f ${BUILDDEF_DIR_NAME:-})
38+
39+
if [ -z "${BUILDDEF_DIR:-}" ]; then
40+
message ERROR "Can't find parent directory of $SINGULARITY_BUILDDEF\n"
41+
exit 1
42+
fi
43+
44+
BUILDDEF=$(basename ${SINGULARITY_BUILDDEF:-})
45+
46+
# create a temporary dir per build instance
47+
export SINGULARITY_WORKDIR=$(mktemp -d)
48+
49+
# create /tmp and /var/tmp into WORKDIR
50+
mkdir -p $SINGULARITY_WORKDIR/tmp $SINGULARITY_WORKDIR/var_tmp
51+
52+
# set sticky bit for these directories
53+
chmod 1777 $SINGULARITY_WORKDIR/tmp
54+
chmod 1777 $SINGULARITY_WORKDIR/var_tmp
55+
56+
# setup a fake root directory
57+
cp -a /etc/skel $SINGULARITY_WORKDIR/root
58+
59+
cat > "$SINGULARITY_WORKDIR/root/.rpmmacros" << RPMMAC
60+
%_var /var
61+
%_dbpath %{_var}/lib/rpm
62+
RPMMAC
63+
64+
REPO_DIR="/root/repo"
65+
STAGED_BUILD_IMAGE="/root/build"
66+
67+
mkdir ${SINGULARITY_WORKDIR}${REPO_DIR}
68+
mkdir ${SINGULARITY_WORKDIR}${STAGED_BUILD_IMAGE}
69+
70+
BUILD_SCRIPT="$SINGULARITY_WORKDIR/tmp/build-script"
71+
TMP_CONF_FILE="$SINGULARITY_WORKDIR/tmp.conf"
72+
FSTAB_FILE="$SINGULARITY_WORKDIR/fstab"
73+
RESOLV_CONF="$SINGULARITY_WORKDIR/resolv.conf"
74+
HOSTS_FILE="$SINGULARITY_WORKDIR/hosts"
75+
76+
cp /etc/resolv.conf $RESOLV_CONF
77+
cp /etc/hosts $HOSTS_FILE
78+
79+
cat > "$FSTAB_FILE" << FSTAB
80+
none $STAGED_BUILD_IMAGE bind dev 0 0
81+
FSTAB
82+
83+
cat > "$TMP_CONF_FILE" << CONF
84+
config passwd = no
85+
config group = no
86+
config resolv_conf = no
87+
mount proc = no
88+
mount sys = no
89+
mount home = no
90+
mount dev = minimal
91+
mount devpts = no
92+
mount tmp = no
93+
enable overlay = no
94+
user bind control = no
95+
bind path = $SINGULARITY_WORKDIR/root:/root
96+
bind path = $SINGULARITY_WORKDIR/tmp:/tmp
97+
bind path = $SINGULARITY_WORKDIR/var_tmp:/var/tmp
98+
bind path = $SINGULARITY_ROOTFS:$STAGED_BUILD_IMAGE
99+
bind path = $BUILDDEF_DIR:$REPO_DIR
100+
bind path = $FSTAB_FILE:/etc/fstab
101+
bind path = $RESOLV_CONF:/etc/resolv.conf
102+
bind path = $HOSTS_FILE:/etc/hosts
103+
root default capabilities = default
104+
allow user capabilities = no
105+
CONF
106+
107+
# here build pre-stage
108+
cat > "$BUILD_SCRIPT" << SCRIPT
109+
#!/bin/sh
110+
mount -r --no-mtab -t proc proc /proc
111+
if [ \$? != 0 ]; then
112+
echo "Can't mount /proc directory"
113+
exit 1
114+
fi
115+
mount -r --no-mtab -t sysfs sysfs /sys
116+
if [ \$? != 0 ]; then
117+
echo "Can't mount /sys directory"
118+
exit 1
119+
fi
120+
mount -o remount,dev $STAGED_BUILD_IMAGE
121+
if [ \$? != 0 ]; then
122+
echo "Can't remount $STAGED_BUILD_IMAGE"
123+
exit 1
124+
fi
125+
cd $REPO_DIR
126+
singularity build --sandbox $STAGED_BUILD_IMAGE $BUILDDEF
127+
exit \$?
128+
SCRIPT
129+
130+
chmod +x $BUILD_SCRIPT
131+
132+
unset SINGULARITY_IMAGE
133+
unset SINGULARITY_NO_PRIVS
134+
unset SINGULARITY_KEEP_PRIVS
135+
unset SINGULARITY_ADD_CAPS
136+
unset SINGULARITY_DROP_CAPS
137+
138+
${SINGULARITY_bindir}/singularity -c $TMP_CONF_FILE exec -e -i -p $SECBUILD_IMAGE /tmp/build-script
139+
if [ $? != 0 ]; then
140+
rm -rf $SINGULARITY_WORKDIR
141+
exit 1
142+
fi
143+
144+
rm -rf $SINGULARITY_WORKDIR
145+
146+
147+
148+
149+
150+
151+
152+
153+
154+
27155
echo "Start Time: $(date)." > /tmp/.shub-log 2>&1
28156
timeout -s KILL 2h sudo python3 -c "from singularity.build.google import run_build; run_build()" >> /tmp/.shub-log 2>&1
29157
ret=$?
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
################################################################################
4+
# Instance Preparation
5+
# For Google cloud, Stackdriver/logging should have Write,
6+
# Google Storage should have Full
7+
# All other APIs None,
8+
#
9+
# Copyright (C) 2016-2019 Vanessa Sochat.
10+
#
11+
# This program is free software: you can redistribute it and/or modify it
12+
# under the terms of the GNU Affero General Public License as published by
13+
# the Free Software Foundation, either version 3 of the License, or (at your
14+
# option) any later version.
15+
#
16+
# This program is distributed in the hope that it will be useful, but WITHOUT
17+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
19+
# License for more details.
20+
#
21+
# You should have received a copy of the GNU Affero General Public License
22+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
23+
#
24+
################################################################################
25+
26+
sudo apt-get update &&
27+
sudo apt-get -y install git \
28+
build-essential \
29+
libtool \
30+
squashfs-tools \
31+
autotools-dev \
32+
libarchive-dev \
33+
automake \
34+
autoconf \
35+
debootstrap \
36+
yum \
37+
uuid-dev \
38+
zypper \
39+
libssl-dev \
40+
python3-pip
41+
42+
43+
# Pip3 installs
44+
sudo pip3 install --upgrade pip &&
45+
sudo pip3 install pyasn1-modules -U &&
46+
sudo pip3 install --upgrade google-api-python-client &&
47+
sudo pip3 install --upgrade google &&
48+
sudo pip3 install oauth2client==3.0.0
49+
50+
# Install Singularity from Github
51+
52+
cd /tmp && git clone -b feature-squashbuild-secbuild-2.5.0 https://github.com/cclerget/singularity.git &&
53+
cd /tmp/singularity && ./autogen.sh && ./configure --prefix=/usr/local && make && sudo make install && sudo make secbuildimg
54+
55+
# Singularity python development
56+
cd /tmp && git clone -b v2.5 https://www.github.com/vsoch/singularity-python.git &&
57+
cd /tmp/singularity-python && sudo python3 setup.py install

0 commit comments

Comments
 (0)