forked from aparcar/openwrt-metabuilder
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build
executable file
·159 lines (121 loc) · 3.72 KB
/
build
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
#!/usr/bin/env bash
#
# Usage:
# ./build <community> <build-profile> <device-name>
show_help() { echo "$(grep -m1 -A1 "# Usage:" $PWD/$0)"; echo "# "; }
PWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# $1 - Community name ................ massmesh
# $2 - Build profile name ............ meshnode
# $3 - Device folder / nickname ...... rpi4
do_build() {
# Packages ########################
## Global Source: Profile Settings
COMMUNITY_PATH="$PWD/communities/$1"
if [ -f "$COMMUNITY_PATH/settings.sh" ]; then
. "$COMMUNITY_PATH/settings.sh"
fi
## Source Type: Radio or Meshnode
PROFILE_PATH="$COMMUNITY_PATH/$2"
if [ -f "$PROFILE_PATH/settings.sh" ]; then
. "$PROFILE_PATH/settings.sh"
fi
## Source: Device Settings
if [ -f "$PROFILE_PATH/$3/settings.sh" ]; then
. "$PROFILE_PATH/$3/settings.sh"
fi
# Copy Files #####################
## Copy All above files ./files
FILESDIR="$(mktemp -d)"
if [ -d "$PWD/communities/$1/files" ]; then
cp -r "$PWD/communities/$1/files/." "$FILESDIR/"
fi
if [ -d "$PROFILE_PATH/files" ]; then
cp -r "$PROFILE_PATH/files/." "$FILESDIR/"
fi
if [ -d "$PROFILE_PATH/$3/files" ]; then
cp -r "$PROFILE_PATH/$3/files/." "$FILESDIR/"
fi
# Peanut Butter Meta Time ########
export BIN_DIR="$PROFILE_PATH/bin/$3"
export FILES="$FILESDIR"
PROFILE_PATH=$PROFILE_PATH /usr/bin/env bash ./meta image
# Peanut Butter Meta Time ########
## meta_build_handler()
if [ $? -eq 0 ]; then
echo "[$0] Firmware cooked: ${BIN_DIR}/"
ls -lh --color=auto ${BIN_DIR}
return 0
else
echo "[$0] --------------------------------------------------------"
echo "[$0] Error building: [$1/$2/$3]"
echo "[$0] --------------------------------------------------------"
echo "[$0] Unexpected \"Package size mismatch\" opkg install errors?"
echo "[$0] Try refreshing old ImageBuilder with this: "
echo " REFRESH=true $0 $1 $2 $3"
return 99
fi
}
if [ -z "$1" ]; then
show_help
echo "[$0] Please specify an available community:"
for x in $(ls $PWD/communities/); do echo "- $x" ; done
echo "[$0] Example:"
echo "% $0 massmesh meshnode rpi-4"
exit 1
fi
COMMUNITY_PATH="$PWD/communities/$1"
if [ ! -d "$COMMUNITY_PATH" ]; then
show_help
echo "Community not found in ./communities"
exit 1
fi
if [ -z "$2" ]; then
show_help
echo "Please specify a build profile:"
for x in $(ls $COMMUNITY_PATH/ | egrep -v 'files|settings.sh'); do echo "- $x" ; done
exit 1
fi
PROFILE_PATH="$COMMUNITY_PATH/$2"
if [ ! -d "$PROFILE_PATH" ]; then
echo "Build profile not found in ./communities/$1"
exit 1
fi
if [ -z "$3" ]; then
show_help
echo "[$0] Please specify a device:"
for x in $(ls $PROFILE_PATH/); do
[ -d $PROFILE_PATH/$x ] && \
[ x"$x" != "xfiles" ] && \
[ x"$x" != "xDockerfile" ] && \
[ x"$x" != "xbin" ] \
&& echo "- $x" \
|| :
done
exit 1
fi
if [ $3 == "docker" ]; then
echo "Building x86/64 target for Docker"
echo "[$0] Docker: Bulding for $1 $2 $3"
do_build "$1" "$2" "apu2"
if [ $? -ne 0 ]; then
echo "[$0] Failed in: do_build()"
exit 99
else
rootfs_archive="${BIN_DIR}/openwrt-massmesh-meshnode-x86-64-generic-rootfs.tar.gz"
rootfs_repo="openwrt-x86-generic-rootfs"
echo "[$0] Docker: Importing OpenWrt Root Filesystem"
ls -l ${rootfs_archive}
docker rmi ${rootfs_repo} 2>/dev/null
docker import ${rootfs_archive} ${rootfs_repo}
docker build -t massmesh/meta \
communities/massmesh/meshnode
# docker run -it -p80:80 --rm massmesh/meta
fi
exit 0
elif [ ! -f "$PROFILE_PATH/$3/settings.sh" ]; then
echo "Missing settings.sh for $3"
exit 1
fi
do_build "$1" "$2" "$3" \
&& exit 0 \
|| exit 1