Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove embedded DESTDIR in make variables, honour them #339

Merged
merged 19 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 54 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,87 @@ RELEASE_MICRO := 11
RELEASE_NAME := dkms
RELEASE_VERSION := $(RELEASE_MAJOR).$(RELEASE_MINOR).$(RELEASE_MICRO)
RELEASE_STRING := $(RELEASE_NAME)-$(RELEASE_VERSION)
DIST := unstable
SHELL=bash

SBIN = $(DESTDIR)/usr/sbin
ETC = $(DESTDIR)/etc/dkms
VAR = $(DESTDIR)/var/lib/dkms
MAN = $(DESTDIR)/usr/share/man/man8
INITD = $(DESTDIR)/etc/rc.d/init.d
LIBDIR = $(DESTDIR)/usr/lib/dkms
BASHDIR = $(DESTDIR)/usr/share/bash-completion/completions
KCONF = $(DESTDIR)/etc/kernel
SHAREDIR = $(DESTDIR)/usr/share
DOCDIR = $(SHAREDIR)/doc/dkms
SYSTEMD = $(DESTDIR)/usr/lib/systemd/system
SBIN = /usr/sbin
LIBDIR = /usr/lib/dkms
KCONF = /etc/kernel
SYSTEMD = /usr/lib/systemd/system

#Define the top-level build directory
BUILDDIR := $(shell pwd)
TOPDIR := $(shell pwd)

.PHONY = tarball

all: clean tarball
all: dkms dkms.8 dkms_autoinstaller dkms.service kernel_install.d_dkms kernel_postinst.d_dkms

clean:
-rm -rf dist/
-rm -rf dkms
-rm -rf dkms.8
-rm -rf dkms_autoinstaller
-rm -rf dkms.service
-rm -rf kernel_install.d_dkms
-rm -rf kernel_postinst.d_dkms

dkms: dkms.in
sed -e 's/#RELEASE_STRING#/$(RELEASE_STRING)/' $^ > $@

dkms.8: dkms.8.in
sed -e 's/#RELEASE_STRING#/$(RELEASE_STRING)/' -e 's/#RELEASE_DATE#/$(RELEASE_DATE)/' $^ > $@

install: dkms dkms.8
mkdir -p $(VAR)
install -D -m 0755 dkms_common.postinst $(LIBDIR)/common.postinst
install -D -m 0755 dkms $(SBIN)/dkms
install -D -m 0755 dkms_autoinstaller $(LIBDIR)/dkms_autoinstaller
install -D -m 0644 dkms_framework.conf $(ETC)/framework.conf
mkdir -p $(ETC)/framework.conf.d
install -D -m 0644 dkms.bash-completion $(BASHDIR)/dkms
install -D -m 0644 dkms.8 $(MAN)/dkms.8
install -D -m 0755 kernel_install.d_dkms $(KCONF)/install.d/40-dkms.install
install -D -m 0755 kernel_postinst.d_dkms $(KCONF)/postinst.d/dkms
install -D -m 0755 kernel_prerm.d_dkms $(KCONF)/prerm.d/dkms
gzip -n -9 $(MAN)/dkms.8
dkms_autoinstaller: dkms_autoinstaller.in
sed -e 's,@SBINDIR@,$(SBIN),g' $^ > $@

dkms.service: dkms.service.in
sed -e 's,@SBINDIR@,$(SBIN),g' $^ > $@

kernel_install.d_dkms: kernel_install.d_dkms.in
sed -e 's,@KCONFDIR@,$(KCONF),g' $^ > $@

kernel_postinst.d_dkms: kernel_postinst.d_dkms.in
sed -e 's,@LIBDIR@,$(LIBDIR),g' $^ > $@

install: all
$(if $(strip $(VAR)),$(error Setting VAR is not supported))
install -d -m 0755 $(DESTDIR)/var/lib/dkms
ifneq (,$(DESTDIR))
$(if $(filter $(DESTDIR)%,$(SBIN)),$(error Using a DESTDIR as prefix for SBIN is no longer supported))
$(if $(filter $(DESTDIR)%,$(LIBDIR)),$(error Using a DESTDIR as prefix for LIBDIR is no longer supported))
$(if $(filter $(DESTDIR)%,$(KCONF)),$(error Using a DESTDIR as prefix for KCONF is no longer supported))
endif
install -D -m 0755 dkms $(DESTDIR)$(SBIN)/dkms
install -D -m 0755 dkms_common.postinst $(DESTDIR)$(LIBDIR)/common.postinst
install -D -m 0755 dkms_autoinstaller $(DESTDIR)$(LIBDIR)/dkms_autoinstaller
$(if $(strip $(ETC)),$(error Setting ETC is not supported))
install -D -m 0644 dkms_framework.conf $(DESTDIR)/etc/dkms/framework.conf
install -d -m 0755 $(DESTDIR)/etc/dkms/framework.conf.d
$(if $(strip $(BASHDIR)),$(error Setting BASHDIR is not supported))
install -D -m 0644 dkms.bash-completion $(DESTDIR)/usr/share/bash-completion/completions/dkms
install -D -m 0644 dkms.8 $(DESTDIR)/usr/share/man/man8/dkms.8
install -D -m 0755 kernel_install.d_dkms $(DESTDIR)$(KCONF)/install.d/40-dkms.install
install -D -m 0755 kernel_postinst.d_dkms $(DESTDIR)$(KCONF)/postinst.d/dkms
install -D -m 0755 kernel_prerm.d_dkms $(DESTDIR)$(KCONF)/prerm.d/dkms

install-redhat: install
install -D -m 0755 dkms_find-provides $(LIBDIR)/find-provides
install -D -m 0755 lsb_release $(LIBDIR)/lsb_release
install -D -m 0644 dkms.service $(SYSTEMD)/dkms.service
ifneq (,$(DESTDIR))
$(if $(filter $(DESTDIR)%,$(SYSTEMD)),$(error Using a DESTDIR as prefix for SYSTEMD is no longer supported))
endif
install -D -m 0644 dkms.service $(DESTDIR)$(SYSTEMD)/dkms.service

install-debian: install
install -D -m 0755 dkms_apport.py $(SHAREDIR)/apport/package-hooks/dkms_packages.py
install -D -m 0755 kernel_postinst.d_dkms $(KCONF)/header_postinst.d/dkms
$(if $(strip $(SHAREDIR)),$(error Setting SHAREDIR is not supported))
install -D -m 0755 dkms_apport.py $(DESTDIR)/usr/share/apport/package-hooks/dkms_packages.py
install -D -m 0755 kernel_postinst.d_dkms $(DESTDIR)$(KCONF)/header_postinst.d/dkms

install-doc:
install -d -m 0644 COPYING $(DOCDIR)
install -d -m 0644 README.md $(DOCDIR)
$(if $(strip $(DOC)),$(error Setting DOCDIR is not supported))
install -d -m 0755 $(DESTDIR)/usr/share/doc/dkms
install -m 0644 COPYING README.md $(DESTDIR)/usr/share/doc/dkms

.PHONY = tarball

TARBALL=$(BUILDDIR)/dist/$(RELEASE_STRING).tar.gz
tarball: $(TARBALL)

$(TARBALL): dkms dkms.8
$(TARBALL): all
mkdir -p $(@D)
git archive --prefix=$(RELEASE_STRING)/ --add-file=dkms --add-file=dkms.8 -o $@ HEAD
11 changes: 0 additions & 11 deletions dkms.8.in
Original file line number Diff line number Diff line change
Expand Up @@ -595,17 +595,6 @@ This also introduces a implicit distribution/version dependency on the
package, as the value of
.B OBSOLETE_BY
is meaningful only in the context of a single distribution/version.

If you feel you must use it, please use as such in dkms.conf:

ubuntu_804="Ubuntu
8.04"
if [ \-x /usr/bin/lsb_release ]; then
if [ "$(/usr/bin/lsb_release \-sir)" == "${ubuntu_804}" ]; then
OBSOLETE_BY="2.6.25"
fi
fi

.TP
.B PATCH[#]=
Use the PATCH directive array to specify patches which should be applied to your source before a build occurs.
Expand Down
38 changes: 3 additions & 35 deletions dkms.in
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ do_depmod()
}

# Grab distro information from os-release.
# Falls back to LSB for compliant distros.
distro_version()
{
if [[ -r /etc/os-release ]]; then
[[ -r /etc/os-release ]] || die 4 $"System is missing /etc/os-release file."
(
. /etc/os-release
if [[ "$ID" = "ubuntu" ]]; then
# ID_LIKE=debian in ubuntu
Expand All @@ -340,36 +340,7 @@ distro_version()
else
echo $ID
fi
return
fi

local DISTRIB_ID

# Try the LSB-provided strings first
if [ -r /etc/lsb-release ]; then
. /etc/lsb-release
elif type lsb_release >/dev/null 2>&1; then
DISTRIB_ID=$(lsb_release -i -s)
fi

case ${DISTRIB_ID} in
Fedora)
echo fedora
;;
RedHatEnterprise*|CentOS|ScientificSL)
echo rhel
;;
SUSE*)
echo sles
;;
*)
if [[ ${DISTRIB_ID} ]]; then
echo "${DISTRIB_ID}"
else
echo unknown
fi
;;
esac
)
}

override_dest_module_location()
Expand Down Expand Up @@ -2339,9 +2310,6 @@ autoinstall() {
#### ####
#############################

# Set a standard path
PATH="$PATH:/usr/lib/dkms"

# Ensure files and directories we create are readable to anyone,
# since we aim to build as a non-root user
umask 022
Expand Down
2 changes: 1 addition & 1 deletion dkms.service → dkms.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Before=network-pre.target graphical.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/sbin/dkms autoinstall --verbose --kernelver %v
ExecStart=@SBINDIR@/dkms autoinstall --verbose --kernelver %v

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion dkms_autoinstaller → dkms_autoinstaller.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if [ ! -f /etc/debian_version ]; then
alias log_action_msg=/bin/echo
fi

exec="/usr/sbin/dkms"
exec="@SBINDIR@/dkms"
prog=${exec##*/}

test -f $exec || exit 0
Expand Down
10 changes: 0 additions & 10 deletions dkms_common.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,6 @@ echo "Building for $KERNELS" | tr '\n' ',' \
| sed -e 's/,/, /g; s/, $/\n/; s/, \([^,]\+\)$/ and \1/'

if [ -n "$ARCH" ]; then
if which lsb_release >/dev/null && [ $(lsb_release -s -i) = "Ubuntu" ]; then
case $ARCH in
amd64)
ARCH="x86_64"
;;
lpia|i?86)
ARCH="i686"
;;
esac
fi
echo "Building for architecture $ARCH"
ARCH="-a $ARCH"
fi
Expand Down
93 changes: 0 additions & 93 deletions dkms_find-provides

This file was deleted.

4 changes: 2 additions & 2 deletions kernel_install.d_dkms → kernel_install.d_dkms.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh

if [ "$1" = "add" ]; then
/etc/kernel/postinst.d/dkms "$2"
@KCONFDIR@/postinst.d/dkms "$2"
fi

if [ "$1" = "remove" ]; then
/etc/kernel/prerm.d/dkms "$2"
@KCONFDIR@/prerm.d/dkms "$2"
fi
4 changes: 2 additions & 2 deletions kernel_postinst.d_dkms → kernel_postinst.d_dkms.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ case "${uname_s}" in
;;
esac

if [ -x /usr/lib/dkms/dkms_autoinstaller ]; then
exec /usr/lib/dkms/dkms_autoinstaller start "$inst_kern"
if [ -x @LIBDIR@/dkms_autoinstaller ]; then
exec @LIBDIR@/dkms_autoinstaller start "$inst_kern"
fi

if ! _check_kernel_dir "$inst_kern" ; then
Expand Down
Loading