Skip to content

Commit 4b74c1b

Browse files
committed
build: Support docker to build binary package
Usage: curl -sL https://rawgit.com/$org/$project/$branch/run.sh | bash -x - ls tmp/out/node-sqlite3/stage/sqlite3/*/node-*-*-* Or run.sh can be run in sources Change-Id: I79000463955d16eec8809c870f7d02c60da53432 Bug: TryGhost#418 Forwarded: TryGhost#1028 Origin: https://github.com/tizenteam/node-sqlite3 Signed-off-by: Philippe Coval <[email protected]>
1 parent 219113f commit 4b74c1b

File tree

2 files changed

+174
-0
lines changed

2 files changed

+174
-0
lines changed

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,10 @@ RUN echo "#log: ${project}: Building sources" \
7474
&& find build/stage/ -type f \
7575
&& sync
7676

77+
WORKDIR /usr/local/${project}/${project}
78+
RUN echo "#log: ${project}: Installing sources" \
79+
&& set -x \
80+
&& install -d /usr/local/src/${project}/ \
81+
&& install *.tgz /usr/local/src/${project}/ \
82+
&& cp -rfva ./build/stage/ /usr/local/src/${project}/ \
83+
&& sync

run.sh

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#!/bin/bash
2+
# -*- coding: utf-8 -*-
3+
#{
4+
# ISC License
5+
# Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
6+
# Copyright (c) 1995-2003 by Internet Software Consortium
7+
# Permission to use, copy, modify, and /or distribute this software
8+
# for any purpose with or without fee is hereby granted,
9+
# provided that the above copyright notice
10+
# and this permission notice appear in all copies.
11+
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
12+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
13+
# OF MERCHANTABILITY AND FITNESS.
14+
# IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
15+
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
17+
# WHETHER IN AN ACTION OF CONTRACT,
18+
# NEGLIGENCE OR OTHER TORTIOUS ACTION,
19+
# ARISING OUT OF OR IN CONNECTION WITH THE USE
20+
# OR PERFORMANCE OF THIS SOFTWARE.
21+
#}
22+
23+
set -e
24+
set -x
25+
26+
env_()
27+
{
28+
project="node-sqlite3"
29+
org="tizenteam"
30+
branch="master"
31+
url_suffix="#{branch}"
32+
33+
# user="rzr" # Update here if forking
34+
# org="TizenTeam"
35+
# branch="sandbox/${user}/${branch}"
36+
# url_suffix="#{branch}"
37+
url_suffix="" # TODO: For older docker
38+
39+
url="https://github.com/${org}/${project}.git${url_suffix}"
40+
run_url="https://raw.githubusercontent.com/${org}/${project}/${branch}/run.sh"
41+
42+
release="0.0.0"
43+
src=false
44+
if [ -d '.git' ] && which git > /dev/null 2>&1 ; then
45+
src=true
46+
branch=$(git rev-parse --abbrev-ref HEAD) ||:
47+
release=$(git describe --tags || echo "$release")
48+
fi
49+
50+
SELF="$0"
51+
[ "$SELF" != "$SHELL" ] || SELF="${PWD}/run.sh"
52+
[ "$SELF" != "/bin/bash" ] || SELF="${DASH_SOURCE}"
53+
[ "$SELF" != "/bin/bash" ] || SELF="${BASH_SOURCE}"
54+
self_basename=$(basename -- "${SELF}")
55+
}
56+
57+
58+
usage_()
59+
{
60+
cat<<EOF
61+
Usage:
62+
$0
63+
or
64+
curl -sL "${run_url}" | bash -
65+
66+
EOF
67+
}
68+
69+
70+
die_()
71+
{
72+
errno=$?
73+
echo "error: [$errno] $@"
74+
exit $errno
75+
}
76+
77+
78+
setup_debian_()
79+
{
80+
which git || sudo apt-get install git
81+
which docker || sudo apt-get install docker.io
82+
83+
sudo apt-get install qemu qemu-user-static binfmt-support
84+
sudo update-binfmts --enable qemu-arm
85+
}
86+
87+
88+
setup_()
89+
{
90+
docker version && return $? ||:
91+
92+
if [ -r /etc/debian_version ] ; then
93+
setup_debian_
94+
else
95+
cat<<EOF
96+
warning: OS not supported
97+
Please ask for support at:
98+
${url}
99+
EOF
100+
cat /etc/os-release ||:
101+
fi
102+
103+
docker version && return $? ||:
104+
docker --version || die_ "please install docker"
105+
groups | grep docker \
106+
|| sudo addgroup ${USER} docker \
107+
|| die_ "${USER} must be in docker group"
108+
su -l $USER -c "docker version" \
109+
&& { su -l $USER -c "$SHELL $SELF $@" ; exit $?; } \
110+
|| die_ "unexpected error"
111+
}
112+
113+
114+
prep_()
115+
{
116+
echo "Prepare: "
117+
cat /etc/os-release
118+
docker version || setup_
119+
}
120+
121+
122+
build_()
123+
{
124+
version="latest"
125+
outdir="${PWD}/tmp/out"
126+
container="${project}"
127+
branch_name=$(echo "${branch}" | sed -e 's|/|.|g')
128+
dir="/usr/local/src/${project}/"
129+
image="${user}/${project}/${branch}"
130+
tag="$image:${version}"
131+
tag="${org}/${project}:${branch_name}"
132+
tag="${org}/${project}:${branch_name}.${release}"
133+
tag=$(echo "${tag}" | tr [A-Z] [a-z])
134+
container="${project}"
135+
container=$(echo "${container}" | sed -e 's|/|-|g')
136+
if $src && [ "run.sh" = "${self_basename}" ] ; then
137+
docker build -t "${tag}" .
138+
else
139+
docker build -t "${tag}" "${url}"
140+
fi
141+
docker rm "${container}" > /dev/null 2>&1 ||:
142+
docker create --name "${container}" "${tag}" /bin/true
143+
rm -rf "${outdir}"
144+
mkdir -p "${outdir}"
145+
docker cp "${container}:${dir}" "${outdir}"
146+
echo "Check Ouput files in:"
147+
ls "${outdir}/"*
148+
find "${outdir}" -type f -a -iname "*.tgz" -o -iname "*.tar.*"
149+
}
150+
151+
152+
test_()
153+
{
154+
curl -sL "${run_url}" | bash -
155+
}
156+
157+
158+
main_()
159+
{
160+
env_ "$@"
161+
usage_ "$@"
162+
prep_ "$@"
163+
build_ "$@"
164+
}
165+
166+
167+
main_ "$@"

0 commit comments

Comments
 (0)