-
Notifications
You must be signed in to change notification settings - Fork 806
/
multibuild.sh
executable file
·83 lines (80 loc) · 2.21 KB
/
multibuild.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
#!/bin/bash
# Copyright 2013-2016 Luke Dashjr
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option)
# any later version. See COPYING for more details.
set -e
set -x
reporoot="$1" # .../files/bfgminer/BFGMINER_VERSION/openwrt/OPENWRT_VERSION
openwrt_root="${2:-openwrt-src}"
BITSTREAM_PKG_PATH="${3}" # Relative to reporoot
test -n "$reporoot"
reporoot="$(realpath "$reporoot")"
test -n "$reporoot"
cd "${openwrt_root}/"
openwrt_root="$PWD"
test -d "$reporoot"
vcfgdir='vanilla_configs'
vcfglist="$(
ls -d "$vcfgdir"/*.config* |
perl -ple 's[.*/][]' |
sort -n
)"
BITSTREAMS=(
fpgaminer_402-1
ztex-ufm1_15b1_121126-1
ztex-ufm1_15d4_121126-1
ztex-ufm1_15y1_121126-1
)
if [ -d "${reporoot}/${BITSTREAM_PKG_PATH}" ]; then
(
for bs in ${BITSTREAMS[@]}; do
if ! [ -r "${reporoot}/${BITSTREAM_PKG_PATH}/bitstream-${bs}_all.ipk" ]; then
echo "Cannot find ${bs} bitstream package" >&2
exit 1
fi
done
)
else
echo 'Cannot find bitstreams directory' >&2
exit 1
fi
plat1=''
for cfn in $vcfglist; do
plat="$(perl -ple 's/^\d+\.config\.(\w+)$/$1/ or $_=""' <<<"$cfn")"
test -n "$plat" ||
continue
if [[ $plat =~ _pkgs$ ]]; then
plat="${plat::-5}"
else
plat="$(perl -ple 's/_.*//' <<<"$plat")"
fi
platlist+=("$plat")
cp -v "$vcfgdir/$cfn" .config
yes '' | make oldconfig
make {tools,toolchain}/install package/bfgminer/{clean,compile} V=s
mkdir "$reporoot/$plat" -pv
files=$(ls bin/"$plat"/packages/{*/,}bfgminer*_${plat}*.ipk bin/packages/"$plat"/{*/,}bfgminer*_${plat}*.ipk || true)
if test -z "${files}"; then
echo "Cannot find built packages"
exit 1
fi
cp -v ${files} "$reporoot/$plat/"
if [ -n "${BITSTREAM_PKG_PATH}" ]; then
(
test -d "$reporoot/${BITSTREAM_PKG_PATH}"
cd "$reporoot/$plat"
for bs in ${BITSTREAMS[@]}; do
ln -vfs "../${BITSTREAM_PKG_PATH}/bitstream-${bs}_all.ipk" .
done
)
fi
(
cd "$reporoot/$plat/"
PATH="${openwrt_root}/staging_dir/host/bin/:${PATH}" \
"${openwrt_root}/scripts/ipkg-make-index.sh" .
) > "$reporoot/$plat/Packages"
gzip -9 < "$reporoot/$plat/Packages" > "$reporoot/$plat/Packages.gz"
done