summaryrefslogtreecommitdiff
path: root/mkinitramfs-kpkg
blob: 6beaad5ca4ce1dffb71ba417811844ae34be6924 (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
#!/bin/sh
set -eu

STATEDIR=/var/lib/initramfs-tools
supported_host_version=""
supported_target_version=""
outfile=""

# FIXME: drop script after Lenny (needed for Etch linux-images)

usage()
{
	cat >&2 << EOF

Usage: ${0} <-o outfile> [version]

Please use update-initramfs(8):
${0} exists for compatibility by kernel-package(5) calls.
See mkinitramfs-kpkg(8) for further details.
EOF
	exit 1
}

OPTIONS=`getopt -o m:o: --long supported-host-version:,supported-target-version: -n "$0" -- "$@"`
# Check for non-GNU getopt
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi

eval set -- "$OPTIONS"

while true; do
	case "$1" in
	-m)
		# ignore
		shift 2
		;;
	-o)
		touch $2
		outfile="$(readlink -f "$2")"
		shift 2
		;;
	--supported-host-version)
		supported_host_version="$2"
		shift 2
		;;
	--supported-target-version)
		supported_target_version="$2"
		shift 2
		;;
	--)
		shift
		break
		;;
	*)
		echo "Internal error!" >&2
		exit 1
		;;
	esac
done

if [ -n "$supported_host_version" ] || [ -n "$supported_target_version" ]; then
	if [ -n "$supported_host_version" ]; then
		host_upstream_version="${supported_host_version%%-*}"
	fi
	if [ -n "$supported_target_version" ]; then
		target_upstream_version="${supported_target_version%%-*}"
		if dpkg --compare-versions "$target_upstream_version" lt "2.6.12"; then
			exit 2
		fi
	fi
	exit 0
fi


if [ -z "${outfile}" ]; then
	usage
fi

# And by "version" we really mean path to kernel modules
# This is braindead, and exists to preserve the interface with mkinitrd
version="${1}"

case "${version}" in
/lib/modules/*/[!/]*)
	;;
/lib/modules/[!/]*)
	version="${version#/lib/modules/}"
	version="${version%%/*}"
	;;
esac

case "${version}" in
*/*)
	echo "$PROG: ${version} is not a valid kernel version" >&2
	exit 1
	;;
esac

echo "Deprecation WARNING: use update-initramfs(8)" >&2

# linux-image installs latest version
mkinitramfs -o ${outfile} ${version}
sha1sum "${outfile}" | sed -e 's/\.new//' > "${STATEDIR}/${version}"