-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild
More file actions
executable file
·158 lines (127 loc) · 3.8 KB
/
Copy pathbuild
File metadata and controls
executable file
·158 lines (127 loc) · 3.8 KB
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
#!/bin/bash
#
# build [ board ]
#
# Max image size in 1024 (k) bytes
MAX_IMAGEFS_SIZE=262144 # 256m
REQUIRED_CMDS="which zcat bzcat make gcc bison flex msgfmt makeinfo autoconf nasm wget rsync sed perl gettext intltool-extract"
ROOTFS_SQUASHFS="output/images/rootfs.squashfs"
ROOTFS_EXT2="output/images/rootfs.ext2"
RUNNIX_VER="$(awk -F'=' '/^RUNNIX_VER/ { print $2; exit }' boot/runnix/runnix.mk)"
RUNNIX_DIR="output/build/runnix-${RUNNIX_VER// /}"
RUNFS_DIR="output/build/runfs"
make_release()
{
echo "
##
## AstLinux Build: Board = \"$board\"
##
## AstLinux Release: Version = \"$ASTVER\"
##
"
mkdir -p ${ASTVER}
cp ${ROOTFS_SQUASHFS} ${ASTVER}/${ASTVER}.run
(
cd ${ASTVER}
sha1sum ${ASTVER}.run > ${ASTVER}.run.sha1
)
touch ${ASTVER}/astflag
sed -e "s/ASTVER/${ASTVER}/g" project/astlinux/board/${board}/runnix.conf > ${ASTVER}/${ASTVER}.run.conf
image_size=$(du -s -k "${ROOTFS_EXT2}" | awk '{ print $1 }')
if [ $image_size -gt $MAX_IMAGEFS_SIZE ]; then
echo "build: WARNING -- Image Size is larger then ${MAX_IMAGEFS_SIZE}KB, 'noram' is set"
sed -i 's/ astlive / astlive noram /' ${ASTVER}/${ASTVER}.run.conf
fi
cp initrd.img ${ASTVER}/${ASTVER}.initrd.img
tar -cvzf ${ASTVER}.tar.gz ${ASTVER}
sha1sum ${ASTVER}.tar.gz > ${ASTVER}.tar.gz.sha1
}
make_runfs()
{
mkdir -p ${RUNFS_DIR}/os
RUNNIX_KCMD_CONSOLE="$(grep -e '^KCMD=' project/astlinux/board/${board}/runnix.conf | \
sed -e 's/"//g' -e 's/^KCMD=.*console=//' -e 's/ .*$//' -e 's/^KCMD=.*$//')"
if [ -f "${RUNNIX_DIR}/configs/${board}.cfg" ]; then
cp -p ${RUNNIX_DIR}/configs/${board}.cfg ${RUNFS_DIR}/syslinux.cfg
elif [ -n "${RUNNIX_KCMD_CONSOLE}" ]; then
cp -p ${RUNNIX_DIR}/configs/default6-serial.cfg ${RUNFS_DIR}/syslinux.cfg
else
cp -p ${RUNNIX_DIR}/configs/default6.cfg ${RUNFS_DIR}/syslinux.cfg
fi
# Install EFI/BOOT syslinux.cfg
if [ -n "${RUNNIX_KCMD_CONSOLE}" ]; then
cp -p ${RUNNIX_DIR}/configs/defaultEFI-serial.cfg ${RUNFS_DIR}/EFI/BOOT/syslinux.cfg
else
cp -p ${RUNNIX_DIR}/configs/defaultEFI.cfg ${RUNFS_DIR}/EFI/BOOT/syslinux.cfg
fi
rm -f ${RUNFS_DIR}/os/astlinux-*
cp -p ${ASTVER}/* ${RUNFS_DIR}/os/
echo ${ASTVER} > ${RUNFS_DIR}/os/ver
}
exit_error()
{
echo "
## ** ERROR **
## AstLinux Build: Board = \"$board\"
## $1
"
exit 1
}
umask 002
PATH=/sbin:/usr/sbin:$PATH
if [ -n "$1" ]; then
echo "Defining Board = \"$1\""
echo "$1" > "astlinux.board"
fi
if [ ! -f "astlinux.board" ]; then
echo "genx86_64" > "astlinux.board"
fi
board="$(cat "astlinux.board")"
if [ -z "$board" ] || [ ! -d "project/astlinux/board/$board" ]; then
exit_error "Unknown Board type."
fi
if [ "$(uname -m)" != "x86_64" ]; then
exit_error "Build system must be x86_64."
fi
x_tools_dir="$(awk -F'"' '/^BR2_TOOLCHAIN_EXTERNAL_PATH=/ { print $2; nextfile }' .config | sed 's:^[^/]*::')"
if [ -z "$x_tools_dir" ]; then
exit_error "BR2_TOOLCHAIN_EXTERNAL_PATH not found in .config file."
fi
if [ ! -d "$HOME$x_tools_dir" ]; then
cat "crosstool-ng-src/README"
exit_error "Toolchain not found, see instructions above."
fi
error=0
for i in $REQUIRED_CMDS; do
if ! which $i >/dev/null 2>&1; then
error=1
echo "build: Required command \"$i\" is missing in your build environment."
if [ "$i" = "which" ]; then # no use proceeding
break
fi
fi
done
if [ $error -ne 0 ]; then
exit_error "Missing Required Command(s)."
fi
echo "
##
## AstLinux Build: Board = \"$board\"
##
"
if ! ./scripts/build-initrd; then
exit 1
fi
make oldconfig
time make all
if [ $? -eq 0 -a -f "$ROOTFS_SQUASHFS" -a -f "initrd.img" -a -d "$RUNNIX_DIR" -a -d "$RUNFS_DIR" ]; then
. ./scripts/ver-label/astlinux_release_version.sh
astlinux_release_version
make_release
make_runfs
else
rm -f "$ROOTFS_SQUASHFS"
echo "build: Incomplete build, no AstLinux Release for you."
exit 1
fi
exit 0