-
Notifications
You must be signed in to change notification settings - Fork 63
/
lfs-image
executable file
·58 lines (45 loc) · 1.34 KB
/
lfs-image
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
#!/usr/bin/env bash
set -e
# Config options you may pass via Docker like so 'docker run -e "<option>=<value>"':
# - IMAGE_NAME=<name>, define a static name for your .img files
firmware_base=/opt/nodemcu-firmware
lua_base=/opt/lua
filelist=$1
cd ${firmware_base}
if [ ! -x luac.cross -a ! -x luac.cross.int ]; then
echo Error: No cross compiler found. You need to build the firmeware first.
exit -1
fi
export BUILD_DATE
BUILD_DATE="$(date "+%Y%m%d-%H%M")"
if [ -z "${filelist}" ]; then
cd ${lua_base}
LUA_FILES=$(find . -iname "*.lua")
else
DIR=$(dirname ${filelist})/
NAME=$(basename ${filelist})
cd ${lua_base}/${DIR}
LUA_FILES=$(cat ${NAME})
LUA_FILES=$(ls ${LUA_FILES})
fi
echo Adding files: ${LUA_FILES}
if [ -z "$IMAGE_NAME" ]; then
IMAGE_NAME="${BUILD_DATE}"
fi
function make_image {
BUILD_TYPE=$1
COMPILER=$2
if [ -x ${firmware_base}/${COMPILER} ]; then
FILENAME=${DIR}LFS_${BUILD_TYPE}_"${IMAGE_NAME}".img
echo creating "${FILENAME}"
if [ -z "${filelist}" ]; then
find ${lua_base} -iname "*.lua" -exec ${firmware_base}/${COMPILER} -f -o ${lua_base}/"${FILENAME}" {} +
else
${firmware_base}/${COMPILER} -f -o ${lua_base}/"${FILENAME}" ${LUA_FILES}
fi
fi
}
# make a float LFS image if available
make_image float luac.cross
# make an int LFS image if available
make_image integer luac.cross.int