blob: 52e86b5698e7abfcc92d73cb9d29c004b1c92cba (
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
|
#!/bin/bash
if [ "$(id -u)" != 0 ]
then
exec sudo -- "$0" "$@"
exit 1
fi
loudly()
{
(set -x
"$@")
}
deb_arch()
{
dpkg-architecture -q DEB_HOST_ARCH
}
up_to_date()
{
local found system_initrd
system_initrd=${1%$OUTPUT_TAG}
[ -e "$1" ] || return
found=$(find "$samizdat_initramfs_conf_dir" \
"$samizdat_initrd_files_dir" \
"$system_initrd" \
-type f -newer "$1" -print -quit) || return
[ -z "$found" ]
}
build_image()
{
OUTPUT=/boot/initrd.img-$1${OUTPUT_TAG}
# Always regenerate when --system specified.
# Otherwise, only regenerate if it appears dependencies changed.
if [ -z "$OUTPUT_TAG" ] || ! up_to_date "$OUTPUT"
then
/usr/sbin/mkinitramfs \
-d "$samizdat_initramfs_conf_dir" \
-o "$OUTPUT" \
-k "$1" || return
fi
loudly ln -sf "${OUTPUT#/}" /initrd.img
}
. samizdat-paths.sh
OUTPUT_TAG=.samizdat
while [ $# -gt 0 ]
do
case "$1" in
-s|--system) OUTPUT_TAG=; shift; continue;;
--) shift; break;;
-?) exit 1;;
*) break;;
esac
done
if [ "$1" ]
then
k=/boot/vmlinuz-$1
if ! [ -e "$k" ]
then
printf 'Error: No such file: %s\n' "$k" >&2
exit 1
fi
build_image "$1" || exit
ln -sf "${k#/}" /vmlinuz
elif [ -L /vmlinuz ]
then
l=$(readlink /vmlinuz)
mv=${l#boot/vmlinuz-}
for v in "$mv" "$mv-$(deb_arch)"
do
[ -e "/boot/vmlinuz-$v" ] || continue
build_image "$v"
exit
done
exit 1
else
printf 'Error: Could not determine kernel version. Create /vmlinuz or specify a version.' >&2
exit 1
fi
|