[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: grub -18 *may* break your system



Steven Chamberlain:
> On 01/09/13 18:04, Robert Millan wrote:
>> [...] maybe we should move the modules to /boot like
>> upstream does? And make /lib/modules a symlink or something.
> 
> Yes I think so.  It already works with grub2 (it resolves the symlink
> for paths used in grub.cfg), and it seems justified by the FHS too:
> 
> http://www.debian.org/doc/packaging-manuals/fhs/fhs-2.3.html#BOOTSTATICFILESOFTHEBOOTLOADER
>> /boot : Static files of the boot loader
>> Purpose:
>> This directory contains everything required for the boot process
>> [...] before the kernel begins executing user-mode programs.
> 
> whereas on Linux the required kernel modules would be already copied to
> /boot/initrd.img
> 
> The FHS docs also imply that /lib/modules may be a symlink:
> 
>> The following directories, or symbolic links to directories, must be in /lib, if the corresponding subsystem is installed:
>>
>> Directory	Description
>> modules	Loadable kernel modules (optional)

Thanks for the research. I've just made a patch for this, and partially
tested it on kfreebsd-10. If there is no opposition I'll commit it after
kernel-wedge is updated (it required a fix to handle symlinks).

-- 
Robert Millan
Index: debian/control.in
===================================================================
--- debian/control.in	(revision 4929)
+++ debian/control.in	(working copy)
@@ -11,7 +11,7 @@
  @cc_pkg@, libdb-dev,
  libbsd-dev (>= 0.3.0), pkg-config,
  libsbuf-dev (>= 9.0+ds1-2),
- kernel-wedge (>= 2.79) [kfreebsd-any],
+ kernel-wedge (>= 2.88) [kfreebsd-any],
 Standards-Version: 3.9.2
 
 Package: kfreebsd-source-@version@
Index: debian/rules
===================================================================
--- debian/rules	(revision 4930)
+++ debian/rules	(working copy)
@@ -157,8 +157,8 @@
 	# Change ident to the kernel version
 	sed -i -e 's/^i=.*/i="Debian $* ($(full_version))"/g' $(FLAVOR_DIR)-$*/sys/conf/newvers.sh
 
-	# Set /lib/modules/${RELEASE} as module dir
-	sed -i -e 's,^KODIR?=.*,KODIR="/lib/modules/$(version)-$(abiname)-$*",g' $(FLAVOR_DIR)-$*/sys/conf/kern.pre.mk
+	# Override module dir
+	sed -i -e 's,^KODIR?=.*,KODIR="/boot/modules/$(version)-$(abiname)-$*",g' $(FLAVOR_DIR)-$*/sys/conf/kern.pre.mk
 
 	# Always set explicit link target to match with ld's implicit target (needed
 	# to build on non-kFreeBSD)
@@ -212,7 +212,7 @@
 	dh_testroot
 	dh_clean -k -pkfreebsd-image-$(version)-$(abiname)-$*
 
-	mkdir -p $(IMAGE_PACKAGE)-$*/{boot,lib/modules/$(version)-$(abiname)-$*}
+	mkdir -p $(IMAGE_PACKAGE)-$*/boot/modules/$(version)-$(abiname)-$*
 
 	# make the install target happy
 	install -o root -g root -m 644 \
@@ -233,12 +233,12 @@
 
 	# now install the kernel
 	$(MAKE) CC=$(cc_cmd) -C $(FLAVOR_DIR)-$*/sys/$(kfreebsd_cpu)/compile/$(configfile) DESTDIR=$(IMAGE_PACKAGE)-$* install
-	mv $(IMAGE_PACKAGE)-$*/lib/modules/$(version)-$(abiname)-$*/kernel $(IMAGE_PACKAGE)-$*/boot/kfreebsd-$(version)-$(abiname)-$*
+	mv $(IMAGE_PACKAGE)-$*/boot/modules/$(version)-$(abiname)-$*/kernel $(IMAGE_PACKAGE)-$*/boot/kfreebsd-$(version)-$(abiname)-$*
 	chmod 644 $(IMAGE_PACKAGE)-$*/boot/kfreebsd-$(version)-$(abiname)-$*
 	gzip -9 $(IMAGE_PACKAGE)-$*/boot/kfreebsd-$(version)-$(abiname)-$*
 
 	# fix broken perms in module dir
-	-chmod 644 $(IMAGE_PACKAGE)-$*/lib/modules/$(version)-$(abiname)-$*/*
+	-chmod 644 $(IMAGE_PACKAGE)-$*/boot/modules/$(version)-$(abiname)-$*/*
 
 	# remove loader.conf (part of kfreebsd-loader)
 	rm -f $(IMAGE_PACKAGE)-$*/boot/loader.conf
@@ -247,6 +247,13 @@
 	# remove device.hints (built into kernel)
 	rm -f $(IMAGE_PACKAGE)-$*/boot/device.hints
 
+	# compatibility symlink
+	mkdir -p $(IMAGE_PACKAGE)-$*/lib/modules
+	ln -s \
+		../../boot/modules/$(version)-$(abiname)-$* \
+		$(IMAGE_PACKAGE)-$*/lib/modules/$(version)-$(abiname)-$*
+
+
 	# README file
 	mkdir -p $(IMAGE_PACKAGE)-$*/usr/share/doc/kfreebsd-image-$(version)-$(abiname)-$*
 	install -p -o root -g root -m 644 \
@@ -333,12 +340,12 @@
 	dh_installdocs -s
 	dh_installchangelogs -s
 	dh_link -s
-	dh_strip -s -X/boot -X/lib/modules
+	dh_strip -s -X/boot
 	dh_compress -s
 	dh_fixperms -s
 	dh_makeshlibs -s
 	dh_installdeb -s
-	dh_shlibdeps -s -X/boot -X/lib/modules
+	dh_shlibdeps -s -X/boot
 	dh_gencontrol -s
 	dh_md5sums -s
 	dh_builddeb -s -- -Zxz

Reply to: