This repository has been archived by the owner on Nov 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·196 lines (152 loc) · 4.38 KB
/
make.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
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
#!/usr/bin/env zsh
emulate -L zsh
0=${(%):-%N}
# Change working directory
cd -q ${0:A:h}
source .envrc
source scripts/setup/general-setup.sh
source scripts/setup/python-site-packages.sh
typeset -a ARCH
typeset -a arch
zparseopts -E -D \
a+:=arch arch+:=arch -arch+:=arch
for key val in $arch; do
ARCH+=($val)
done
unset arch
typeset -A SSH_HOSTS=(
x86-64 ascross
i386 ascross
arm ascross-arm
)
if ! [[ -d $1 ]] && [[ $1 != all ]] && [[ $1 != update ]]; then
print -u2 "please provide make target"
exit 1
fi
if [[ $1 == update ]]; then
shift
apks=()
for pkg in $@; do
source scripts/setup/parse-setup-yaml.sh $pkg/config.yml config_
apks+=($pkg/dist/*${config_version}*)
done
print "Updating packages: $apks"
asdev update ${=apks}
exit $?
fi
make_package() {
cd -q $1
if [[ -f pre_setup.sh ]]; then
source pre_setup.sh
fi
source ../scripts/setup/parse-setup-yaml.sh ./config.yml config_
dist_dir=dist
build_dir=build
mkdir -p $dist_dir $build_dir
if [[ $config_case_sensitive == 1 ]]; then
source ../scripts/case_sensitive.sh
cs_create build.dmg.sparseimage ${config_package}_build
cs_attach build.dmg.sparseimage $build_dir
fi
build_apk=$build_dir/apk
build_files=$build_dir/files
mkdir -p $build_apk $build_files
# Clean up any .DS_Store files
find $build_dir -name .DS_Store -exec rm {} \;
build_arch() {
local arch=$1
local prefix=$2
local ssh_host=$SSH_HOSTS[$arch]
log() {
local len=$(( ${#config_package} + 8 + 2))
printf "%${len}s: $@\n" "${arch}(${config_package})"
}
log "Building $config_name $config_version for $arch"
# Cleanup build directory
[[ -d $build_apk/$arch ]] && rm -rf $build_apk/$arch
mkdir -p $build_apk/$arch
log "Copying APK skeleton"
rsync -a source/ $build_apk/$arch
typeset -a files exclude
if (( ${#config_files} )) || (( ${#config_site_packages} )); then
(( ${#config_files} )) && files+=( $prefix$^config_files )
(( ${#config_site_packages} )) && {
python_site_packages=( $(get_site_packages $ssh_host $prefix "$config_site_packages") )
files+=( $prefix$^python_site_packages )
}
if [[ $config_updated_libstdcpp == 1 ]] && [[ $arch != arm ]]; then
# App requires an updated version of libstdc++ so we pull it in as
# an extra. The ARM already supports libstdc++ from GCC 4.8 so we
# skip it.
gcc_path=/usr/lib/gcc/${prefix:t}/4.9.4
files+=( "$prefix$gcc_path/libstdc++.so*" )
local remove_root=$config_root
if [[ $remove_root = / ]]; then
remove_root=''
fi
config_runpath=$config_runpath:/usr/local/AppCentral/$config_package${gcc_path#$remove_root}
fi
if (( ! ${#files} )); then
log "No files found? Aborting..."
continue
fi
(( ${#config_exclude} )) && exclude+=( "--exclude "$^config_exclude )
[[ -d pkgversions ]] || mkdir pkgversions &>/dev/null
write_pkgversions $ssh_host $prefix "$files" pkgversions/$arch.txt $config_eprefix &
if (( ${#config_runpath} > 1 )) ; then # ignore null / false
log "Updating runpath on remote..."
patched_files=$(update_runpath $ssh_host $prefix $config_runpath "$files")
log "Patched runpath for: $patched_files"
fi
log "Rsyncing files..."
rsync -q -a --relative --delete ${(s. .)exclude} \
$ssh_host:"$files" $build_files/
if (( $? )); then
log "Failed fetching files for $arch"
continue
fi
log "Copying $arch files to $build_apk/$arch..."
rsync -a $build_files/${prefix#\/}${config_root%/}/ $build_apk/$arch/
fi
# Run pre-build script
if [[ -f pre_build.sh ]]; then
source pre_build.sh $build_apk/$arch
fi
config2json $arch > $build_apk/$arch/CONTROL/config.json
cp CHANGELOG.md $build_apk/$arch/CONTROL/changelog.txt
log "Building APK..."
build_apk $build_apk/$arch $dist_dir
log "Done!"
wait
}
if (( $#config_architecture > 1 )); then
build_arch $config_architecture $adm_arch[$config_architecture]
elif (( $#ARCH )); then
for arch in $ARCH; do
build_arch $arch $adm_arch[$arch]
done
else
for arch prefix in ${(kv)adm_arch}; do
build_arch $arch $prefix &
done
fi
wait
if [[ $config_case_sensitive == 1 ]]; then
cs_detach $build_dir
cs_compact build.dmg.sparseimage
fi
}
print "Requesting sudo for build session..."
sudo echo -n
if [[ $1 == all ]]; then
for i in */config.yml; do
make_package ${i:h} &
done
wait
else
for pkg in $@; do
make_package $pkg &
done
wait
fi
print "\nThank you, come again!"