blob: 2ec278dcfbc7137a838687f5a39b5114f3fd9295 (
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
|
#!/bin/sh
. samizdat-paths.sh
if [ -d "$1" ]
then
samizdat_linux_dir=$1
fi
initrd=${samizdat_linux_dir}/initrd.img
vmlinuz=${samizdat_linux_dir}/vmlinuz
conf_dir=$samizdat_initramfs_conf_dir
get_kernel_version()
{
local pkgs_file="$1"
egrep '^ii linux-image-(amd64|686)' "$pkgs_file" |
(read _ pkg ver _; apt-cache show "$pkg=$ver") |
grep Depends |
(read _ a; echo ${a#linux-image-})
}
pkgs_file=rootfs/_build/${rootfs:-samizdat}.pkgs.txt
[ -f "$pkgs_file" ] || exit
kernel_version=$(get_kernel_version rootfs/_build/${rootfs:-samizdat}.pkgs.txt)
[ "$kernel_version" ] || exit
debian_initrd=/boot/initrd.img-${kernel_version}
find_deps() {
find "$conf_dir" "$samizdat_initrd_files_dir" "$debian_initrd" "$@"
}
force_rebuild()
{
touch "$conf_dir"
return 1
}
rebuild()
{
set -ex
cp -f /boot/vmlinuz-"${kernel_version}" "$vmlinuz"
/usr/sbin/mkinitramfs -d "$conf_dir" -o "$initrd" "${kernel_version}" || force_rebuild
}
if [ ! -e "$initrd" -o ! -e "$vmlinuz" ]; then
rebuild
else
found=$(find_deps -newer "$initrd" -print -quit)
if [ "$found" ]; then
echo "initrd.sh: rebuild forced: found modified source: $found" >&2
rebuild
fi
fi
|