-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.yaml
92 lines (85 loc) · 3.71 KB
/
common.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
jobs:
# ------------------
- name: Build step 1
lang: shell
typeArgs:
shellPrefix: build1
exec: |
CDIR=`pwd`
FOLDER=/tmp/__oaf_{{os}}_{{arch}}_{{version}}_{{dist}}
echo Preparing $FOLDER...
rm -rf $FOLDER 2> /dev/null
mkdir -p $FOLDER/src
cd $FOLDER/src
{{oafpath}}ojob ojob.io/java/download type=jre os={{os}} arch={{arch}} version={{version}} output=jre.tgz
tar xzf jre.tgz
rm jre.tgz
curl -s https://openaf.io/{{dist}}/openaf.jar.repacked -o openaf.jar
# return CDIR, FOLDER
# ------------------
- name: Build step 3
lang: shell
typeArgs:
shellPrefix: build3
exec: |
cd $FOLDER
{{oafpath}}ojob $CDIR/genSelfExtract.yaml file=oaf path=src setup=ojob tmppath=/tmp/_oaf_{{os}}_{{arch}}_{{version}}_{{dist}}`java -jar src/openaf.jar -c 'printnl(getVersion())'`
rm -rf src
sed -i '3s/.*/[ "$(basename $0)" != "oaf" ] \&\& [ "$(basename $0)" != "ojob" ] \&\& [ "$(basename $0)" != "opack" ] \&\& [ "$(basename $0)" != "oafc" ] \&\& [ "$(basename $0)" != "ojob-sb" ] \&\& [ "$(basename $0)" != "oaf-sb" ] \&\& [ "$(basename $0)" != "oafp" ] \&\& ln -sf "$(realpath $0)" oaf \&\& ln -sf "$(realpath $0)" ojob \&\& ln -sf "$(realpath $0)" opack \&\& ln -sf "$(realpath $0)" oafc \&\& ln -sf "$(realpath $0)" ojob-sb \&\& ln -sf "$(realpath $0)" oaf-sb \&\& ln -sf "$(realpath $0)" oafp \&\& echo "Please use the created symlinks: oaf, ojob, opack, oafc, oafp, oaf-sb or ojob-sb" \&\& exit 0/' oaf
sed -i "2s/.*/if [ ! -e \/bin\/tar ] \&\& [ ! -e \/usr\/bin\/tar ]; then echo 'tar is required!'; exit 1; fi \&\& if [ ! -e \/bin\/gzip ] \&\& [ ! -e \/usr\/bin\/gzip ]; then echo 'gzip is required!'; exit 1; fi \&\& trap 'rm -rf \/tmp\/_oaf_\*\' INT/" oaf
sed -i '9s/.*/cd $CDIR/' oaf
sed -i '10s/.*/sh $TMPDIR\/$(basename $0) "$@"/' oaf
#tar czf $CDIR/{{output}}.tgz .
mkdir -p $(dirname $CDIR/{{output}})
mv oaf $CDIR/{{output}}
# -----------
- name: Build
from:
- Get OpenAF path
- Build step 1
exec: |
// Build step 2
if (isUnDef(args.main)) {
// Find java and use it
$sh("`find . | egrep /bin/java$` -jar openaf.jar --install")
.sh("rm .opack.db")
.pwd(args.FOLDER + "/src")
.exec()
io.rm("/tmp/_oaf_scripts")
io.mkdir("/tmp/_oaf_scripts")
$from(io.listFiles(args.FOLDER + "/src").files)
.notEquals("filename", "openaf.jar")
.equals("isFile", true)
.select(f => {
log(" copy " + f.filepath)
io.cp(f.canonicalPath, "/tmp/_oaf_scripts/" + f.filename)
})
} else {
// List files that aren't openaf.jar
log("Listing files in " + args.main + "...")
$from(io.listFiles(args.main).files)
.notEquals("filename", "openaf.jar")
.equals("isFile", true)
.select(f => {
try {
log(" processing " + f.filepath)
// Read contents of file
var _c = io.readFileString(f.canonicalPath)
// Replace JAVA_HOME="$DIR/jre" by the appropriate folder
var whereIsJava = $sh("find . | egrep /bin/java$").pwd(args.FOLDER + "/src").get(0).stdout.replace(/\n/g, "")
whereIsJava = whereIsJava.replace(/^\.\//, "").replace(/\/bin\/java/, "")
_c = _c.replace(/JAVA_HOME=\"\$DIR\/jre\"/, "JAVA_HOME=\"\$DIR\/" + whereIsJava + "\"")
// Write changed contents
log(" writing " + f.filename + " in " + args.FOLDER + "/src")
io.writeFileString(args.FOLDER + "/src/" + f.filename, _c)
$sh("chmod a+x " + args.FOLDER + "/src/" + f.filename).exec()
} catch(ee) { printErr("ERROR: " + ee) }
})
}
to :
- Build step 3
# ---------------------
- name: Get OpenAF path
exec: |
args.oafpath = getOpenAFPath()
log("OpenAF path = " + args.oafpath)