]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - debian/scripts/dkms-build--nvidia-390
UBUNTU: [Packaging] nvidia -- build and sign nvidia packages and ship signatures
[mirror_ubuntu-bionic-kernel.git] / debian / scripts / dkms-build--nvidia-390
CommitLineData
e8eea6b4
AW
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"
13package="$6"
14shift 6
15
16build="$( dirname "$objects" )/build"
17
18# Copy over the objects ready for reconstruction.
19mkdir -p "$pkgdir/bits/scripts"
20cp -rp "$objects"/* "$pkgdir/bits"
21
22# Install the support files we need.
23cp "$srcdir/scripts/module-common.lds" "$pkgdir/bits/scripts"
24grep /usr/bin/ld.bfd "$log" | sed -e "s@$build/@@g" >"$pkgdir/bits/BUILD"
25grep /usr/bin/ld.bfd "$log" | sed -e "s@$build/@@g" \
26 -e 's/.*-o *\([^ ]*\) .*/rm -f \1/g' >"$pkgdir/bits/CLEAN"
27
28# As the builds contain the absolute filenames as used. Use RECONSTRUCT to
29# rebuild the .ko's, sign them, pull off the signatures and then finally clean
30# up again.
31(
32 cd "$pkgdir/bits" || exit 1
33 sh ./CLEAN
34 sh ./BUILD
35 for ko in *.ko
36 do
37 echo "cat '$ko' '$ko.sig' >'../$ko'" >>"$pkgdir/bits/BUILD"
38 echo "rm -f '../$ko'" >>"$pkgdir/bits/CLEAN"
39 done
40
41 if [ "$sign" = "--custom" ]; then
42 # We are building for and archive custom signing upload. Keep everything.
43 :
44 elif [ "$sign" = "--lrm" ]; then
45 # We are in LRM build the package a copy in any signatures we can
46 # find for them. These will be added after linking.
47
48 # Apply any local signatures.
49 base="/usr/lib/linux/$abi_flavour"
50 echo "II: adding signatures from $base ..."
51 cp "$base/signatures/$package/"*".ko.sig" "$pkgdir/bits"
52 sha256sum -c "$base/signatures/$package/SHA256SUMS" || exit 1
53 sh ./CLEAN
54 else
55 # We are in the main kernel, put the .kos together as we will
56 # on the users machine, sign them, and keep just the signature.
57 : >"SHA256SUMS"
58 for ko in *.ko
59 do
60 echo "detached-signature $ko"
61 $sign "$ko" "$ko.signed"
62 length=$( stat --format %s "$ko" )
63 dd if="$ko.signed" of="$ko.sig" bs=1 skip="$length" 2>/dev/null
64
65 rm -f "$ko.signed"
66 # Keep a checksum of the pre-signed object so we can check it is
67 # built correctly in LRM.
68 sha256sum -b "$ko" >>"SHA256SUMS"
69 done
70
71 # Clean out anything which not a signature.
72 mv "$pkgdir/bits/"*.sig "$pkgdir"
73 mv "$pkgdir/bits/SHA256SUMS" "$pkgdir"
74 find "$pkgdir" -name \*.sig -prune -o -name SHA256SUMS -prune -o -type f -print | xargs rm -f
75 find "$pkgdir" -depth -type d -print | xargs rmdir --ignore-fail-on-non-empty
76 fi
77) || exit "$?"