]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - debian/scripts/dkms-build
13 here
=$
(dirname "$(readlink -f "${0}")")
16 cd "$dkms_dir" ||
exit 1
21 local built_using
="$2"
22 if [ ! -f "$subst" ]; then
25 if ! grep -q -s "^linux:BuiltUsing=" "$subst"; then
26 echo "linux:BuiltUsing=" >>"$subst"
28 sed -i -e "s/^\(linux:BuiltUsing=.*\)/\1$built_using, /" "$subst"
31 # ABI: returns present in $? and located path in lpackage_path when found.
34 for lpackage_path
in "$1"_
*.deb
38 [ -f "$lpackage_path" ]
41 # Download and extract the DKMS package -- note there may be more
42 # than one package to install.
43 for package_path
in "$@"
45 package_file
=$
(basename "$package_path")
46 echo "II: dkms-build downloading $package ($package_file)"
47 rpackage
=$
( echo "$package_path" |
sed -e 's@.*/@@' -e 's@_.*@@' )
48 lpackage
=$
( echo "$rpackage" |
sed -e 's@=.*@@' )
52 if package_present
"$lpackage"; then
55 case "$package_path" in
57 # Attempt download from the launchpad librarian first.
58 "$here/file-downloader" "https://launchpad.net/ubuntu/+archive/primary/+files/$package_file" || true
59 if package_present
"$lpackage"; then
63 # Download from the available pools.
64 for pool
in $
( grep -h '^deb ' /etc
/apt
/sources.list
/etc
/apt
/sources.list.d
/*.list |
awk '{print $2}' |
sort -u )
66 if package_present
"$lpackage"; then
69 url
="$pool/$package_path"
70 "$here/file-downloader" "$url" && break || true
71 # No components in PPAs.
72 url
=$
(echo "$url" |
sed -e 's@/pool/[^/]*/@/pool/main/@')
73 "$here/file-downloader" "$url" && break || true
77 "$here/file-downloader" "$package_path"
80 cp -p "$package_path" .
83 apt-get download
"$rpackage"
88 if ! package_present
"$lpackage"; then
89 echo "EE: $lpackage not found"
93 dpkg
-x "$lpackage"_
*.deb
"$package"
95 lversion
=$
( echo "$lpackage_path" |
sed -e 's@.*/@@' -e 's@_[^_]*$@@' -e 's@.*_@@')
96 #built_using_record "$srcdir/debian/$pkgname.substvars" "$built_using$lpackage (= $lversion)"
99 # Pick out the package/version from the dkms.conf.
100 for dkms_conf
in "$package/usr/src"/*/"dkms.conf"
105 # It seems some packages have a # in the name which works fine if the
106 # package is installed directly, but not so much if we build it out
107 # of the normal location.
108 sed -i -e '/^PACKAGE_NAME=/ s/#//g' "$dkms_conf"
110 # Run any dkms-package specfic configuration steps
111 dkms_config_specific
="$srcdir/$0-configure--$package"
112 dkms_config_generic
=$
(echo "$dkms_config_specific" |
sed -e 's/-[0-9][0-9]*$/-N/')
113 for dkms_config
in "$dkms_config_specific" "$dkms_config_generic"
115 if [ -z "$dkms_config" -o ! -e "$dkms_config" ]; then
118 echo "II: dkms-build-configure $(basename "$dkms_config") found, executing"
119 $SHELL "$dkms_config" \
133 cat - <<'EOF' >>"$dkms_conf"
134 POST_BUILD="ubuntu-save-objects ${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build ${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/objects $POST_BUILD"
136 ubuntu_script
="$(dirname "$dkms_conf")/ubuntu-save-objects"
137 cat - <<'EOF' >"$ubuntu_script"
145 echo "II: copying objects to '$to'"
147 (cd "$from" && find -name \*.o -o -name \*.o.ur-\* | cpio -Lpd "$to")
149 # Call the original post_install script if there is one.
150 [ "$script" = '' ] && exit 0
153 exec "$(dirname "$0")/$script" "$@"
155 chmod +x
"$ubuntu_script"
156 dkms_package
=$
( sed -ne 's/PACKAGE_NAME="\(.*\)"/\1/p' "$dkms_conf" )
157 dkms_version
=$
( sed -ne 's/PACKAGE_VERSION="\(.*\)"/\1/p' "$dkms_conf" )
159 # Build the DKMS binaries.
160 echo "II: dkms-build building $package"
162 /usr
/sbin
/dkms build
--no-prepare-kernel --no-clean-kernel \
164 --sourcetree "$dkms_dir/source" \
165 --dkmstree "$dkms_dir/build" \
166 --kernelsourcedir "$dkms_dir/headers/linux-headers-$abi_flavour" \
169 # Find the log and add it to our own.
170 for log
in "$dkms_dir/build/$dkms_package/$dkms_version/$abi_flavour"/*/"log/make.log" "$dkms_dir/build/$dkms_package/$dkms_version/build/make.log"
172 [ -f "$log" ] && break
174 sed -e "s@$dkms_dir@<<DKMSDIR>>@g" <"$log"
176 # If this build failed then exit here.
177 [ "$rc" != 0 ] && exit "$rc"
179 # Install the modules with debug symbols we possibly built,
180 # and strip the original modules for the next install step.
181 if [ -n "$dbgpkgdir" ]; then
182 dbgpkgdir
="$dbgpkgdir/$package"
183 echo "II: dkms-build installing $package into $dbgpkgdir (debug symbols)"
184 install -d "$dbgpkgdir"
185 find "$dkms_dir/build/$dkms_package/$dkms_version/$abi_version" -name \
*.ko |
186 while read module
; do
187 vmodule
=$
( basename "$module" )
189 # Check for '.debug_info' section in order to copy module.
190 # Useful if debug symbols are requested but not built for
191 # any reason (including not yet supported by DKMS package).
192 # Strip module just in case even if section isn't present.
193 if ${CROSS_COMPILE}objdump
-h -j '.debug_info' "$module" >/dev
/null
2>&1
195 echo "copying $vmodule"
196 cp "$module" "$dbgpkgdir"
198 echo "ignoring $vmodule (missing debug symbols)"
201 # Just 'strip -g' as '/usr/sbin/dkms' does.
202 echo "stripping $vmodule"
207 # Install and optionally sign the modules we have built.
208 pkgdir
="$pkgdir/$package"
209 echo "II: dkms-build installing $package into $pkgdir"
211 find "$dkms_dir/build/$dkms_package/$dkms_version/$abi_version" -name \
*.ko |
212 while read module
; do
213 vmodule
=$
( basename "$module" )
216 echo "copying $vmodule"
217 cp "$module" "$pkgdir"
220 echo "signing $vmodule"
221 $sign "$module" "$pkgdir/$vmodule"
226 find "$dkms_dir/build/$dkms_package/$dkms_version/objects" -name \
*.o
-print | \
229 "$srcdir/debian/scripts/fix-filenames" "$object" "$dkms_dir"
232 # Finally see if there is a dkms-package specific post processor present. Hand
233 # it the original source directory, destination package directory, the objects
234 # as squirreled away, and the log in case it is useful. Finally pass a formed
235 # signing command line in case we need to do that.
236 dkms_build_specific
="$srcdir/$0--$package"
237 dkms_build_generic
=$
(echo "$dkms_build_specific" |
sed -n -e 's/-[0-9][0-9]*[a-z]*$/-N/p')
238 for dkms_build
in "$dkms_build_specific" "$dkms_build_generic"
240 if [ -z "$dkms_build" -o ! -e "$dkms_build" ]; then
243 echo "II: dkms-build override $(basename "$dkms_build") found, executing"
244 $SHELL "$dkms_build" \
246 "$dkms_dir/build/$dkms_package/$dkms_version/objects" \
259 echo "II: dkms-build build $package complete"