]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - debian/scripts/dkms-build--nvidia-N
UBUNTU: [Packaging] initial packaging import from linux-unstable-5.12
[mirror_ubuntu-jammy-kernel.git] / debian / scripts / dkms-build--nvidia-N
CommitLineData
29f98055
LO
1#!/bin/sh
2
3srcdir="$1"
4objects="$2"
5log="$3"
6shift 3
7
8dkms_dir="$1"
9abi_flavour="$2"
10sign="$3"
11pkgname="$4"
12pkgdir="$5"
13dbgpkgdir="$6"
14package="$7"
15shift 7
16
17build="$( dirname "$objects" )/build"
18
19# Copy over the objects ready for reconstruction. The objects copy contains
20# the *.o files and the *.o-ur* retpoline files to allow the kernel to track
21# any retpoline sequences therein. For our purposes we only want the *.o
22# files, elide the rest.
23mkdir -p "$pkgdir/bits/scripts"
24(
25 gcc_variant1=$(gcc --version | head -1 | sed -e 's/^gcc/GCC:/')
26 gcc_variant2=$(gcc --version | head -1 | sed -e 's/^\(gcc\) \((.*)\) \(.*\)$/\1 version \3 \2/')
27 cd "$objects" || exit 1
28 find -name \*.o | \
29 while read file
30 do
31 cp --parents "$file" "$pkgdir/bits"
32 "$srcdir/debian/scripts/fix-filenames" "$pkgdir/bits/$file" "$gcc_variant1"
33 "$srcdir/debian/scripts/fix-filenames" "$pkgdir/bits/$file" "$gcc_variant2"
34 done
35)
36
37# Install the support files we need.
2392988e
AR
38echo "II: copying support files ..."
39for lds_src in \
40 "$dkms_dir/headers/linux-headers-$abi_flavour/scripts/module.lds" \
41 "/usr/src/linux-headers-$abi_flavour/scripts/module.lds" \
42 "$dkms_dir/headers/linux-headers-$abi_flavour/scripts/module-common.lds" \
43 "/usr/src/linux-headers-$abi_flavour/scripts/module-common.lds"
44do
45 [ ! -f "$lds_src" ] && continue
46 echo "II: copying support files ... found $lds_src"
47 cp "$lds_src" "$pkgdir/bits/scripts"
48 break
49done
50
51# Build helper scripts.
52cat - <<'EOL' >"$pkgdir/bits/BUILD"
53[ "$1" = "unsigned" ] && signed_only=:
54EOL
55grep /usr/bin/ld.bfd "$log" | grep -v scripts/genksyms/genksyms | sed -e "s@$build/@@g" >>"$pkgdir/bits/BUILD"
56sed -e 's/.*-o *\([^ ]*\) .*/rm -f \1/g' <"$pkgdir/bits/BUILD" >"$pkgdir/bits/CLEAN"
29f98055
LO
57
58# As the builds contain the absolute filenames as used. Use RECONSTRUCT to
59# rebuild the .ko's, sign them, pull off the signatures and then finally clean
60# up again.
61(
62 cd "$pkgdir/bits" || exit 1
2392988e
AR
63
64 # Add .ko handling to the CLEAN/BUILD dance.
65 for ko in "$pkgdir"/*.ko
29f98055 66 do
2392988e
AR
67 ko=$(basename "$ko")
68 echo "\$signed_only cat '$ko' '$ko.sig' >'../$ko'" >>"$pkgdir/bits/BUILD"
69 echo "\$signed_only rm -f '$ko'" >>"$pkgdir/bits/BUILD"
29f98055
LO
70 echo "rm -f '../$ko'" >>"$pkgdir/bits/CLEAN"
71 done
72
2392988e
AR
73 # Clear out anything we are not going to distribute and build unsigned .kos.
74 sh ./CLEAN
75 sh ./BUILD unsigned
76
29f98055
LO
77 if [ "$sign" = "--custom" ]; then
78 # We are building for and archive custom signing upload. Keep everything.
79 :
80 elif [ "$sign" = "--lrm" ]; then
2392988e
AR
81 # We are in the LRM build; grab sha256 checksums and clean up.
82 sha256sum -b *.ko >"SHA256SUMS"
29f98055 83 sh ./CLEAN
2392988e 84
29f98055
LO
85 else
86 # We are in the main kernel, put the .kos together as we will
87 # on the users machine, sign them, and keep just the signature.
88 : >"SHA256SUMS"
89 for ko in *.ko
90 do
91 echo "detached-signature $ko"
92 $sign "$ko" "$ko.signed"
93 length=$( stat --format %s "$ko" )
94 dd if="$ko.signed" of="$ko.sig" bs=1 skip="$length" 2>/dev/null
95
96 rm -f "$ko.signed"
97 # Keep a checksum of the pre-signed object so we can check it is
98 # built correctly in LRM.
99 sha256sum -b "$ko" >>"SHA256SUMS"
100 done
101
102 # Clean out anything which not a signature.
103 mv "$pkgdir/bits/"*.sig "$pkgdir"
104 mv "$pkgdir/bits/SHA256SUMS" "$pkgdir"
105 find "$pkgdir" -name \*.sig -prune -o -name SHA256SUMS -prune -o -type f -print | xargs rm -f
106 find "$pkgdir" -depth -type d -print | xargs rmdir --ignore-fail-on-non-empty
107 fi
108) || exit "$?"