forked from ponylang/ponyc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis_commands.bash
220 lines (170 loc) · 7.96 KB
/
.travis_commands.bash
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#! /bin/bash
set -o errexit
set -o nounset
download_vagrant(){
echo "Downloading and installing vagrant/libvirt..."
sudo add-apt-repository ppa:linuxsimba/libvirt-udp-tunnel -y
sudo apt-get update
sudo apt-get install libvirt-bin libvirt-dev qemu-utils qemu -y
sudo /etc/init.d/libvirt-bin restart
sudo virsh pool-define-as --name default --type dir --target /var/lib/libvirt/images
sudo virsh pool-autostart default || true
sudo virsh pool-build default || true
sudo virsh pool-start default || true
sudo /etc/init.d/libvirt-bin restart
sudo libvirtd --version
wget "https://releases.hashicorp.com/vagrant/2.1.2/vagrant_2.1.2_x86_64.deb"
sudo dpkg -i vagrant_2.1.2_x86_64.deb
rm vagrant_2.1.2_x86_64.deb
vagrant plugin install vagrant-libvirt
cd .ci-vagrantfiles/${VAGRANT_ENV}
sudo vagrant up --provider=libvirt
}
osx-ponyc-test(){
echo "Building and testing ponyc..."
make CC="$CC1" CXX="$CXX1" -j$(sysctl -n hw.ncpu) all
make CC="$CC1" CXX="$CXX1" test-ci
}
build_appimage(){
package_version=$1
mkdir ponyc.AppDir
cat > ./ponyc.desktop <<\EOF
[Desktop Entry]
Name=Pony Compiler
Icon=ponyc
Type=Application
NoDisplay=true
Exec=ponyc
Terminal=true
Categories=Development;
EOF
curl https://www.ponylang.io/images/logo.png -o ponyc.png
curl https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage -o linuxdeploy-x86_64.AppImage -J -L
chmod +x linuxdeploy-x86_64.AppImage
# remove any existing build artifacts
sudo rm -rf build
# can't run appimages in docker; need to extract and then run
sudo docker run -v "$(pwd):/home/pony" -u pony:2000 --rm ponylang/ponyc-ci:centos7-llvm-3.9.1 sh -c "./linuxdeploy-x86_64.AppImage --appimage-extract"
# need to run in CentOS 7 docker image
sudo docker run -v "$(pwd):/home/pony" -u pony:2000 --rm ponylang/ponyc-ci:centos7-llvm-3.9.1 sh -c "make LLVM_CONFIG=/opt/llvm-3.9.1/bin/llvm-config arch=x86-64 tune=generic default_pic=true use=llvm_link_static DESTDIR=ponyc.AppDir ponydir=/usr prefix= test-ci"
sudo docker run -v "$(pwd):/home/pony" -u pony:2000 --rm ponylang/ponyc-ci:centos7-llvm-3.9.1 sh -c "make LLVM_CONFIG=/opt/llvm-3.9.1/bin/llvm-config arch=x86-64 tune=generic default_pic=true use=llvm_link_static DESTDIR=ponyc.AppDir ponydir=/usr prefix= install"
# build stdlib to ensure libraries like openssl and pcre2 get packaged in the appimage
sudo docker run -v "$(pwd):/home/pony" -u pony:2000 --rm ponylang/ponyc-ci:centos7-llvm-3.9.1 sh -c "./build/release/ponyc packages/stdlib"
sudo docker run -v "$(pwd):/home/pony" -u pony:2000 --rm ponylang/ponyc-ci:centos7-llvm-3.9.1 sh -c "cp stdlib ponyc.AppDir/usr/bin"
sudo docker run -v "$(pwd):/home/pony" -u pony:2000 --rm ponylang/ponyc-ci:centos7-llvm-3.9.1 sh -c "ARCH=x86_64 ./squashfs-root/AppRun --appdir ponyc.AppDir --desktop-file=ponyc.desktop --icon-file=ponyc.png"
# delete stdlib to not include it in appimage
sudo docker run -v "$(pwd):/home/pony" -u pony:2000 --rm ponylang/ponyc-ci:centos7-llvm-3.9.1 sh -c "rm ponyc.AppDir/usr/bin/stdlib"
# build appimage
sudo docker run -v "$(pwd):/home/pony" -u pony:2000 --rm ponylang/ponyc-ci:centos7-llvm-3.9.1 sh -c "ARCH=x86_64 ./squashfs-root/AppRun --appdir ponyc.AppDir --desktop-file=ponyc.desktop --icon-file=ponyc.png --output appimage"
mv Pony_Compiler-x86_64.AppImage "Pony_Compiler-${package_version}-x86_64.AppImage"
bash .bintray.bash appimage "${package_version}" ponyc
rm linuxdeploy-x86_64.AppImage
# cleanup
sudo rm -rf build
}
build_deb(){
deb_distro=$1
# untar source code
tar -xzf "ponyc_${package_version}.orig.tar.gz"
pushd ponyc-*
cp -r .packaging/deb debian
cp LICENSE debian/copyright
# create changelog
rm -f debian/changelog
dch --package ponyc -v "${package_version}" -D "${deb_distro}" --force-distribution --controlmaint --create "Release ${package_version}"
# create package for distro using docker to run debuild
sudo docker run -v "$(pwd)/..:/home/pony" --rm --user root "ponylang/ponyc-ci:${deb_distro}-deb-builder" sh -c 'cd ponyc* && apt-get update && mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i -r && debuild -b -us -uc'
ls -l ..
# restore original working directory
popd
# create bintray upload json file
bash .bintray_deb.bash "$package_version" "$deb_distro"
# rename package to avoid clashing across different distros packages
mv "ponyc_${package_version}_amd64.deb" "ponyc_${package_version}_${deb_distro}_amd64.deb"
# clean up old build directory to ensure things are all clean
sudo rm -rf ponyc-*
}
ponyc-build-debs-ubuntu(){
package_version=$1
set -x
echo "Install devscripts..."
sudo apt-get update
sudo apt-get install -y devscripts
echo "Building off ponyc debs for bintray..."
wget "https://github.com/ponylang/ponyc/archive/${package_version}.tar.gz" -O "ponyc_${package_version}.orig.tar.gz"
if [ "${package_version}" == "master" ]
then
mv "ponyc_${package_version}.orig.tar.gz" "ponyc_$(cat VERSION).orig.tar.gz"
package_version=$(cat VERSION)
fi
# To add a new ubuntu version
# * Create and upload the appropriate docker image using .ci-dockerfiles/deb-builder templated Docker file
# * Add a new entry to the following list calling `build_deb` for the new distribution
#
# To remove a existing ubuntu version
# * Remove the exiting entry from the following list calling `build_deb` for the retired distribution
#
# To update the builder image for an existing ubuntu version
# * Create and upload a new version of the appropriate docker image using .ci-dockerfiles/deb-builder
build_deb xenial
build_deb artful
build_deb bionic
ls -la
set +x
}
ponyc-build-debs-debian(){
package_version=$1
set -x
echo "Install devscripts..."
sudo apt-get update
sudo apt-get install -y devscripts
echo "Building off ponyc debs for bintray..."
wget "https://github.com/ponylang/ponyc/archive/${package_version}.tar.gz" -O "ponyc_${package_version}.orig.tar.gz"
if [ "${package_version}" == "master" ]
then
mv "ponyc_${package_version}.orig.tar.gz" "ponyc_$(cat VERSION).orig.tar.gz"
package_version=$(cat VERSION)
fi
# To add a new debian version
# * Create and upload the appropriate docker image using .ci-dockerfiles/deb-builder templated Docker file
# * Add a new entry to the following list calling `build_deb` for the new distribution
#
# To remove a existing debian version
# * Remove the exiting entry from the following list calling `build_deb` for the retired distribution
#
# To update the builder image for an existing debian version
# * Create and upload a new version of the appropriate docker image using .ci-dockerfiles/deb-builder
build_deb buster
build_deb stretch
ls -la
set +x
}
ponyc-kickoff-copr(){
package_version=$(cat VERSION)
# COPR for fedora/centos/suse
echo "Kicking off ponyc packaging for COPR..."
docker run -it --rm -e COPR_LOGIN="${COPR_LOGIN}" -e COPR_USERNAME=ponylang -e COPR_TOKEN="${COPR_TOKEN}" -e COPR_COPR_URL=https://copr.fedorainfracloud.org mgruener/copr-cli buildscm --clone-url https://github.com/ponylang/ponyc --commit "${package_version}" --subdir /.packaging/rpm/ --spec ponyc.spec --type git --nowait ponylang
}
ponyc-build-packages(){
echo "Installing ruby, rpm, and fpm..."
rvm use 2.2.3 --default
sudo apt-get install -y rpm
gem install fpm
echo "Building ponyc packages for deployment..."
make CC="$CC1" CXX="$CXX1" verbose=1 arch=x86-64 tune=intel package_name="ponyc" package_base_version="$(cat VERSION)" deploy
}
ponyc-build-docs(){
echo "Installing mkdocs and offical theme..."
pip3 install --user mkdocs-ponylang
echo "Building ponyc docs..."
make CC="$CC1" CXX="$CXX1" docs-online
}
ponyc-upload-docs(){
echo "Uploading docs using mkdocs..."
git remote add gh-token "https://${STDLIB_TOKEN}@github.com/ponylang/stdlib.ponylang.io"
git fetch gh-token
git reset gh-token/master
pushd stdlib-docs
mkdocs gh-deploy -v --clean --remote-name gh-token --remote-branch master
popd
}