blob: 07d2bed4d5db4e04e185aea51ab0be832588ffd3 (
plain)
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
221
222
223
224
225
226
227
228
229
230
231
|
#!/bin/bash
set -e
shopt -s extglob nullglob
if [[ $# == 0 ]]; then
echo "usage: $0 <package>"
exit
fi
export PKG_MAKE=$0
export PKG_NAME=${1%_}
export PKG_BASE=$(realpath "$(dirname "$0")")
. "${PKG_BASE}/helper.sh"
if [[ ! -x ${PKG_BASE}/util/arid || ${PKG_BASE}/util/arid -ot ${PKG_BASE}/util/arid.cpp ]]; then
g++ -I ~/menes -o "${PKG_BASE}"/util/arid{,.cpp}
fi
if [[ ! -x ${PKG_BASE}/util/ldid || ${PKG_BASE}/util/ldid -ot ${PKG_BASE}/util/ldid.cpp ]]; then
g++ -I ~/menes -o "${PKG_BASE}"/util/ldid{,.cpp} -x c "${PKG_BASE}"/util/{lookup2,sha1}.c
fi
export CODESIGN_ALLOCATE=$(which codesign_allocate)
for DEP_NAME in "${PKG_DEPS[@]}"; do
"${PKG_MAKE}" "${DEP_NAME}"
done
export PKG_HASH=$({
"${PKG_BASE}"/util/catdir.sh "${PKG_DATA}" -L \( -name '.svn' -o -name '_*' \) -prune -o
for DEP_NAME in "${PKG_DEPS[@]}"; do
"${PKG_BASE}"/util/catdir.sh "$(PKG_DEST_ "${DEP_NAME}")"
DEP_MORE="$(PKG_MORE_ "${DEP_NAME}")"
if [[ -d ${DEP_MORE} ]]; then
"${PKG_BASE}"/util/catdir.sh "${DEP_MORE}"
fi
done
} | md5sum | cut -d ' ' -f 1)
echo "hashed data ${PKG_NAME} to: ${PKG_HASH}"
if [[ -e "${PKG_STAT}/data-md5" && ${PKG_HASH} == $(cat "${PKG_STAT}/data-md5") ]]; then
echo "skipping re-build of ${PKG_NAME}"
exit
fi
mkdir -p "${PKG_STAT}"
rm -f "${PKG_STAT}/data-md5"
rm -rf "${PKG_MORE}"
mkdir -p "${PKG_MORE}"
rm -rf "${PKG_DEST}"
mkdir -p "${PKG_DEST}"
rm -rf "${PKG_WORK}"
mkdir -p "${PKG_WORK}"
function pkg:patch() {
pkg:libtool_ libtool
pkg:libtool_ ltmain.sh
for diff in "${PKG_DATA}"/*.diff; do
if [[ ${diff} =~ .*/_[^/]*.diff$ ]]; then
continue;
fi
args=$(cat ${diff%.diff}.args 2>/dev/null || true)
echo "patching with ${diff}..."
patch ${args:=-p1} <"${diff}"
done
}
export -f pkg:patch
function pkg:bin() {
if [[ $# -eq 0 ]]; then
pushd "${PKG_DEST}/usr/bin"
set $(ls)
popd
fi
${FAKEROOT} mkdir -p "${PKG_DEST}/bin"
for bin in "$@"; do
${FAKEROOT} mv -v "${PKG_DEST}/usr/bin/${bin}" "${PKG_DEST}/bin/${bin}"
done
${FAKEROOT} rmdir --ignore-fail-on-non-empty -p "${PKG_DEST}/usr/bin"
}
export -f pkg:bin
function pkg:autoconf() {
for m4 in $(find -name "*.m4"); do
patch -F 3 -r/dev/null "${m4}" "${PKG_BASE}/util/libtool.m4.diff" || true
done
autoconf
}
export -f pkg:autoconf
export PKG_CONF=./configure
function pkg:libtool_() {
for ltmain in $(find -name "$1"); do
patch -r/dev/null "${ltmain}" "${PKG_BASE}/util/libtool.diff" || true
done
}
export -f pkg:libtool_
function pkg:setup() {
pkg:extract
if [ -z ""*/ ]; then
echo "Empty package??"
exit 1
fi
cd */
pkg:patch
}
export -f pkg:setup
function pkg:configure() {
cfg=("${PKG_CONF}" \
ac_cv_prog_cc_g=no ac_cv_prog_cxx_g=no \
--build="$(${PKG_BASE}/util/config.guess)" \
--host="${PKG_TARG}" \
--enable-static=no \
--enable-shared=yes \
--prefix=$(cat "${PKG_BASE}/arch/${PKG_ARCH}/${PKG_CFTARG}/prefix") \
--localstatedir="/var/cache/${PKG_NAME}" \
CFLAGS="-O2 ${PKG_MCPU} ${CFLAGS}" \
CXXFLAGS="-O2 ${PKG_MCPU} ${CXXFLAGS}" \
"$@")
echo "${cfg[@]}"
PKG_CONFIG="$(realpath "${PKG_BASE}/util/pkg-config.sh")" \
"${cfg[@]}"
}
export -f pkg:configure
function pkg:make() {
make -j16 CC="${PKG_TARG}-gcc" CXX="${PKG_TARG}-g++" AR="${PKG_TARG}-ar" "$@"
}
export -f pkg:make
function pkg:install() {
${FAKEROOT} make install -j16 CC="${PKG_TARG}-gcc" CXX="${PKG_TARG}-g++" AR="${PKG_TARG}-ar" DESTDIR="${PKG_DEST}" "$@"
# Go die in a horrible fire, libtool
find "${PKG_DEST}" -name '*.la' -exec rm {} +
}
export -f pkg:install
function pkg:extract() {
for tgz in "${PKG_DATA}"/*.{tar.{gz,xz,bz2,lz},tgz}; do
tar -xf "${tgz}"
done
for zip in "${PKG_DATA}"/*.zip; do
unzip "${zip}"
done
}
export -f pkg:extract
function pkg:usrbin() {
pkg: mkdir -p /usr/bin
pkg: cp -a "$@" /usr/bin
}
export -f pkg:usrbin
cd "${PKG_WORK}"
"${PKG_BASE}/exec.sh" "${PKG_NAME}" . "${PKG_DATA}/make.sh"
function rmdir_() {
if [[ -d "$1" ]]; then
rmdir --ignore-fail-on-non-empty "$1"
fi
}
rm -rf "${PKG_DEST}/usr/share/man"
rm -rf "${PKG_DEST}/usr/share/info"
rm -rf "${PKG_DEST}/usr/share/gtk-doc"
rm -rf "${PKG_DEST}/usr/share/doc"
rm -rf "${PKG_DEST}/usr/share/locale"
rm -rf "${PKG_DEST}/usr/man"
rm -rf "${PKG_DEST}/usr/local/share/man"
rm -rf "${PKG_DEST}/usr/local/OpenSourceVersions"
rm -rf "${PKG_DEST}/usr/local/OpenSourceLicenses"
rm -f "${PKG_DEST}/usr/lib/charset.alias"
rm -rf "${PKG_DEST}/usr/info"
rm -rf "${PKG_DEST}/usr/docs"
rm -rf "${PKG_DEST}/usr/doc"
rmdir_ "${PKG_DEST}/usr/share"
rmdir_ "${PKG_DEST}/usr/local/share"
rmdir_ "${PKG_DEST}/usr/local"
rmdir_ "${PKG_DEST}/usr/lib"
rmdir_ "${PKG_DEST}/usr"
if [[ -e "${PKG_BASE}/arch/${PKG_ARCH}/${PKG_CFTARG}/strip" ]]; then
. "${PKG_BASE}/arch/${PKG_ARCH}/${PKG_CFTARG}/strip"
fi
find "${PKG_DEST}" -type f -name '*.elc' -print0 | while read -r -d $'\0' bin; do
sed -i -e '
s/^;;; Compiled by .*$//
s/^;;; from file .*$//
s/^;;; in Emacs version .*$//
s/^;;; with .*$//
' "${bin}"
done
find "${PKG_DEST}" -type f -name '*.a' -print0 | while read -r -d $'\0' bin; do
"${PKG_BASE}/util/arid" "${bin}"
done
if [[ -f "${PKG_STAT}/data-ver" && -f "${PKG_STAT}/dest-ver" ]] && dpkg --compare-versions $(cat "${PKG_DATA}/_metadata/version") gt $(cat "${PKG_STAT}/data-ver"); then
rm "${PKG_STAT}/dest-ver"
fi
cp -aL "${PKG_DATA}/_metadata/version" "${PKG_STAT}/data-ver"
echo "${PKG_HASH}" >"${PKG_STAT}/data-md5"
echo "hashed code ${PKG_NAME} to: $("${PKG_BASE}"/util/catdir.sh "${PKG_DEST}" | md5sum | cut -d ' ' -f 1)"
|