package="$6"
shift 6
+srcdir=$(pwd)
cd "$dkms_dir" || exit 1
+built_using_record()
+{
+ local subst="$1"
+ local built_using="$2"
+ if [ ! -f "$subst" ]; then
+ touch "$subst"
+ fi
+ if ! grep -q -s "^linux:BuiltUsing=" "$subst"; then
+ echo "linux:BuiltUsing=" >>"$subst"
+ fi
+ sed -i -e "s/^\(linux:BuiltUsing=.*\)/\1$built_using, /" "$subst"
+}
+
# Download and extract the DKMS package -- note there may be more
# than one package to install.
for package_path in "$@"
;;
esac
dpkg -x "$lpackage"_*.deb "$package"
+
+ for lpackage_path in "$lpackage"_*.deb
+ do
+ break
+ done
+ lversion=$( echo "$lpackage_path" | sed -e 's@.*/@@' -e 's@_[^_]*$@@' -e 's@.*_@@')
+ built_using_record "$srcdir/debian/$pkgname.substvars" "$built_using$lpackage (= $lversion)"
done
# Pick out the package/version from the dkms.conf.
# package is installed directly, but not so much if we build it out
# of the normal location.
sed -i -e '/^PACKAGE_NAME=/ s/#//g' "$dkms_conf"
+cat - <<'EOF' >>"$dkms_conf"
+POST_BUILD="ubuntu-save-objects ${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build ${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/objects $POST_BUILD"
+EOF
+ubuntu_script="$(dirname "$dkms_conf")/ubuntu-save-objects"
+cat - <<'EOF' >"$ubuntu_script"
+#!/bin/sh
+from="$1"
+to="$2"
+script="$3"
+shift 2
+
+# Copy the objects.
+echo "II: copying objects to '$to'"
+mkdir -p "$to"
+(cd "$from" && find -name \*.o -o -name \*.o.ur-\* | cpio -Lpd "$to")
+
+# Call the original post_install script if there is one.
+[ "$script" = '' ] && exit 0
+
+shift
+exec "$(dirname "$0")/$script" "$@"
+EOF
+chmod +x "$ubuntu_script"
dkms_package=$( sed -ne 's/PACKAGE_NAME="\(.*\)"/\1/p' "$dkms_conf" )
dkms_version=$( sed -ne 's/PACKAGE_VERSION="\(.*\)"/\1/p' "$dkms_conf" )