blob: ddbb63aeffbbbe9e957a21c972a10d4beafda258 (
plain)
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
#!/bin/sh
####################################################################
# This is a simple Buildroot helper script. Place this script into #
# your Buildroot directory. #
# If you want any features to be added or found some bugs or #
# feedback, feel free to mail me some words: #
# matzeton@googlemail.com #
# #
# gl&hf #
####################################################################
NAME=`basename $0`
DIRNAME=`dirname $0`
OLDPWD=`pwd`
BACKUP_DIR="$DIRNAME/bck"
BACKUP_SRCS="fs/minlin_skel minlin_buildroot.config minlin_kernel_i386.config minlin_uclibc.config minlin_busybox.config package/sysvinit package/ncurses package/htop package/squid package/libpth package/pppd package/openssh package/iptables package/tor target"
BR_KERNEL="$DIRNAME/output/images/bzImage"
BR_ROOTFS="$DIRNAME/output/images/rootfs.ext2"
BR_INITRD="$DIRNAME/output/images/rootfs.cpio"
TARGET_DIR="$DIRNAME/output/target"
STAGING_DIR="$DIRNAME/output/staging"
STAMP_DIR="$DIRNAME/output/stamps"
BUILD_DIR="$DIRNAME/output/build"
print() {
echo "> $NAME: $1."
}
usage() {
cat << EOF
$NAME [arg0]
help - this
make - make
rebuild - rebuild target
backup - create backup dir
restore - restore files from backup dir
br - Buildroot menuconfig
bbox - make busybox-menuconfig
uclibc - make uclibc-menuconfig
linux - make linux-menuconfig
qemu -[argN] - start qemu with buildroot kernel
where [argN] can be:
i - start qemu with kernel & initrd
s - using stdio for input/output
n - append init=/bin/sh
r - using ext2 rootfs
x - extra append parameter
EOF
}
clean_conf() {
[ -z "$BACKUP_DIR" ] && print '$BACKUP_DIR var missing' && return 1
print 'cleaning up'
rm -rf "$BACKUP_DIR" 2>/dev/null
}
backup_conf() {
[ -z "$BACKUP_SRCS" ] && print 'missing $BACKUP_SRCS' && return 1
clean_conf
mkdir -p "$BACKUP_DIR"
for bck_obj in $BACKUP_SRCS; do
[ -e "$DIRNAME/$bck_obj" ] || {
print "nonexisting object $DIRNAME/$bck_obj"
continue
}
dir=`dirname "$BACKUP_DIR/$bck_obj"`
mkdir -p "$dir"
[ -f "$DIRNAME/$bck_obj" -a -r "$DIRNAME/$bck_obj" ] && {
print "backup file $DIRNAME/$bck_obj"
cp "$DIRNAME/$bck_obj" "$BACKUP_DIR/$bck_obj"
} || {
print "backup dir $DIRNAME/$bck_obj"
cp -rf "$DIRNAME/$bck_obj" "$dir"
}
done
}
restore_conf() {
[ -z "$BACKUP_DIR" ] && print '$BACKUP_DIR var missing' && return 1
[ -z "$BACKUP_SRCS" ] && print 'missing $BACKUP_SRCS' && return 2
for bck_obj in $BACKUP_SRCS; do
print "restoring object $DIRNAME/$bck_obj"
rm -rf "$DIRNAME/$bck_obj"
cp -rf "$BACKUP_DIR/$bck_obj" "$DIRNAME/$bck_obj"
done
}
start_qemu() {
BIN=
APPEND=
[ -x /usr/bin/kvm ] && BIN=/usr/bin/kvm || BIN=/usr/bin/qemu
while getopts isnrx: opt
do
case "$opt" in
i) INITRD="-initrd $BR_INITRD" ;;
s) SERIAL="-serial stdio" ;;
n) APPEND="$APPEND init=/bin/sh" ;;
r) ROOTFS="-hda $BR_ROOTFS -boot c" ;;
x) [ -z $2 ] || APPEND="$APPEND $2" ;;
esac
done
print "starting $BIN"
print "kernel: $BR_KERNEL"
print "parameter: $ROOTFS $INITRD $SERIAL -append \"$APPEND\""
$BIN -kernel $BR_KERNEL -m 512 -localtime -no-reboot -name brlinux -net none $ROOTFS $INITRD $SERIAL -append "$APPEND"
}
[ -r "$DIRNAME/Makefile" ] || {
print "No Makefile in $DIRNAME"
print "Please copy me in the Buildroot dir"
exit 1
}
[ $# -gt 0 ] && {
print "init"
print "cd to $DIRNAME"
cd "$DIRNAME"
}
case "$1" in
make) print "make all"
make
break
;;
rebuild)
print "rebuild target/rootfs"
rm -f output/build/.root
find ./output -name ".stamp_target_installed*" -print | xargs rm -f
make
;;
bck|backup)
print "backup"
backup_conf
break
;;
rst|restore)
print "restore"
restore_conf
break
;;
br|b) print "make menuconfig"
make menuconfig
break
;;
busybox|bbox|bb)
print "make busybox"
make busybox-menuconfig
break
;;
uclibc|libc) print "make uclibc"
make uclibc-menuconfig
break
;;
linux|kernel|lin)
print "make linux"
make linux-menuconfig
break
;;
qemu|kvm)
print "start qemu/kvm"
start_qemu $2 $3
break
;;
*) usage
break
;;
esac
[ $# -gt 0 ] && {
print "cd back to $OLDPWD"
cd "$OLDPWD"
}
|