-
Notifications
You must be signed in to change notification settings - Fork 136
/
build
executable file
·133 lines (120 loc) · 4.47 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
#! /bin/sh
#
# Script to build binary
#
# Usage:
# sh build
# or
# ./build
SOURCE_DIR=`pwd`
VER=`cat grub4dos_version`
DATE=`date -u +%Y-%m-%d`
RELEASE=grub4dos-${VER}-${DATE}
COPY_FILES="COPYING README_GRUB4DOS*.txt ChangeLog_*.txt \
config.sys default menu.lst grub.pif \
stage2/grldr stage2/grub.exe stage2/badgrub.exe stage2/grldr.mbr stage2/bootlace.com \
stage2/hmload.com stage2/grldr.pbr stage2/grldr_cd.bin"
rm -rf *.zip *.7z *~ || exit $?
[ -z "$GRUB4DOS_TEMP" ] && GRUB4DOS_TEMP=/tmp/grub4dos-temp
if svn export . ${GRUB4DOS_TEMP} --force 2>/dev/null ; then
# check for svn version
export LC_ALL=C
svninfo=$(svn info)
if [ "$svninfo" ]; then
while read w1 w2 w3; do
if [ "$w1" = "Revision:" -a "$w2" != "" -a "$w3" = "" ]; then
CURR_REVISION=r$w2
fi
if [ "$w1" = "URL:" -a "$w2" != "" -a "$w3" = "" ]; then
SVN_URL=$w2
fi
[ "$CURR_REVISION" != "" -a "$SVN_URL" != "" ] && break
done << EOF
$svninfo
EOF
fi
[ "$SVN_URL" = "" ] && SVN_URL="https://github.com/chenall/grub4dos"
[ "$CURR_REVISION" = "" ] && CURR_REVISION=rHEAD
Get_source="\tsvn co -$CURR_REVISION $SVN_URL grub4dos\r\n\tcd grub4dos\r\n\r\n"
# Generate patch file
svn diff . > ${GRUB4DOS_TEMP}/grub4dos_${CURR_REVISION}.diff 2>/dev/null
elif git checkout-index -a -f --prefix=${GRUB4DOS_TEMP}/ 2>/dev/null ; then
# check for git version
CURR_REVISION=$(git log -1 --pretty=format:%h)
Get_source="\tgit clone git://github.com/chenall/grub4dos.git\r\n\tcd grub4dos\r\n\tgit checkout $CURR_REVISION -b build\r\n\r\n"
# Generate patch file
git diff --no-prefix > ${GRUB4DOS_TEMP}/grub4dos_${CURR_REVISION}.diff 2> /dev/null
if [ -s ${GRUB4DOS_TEMP}/grub4dos_${CURR_REVISION}.diff ]; then
cd ${GRUB4DOS_TEMP} || exit $?
patch -p0 < grub4dos_${CURR_REVISION}.diff
fi
else
files=$(echo *)
if ! [ -d ${GRUB4DOS_TEMP} ] ; then
mkdir ${GRUB4DOS_TEMP} || exit $?
fi
cp -a $files ${GRUB4DOS_TEMP} || exit $?
fi
cd ${GRUB4DOS_TEMP} || exit $?
if [ "$Get_source" ]; then
echo -n -e "Get the source code of this build in this way:\r\n\r\n${Get_source}" > Get_Source_of_This_Build.txt
if [ -s grub4dos_${CURR_REVISION}.diff ]; then
echo -n -e "and then apply the patch against revision ${CURR_REVISION} you just downloaded:\r\n\r\n\
patch -p0 < ../grub4dos_${CURR_REVISION}.diff\r\n\r\n" >> Get_Source_of_This_Build.txt
fi
echo -n -e "and now you may do a \"make\" to compile.\r\n\r\n" >> Get_Source_of_This_Build.txt
fi
#############################################
# Build english version
#############################################
./configure --enable-preset-menu=preset_menu.lst || exit $?
make clean
make || exit $?
rm -rf grub4dos-${VER}
mkdir grub4dos-${VER} || exit $?
[ -f stage2/eltorito.sys ] && cp stage2/eltorito.sys grub4dos-${VER}
cp $COPY_FILES grub4dos-${VER} || exit $?
cd grub4dos-${VER}
# generate bootlace64.com
if [ -f bootlace.com ]; then
Seek=$((0x`objdump -s bootlace.com|awk '/7f45/{print $1|"sed s/4/0/"}'`))
dd if=bootlace.com of=bootlace.head bs=1 count=64 skip=$Seek
dd if=bootlace.com of=bootlace.body bs=1 skip=64
cat bootlace.head bootlace.body > bootlace64.com
chmod a+x bootlace64.com
rm -f bootlace.body bootlace.head
fi
mkdir docs && mv *.txt docs/
mkdir sample && mv menu.lst default config.sys sample/
cd ..
if [ -f Get_Source_of_This_Build.txt ]; then
cp Get_Source_of_This_Build.txt grub4dos-${VER}
if [ -s grub4dos_${CURR_REVISION}.diff ]; then
cp grub4dos_${CURR_REVISION}.diff grub4dos-${VER}
fi
fi
#############################################
# Build chinese version
#############################################
#patch -p1 < patch-chinese.diff || exit $?
#make || exit $?
#mkdir grub4dos-${VER}/chinese || exit $?
#cp README_GRUB4DOS_CN.txt stage2/grldr stage2/grub.exe stage2/badgrub.exe grub4dos-${VER}/chinese || exit $?
#############################################
# Create ZIP ball or TAR ball
#############################################
cd $SOURCE_DIR
if [ -d ipxe ] ; then
cd ipxe/src
[ -d .git ] && git pull
make bin/undionly.kpxe EMBED=$SOURCE_DIR/ipxegrldr.ipxe,${GRUB4DOS_TEMP}/grub4dos-${VER}/grldr && cp -af bin/undionly.kpxe ${GRUB4DOS_TEMP}/grub4dos-${VER}/ipxegrldr
cd $SOURCE_DIR
fi
rm -f ${RELEASE}.zip ${RELEASE}.rar ${RELEASE}.tar.gz || exit $?
if ! 7z a ${RELEASE}.7z ${GRUB4DOS_TEMP}/grub4dos-${VER} ; then
echo 7z failed. Continue with zip or tar...
if ! zip -r -q ${RELEASE}.zip ${GRUB4DOS_TEMP}/grub4dos-${VER} ; then
tar -czf ${RELEASE}.tar.gz ${GRUB4DOS_TEMP}/grub4dos-${VER}
fi
fi
# Do not remove grub4dos-temp as we can check and re-use it later.