-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·90 lines (65 loc) · 2.4 KB
/
build.sh
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
#!/usr/bin/env bash
set -euo pipefail
SANOID_VERSION=$(jq -r '.Sanoid' versions.json)
PACKAGING_REVISION=$(jq -r '.PackagingRevision' versions.json)
APPERL_VERSION=$(jq -r '.APPerl' versions.json)
SANOID_PORTABLE_VERSION="${SANOID_VERSION}-${PACKAGING_REVISION}"
echo "Building sanoid-portable version ${SANOID_PORTABLE_VERSION}, based on Sanoid version ${SANOID_VERSION} and APPerl version ${APPERL_VERSION}"
repo_root="$(realpath "$(dirname "$0")")"
# Cleanup previous artifacts if they exist
if [ -d output ]; then
echo 'Cleaning up previous build output...'
rm -rf output
fi
mkdir output
pushd output > /dev/null
echo 'Downloading necessary modules...'
# Perl build dependency
# https://metacpan.org/dist/Module-Build
wget -q https://cpan.metacpan.org/authors/id/L/LE/LEONT/Module-Build-0.4234.tar.gz
# Sanoid dependency
# https://metacpan.org/dist/Config-IniFiles
wget -q https://cpan.metacpan.org/authors/id/S/SH/SHLOMIF/Config-IniFiles-3.000003.tar.gz
# Sanoid dependency
## https://metacpan.org/dist/Capture-Tiny
wget -q https://cpan.metacpan.org/authors/id/D/DA/DAGOLDEN/Capture-Tiny-0.48.tar.gz
echo 'Cloning sanoid repository...'
rm -rf sanoid_source
git clone https://github.com/jimsalterjrs/sanoid.git sanoid_source
echo ''
echo "Checking out Sanoid version \"${SANOID_VERSION}\""
pushd sanoid_source > /dev/null
git -c advice.detachedHead=false checkout "v${SANOID_VERSION}"
git log -1
echo 'Applying custom patches to sanoid scripts to support bundling in APPerl binary...'
for tool in sanoid syncoid findoid; do
patch < "${repo_root}/patches/${tool}.patch"
done
popd > /dev/null
echo ''
echo 'Downloading APPerl (Actually Portable Perl)...'
wget -q -O perl.com "https://github.com/G4Vi/Perl-Dist-APPerl/releases/download/v${APPERL_VERSION}/perl.com"
chmod u+x perl.com
echo 'APPerl (perl.com) SHA-256 checksum:'
sha256sum perl.com
echo ''
# Bootstrap; use APPerl to build a custom APPerl.
ln -s perl.com apperlm
cp "${repo_root}/apperl-project.json" .
cp "${repo_root}/sanoid-portable.pl" .
cp "${repo_root}/versions.json" .
echo 'Installing build dependencies...'
./apperlm install-build-deps
echo 'Checking out the APPerl sanoid-portable build...'
./apperlm checkout sanoid-portable
echo 'Configuring build environment...'
./apperlm configure
echo 'Building sanoid-portable...'
./apperlm build
echo ''
echo 'Build complete.'
echo ''
echo 'Testing...'
echo ''
"${repo_root}/test-smoke.sh"
popd > /dev/null