-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild-initrd
More file actions
executable file
·92 lines (67 loc) · 1.61 KB
/
Copy pathbuild-initrd
File metadata and controls
executable file
·92 lines (67 loc) · 1.61 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
#!/bin/bash
#
# build-initrd [ force ]
#
save_state()
{
cp -p .config .config.initrd.save
cp -p "$initrd_config_file" .config
if [ -d "output" ]; then
mv output output.initrd.save
fi
}
restore_state()
{
# This may be called multiple times on a interrupt
# Only restore once
if [ -f ".config.initrd.save" ]; then
rm -rf output
if [ -d "output.initrd.save" ]; then
mv output.initrd.save output
fi
cp -p .config.initrd.save .config
rm -f .config.initrd.save
fi
}
umask 002
PATH=/sbin:/usr/sbin:$PATH
build_arch="$(awk -F'"' '/^BR2_ARCH=/ { print $2; nextfile }' .config)"
if [ -z "$build_arch" ]; then
echo "Unknown build architecture, exiting."
exit 1
fi
initrd_config_file="${build_arch}-configs/initrd.config"
if [ ! -f "$initrd_config_file" ]; then
echo "Invalid build architecture '$build_arch', exiting."
exit 1
fi
if [ -f "initrd.arch" ]; then
initrd_arch="$(cat initrd.arch)"
else
initrd_arch=""
fi
if [ -f "initrd.img" -a "$initrd_arch" = "$build_arch" -a "$1" != "force" ]; then
echo "The initrd image (initrd.img) already exists, skipping build."
exit 0
fi
if [ ! -f "$initrd_config_file" ]; then
echo "The $initrd_config_file file does not exist, exiting."
exit 1
fi
save_state
trap 'restore_state; exit $?' INT TERM EXIT
make oldconfig
time make all
trap - INT TERM EXIT
if [ -f "output/images/rootfs.ext2.gz" ]; then
echo "Installing initrd.img..."
cp "output/images/rootfs.ext2.gz" "initrd.img"
echo "$build_arch" > "initrd.arch"
rtn_val=0
else
echo "Initrd build failed."
rtn_val=1
fi
restore_state
make oldconfig
exit $rtn_val