Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 410199 - New ebuild: sys-freebsd/virtio-kmod
Summary: New ebuild: sys-freebsd/virtio-kmod
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: FreeBSD (show other bugs)
Hardware: All FreeBSD
: High enhancement (vote)
Assignee: Gentoo/BSD Team
URL:
Whiteboard:
Keywords: EBUILD, Inclusion
Depends on:
Blocks:
 
Reported: 2012-03-30 01:14 UTC by Richard Yao (RETIRED)
Modified: 2012-05-19 20:50 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
sys-freebsd/virtio-kmod (virtio-kmod-0.228301.ebuild,1.54 KB, text/plain)
2012-03-30 01:14 UTC, Richard Yao (RETIRED)
Details
pkg-descr file from FreeBSD ports (pkg-descr,156 bytes, text/plain)
2012-03-30 01:15 UTC, Richard Yao (RETIRED)
Details
pkg-message from FreeBSD ports (pkg-message,675 bytes, text/plain)
2012-03-30 01:16 UTC, Richard Yao (RETIRED)
Details
Manifest file (Manifest,776 bytes, text/plain)
2012-03-30 01:16 UTC, Richard Yao (RETIRED)
Details
sys-freebsd/virtio-kmod (virtio-kmod-0.228301.ebuild,1.52 KB, text/plain)
2012-03-30 01:21 UTC, Richard Yao (RETIRED)
Details
sys-freebsd/virtio-kmod manifest file (Manifest,776 bytes, text/plain)
2012-03-30 01:21 UTC, Richard Yao (RETIRED)
Details
sys-freebsd/virtio-kmod-0.228301 (virtio-kmod-0.228301.ebuild,1.69 KB, text/plain)
2012-03-30 02:27 UTC, Richard Yao (RETIRED)
Details
sys-freebsd/virtio-kmod manifest file (Manifest,776 bytes, text/plain)
2012-03-30 02:27 UTC, Richard Yao (RETIRED)
Details
sys-freebsd/virtio-kmod-0.228301 (virtio-kmod-0.228301.ebuild,1.60 KB, text/plain)
2012-03-30 03:19 UTC, Richard Yao (RETIRED)
Details
sys-freebsd/virtio-kmod manifest file (Manifest,776 bytes, text/plain)
2012-03-30 03:19 UTC, Richard Yao (RETIRED)
Details
sys-freebsd/virtio-kmod-0.228301 (virtio-kmod-0.228301.ebuild,1.67 KB, text/plain)
2012-03-30 15:47 UTC, Richard Yao (RETIRED)
Details
sys-freebsd/virtio-kmod manifest file (Manifest,776 bytes, text/plain)
2012-03-30 15:48 UTC, Richard Yao (RETIRED)
Details
sys-freebsd/virtio-kmod-0.228301 (virtio-kmod-0.228301.ebuild,1.59 KB, text/plain)
2012-03-30 15:56 UTC, Richard Yao (RETIRED)
Details
sys-freebsd/virtio-kmod manifest file (Manifest,776 bytes, text/plain)
2012-03-30 15:56 UTC, Richard Yao (RETIRED)
Details
sys-freebsd/virtio-kmod-0.228301.ebuild (virtio-kmod-0.228301.ebuild,1.54 KB, text/plain)
2012-03-30 16:12 UTC, Richard Yao (RETIRED)
Details
Manifest (Manifest,592 bytes, text/plain)
2012-03-30 16:12 UTC, Richard Yao (RETIRED)
Details
sys-freebsd/virtio-kmod-0.228301.ebuild (virtio-kmod-0.228301.ebuild,1.44 KB, text/plain)
2012-03-30 22:26 UTC, Richard Yao (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Yao (RETIRED) gentoo-dev 2012-03-30 01:14:21 UTC
Created attachment 307139 [details]
sys-freebsd/virtio-kmod

This is a port of FreeBSD's emulators/virtio-kmod port:

http://www.freshports.org/emulators/virtio-kmod/

I tested this on ~x86-fbsd, but I used the an amd64 FreeBSD system as a reference platform. The ebuild follows the upstream port file very closely, so I believe that this is safe to keyword on both ~amd64-fbsd and ~x86-fbsd.
Comment 1 Richard Yao (RETIRED) gentoo-dev 2012-03-30 01:15:49 UTC
Created attachment 307141 [details]
pkg-descr file from FreeBSD ports

Since this is a translation of the upstream port, I am including two files from it, which are referenced by the ebuild.
Comment 2 Richard Yao (RETIRED) gentoo-dev 2012-03-30 01:16:06 UTC
Created attachment 307143 [details]
pkg-message from FreeBSD ports
Comment 3 Richard Yao (RETIRED) gentoo-dev 2012-03-30 01:16:20 UTC
Created attachment 307145 [details]
Manifest file
Comment 4 Richard Yao (RETIRED) gentoo-dev 2012-03-30 01:21:32 UTC
Created attachment 307147 [details]
sys-freebsd/virtio-kmod

I am attaching a minor correction to remove RDEPEND from the ebuild.
Comment 5 Richard Yao (RETIRED) gentoo-dev 2012-03-30 01:21:56 UTC
Created attachment 307149 [details]
sys-freebsd/virtio-kmod manifest file
Comment 6 Richard Yao (RETIRED) gentoo-dev 2012-03-30 02:27:33 UTC
Created attachment 307151 [details]
sys-freebsd/virtio-kmod-0.228301

I have revised the ebuild to include custom-optimization and debug USE flags. Since the FreeBSD port doesn't technically provide us with the option to turn this off, I set it to be selected by default in IUSE.

Also, we seem to be triggered text relocation QA checks. I checked my Gentoo/FreeBSD install and every module appears to have one. I have added QA_TEXTRELS="*" to the ebuild to turn this off, although it is probably a good idea to find out if upstream FreeBSD suffers from this problem.
Comment 7 Richard Yao (RETIRED) gentoo-dev 2012-03-30 02:27:54 UTC
Created attachment 307153 [details]
sys-freebsd/virtio-kmod manifest file
Comment 8 Richard Yao (RETIRED) gentoo-dev 2012-03-30 03:19:20 UTC
Created attachment 307155 [details]
sys-freebsd/virtio-kmod-0.228301

Additional Improvements from working with naota in IRC.
Comment 9 Richard Yao (RETIRED) gentoo-dev 2012-03-30 03:19:40 UTC
Created attachment 307157 [details]
sys-freebsd/virtio-kmod manifest file
Comment 10 Richard Yao (RETIRED) gentoo-dev 2012-03-30 15:47:48 UTC
Created attachment 307191 [details]
sys-freebsd/virtio-kmod-0.228301

I cleaned up src_unpack.
Comment 11 Richard Yao (RETIRED) gentoo-dev 2012-03-30 15:48:02 UTC
Created attachment 307193 [details]
sys-freebsd/virtio-kmod manifest file
Comment 12 Richard Yao (RETIRED) gentoo-dev 2012-03-30 15:56:12 UTC
Created attachment 307199 [details]
sys-freebsd/virtio-kmod-0.228301

Merge functionality from src_prepare into src_unpack. The ebuild should be ready for inclusion into the main tree.
Comment 13 Richard Yao (RETIRED) gentoo-dev 2012-03-30 15:56:32 UTC
Created attachment 307201 [details]
sys-freebsd/virtio-kmod manifest file
Comment 14 Richard Yao (RETIRED) gentoo-dev 2012-03-30 16:12:03 UTC
Created attachment 307203 [details]
sys-freebsd/virtio-kmod-0.228301.ebuild

Remove pkg_info, which was broken and implement floppym's suggestion to use $UID instead of `id -u`.
Comment 15 Richard Yao (RETIRED) gentoo-dev 2012-03-30 16:12:54 UTC
Created attachment 307205 [details]
Manifest
Comment 16 Richard Yao (RETIRED) gentoo-dev 2012-03-30 22:26:25 UTC
Created attachment 307241 [details]
sys-freebsd/virtio-kmod-0.228301.ebuild

I removed the QA_TEXTRELS="*" line. It turns out that text relocations are not normal in upstream FreeBSD, but EVERY module on Gentoo/FreeBSD appears to have one, including the ones in /boot/modules.

After talking to Zorry and blueness, it seems that this is a security issue because it negatively affects ASLR. Every module has it, so it should not block my inclusion request because, but it is something that needs to be addressed. I will file another bug report when I know more.
Comment 17 Richard Yao (RETIRED) gentoo-dev 2012-03-30 22:29:05 UTC
I should have re-read that last comment before hitting submit. I had revised that a few times and it was mangled in the process. It should say:
 
I removed the QA_TEXTRELS="*" line. It seems that EVERY module in Gentoo/FreeBSD appears to have one, including the ones in /boot/modules. After talking to Zorry and blueness, it seems that this is a security issue because it negatively affects ASLR.

It should not block my inclusion request because since every module has it, but it is something that needs to be addressed. I will file another bug report when I know more.
Comment 18 Naohiro Aota gentoo-dev 2012-05-14 22:19:16 UTC
Could any other bsd team review this ebuild? The point I don't like is that this ebuild copy almost all the kernel source from /usr/src/sys.
Comment 19 Alexis Ballier gentoo-dev 2012-05-14 22:39:56 UTC
--
I removed the QA_TEXTRELS="*" line. It turns out that text relocations are not normal in upstream FreeBSD, but EVERY module on Gentoo/FreeBSD appears to have one, including the ones in /boot/modules.
--

please readd them, thats perfectly normal and fine for kernel modules.

---
	cd /usr/src/sys/
	for d in $NEEDSUBDIRS; do
		find $d ! -name @ | cpio --quiet "${CPIO_ARGS}" "${WORKDIR}"
	done
---

you should really do something alike to the other ebuilds.
freebsd-usbin-9.0 has, for example:
        ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys"
        ln -s "/usr/include" "${WORKDIR}/include"

moreover, sys may not be pointing to the right kernel.

--
	use debug && export DEBUG_FLAGS="-g"
--
useless imho, people are clever enough to add -g when they want debug symbols.

--
	dodir /boot/modules
	cp "${WORKDIR}"/modules/virtio/*/*.ko{,.symbols} "${ED}/boot/modules"
--

please use insinto + doins

}

--
pkg_postinst() {
	# Update linker.hints file
	/usr/sbin/kldxref "${EPREFIX}/boot/modules"
--
pkg_* functions should be ROOT-aware

--
	# Print message from FreeBSD Ports
	elog "$(cat "${FILESDIR}/pkg-message")"
}
--
better copy the message into the ebuild


--
and edit fstab and interface config in rc.conf:

# sed -i.bak -Ee 's|/dev/ada?|/dev/vtbd|' /etc/fstab
# sed -i.bak -e 's|em0|vtnet0|' /etc/rc.conf
--

moreover the message doesnt seem completely accurate: shall we really sed rc.conf with openrc ?
Comment 20 Richard Yao (RETIRED) gentoo-dev 2012-05-14 23:00:40 UTC
(In reply to comment #19)
> --
> I removed the QA_TEXTRELS="*" line. It turns out that text relocations are
> not normal in upstream FreeBSD, but EVERY module on Gentoo/FreeBSD appears
> to have one, including the ones in /boot/modules.
> --
> 
> please readd them, thats perfectly normal and fine for kernel modules.

Okay.

> ---
> 	cd /usr/src/sys/
> 	for d in $NEEDSUBDIRS; do
> 		find $d ! -name @ | cpio --quiet "${CPIO_ARGS}" "${WORKDIR}"
> 	done
> ---
> 
> you should really do something alike to the other ebuilds.
> freebsd-usbin-9.0 has, for example:
>         ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys"
>         ln -s "/usr/include" "${WORKDIR}/include"

That is not possible because the build system expects to write into the kernel sources directory.

> moreover, sys may not be pointing to the right kernel.

The same is true on Gentoo Linux with out of tree modules.

> --
> 	use debug && export DEBUG_FLAGS="-g"
> --
> useless imho, people are clever enough to add -g when they want debug
> symbols.

This was inherited from emulators/virtio-kmod.

> --
> 	dodir /boot/modules
> 	cp "${WORKDIR}"/modules/virtio/*/*.ko{,.symbols} "${ED}/boot/modules"
> --
> 
> please use insinto + doins

Good point. Thanks. :)

> --
> pkg_postinst() {
> 	# Update linker.hints file
> 	/usr/sbin/kldxref "${EPREFIX}/boot/modules"
> --
> pkg_* functions should be ROOT-aware
> 
> --
> 	# Print message from FreeBSD Ports
> 	elog "$(cat "${FILESDIR}/pkg-message")"
> }
> --
> better copy the message into the ebuild

That file is lifted from FreeBSD ports, which is why it is separate from the ebuild.

> 
> --
> and edit fstab and interface config in rc.conf:
> 
> # sed -i.bak -Ee 's|/dev/ada?|/dev/vtbd|' /etc/fstab
> # sed -i.bak -e 's|em0|vtnet0|' /etc/rc.conf
> --
> 
> moreover the message doesnt seem completely accurate: shall we really sed
> rc.conf with openrc ?

It is accurate for FreeBSD upstream, but there is no point in Gentoo/FreeBSD. I will try to revise the message.
Comment 21 Richard Yao (RETIRED) gentoo-dev 2012-05-19 20:48:18 UTC
I have committed this to the main tree. I will maintain it.
Comment 22 Richard Yao (RETIRED) gentoo-dev 2012-05-19 20:50:14 UTC
I forgot to mention that I believe I have addressed most concerns. The only thing I have not done is put pkg-message into the ebuild. I find it appealing to leave that outside the ebuild, so that I do not have to worry about where newline characters go and how indentation in the ebuild is handled.