3 # First argument is the path to the kernel headers.
6 if [ ! -f ${KPATH}/include
/generated
/package.h
]; then
11 # Debian snippet courtesy of Ben Hutchings
13 # Assuming KPATH is the target kernel headers directory
14 DEB_PACKAGE_VERSION
=$
(sed -rn 's/^#define LINUX_PACKAGE_ID " Debian (.*)"/\1/p' ${KPATH}/include
/generated
/package.h
)
15 # Ignore backports part
16 DEB_PACKAGE_VERSION
=$
(echo ${DEB_PACKAGE_VERSION} |
sed -r 's/~(bpo|deb).*//')
17 # Get -ckt update number, if present
18 KERNEL_CKT_UPDATE
=$
(echo ${DEB_PACKAGE_VERSION} |
sed -rn 's/^[0-9]+\.[0-9]+\.[0-9]+-ckt([0-9]+).*/\1/p')
19 test -n "${KERNEL_CKT_UPDATE}" || KERNEL_CKT_UPDATE
=0
20 # Get package revision
21 DEB_PACKAGE_REVISION
=$
(echo ${DEB_PACKAGE_VERSION} |
sed -r 's/.*-([^-]+)$/\1/')
22 # Get non-sec update number
23 DEB_PACKAGE_REVISION_BASE
=$
(echo ${DEB_PACKAGE_REVISION} |
sed -r 's/^([0-9]+).*/\1/')
24 # Get security update number, if present
25 DEB_PACKAGE_REVISION_SECURITY
=$
(echo ${DEB_PACKAGE_REVISION} |
sed -rn 's/.*\+(squeeze|deb[0-9])+u([0-9]+)$/\1/p')
26 test -n "${DEB_PACKAGE_REVISION_SECURITY}" || DEB_PACKAGE_REVISION_SECURITY
=0
27 # Combine all update numbers into one
28 DEB_API_VERSION
=$
((KERNEL_CKT_UPDATE
* 10000 + DEB_PACKAGE_REVISION_BASE
* 100 + DEB_PACKAGE_REVISION_SECURITY
))
30 echo ${DEB_API_VERSION}