summaryrefslogtreecommitdiff
path: root/sys-freebsd
diff options
context:
space:
mode:
Diffstat (limited to 'sys-freebsd')
-rw-r--r--sys-freebsd/boot0/Manifest25
-rw-r--r--sys-freebsd/boot0/boot0-10.3.ebuild82
-rw-r--r--sys-freebsd/boot0/boot0-11.0-r1.ebuild86
-rw-r--r--sys-freebsd/boot0/boot0-11.1.ebuild86
-rw-r--r--sys-freebsd/boot0/boot0-8.2.ebuild53
-rw-r--r--sys-freebsd/boot0/boot0-9.1.ebuild63
-rw-r--r--sys-freebsd/boot0/files/boot0-10.1-gcc46.patch67
-rw-r--r--sys-freebsd/boot0/files/boot0-10.3-clang.patch30
-rw-r--r--sys-freebsd/boot0/files/boot0-10.3-drop-unsupport-cflags.patch28
-rw-r--r--sys-freebsd/boot0/files/boot0-10.3-uefi-support.patch33
-rw-r--r--sys-freebsd/boot0/files/boot0-11.0-gcc46.patch14
-rw-r--r--sys-freebsd/boot0/files/boot0-11.0-uefi-support.patch21
-rw-r--r--sys-freebsd/boot0/files/boot0-8.2-zfsboot-makefile.patch13
-rw-r--r--sys-freebsd/boot0/files/boot0-9.2-gcc46.patch66
-rw-r--r--sys-freebsd/boot0/files/boot0-add-nossp-cflags.patch11
-rw-r--r--sys-freebsd/boot0/metadata.xml12
-rw-r--r--sys-freebsd/freebsd-bin/Manifest18
-rw-r--r--sys-freebsd/freebsd-bin/freebsd-bin-10.3.ebuild41
-rw-r--r--sys-freebsd/freebsd-bin/freebsd-bin-11.0.ebuild41
-rw-r--r--sys-freebsd/freebsd-bin/freebsd-bin-11.1.ebuild41
-rw-r--r--sys-freebsd/freebsd-bin/freebsd-bin-8.2.ebuild33
-rw-r--r--sys-freebsd/freebsd-bin/freebsd-bin-9.1.ebuild34
-rw-r--r--sys-freebsd/freebsd-bin/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-cddl/Manifest37
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.2-libpaths.patch220
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.3-underlink.patch12
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-11.0-add-libs.patch87
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-11.0-workaround.patch12
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.0-libpaths.patch114
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.2-libpaths.patch22
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-bsdxml.patch28
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-libpaths.patch167
-rw-r--r--sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-underlink.patch22
-rw-r--r--sys-freebsd/freebsd-cddl/files/zfs.initd23
-rw-r--r--sys-freebsd/freebsd-cddl/files/zvol.initd46
-rw-r--r--sys-freebsd/freebsd-cddl/files/zvol.initd-9.044
-rw-r--r--sys-freebsd/freebsd-cddl/freebsd-cddl-10.3.ebuild74
-rw-r--r--sys-freebsd/freebsd-cddl/freebsd-cddl-11.0.ebuild78
-rw-r--r--sys-freebsd/freebsd-cddl/freebsd-cddl-11.1.ebuild77
-rw-r--r--sys-freebsd/freebsd-cddl/freebsd-cddl-8.2.ebuild47
-rw-r--r--sys-freebsd/freebsd-cddl/freebsd-cddl-9.1.ebuild60
-rw-r--r--sys-freebsd/freebsd-cddl/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-contrib/Manifest9
-rw-r--r--sys-freebsd/freebsd-contrib/freebsd-contrib-8.2.ebuild55
-rw-r--r--sys-freebsd/freebsd-contrib/freebsd-contrib-9.1.ebuild54
-rw-r--r--sys-freebsd/freebsd-contrib/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-lib/Manifest77
-rw-r--r--sys-freebsd/freebsd-lib/files/bootpd.confd7
-rw-r--r--sys-freebsd/freebsd-lib/files/bootpd.initd27
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-atfcxx.patch49
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-liblink.patch98
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-libproc-libcxx.patch16
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-bsdxml2expat.patch39
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-liblink.patch26
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-10.3-libusb.patch13
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-bsdxml2expat.patch39
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-libproc-libcxx.patch13
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-libsysdecode.patch22
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-workaround.patch12
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-11.1-liblink.patch142
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-flex-2.5.31.patch13
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-gccfloat.patch16
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-pmc.patch13
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-6.1-csu.patch20
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-6.2-bluetooth.patch11
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-7.1-types.h-fix.patch15
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-gcc45.patch28
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-log2.patch21
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-rpcsec_gss.patch12
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-liblink.patch19
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-nlm_syscall.patch10
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-bluetooth.patch12
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-cve-2010-2632.patch215
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-liblink.patch21
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-netware.patch11
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-opieincludes.patch122
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-.eh_frame_hdr-fix.patch17
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-aligned_alloc.patch51
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-rmgssapi.patch16
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-add-nossp-cflags.patch30
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-bsdxml2expat.patch26
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-lib-includes.patch13
-rw-r--r--sys-freebsd/freebsd-lib/files/freebsd-sources-9.0-sysctluint.patch13
-rw-r--r--sys-freebsd/freebsd-lib/files/ftpd.pamd8
-rw-r--r--sys-freebsd/freebsd-lib/files/libusb-1.0.pc.in11
-rw-r--r--sys-freebsd/freebsd-lib/files/libusb.pc.in11
-rw-r--r--sys-freebsd/freebsd-lib/files/rquotad.xinetd11
-rw-r--r--sys-freebsd/freebsd-lib/files/rstatd.xinetd11
-rw-r--r--sys-freebsd/freebsd-lib/files/rusersd.xinetd11
-rw-r--r--sys-freebsd/freebsd-lib/files/sprayd.xinetd11
-rw-r--r--sys-freebsd/freebsd-lib/files/walld.xinetd11
-rw-r--r--sys-freebsd/freebsd-lib/freebsd-lib-10.3-r3.ebuild648
-rw-r--r--sys-freebsd/freebsd-lib/freebsd-lib-11.0-r1.ebuild644
-rw-r--r--sys-freebsd/freebsd-lib/freebsd-lib-11.1.ebuild708
-rw-r--r--sys-freebsd/freebsd-lib/freebsd-lib-8.2-r1.ebuild438
-rw-r--r--sys-freebsd/freebsd-lib/freebsd-lib-9.1-r11.ebuild617
-rw-r--r--sys-freebsd/freebsd-lib/metadata.xml16
-rw-r--r--sys-freebsd/freebsd-libexec/Manifest36
-rw-r--r--sys-freebsd/freebsd-libexec/files/bootpd.confd7
-rw-r--r--sys-freebsd/freebsd-libexec/files/bootpd.initd27
-rw-r--r--sys-freebsd/freebsd-libexec/files/freebsd-libexec-10.2-atf-check.patch28
-rw-r--r--sys-freebsd/freebsd-libexec/files/freebsd-libexec-7.2-pic.patch13
-rw-r--r--sys-freebsd/freebsd-libexec/files/freebsd-libexec-8.2-rtld.patch40
-rw-r--r--sys-freebsd/freebsd-libexec/files/freebsd-libexec-9.2-no_ld32.patch15
-rw-r--r--sys-freebsd/freebsd-libexec/files/ftpd.pamd8
-rw-r--r--sys-freebsd/freebsd-libexec/files/rquotad.xinetd11
-rw-r--r--sys-freebsd/freebsd-libexec/files/rstatd.xinetd11
-rw-r--r--sys-freebsd/freebsd-libexec/files/rusersd.xinetd11
-rw-r--r--sys-freebsd/freebsd-libexec/files/sprayd.xinetd11
-rw-r--r--sys-freebsd/freebsd-libexec/files/walld.xinetd11
-rw-r--r--sys-freebsd/freebsd-libexec/freebsd-libexec-10.3.ebuild111
-rw-r--r--sys-freebsd/freebsd-libexec/freebsd-libexec-11.0.ebuild130
-rw-r--r--sys-freebsd/freebsd-libexec/freebsd-libexec-8.2-r1.ebuild65
-rw-r--r--sys-freebsd/freebsd-libexec/freebsd-libexec-8.2.ebuild64
-rw-r--r--sys-freebsd/freebsd-libexec/freebsd-libexec-9.1-r2.ebuild80
-rw-r--r--sys-freebsd/freebsd-libexec/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-mk-defs/Manifest26
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.2-gnu.patch63
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.3-gentoo.patch337
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-drop-unsupport-cflags.patch13
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-gentoo.patch343
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-gnu.patch63
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-libproc-libcxx.patch13
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-rename-libs.patch16
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.1-gentoo.patch343
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gentoo.patch332
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gnu.patch121
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gentoo.patch326
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gnu.patch77
-rw-r--r--sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-add-nossp-cflags.patch28
-rw-r--r--sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-10.3.ebuild41
-rw-r--r--sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-11.0.ebuild54
-rw-r--r--sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-11.1.ebuild54
-rw-r--r--sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-8.2.ebuild40
-rw-r--r--sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-9.1.ebuild38
-rw-r--r--sys-freebsd/freebsd-mk-defs/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-pam-modules/Manifest16
-rw-r--r--sys-freebsd/freebsd-pam-modules/files/README.pamd61
-rw-r--r--sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-6.0-gentoo.patch24
-rw-r--r--sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-9.0-gentoo.patch22
-rw-r--r--sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-10.3.ebuild47
-rw-r--r--sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-11.0.ebuild45
-rw-r--r--sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-11.1.ebuild45
-rw-r--r--sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-8.2.ebuild47
-rw-r--r--sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-9.1-r1.ebuild44
-rw-r--r--sys-freebsd/freebsd-pam-modules/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-pf/Manifest34
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-libevent.patch16
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-pflogd.patch15
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-11.0-libevent.patch13
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-11.0-pflogd.patch13
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-11.1-libevent.patch13
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-11.1-pflogd.patch14
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-libevent.patch12
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-pcap_pollution.patch18
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-bpf.patch10
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-getline.patch38
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-libevent.patch15
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pcap_pollution.patch17
-rw-r--r--sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pflogd.patch13
-rw-r--r--sys-freebsd/freebsd-pf/files/pf.confd9
-rw-r--r--sys-freebsd/freebsd-pf/files/pf.initd49
-rw-r--r--sys-freebsd/freebsd-pf/freebsd-pf-10.3.ebuild72
-rw-r--r--sys-freebsd/freebsd-pf/freebsd-pf-11.0.ebuild70
-rw-r--r--sys-freebsd/freebsd-pf/freebsd-pf-11.1.ebuild70
-rw-r--r--sys-freebsd/freebsd-pf/freebsd-pf-8.2.ebuild64
-rw-r--r--sys-freebsd/freebsd-pf/freebsd-pf-9.1.ebuild66
-rw-r--r--sys-freebsd/freebsd-pf/metadata.xml8
-rw-r--r--sys-freebsd/freebsd-rescue/Manifest42
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-10.0-zlib.patch22
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-11.0-rename-libs.patch22
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-7.1-zlib.patch21
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.0-pkgconfig_static_libarchive.patch11
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.2-libzcleverlink.patch20
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-bsdtar.patch12
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-libcleverlink.patch21
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-sbin-bsdxml2expat.patch13
-rw-r--r--sys-freebsd/freebsd-rescue/files/freebsd-ubin-10.2-bsdxml.patch13
-rw-r--r--sys-freebsd/freebsd-rescue/freebsd-rescue-10.3.ebuild81
-rw-r--r--sys-freebsd/freebsd-rescue/freebsd-rescue-11.0.ebuild84
-rw-r--r--sys-freebsd/freebsd-rescue/freebsd-rescue-11.1.ebuild83
-rw-r--r--sys-freebsd/freebsd-rescue/freebsd-rescue-8.2.ebuild53
-rw-r--r--sys-freebsd/freebsd-rescue/freebsd-rescue-9.1.ebuild61
-rw-r--r--sys-freebsd/freebsd-rescue/metadata.xml12
-rw-r--r--sys-freebsd/freebsd-sbin/Manifest33
-rw-r--r--sys-freebsd/freebsd-sbin/files/adjkerntz-crontab4
-rw-r--r--sys-freebsd/freebsd-sbin/files/freebsd-sbin-10.0-zlib.patch22
-rw-r--r--sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.1-pr102701.patch17
-rw-r--r--sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.2-ldconfig.patch13
-rw-r--r--sys-freebsd/freebsd-sbin/files/freebsd-sbin-7.1-zlib.patch21
-rw-r--r--sys-freebsd/freebsd-sbin/files/freebsd-sbin-bsdxml2expat.patch13
-rw-r--r--sys-freebsd/freebsd-sbin/files/freebsd-sbin-setXid.patch20
-rw-r--r--sys-freebsd/freebsd-sbin/files/idmapd.initd20
-rw-r--r--sys-freebsd/freebsd-sbin/freebsd-sbin-10.3.ebuild100
-rw-r--r--sys-freebsd/freebsd-sbin/freebsd-sbin-11.0.ebuild99
-rw-r--r--sys-freebsd/freebsd-sbin/freebsd-sbin-11.1.ebuild102
-rw-r--r--sys-freebsd/freebsd-sbin/freebsd-sbin-8.2-r1.ebuild93
-rw-r--r--sys-freebsd/freebsd-sbin/freebsd-sbin-9.1.ebuild94
-rw-r--r--sys-freebsd/freebsd-sbin/metadata.xml21
-rw-r--r--sys-freebsd/freebsd-share/Manifest35
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-10.0-gentoo-eapi3.patch17
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-10.2-gnu-miscfiles.patch30
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-10.3-gentoo-skel.patch20
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-5.3-doc-locations.patch20
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-5.4-gentoo-skel.patch20
-rw-r--r--sys-freebsd/freebsd-share/files/freebsd-share-8.0-gnu-miscfiles.patch26
-rw-r--r--sys-freebsd/freebsd-share/freebsd-share-10.3.ebuild112
-rw-r--r--sys-freebsd/freebsd-share/freebsd-share-11.0.ebuild113
-rw-r--r--sys-freebsd/freebsd-share/freebsd-share-11.1.ebuild118
-rw-r--r--sys-freebsd/freebsd-share/freebsd-share-8.2.ebuild84
-rw-r--r--sys-freebsd/freebsd-share/freebsd-share-9.1.ebuild86
-rw-r--r--sys-freebsd/freebsd-share/metadata.xml12
-rw-r--r--sys-freebsd/freebsd-sources/Manifest67
-rw-r--r--sys-freebsd/freebsd-sources/files/config-GENTOO4
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-10.0-gentoo.patch22
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-10.1-gcc48.patch18
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-11.0-gentoo-gcc.patch13
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-11.0-gentoo.patch22
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-6.0-flex-2.5.31.patch22
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-6.1-ntfs.patch32
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-7.0-tmpfs_whiteout_stub.patch44
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-binutils_link.patch37
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-includes.patch13
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-types.h-fix.patch15
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-7.2-debug-O2.patch27
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-gentoo.patch33
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-subnet-route-pr40133.patch21
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-8.2-unix2.patch55
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-disable-optimization.patch32
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-ipv6refcount.patch128
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-sysctluint.patch13
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ciss.patch65
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3077.patch26
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3266.patch13
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5209.patch19
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5691.patch89
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5710.patch28
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2014-1453.patch70
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-exec.patch66
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-gentoo.patch21
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ktrace.patch12
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap-2014.patch20
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap.patch20
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-nfsserver.patch16
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-random.patch27
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-tcp.patch32
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-9.2-gentoo-gcc.patch13
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-sources-cve-2012-0217.patch26
-rw-r--r--sys-freebsd/freebsd-sources/files/freebsd-ubin-10.3-bmake-workaround.patch13
-rw-r--r--sys-freebsd/freebsd-sources/freebsd-sources-10.3-r6.ebuild175
-rw-r--r--sys-freebsd/freebsd-sources/freebsd-sources-11.0-r1.ebuild169
-rw-r--r--sys-freebsd/freebsd-sources/freebsd-sources-11.1_p1.ebuild170
-rw-r--r--sys-freebsd/freebsd-sources/freebsd-sources-8.2-r2.ebuild108
-rw-r--r--sys-freebsd/freebsd-sources/freebsd-sources-9.1-r3.ebuild83
-rw-r--r--sys-freebsd/freebsd-sources/freebsd-sources-9.1-r9.ebuild96
-rw-r--r--sys-freebsd/freebsd-sources/metadata.xml13
-rw-r--r--sys-freebsd/freebsd-ubin/Manifest61
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-atf.patch15
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-dtc-gcc46.patch25
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-kdump-ioctl.patch26
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-mandoc.patch13
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-bsdxml.patch13
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-talk-workaround.patch12
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.3-bmake-workaround.patch13
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-11.0-setXid.patch147
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-11.1-fixmakefiles.patch12
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-bsdcmp.patch13
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-fixmakefiles.patch35
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-kdump-ioctl.patch28
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-bsdar.patch21
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-xinstall.patch26
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.2-compress.patch55
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.0-fixmakefiles.patch11
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-ar-libarchive3.patch19
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-bsdar.patch25
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-grep.patch17
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-kdump-ioctl.patch24
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-minigzip.patch10
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-lint-stdarg.patch24
-rw-r--r--sys-freebsd/freebsd-ubin/files/freebsd-ubin-setXid.patch129
-rw-r--r--sys-freebsd/freebsd-ubin/files/locate-updatedb-cron6
-rw-r--r--sys-freebsd/freebsd-ubin/files/login.1.pamd4
-rw-r--r--sys-freebsd/freebsd-ubin/files/login.pamd18
-rw-r--r--sys-freebsd/freebsd-ubin/files/passwd.1.pamd7
-rw-r--r--sys-freebsd/freebsd-ubin/files/passwd.pamd9
-rw-r--r--sys-freebsd/freebsd-ubin/files/su.1.pamd15
-rw-r--r--sys-freebsd/freebsd-ubin/files/su.pamd15
-rw-r--r--sys-freebsd/freebsd-ubin/freebsd-ubin-10.3-r2.ebuild210
-rw-r--r--sys-freebsd/freebsd-ubin/freebsd-ubin-11.0-r1.ebuild212
-rw-r--r--sys-freebsd/freebsd-ubin/freebsd-ubin-11.1.ebuild211
-rw-r--r--sys-freebsd/freebsd-ubin/freebsd-ubin-8.2-r1.ebuild151
-rw-r--r--sys-freebsd/freebsd-ubin/freebsd-ubin-9.1-r2.ebuild180
-rw-r--r--sys-freebsd/freebsd-ubin/freebsd-ubin-9.1-r3.ebuild180
-rw-r--r--sys-freebsd/freebsd-ubin/metadata.xml24
-rw-r--r--sys-freebsd/freebsd-usbin/Manifest52
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.0-bsdxml2expat.patch24
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.3-bsdxml2expat.patch13
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-11.0-workaround.patch13
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-11.1-bsdxml2expat.patch26
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-7.0-nowrap.patch45
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-8.2-newsyslog.patch10
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.0-newsyslog.patch12
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-bsdxml2expat.patch12
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-kldxref.patch30
-rw-r--r--sys-freebsd/freebsd-usbin/files/freebsd-usbin-adduser.patch20
-rw-r--r--sys-freebsd/freebsd-usbin/files/iscsid.initd20
-rw-r--r--sys-freebsd/freebsd-usbin/files/mountd.patch15
-rw-r--r--sys-freebsd/freebsd-usbin/files/nfs.confd10
-rw-r--r--sys-freebsd/freebsd-usbin/files/nfs.initd54
-rw-r--r--sys-freebsd/freebsd-usbin/files/nfsuserd.confd5
-rw-r--r--sys-freebsd/freebsd-usbin/files/nfsuserd.initd20
-rw-r--r--sys-freebsd/freebsd-usbin/files/pw.conf5
-rw-r--r--sys-freebsd/freebsd-usbin/files/rpc.lockd.initd20
-rw-r--r--sys-freebsd/freebsd-usbin/files/rpc.statd.initd20
-rw-r--r--sys-freebsd/freebsd-usbin/freebsd-usbin-10.3-r1.ebuild189
-rw-r--r--sys-freebsd/freebsd-usbin/freebsd-usbin-11.0-r1.ebuild188
-rw-r--r--sys-freebsd/freebsd-usbin/freebsd-usbin-11.1.ebuild189
-rw-r--r--sys-freebsd/freebsd-usbin/freebsd-usbin-8.2-r2.ebuild162
-rw-r--r--sys-freebsd/freebsd-usbin/freebsd-usbin-9.1-r1.ebuild170
-rw-r--r--sys-freebsd/freebsd-usbin/metadata.xml19
-rw-r--r--sys-freebsd/metadata.xml14
-rw-r--r--sys-freebsd/ubin-wrappers/Manifest4
-rw-r--r--sys-freebsd/ubin-wrappers/metadata.xml8
-rw-r--r--sys-freebsd/ubin-wrappers/ubin-wrappers-0.ebuild36
-rw-r--r--sys-freebsd/virtio-kmod/Manifest6
-rw-r--r--sys-freebsd/virtio-kmod/files/pkg-message22
-rw-r--r--sys-freebsd/virtio-kmod/metadata.xml8
-rw-r--r--sys-freebsd/virtio-kmod/virtio-kmod-0.228301-r1.ebuild70
328 files changed, 18173 insertions, 0 deletions
diff --git a/sys-freebsd/boot0/Manifest b/sys-freebsd/boot0/Manifest
new file mode 100644
index 000000000000..a6f55d4a4e07
--- /dev/null
+++ b/sys-freebsd/boot0/Manifest
@@ -0,0 +1,25 @@
+AUX boot0-10.1-gcc46.patch 2180 SHA256 a664f792660fe1dc25b6e54a973ad6d8ac6c19ef309954f5bb7973b52832cc82 SHA512 a0633fe171c668b976277d26c3406d75ec5892cd6fe28845ea9faca03659689ad87fee6eeac5968b00026733e854bb0d2216e6f3987cf1ed9bcedb3bc2b210b6 WHIRLPOOL 2d5ba9602c93ab02aef29838478b578603b39e7d26dbf688e3fccd1cdd7e5fec3aec729db81b4548b69841ab330e8898eb445ee09d06ccd8500fb0f7387c3fc8
+AUX boot0-10.3-clang.patch 847 SHA256 6687fa92439ec0813a61221f5acfc6fe4588432c6660f9e6962437d2589f5a1c SHA512 74a64f9853dc28e5354d1d3d1a97c9543b6f80d48568d264874a23355c4bcab9e6a90a22630b2c7afea4b51c906db4745cb2773feaf42979a9192b8f995d7405 WHIRLPOOL 3a299ffc554ad91a763a974268978755dc7819a6e4c21736efca6df1c0e5a95b07184103724634af3eb634fb2da77abb40d6bfb493cb6effb7463abe2c339905
+AUX boot0-10.3-drop-unsupport-cflags.patch 971 SHA256 26a7aef66e0b436201698f0df262d8af50061da203f90e1bc8babd79815f62b9 SHA512 ca2d36c332515c0c7b89bae24213e5dd21065e7bdd689726e1777d4439dfc850918ad4312751cdc69a417f05724f484f14a8254895e673844245e69133b8cf46 WHIRLPOOL 6ff2f96c33857433ed3160241a7137aef9375d15533f7fd3db979ac8294ee28f21fc9e1c292450fac6a3dd515e86f5969b7b517d36636712ef921af5956faa0f
+AUX boot0-10.3-uefi-support.patch 762 SHA256 5089401accfd622091253ec652b0e86edaf00021ec7372829bec56d08ba4d83c SHA512 6ff9b34969475f9580b364c6fca591901554107ac0eacb7e19888a05411fc4e9928ec632525dba30449678bb14f22cef23605ca5843370f882ca90bb1dc32a1a WHIRLPOOL cb83d397f0a1660b6ee0154b1c2d6e7807e2c6e61d92790e5be37233fa6f8bec3947f9c49d5046329486654a648e758f0e4d9f6d2ce7b2cf448c181059745281
+AUX boot0-11.0-gcc46.patch 481 SHA256 d05e22731b13b3eb12c75034c3f3d5ba74c1d842271ba1c81669698d0cfe1911 SHA512 114580260572d03ae145f38d9e7552e18d1d9eace430c102dbc73de055e453fdff9fd81e1ee6f4237d36b87800ff1da63b78ecdd17208ecf8969919fa245cf01 WHIRLPOOL a4a1620b892850f9affac443399901f52af2344539e251169d08d6b7db588a23db5ec3b4857992acda96b9893a7acde848a3171689eebf332fdbb1c9e18e858a
+AUX boot0-11.0-uefi-support.patch 715 SHA256 ca983122c1a73575ce81cfad1c11378b60cdcb869dea4db4fafd387a38136086 SHA512 e6b4b48e5442ad4d948389aa4862484947fce5f15deedd6603cf5616054ccf9fa61a0c190443cdbe76502225a44da37675d1bccf49476ffedd633fe8128a2db6 WHIRLPOOL 0bf282dff86cd8cd59dbf42ad99aae10cf056260e356f4ac88392698107b4c26970c2028300c795ee28e91b8b5129b414e6c25d8f8587effac6cdf8ee56e6e65
+AUX boot0-8.2-zfsboot-makefile.patch 436 SHA256 74a494fce8011f018542a54d6d188c1aa9977b982a3b0c333ea64445dbfab994 SHA512 2d2c1572415362eed73580b681a6e6cd95b1f4abb415221e8904097ac078c620223ca652282404c4f1881dcb605f25f126b53ec0b8409ad4fbbd9bed603ba7c2 WHIRLPOOL ddf074f25ebf256f543cd5ceb8e64934cc045e6dc81f49ef14aad009de69c84309d0b7927c87ff36c75c008fae975e25708b9ec8f21cb083bba77daf3e5107d4
+AUX boot0-9.2-gcc46.patch 2119 SHA256 745245270e8ac2e8a1084f1785bb31ce7a5d2c7242f762260ad9a97fa02970f5 SHA512 ee834269bdc4a79da6854f59fe896b8e13efd1f60d97aefc8829cd1137f8f84810bba4344aac79424a4f31503a1a8579caf468e83a60d127d81f5d10fcbc4ae9 WHIRLPOOL 0c057ffe2baa7cb1b74912cebed5ec5f31adee7780a77993b40bad256e89baf3ed4dc18567c263bfed9a76e63e274072945e37dd729ac62c8538ab7678e4dfe1
+AUX boot0-add-nossp-cflags.patch 341 SHA256 ed801285f9e9846c7fc4f334a2dfceec2d023be9b22e53aa3713d648cac899be SHA512 980a6b8f247f0d51724f409627c81e5e089e4b2a7b11732bc3cf569f87a5c308e7c2e5985ce3ba32c61c489a5a1e16596bde43ef3c260b0730ec67e50f42e9bb WHIRLPOOL 06ae4058fd8c39abe215e417fdffd1c13fdc641891fcb8f8a37af3ac31e781da666c3cd9cf2b800174439ebcc2ecb5b6efb9e9e5880a216878fb4ced7ffd9bfe
+DIST boot0-EN-1618-loader.patch 1092 SHA256 9c145ceeebcf96e562933ec824a942baa9098177b9c01e5bd56d670f6514030e SHA512 c2d28dc48289683c009a783db59ce62008a8d9231d4ea5b1ebe6dac2d6d0d86a285524195be9a806c23fbc2ceb6e159fcd7a7e8d01fe973b6ea6d154bfca298c WHIRLPOOL f2e7d87ec26b2607ad99eed5516bfd28b6d31fee495fc0c031e7c47bcd6d049ed6ccc7f6c6675c35f1afd3e5ae294584e66d49052a16230bfe15f3e29f177d0f
+DIST freebsd-contrib-9.1.tar.bz2 54751432 SHA256 e7ffa056d4050ce03ee8e23e276e2a9a494326a98d60c43bee2afcc59576deb8 SHA512 71be13049258c6e6b5e4f63cc16da5d349a89d68f04d87446e4ad33ae8bf2a93ea67d9c256b7bec60b61e65db0487268070cfb77a484c3ac0f8ba368b48c2438 WHIRLPOOL a2a84423175499208d34809e802284d6ba649f317c3a9ad8b7312fa19efe142ebadab0048bac0db8e988e59f9a7468ac7c5d0d25e78b82bdb269a20d18153cee
+DIST freebsd-lib-9.1.tar.bz2 3206685 SHA256 f31fa8107b4de711c548f6d0c1bb1f81d09f51bcc3b14a1e9e90bb0e7cc4a35d SHA512 40d0c36b6b889c404fa0e0afa38ba4e84a55bc88ffa2f98a70afbd7a32c4f32c158617ba770567d082a986d62c09b3ec8db3dc5ab853ee1c9bbe0b90bb82396e WHIRLPOOL 581878bf9c43184b043b4293409b85901c9ed1f9bd279e965414aca41ba50950848ebda3ee10a503a028135dfd2765e95a11acd4e62a11c528e104392bbbd8d0
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+DIST freebsd-sys-8.2.tar.bz2 25835329 SHA256 0c6c7b61aae94db2931f985d5899f3bca78fc8ffab6b598fbaa158142d676f16 SHA512 6ea4516a5c52e25c4f993f7acb875463a5caea93dbdf250c5d48eee95fff226956e9f030cab7e341b5e6a132325bc3dbf93dcb4b1185acb011918e50b1a22be3 WHIRLPOOL 870deeff877c6b9fc812a4260e4fdbb6715a5dc2065cab3bfbf2a42d876f6654703ccb124275a4e2c410cef48f3db02b63cc76059eccf9cf90244826f35b7a15
+DIST freebsd-sys-9.1.tar.bz2 32588103 SHA256 b93a7ac8334ac16cc9f60665048e5ef812c0a6c62f10d0b0a674aec3f56516a8 SHA512 7dc9d9e00dde8f592bb171f4386d02b655b73cb4f153fe5ec063d010a148ef0639eae0dcdb3eeb09ecd1e3653c69e49a2d261329fa6d0381d2ddabe258ddde6d WHIRLPOOL c8348344dfb14bad64bd3a78ee615ddd29203175b292233254f8ba175e7a3fb7218af6f95f7b4dbf394c0354bafe9d8bb0c21cdf0ceaeb697214964b280469b3
+EBUILD boot0-10.3.ebuild 1888 SHA256 119cbee68507d93b39e3b4f4e7e32bc0002e1c221871974e7353c8ec308b1356 SHA512 65d46563288ccb402b22f3f722148d6bdb4d0ab209b69fe2c9fcd97abc6995127007a2f8b8b1fb276a7d5b60bdf74fa397227f77234c3b697a1d106f9ac6d345 WHIRLPOOL a74b6cbc70eadc87df1e2af6abc80e933e5559dc1f0c45ba828fbe30b8dddb72fb7bbb7320700f9d22293550d74c7e8050decc7d3241990e66a992d89e3d1901
+EBUILD boot0-11.0-r1.ebuild 1993 SHA256 a4aaf0c88052c60f99c0dc55e9ad286d2f9e911421ffd46460a80e0176045d8a SHA512 c74a033c1c76277333fa707b0da9e4e27d10f6aa92ad797c628337db9293a497fb6f22df928bcd0bdcfb0c7df89bba24917ebe4aef7f5925674f6944da64bcb5 WHIRLPOOL 9305464e9f0a41f0f9f5051e8788342eff2eda59877fb151a2cd5c0df0494cf415caaab29738f1055220dd70f9f7080aed38bb7819b99930e1fc0bdd9c461553
+EBUILD boot0-11.1.ebuild 1940 SHA256 f8d6fe44b7f185d98678e3b7bd1303ea5f6147988b3a393b6c7d47c7ab0837e0 SHA512 8d8890bac720309a9ee5e56e950139ec0a3862d64643b73f92bb7783da8ac56db1d271fdd09bb7aa19f062ef6b9ffbac3b98d952d982911b3392fc59a4fd94eb WHIRLPOOL 7ae1e314cd24fe2c1d487fb8a5dfbbd04c896c40415d4a938f1072ed09240ea49b47965b1e3031ea443b111d8302a06a3c33f09f7e4cc647826e5b28b5eeac68
+EBUILD boot0-8.2.ebuild 1181 SHA256 88c80a564986c2029803d627fefcce1cf9286288dbbc014f4a13a8bbf1551004 SHA512 955c8d97b4ca370a9e8941ccec006d113c89baa25188abfb0e5e9d14ab1c9723ab3c2e32ccf58adbe2f3730c69f782abf645dd6931e1e6a689cba72b3651fb32 WHIRLPOOL 3365447db144ac83bc083057f07523a8a0d0864c62e37c48c7597ef2ad1b387111305033d4a12cd59d6d1c5537c392b3ad140f6535aa8a2df8f7b67491b567ea
+EBUILD boot0-9.1.ebuild 1477 SHA256 9c9413d705414132214a168f572abe597557ba88b01bdbae74dda6c7acf8665d SHA512 fe21b5d7105aecf6419be9339f989f85112b7f4ef1c061c069a60789af202d49bec44123aaf5f69d8ea732d63d87d041272540ba988b054ff51fc08c0b43bf06 WHIRLPOOL dcebac2809862ded9fca4437eba6300ec76e7a564616acfe3614474994a2627faa7a3cda08ce81d03d1e13acfabca5cd57b30f07601e8727025192690b8e15ba
+MISC ChangeLog 4356 SHA256 d46fb641132655adf9fe74fcfa886e964e6e6e43143e5a68e90b1da83e82f10e SHA512 132d392db914928b87dd9eb68cf9bbad409325b1a7acd6af834b45877f8f6cdbc2f15bf15f16a5d141bafb0d4d266b400138a0b5ecf2fd407b720e62e9bf7e57 WHIRLPOOL 7a8dcf921afe3bf1b33b64c05fe0d07a10f93206d82adb6afdc1cca0aeabda61ac82fa5eb66295014684bb5bb7e03d5b73268896b21cbb84cb4fd95e025acc02
+MISC ChangeLog-2015 8356 SHA256 8c0af2a79e25332eaad01fbc8d7a9f2687f09d78dcb6b64eab3a09c018a5ba72 SHA512 5a6eef7c4b64c46225715cdb9cb1e1d7182a8f5b42f1ac346d71dcdfc95e13a1ddf517ad509963e1e2b832713e44ba1810739834f458ca22e21090f67de113d1 WHIRLPOOL 97aa61125896c790634a8b8f43ddea1e0d2ac274654e4cb9bbdd35c94194653edc3a9c9cd61b4b810f9280e8a3d4a3b94268e92a4f7599a715f56bceba35d2f4
+MISC metadata.xml 385 SHA256 1b6dbb50d321102c9a48b5f6bce5825e88ce8dfcabd86892194b2fa10e540b11 SHA512 b65045bfb5e261f1a26102c00ff576065570701658bc643ded73761de269e72fb8843ce38231e92def5c7823720e1ec687b8cce575307097847d10dd35b8a808 WHIRLPOOL f073e698718e05e55026bad3888ce2809d2a0a7f4d0e4090e5c1fb16be55846e0bbf81c09748b76ea960a77e74b96678031c888852b8e4e259640d67386cc655
diff --git a/sys-freebsd/boot0/boot0-10.3.ebuild b/sys-freebsd/boot0/boot0-10.3.ebuild
new file mode 100644
index 000000000000..d33328cf5f42
--- /dev/null
+++ b/sys-freebsd/boot0/boot0-10.3.ebuild
@@ -0,0 +1,82 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic toolchain-funcs
+
+DESCRIPTION="FreeBSD's bootloader"
+SLOT="0"
+
+IUSE="bzip2 ieee1394 tftp zfs"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ sys/
+ lib/
+ contrib/bzip2/
+"
+
+RDEPEND=""
+DEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-lib-${RV}*"
+
+S="${WORKDIR}/sys/boot"
+
+PATCHES=( "${FILESDIR}/${PN}-10.1-gcc46.patch"
+ "${FILESDIR}/${PN}-10.3-clang.patch"
+ "${FILESDIR}/${PN}-10.3-drop-unsupport-cflags.patch"
+ "${FILESDIR}/${PN}-10.3-uefi-support.patch"
+ "${FILESDIR}/${PN}-add-nossp-cflags.patch" )
+
+boot0_use_enable() {
+ use ${1} && mymakeopts="${mymakeopts} LOADER_${2}_SUPPORT=\"yes\""
+ use ${1} || mymakeopts="${mymakeopts} WITHOUT_${2}= "
+}
+
+pkg_setup() {
+ boot0_use_enable ieee1394 FIREWIRE
+ boot0_use_enable zfs ZFS
+ boot0_use_enable tftp TFTP
+ boot0_use_enable bzip2 BZIP2
+}
+
+src_prepare() {
+ sed -e '/-mno-align-long-strings/d' \
+ -i "${S}"/i386/boot2/Makefile \
+ -i "${S}"/i386/gptboot/Makefile \
+ -i "${S}"/i386/gptzfsboot/Makefile \
+ -i "${S}"/i386/zfsboot/Makefile || die
+
+ export MAKEOBJDIRPREFIX="${WORKDIR}/build"
+}
+
+src_compile() {
+ strip-flags
+ append-flags "-fno-strict-aliasing"
+
+ cd "${WORKDIR}/lib/libstand" || die
+ freebsd_src_compile
+
+ CFLAGS="${CFLAGS} -I${WORKDIR}/lib/libstand"
+ LDFLAGS="${LDFLAGS} -L${WORKDIR}/lib/libstand"
+ export LIBSTAND="${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libstand/libstand.a"
+
+ cd "${S}" || die
+ NOFLAGSTRIP="yes" freebsd_src_compile
+}
+
+src_install() {
+ dodir /boot/defaults
+ mkinstall FILESDIR=/boot || die "mkinstall failed"
+
+ cd "${WORKDIR}/sys/$(tc-arch-kernel)/conf" || die
+ insinto /boot
+ newins GENERIC.hints device.hints
+
+ echo 'CONFIG_PROTECT="/boot/device.hints"' > "${T}"/50boot0
+ doenvd "${T}"/50boot0
+}
diff --git a/sys-freebsd/boot0/boot0-11.0-r1.ebuild b/sys-freebsd/boot0/boot0-11.0-r1.ebuild
new file mode 100644
index 000000000000..1b56c9159994
--- /dev/null
+++ b/sys-freebsd/boot0/boot0-11.0-r1.ebuild
@@ -0,0 +1,86 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic toolchain-funcs
+
+DESCRIPTION="FreeBSD's bootloader"
+SLOT="0"
+
+IUSE="bzip2 ieee1394 tftp zfs"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "EN-16:18/loader.patch" )
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ sys/
+ lib/
+ contrib/bzip2/
+"
+
+RDEPEND=""
+DEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-lib-${RV}*"
+
+S="${WORKDIR}/sys/boot"
+
+PATCHES=( "${FILESDIR}/${PN}-11.0-gcc46.patch"
+ "${FILESDIR}/${PN}-11.0-uefi-support.patch"
+ "${FILESDIR}/${PN}-add-nossp-cflags.patch" )
+
+boot0_use_enable() {
+ use ${1} && mymakeopts="${mymakeopts} LOADER_${2}_SUPPORT=\"yes\""
+ use ${1} || mymakeopts="${mymakeopts} WITHOUT_${2}= "
+}
+
+pkg_setup() {
+ boot0_use_enable ieee1394 FIREWIRE
+ boot0_use_enable zfs ZFS
+ boot0_use_enable tftp TFTP
+ boot0_use_enable bzip2 BZIP2
+}
+
+src_prepare() {
+ sed -e '/-mno-align-long-strings/d' \
+ -i "${S}"/i386/boot2/Makefile \
+ -i "${S}"/i386/gptboot/Makefile \
+ -i "${S}"/i386/gptzfsboot/Makefile \
+ -i "${S}"/i386/zfsboot/Makefile || die
+
+ mymakeopts="${mymakeopts} LOADER_NO_GELI_SUPPORT=yes"
+ export MAKEOBJDIRPREFIX="${WORKDIR}/build"
+}
+
+src_compile() {
+ strip-flags
+ append-flags "-fno-strict-aliasing"
+
+ cd "${WORKDIR}/lib/libstand" || die
+ freebsd_src_compile
+
+ CFLAGS="${CFLAGS} -I${WORKDIR}/lib/libstand"
+ LDFLAGS="${LDFLAGS} -L${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libstand"
+ export LIBSTAND="${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libstand/libstand.a"
+
+ cd "${S}" || die
+ NOFLAGSTRIP="yes" freebsd_src_compile
+}
+
+src_install() {
+ dodir /boot/defaults
+ freebsd_src_install FILESDIR=/boot
+
+ cd "${WORKDIR}/sys/$(tc-arch-kernel)/conf" || die
+ insinto /boot
+ newins GENERIC.hints device.hints
+
+ echo 'CONFIG_PROTECT="/boot/device.hints"' > "${T}"/50boot0
+ doenvd "${T}"/50boot0
+}
diff --git a/sys-freebsd/boot0/boot0-11.1.ebuild b/sys-freebsd/boot0/boot0-11.1.ebuild
new file mode 100644
index 000000000000..2f95e76f3e23
--- /dev/null
+++ b/sys-freebsd/boot0/boot0-11.1.ebuild
@@ -0,0 +1,86 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic toolchain-funcs
+
+DESCRIPTION="FreeBSD's bootloader"
+SLOT="0"
+
+IUSE="bzip2 ieee1394 tftp zfs"
+
+# Security Advisory and Errata patches.
+# UPSTREAM_PATCHES=()
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ sys/
+ lib/
+ contrib/bzip2/
+ contrib/zlib/
+"
+
+RDEPEND=""
+DEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-lib-${RV}*"
+
+S="${WORKDIR}/sys/boot"
+
+PATCHES=( "${FILESDIR}/${PN}-11.0-gcc46.patch"
+ "${FILESDIR}/${PN}-add-nossp-cflags.patch" )
+
+boot0_use_enable() {
+ use ${1} && mymakeopts="${mymakeopts} LOADER_${2}_SUPPORT=\"yes\""
+ use ${1} || mymakeopts="${mymakeopts} WITHOUT_${2}= "
+}
+
+pkg_setup() {
+ boot0_use_enable ieee1394 FIREWIRE
+ boot0_use_enable zfs ZFS
+ boot0_use_enable tftp TFTP
+ boot0_use_enable bzip2 BZIP2
+}
+
+src_prepare() {
+ sed -e '/-mno-align-long-strings/d' \
+ -i "${S}"/i386/boot2/Makefile \
+ -i "${S}"/i386/gptboot/Makefile \
+ -i "${S}"/i386/gptzfsboot/Makefile \
+ -i "${S}"/i386/zfsboot/Makefile || die
+
+ mymakeopts="${mymakeopts} LOADER_NO_GELI_SUPPORT=yes"
+ export MAKEOBJDIRPREFIX="${WORKDIR}/build"
+}
+
+src_compile() {
+ strip-flags
+ append-flags "-fno-strict-aliasing"
+
+ cd "${WORKDIR}/lib/libstand" || die
+ freebsd_src_compile
+
+ CFLAGS="${CFLAGS} -I${WORKDIR}/lib/libstand"
+ LDFLAGS="${LDFLAGS} -L${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libstand"
+ export LIBSTAND="${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libstand/libstand.a"
+
+ cd "${S}" || die
+ NOFLAGSTRIP="yes" freebsd_src_compile
+}
+
+src_install() {
+ dodir /boot/defaults
+ freebsd_src_install FILESDIR=/boot
+
+ cd "${WORKDIR}/sys/$(tc-arch-kernel)/conf" || die
+ insinto /boot
+ newins GENERIC.hints device.hints
+
+ echo 'CONFIG_PROTECT="/boot/device.hints"' > "${T}"/50boot0
+ doenvd "${T}"/50boot0
+}
diff --git a/sys-freebsd/boot0/boot0-8.2.ebuild b/sys-freebsd/boot0/boot0-8.2.ebuild
new file mode 100644
index 000000000000..1cf02f669187
--- /dev/null
+++ b/sys-freebsd/boot0/boot0-8.2.ebuild
@@ -0,0 +1,53 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=2
+
+inherit bsdmk freebsd flag-o-matic
+
+DESCRIPTION="FreeBSD's bootloader"
+SLOT="0"
+KEYWORDS="~sparc-fbsd ~x86-fbsd"
+
+IUSE="bzip2 ieee1394 tftp zfs"
+
+SRC_URI="mirror://gentoo/${SYS}.tar.bz2"
+
+RDEPEND=""
+DEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-lib-${RV}*"
+
+S="${WORKDIR}/sys/boot"
+
+PATCHES=( "${FILESDIR}"/${P}-zfsboot-makefile.patch )
+
+boot0_use_enable() {
+ use ${1} && mymakeopts="${mymakeopts} LOADER_${2}_SUPPORT=\"yes\""
+}
+
+pkg_setup() {
+ boot0_use_enable ieee1394 FIREWIRE
+ boot0_use_enable zfs ZFS
+ boot0_use_enable tftp TFTP
+ boot0_use_enable bzip2 BZIP2
+}
+
+src_prepare() {
+ sed -e '/-fomit-frame-pointer/d' -e '/-mno-align-long-strings/d' \
+ -i "${S}"/i386/boot2/Makefile \
+ -i "${S}"/i386/gptboot/Makefile \
+ -i "${S}"/i386/gptzfsboot/Makefile \
+ -i "${S}"/i386/zfsboot/Makefile || die
+}
+
+src_compile() {
+ strip-flags
+ append-flags "-I/usr/include/libstand/"
+ append-flags "-fno-strict-aliasing"
+ NOFLAGSTRIP="yes" freebsd_src_compile
+}
+
+src_install() {
+ dodir /boot/defaults
+ mkinstall FILESDIR=/boot || die "mkinstall failed"
+}
diff --git a/sys-freebsd/boot0/boot0-9.1.ebuild b/sys-freebsd/boot0/boot0-9.1.ebuild
new file mode 100644
index 000000000000..df9341b45fd2
--- /dev/null
+++ b/sys-freebsd/boot0/boot0-9.1.ebuild
@@ -0,0 +1,63 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=2
+
+inherit bsdmk freebsd flag-o-matic
+
+DESCRIPTION="FreeBSD's bootloader"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+
+IUSE="bzip2 ieee1394 tftp zfs"
+
+SRC_URI="mirror://gentoo/${SYS}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2"
+
+RDEPEND=""
+DEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-lib-${RV}*"
+
+S="${WORKDIR}/sys/boot"
+
+PATCHES=( "${FILESDIR}/${PN}-9.2-gcc46.patch"
+ "${FILESDIR}/${PN}-add-nossp-cflags.patch" )
+
+boot0_use_enable() {
+ use ${1} && mymakeopts="${mymakeopts} LOADER_${2}_SUPPORT=\"yes\""
+}
+
+pkg_setup() {
+ boot0_use_enable ieee1394 FIREWIRE
+ boot0_use_enable zfs ZFS
+ boot0_use_enable tftp TFTP
+ boot0_use_enable bzip2 BZIP2
+}
+
+src_prepare() {
+ sed -e '/-fomit-frame-pointer/d' -e '/-mno-align-long-strings/d' \
+ -i "${S}"/i386/boot2/Makefile \
+ -i "${S}"/i386/gptboot/Makefile \
+ -i "${S}"/i386/gptzfsboot/Makefile \
+ -i "${S}"/i386/zfsboot/Makefile || die
+}
+
+src_compile() {
+ strip-flags
+ append-flags "-fno-strict-aliasing"
+
+ cd "${WORKDIR}/lib/libstand" || die
+ freebsd_src_compile
+
+ cd "${S}"
+ CFLAGS="${CFLAGS} -I${WORKDIR}/lib/libstand"
+ LDFLAGS="${LDFLAGS} -L${WORKDIR}/lib/libstand"
+ export LIBSTAND="${WORKDIR}/lib/libstand/libstand.a"
+ NOFLAGSTRIP="yes" freebsd_src_compile
+}
+
+src_install() {
+ dodir /boot/defaults
+ mkinstall FILESDIR=/boot || die "mkinstall failed"
+}
diff --git a/sys-freebsd/boot0/files/boot0-10.1-gcc46.patch b/sys-freebsd/boot0/files/boot0-10.1-gcc46.patch
new file mode 100644
index 000000000000..9b31e7c0d1ba
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-10.1-gcc46.patch
@@ -0,0 +1,67 @@
+diff --git a/sys/boot/i386/Makefile.inc b/sys/boot/i386/Makefile.inc
+index 472b275..0c9409d 100644
+--- a/sys/boot/i386/Makefile.inc
++++ b/sys/boot/i386/Makefile.inc
+@@ -13,8 +13,6 @@ LDFLAGS+= -nostdlib
+ .if ${MACHINE_CPUARCH} == "amd64"
+ CFLAGS+= -m32
+ ACFLAGS+= -m32
+-# LD_FLAGS is passed directly to ${LD}, not via ${CC}:
+-LD_FLAGS+= -m elf_i386_fbsd
+ AFLAGS+= --32
+ .endif
+
+diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
+index 428950e..6a15450 100644
+--- a/sys/boot/i386/boot2/Makefile
++++ b/sys/boot/i386/boot2/Makefile
+@@ -113,3 +113,10 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.boot1.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++# gcc 4.6 or later version, -fno-asynchronous-unwind-tables is required to build.
++CFLAGS+= -fno-asynchronous-unwind-tables
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LD_FLAGS+= -m elf_i386_fbsd
++.endif
+diff --git a/sys/boot/i386/gptboot/Makefile b/sys/boot/i386/gptboot/Makefile
+index a90e712..d60ae00 100644
+--- a/sys/boot/i386/gptboot/Makefile
++++ b/sys/boot/i386/gptboot/Makefile
+@@ -81,3 +81,8 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.gptldr.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LD_FLAGS+= -m elf_i386_fbsd
++.endif
++
+diff --git a/sys/boot/i386/gptzfsboot/Makefile b/sys/boot/i386/gptzfsboot/Makefile
+index 5eb2383..c10a917 100644
+--- a/sys/boot/i386/gptzfsboot/Makefile
++++ b/sys/boot/i386/gptzfsboot/Makefile
+@@ -78,3 +78,8 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.gptldr.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LD_FLAGS+= -m elf_i386_fbsd
++.endif
++
+diff --git a/sys/boot/i386/zfsboot/Makefile b/sys/boot/i386/zfsboot/Makefile
+index 149f43a..be1e46a 100644
+--- a/sys/boot/i386/zfsboot/Makefile
++++ b/sys/boot/i386/zfsboot/Makefile
+@@ -91,3 +91,8 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.zfsldr.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LD_FLAGS+= -m elf_i386_fbsd
++.endif
++
diff --git a/sys-freebsd/boot0/files/boot0-10.3-clang.patch b/sys-freebsd/boot0/files/boot0-10.3-clang.patch
new file mode 100644
index 000000000000..4245e21a96e1
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-10.3-clang.patch
@@ -0,0 +1,30 @@
+Gentoo Bug: https://bugs.gentoo.org/show_bug.cgi?id=542676
+
+https://svnweb.freebsd.org/base/head/sys/boot/i386/boot2/Makefile?r1=272249&r2=276479
+
+diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
+index 8a6e771..c030853 100644
+--- a/sys/boot/i386/boot2/Makefile
++++ b/sys/boot/i386/boot2/Makefile
+@@ -22,8 +22,7 @@ BOOT2_UFS?= UFS1_AND_UFS2
+ #BOOT2_UFS?= UFS2_ONLY
+ #BOOT2_UFS?= UFS1_ONLY
+
+-CFLAGS= -Os \
+- -fomit-frame-pointer \
++CFLAGS= -fomit-frame-pointer \
+ -mrtd \
+ -mregparm=3 \
+ -DUSE_XREAD \
+@@ -40,7 +39,10 @@ CFLAGS= -Os \
+ -Winline \
+ ${CLANG_OPT_SMALL}
+
+-CFLAGS.gcc+= -fno-guess-branch-probability \
++CFLAGS.clang+= -Oz
++
++CFLAGS.gcc+= -Os \
++ -fno-guess-branch-probability \
+ -fno-unit-at-a-time \
+ --param max-inline-insns-single=100
+ .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} <= 40201
diff --git a/sys-freebsd/boot0/files/boot0-10.3-drop-unsupport-cflags.patch b/sys-freebsd/boot0/files/boot0-10.3-drop-unsupport-cflags.patch
new file mode 100644
index 000000000000..af1d3512e7da
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-10.3-drop-unsupport-cflags.patch
@@ -0,0 +1,28 @@
+diff --git a/sys/boot/efi/libefi/Makefile b/sys/boot/efi/libefi/Makefile
+index fc66e01..470453d 100644
+--- a/sys/boot/efi/libefi/Makefile
++++ b/sys/boot/efi/libefi/Makefile
+@@ -17,9 +17,6 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/libstand
+ # Pick up the bootstrap header for some interface items
+ CFLAGS+= -I${.CURDIR}/../../common
+
+-
+-# Suppress warning from clang for FreeBSD %b and %D formats
+-CFLAGS+= -fformat-extensions
+ CFLAGS+= -DTERM_EMU
+
+ .include <bsd.lib.mk>
+diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile
+index 24cc4c1..e5d2bae 100644
+--- a/sys/boot/i386/libi386/Makefile
++++ b/sys/boot/i386/libi386/Makefile
+@@ -55,9 +55,6 @@ CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../common \
+ # the location of libstand
+ CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
+
+-# Suppress warning from clang for FreeBSD %b and %D formats
+-CFLAGS+= -fformat-extensions
+-
+ .if ${MACHINE_CPUARCH} == "amd64"
+ CLEANFILES+= machine
+ machine:
diff --git a/sys-freebsd/boot0/files/boot0-10.3-uefi-support.patch b/sys-freebsd/boot0/files/boot0-10.3-uefi-support.patch
new file mode 100644
index 000000000000..fdafe74252bc
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-10.3-uefi-support.patch
@@ -0,0 +1,33 @@
+diff --git a/efi/Makefile b/efi/Makefile
+index 30024e3..a33efb2 100644
+--- a/efi/Makefile
++++ b/efi/Makefile
+@@ -2,15 +2,10 @@
+
+ .include <bsd.own.mk>
+
+-# In-tree GCC does not support __attribute__((ms_abi)).
+-.if ${COMPILER_TYPE} != "gcc"
+-
+ .if ${MACHINE_CPUARCH} == "amd64"
+ SUBDIR+= libefi loader boot1
+ .endif
+
+-.endif # ${COMPILER_TYPE} != "gcc"
+-
+ .if ${MACHINE_CPUARCH} == "ia64"
+ SUBDIR+= libefi
+ .endif
+diff --git a/efi/boot1/Makefile b/efi/boot1/Makefile
+index 4ffdfda..8ec0e00 100644
+--- a/efi/boot1/Makefile
++++ b/efi/boot1/Makefile
+@@ -64,7 +64,7 @@ LDFLAGS+= -Wl,-znocombreloc
+ # Add libstand for required string and memory functions for all platforms.
+ #
+ DPADD+= ${LIBSTAND}
+-LDADD+= -lstand
++LDADD+= ${LIBSTAND}
+
+ DPADD+= ${LDSCRIPT}
+
diff --git a/sys-freebsd/boot0/files/boot0-11.0-gcc46.patch b/sys-freebsd/boot0/files/boot0-11.0-gcc46.patch
new file mode 100644
index 000000000000..ec17d92b5790
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-11.0-gcc46.patch
@@ -0,0 +1,14 @@
+diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
+index ead9ad1..af5e021 100644
+--- a/sys/boot/i386/boot2/Makefile
++++ b/sys/boot/i386/boot2/Makefile
+@@ -45,6 +45,9 @@ CFLAGS.gcc+= -Os \
+ .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} <= 40201
+ CFLAGS.gcc+= -mno-align-long-strings
+ .endif
++.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40600
++CFLAGS.gcc+= -fno-asynchronous-unwind-tables
++.endif
+
+ CFLAGS.clang+= -Oz ${CLANG_OPT_SMALL}
+
diff --git a/sys-freebsd/boot0/files/boot0-11.0-uefi-support.patch b/sys-freebsd/boot0/files/boot0-11.0-uefi-support.patch
new file mode 100644
index 000000000000..c7a69d62aa8b
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-11.0-uefi-support.patch
@@ -0,0 +1,21 @@
+diff --git a/sys/boot/efi/Makefile b/sys/boot/efi/Makefile
+index 79ee9a9..f7789f1 100644
+--- a/sys/boot/efi/Makefile
++++ b/sys/boot/efi/Makefile
+@@ -4,7 +4,7 @@
+
+ # In-tree GCC does not support __attribute__((ms_abi)), but gcc newer
+ # than 4.5 supports it.
+-.if ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 404500
++.if ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500
+
+ .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm"
+ .if ${MK_FDT} != "no"
+@@ -18,6 +18,6 @@ SUBDIR+= fdt
+ SUBDIR+= libefi loader boot1
+ .endif
+
+-.endif # ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 404500
++.endif # ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500
+
+ .include <bsd.subdir.mk>
diff --git a/sys-freebsd/boot0/files/boot0-8.2-zfsboot-makefile.patch b/sys-freebsd/boot0/files/boot0-8.2-zfsboot-makefile.patch
new file mode 100644
index 000000000000..a3a33d5d7c5b
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-8.2-zfsboot-makefile.patch
@@ -0,0 +1,13 @@
+diff --git a/sys/boot/i386/zfsboot/Makefile b/sys/boot/i386/zfsboot/Makefile
+index bb16ea3..7dedb49 100644
+--- a/sys/boot/i386/zfsboot/Makefile
++++ b/sys/boot/i386/zfsboot/Makefile
+@@ -83,6 +83,8 @@ zfsboot.bin: zfsboot.out
+ zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o util.o
+ ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
+
++drv.o: drv.c xreadorg.h
++
+ zfsboot.o: zfsboot.s
+
+ SRCS= zfsboot.c xreadorg.h
diff --git a/sys-freebsd/boot0/files/boot0-9.2-gcc46.patch b/sys-freebsd/boot0/files/boot0-9.2-gcc46.patch
new file mode 100644
index 000000000000..ffd9f4351d1f
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-9.2-gcc46.patch
@@ -0,0 +1,66 @@
+diff --git a/sys/boot/i386/Makefile.inc b/sys/boot/i386/Makefile.inc
+index f5faec7..a9cf593 100644
+--- a/sys/boot/i386/Makefile.inc
++++ b/sys/boot/i386/Makefile.inc
+@@ -12,7 +12,6 @@ LDFLAGS+= -nostdlib
+ .if ${MACHINE_CPUARCH} == "amd64"
+ CFLAGS+= -m32
+ ACFLAGS+= -m32
+-LDFLAGS+= -m elf_i386_fbsd
+ AFLAGS+= --32
+ .endif
+
+diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
+index 65815a5..61840dd 100644
+--- a/sys/boot/i386/boot2/Makefile
++++ b/sys/boot/i386/boot2/Makefile
+@@ -109,3 +109,10 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.boot1.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++# gcc 4.6 or later version, -fno-asynchronous-unwind-tables is required to build.
++CFLAGS+= -fno-asynchronous-unwind-tables
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LDFLAGS+= -m elf_i386_fbsd
++.endif
+diff --git a/sys/boot/i386/gptboot/Makefile b/sys/boot/i386/gptboot/Makefile
+index e1a640a..29886cc 100644
+--- a/sys/boot/i386/gptboot/Makefile
++++ b/sys/boot/i386/gptboot/Makefile
+@@ -78,3 +78,8 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.gptldr.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LDFLAGS+= -m elf_i386_fbsd
++.endif
++
+diff --git a/sys/boot/i386/gptzfsboot/Makefile b/sys/boot/i386/gptzfsboot/Makefile
+index a2b8fcc..107f531 100644
+--- a/sys/boot/i386/gptzfsboot/Makefile
++++ b/sys/boot/i386/gptzfsboot/Makefile
+@@ -76,3 +76,8 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.gptldr.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LDFLAGS+= -m elf_i386_fbsd
++.endif
++
+diff --git a/sys/boot/i386/zfsboot/Makefile b/sys/boot/i386/zfsboot/Makefile
+index b2db778..252dc62 100644
+--- a/sys/boot/i386/zfsboot/Makefile
++++ b/sys/boot/i386/zfsboot/Makefile
+@@ -89,3 +89,8 @@ machine:
+ # XXX: clang integrated-as doesn't grok .codeNN directives yet
+ CFLAGS.zfsldr.S= ${CLANG_NO_IAS}
+ CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
++
++.if ${MACHINE_CPUARCH} == "amd64"
++LDFLAGS+= -m elf_i386_fbsd
++.endif
++
diff --git a/sys-freebsd/boot0/files/boot0-add-nossp-cflags.patch b/sys-freebsd/boot0/files/boot0-add-nossp-cflags.patch
new file mode 100644
index 000000000000..abc6a57bf4b0
--- /dev/null
+++ b/sys-freebsd/boot0/files/boot0-add-nossp-cflags.patch
@@ -0,0 +1,11 @@
+https://bugs.gentoo.org/show_bug.cgi?id=511698
+
+diff --git a/sys/boot/Makefile.inc b/sys/boot/Makefile.inc
+index e0039b9..533dea0 100644
+--- a/sys/boot/Makefile.inc
++++ b/sys/boot/Makefile.inc
+@@ -1,3 +1,3 @@
+ # $FreeBSD: release/10.0.0/sys/boot/Makefile.inc 188895 2009-02-21 15:04:31Z ru $
+
+-SSP_CFLAGS=
++SSP_CFLAGS= -fno-stack-protector
diff --git a/sys-freebsd/boot0/metadata.xml b/sys-freebsd/boot0/metadata.xml
new file mode 100644
index 000000000000..d9f0c8324191
--- /dev/null
+++ b/sys-freebsd/boot0/metadata.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="tftp">Enable PXE/TFTP boot support.</flag>
+ <flag name="zfs">Enable booting on ZFS filesystems.</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-bin/Manifest b/sys-freebsd/freebsd-bin/Manifest
new file mode 100644
index 000000000000..4bd936b4979c
--- /dev/null
+++ b/sys-freebsd/freebsd-bin/Manifest
@@ -0,0 +1,18 @@
+DIST freebsd-bin-8.2.tar.bz2 415900 SHA256 fb31b7fab259bda8396e615246f85dc99c3c9f7e98f4e4a613e20b6a394c4921 SHA512 c39b26f75f7d812f46e907acabd8dfaf45c97adf4488bcafa35fd46c805d821e177609d403cf5e677f3674020290199ac97059a0609f7705bce58a7aab3ee8e3 WHIRLPOOL 49e70b1c09c4b72b3f23850e8c9873556571ec02d70ade8f18f683eff6fa92dc8f6d02d58473fe7b4d8d1f3de96c63df41150b2091caafbc9a0e92e6055b43fd
+DIST freebsd-bin-9.1.tar.bz2 385664 SHA256 0a9524d75a8cb4c9c2654f2f9843087b09e8599bba97b9b59f00bc2e92b87e00 SHA512 fa0571a705befe1cb9c07285d3df55c9b5f4f295760511d668d80fec8cd4d59b70c676f07164f2aa44911decef0fb54fa6d78405ac2ceec822b6b8920abc5ca8 WHIRLPOOL 6f2bfe17604339e8260c49582bc941d255932b5c0a7b604e58187626a3a38766cd1e4aed9fc93a737ec9b4fa661f88aac23769b3542f35eb20da8b260216e985
+DIST freebsd-lib-8.2.tar.bz2 3323878 SHA256 e3590c12794fcb5ba8eb7a1f58b497587cf19f9200b3254c194a793da3b5bfb0 SHA512 c059cfdd1099bb519b2a5c43fb7e7104c500ef8906229ed7eb9e420cb3a217cdaf8655e9e7a9f45cfadc5491f8115e0e738fd49251d9f0c3a83780845b09f007 WHIRLPOOL 95f98a372f44a89bc8ac3029ec065dbbfec338e6f889d057d75644bfcdfb9d27fdc0421d7e392cad5a823712b97f0857297ec3d321580254c63032c22b95792e
+DIST freebsd-lib-9.1.tar.bz2 3206685 SHA256 f31fa8107b4de711c548f6d0c1bb1f81d09f51bcc3b14a1e9e90bb0e7cc4a35d SHA512 40d0c36b6b889c404fa0e0afa38ba4e84a55bc88ffa2f98a70afbd7a32c4f32c158617ba770567d082a986d62c09b3ec8db3dc5ab853ee1c9bbe0b90bb82396e WHIRLPOOL 581878bf9c43184b043b4293409b85901c9ed1f9bd279e965414aca41ba50950848ebda3ee10a503a028135dfd2765e95a11acd4e62a11c528e104392bbbd8d0
+DIST freebsd-sbin-8.2.tar.bz2 1211665 SHA256 8b7e21a66b4696e8763d29b8b02b2d35f29fc51820a194d1e469e7cace84c527 SHA512 c6643c29ab62344c98d8991708798730ee1c17e6478071718beeaa79788300a1f4ed2e6aeb8e39e3c216877d4ed2ac85b2a9531d534f1ac5125a508927898959 WHIRLPOOL 2a21cd0f15f95d66718031680ac87f1fe73f1e1b03cb012e1db1dd1bd2fe2bb7897457a8ba2f5a28c8806775611dca542cbadec16566c47ab9efa673e2cb53f3
+DIST freebsd-sbin-9.1.tar.bz2 1273913 SHA256 45008b0733b232ef03707ef5fa3e5c889e3b3728393d736bd9a869ea83be6447 SHA512 9f186602b7de96f268c352ca386986652fddf5570e7eca1afa8c0d2bdc83b57df1198efe47f36dd5c7a6abf4f9c935f1c8207a4a12a6b2153bd6c3c6292719dc WHIRLPOOL 20920dfa9607a0ce854319cef29bbd77fb1b31f6f6cfd5ac60cbd678169e43929e215743fe636d0c224443f3e6149a8f07c292d647f7f901592795ac292699f9
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+DIST freebsd-ubin-9.1.tar.bz2 1910472 SHA256 ff6e586f213534b6ec2e65002c0dee64063d76ddad515c12221b1a80a1815e48 SHA512 74ae0aceec8597aa66c3f1ab313f0685a3c63d7273c36ae7baf8794275ad9bca241c60c3f6281cccf6d531d250d7611099977d3b1a27279cef3586401b6af05e WHIRLPOOL c85a3c9cf2bceff2c60ff03556bcc81d3aca22b0bce3c9538990071ac0a907236eee5ae7743ad22c5fd309b047ebf392aaaf2fe177ef5790ea869aff3da7e2fe
+EBUILD freebsd-bin-10.3.ebuild 793 SHA256 12dfbf564c2de4c68bc2506635a4a8a39c02eedf0a11c9c3ab1303ed3e03ba44 SHA512 8944cf5943d5832f1b54d876a1d392c35a90a78b0327d47d59fd1bf3dd1a69e492f3233eff3d5aef47686d7a2aa8baefd444240c3359d70159d1c88f355df198 WHIRLPOOL c917a9e751f57165099de6ddb7529613d947b607bbfd90eb85de049fe2c19b6647da57eae3d2cd249e4de232bb761e60cb9cc37eac21e0ed73921aad30c6f36b
+EBUILD freebsd-bin-11.0.ebuild 793 SHA256 12dfbf564c2de4c68bc2506635a4a8a39c02eedf0a11c9c3ab1303ed3e03ba44 SHA512 8944cf5943d5832f1b54d876a1d392c35a90a78b0327d47d59fd1bf3dd1a69e492f3233eff3d5aef47686d7a2aa8baefd444240c3359d70159d1c88f355df198 WHIRLPOOL c917a9e751f57165099de6ddb7529613d947b607bbfd90eb85de049fe2c19b6647da57eae3d2cd249e4de232bb761e60cb9cc37eac21e0ed73921aad30c6f36b
+EBUILD freebsd-bin-11.1.ebuild 793 SHA256 050e60f1d0cfff8bd9e0beea9fa5a1142a3388440af44dfe0738e57ccf2868bf SHA512 bd94a54161944bf37c9cbd3e45d00d01328340952e379d168f47ff0b951f77b96f47606b8fec03d31e29b6086a8d3822b065873fccb793114dbc5beaa1b697bb WHIRLPOOL e58f4d8d943853afa9e85a14ea0d08ec84e2434451dd5ce9bbb56fb8f5cecf41210d01f9732fc5ffa18fa95303f7b6a47b335c508d8beab5f0a50da622552a47
+EBUILD freebsd-bin-8.2.ebuild 763 SHA256 d7375dbf8a436fa464f7b823dd77ef7abfe77844f963cf99eff3b32eae3e52ae SHA512 90cd9abe75073f7b8af399637cb7e0f022200b91a83dfe5623c0d9e7def4d62f5b45128bda87b47f4a28fec3fce3c0bff8ea25640106edbab0635388537afe28 WHIRLPOOL 0e5f1f29261d9bd5ae8440fc1e3301f4e29f410cd2059e1b587f28914e01eec704cdd24699628748f8ce341817d8bde681725fcaf54b410d0ffb8b9db8eda3cb
+EBUILD freebsd-bin-9.1.ebuild 827 SHA256 1d8e7b5fe33c9dedcad92df65bc068e9c2f089ebcffa219f14b1b1dbd57b8bd3 SHA512 fc658efd1a1c38bb07af1b47a194cc4b6a8cf78eb5f8c8119aa8a2ef07c84b16b498acf676119752928aa919f1e8e181b4908395f7b10c88b7540ae785c47fff WHIRLPOOL 0ac0cdd9dbdef292b3c97d55f7708ae87d49428cd73adec29ef477ce082ad200e9284459f6cb2f58fe63dbc3bc86bce6ef3fcb785c776626d3ff7e5e7146248d
+MISC ChangeLog 3292 SHA256 5fc18d65c8e72d9f06c0fc3896b541383b08736491af84f4e5761a347304998e SHA512 dbdce05fc833b2578b7f0bd7d77ad902352e4066ff247430d678e36e142c2449014ac405099afe769d463be9d5a77c66a1aec931e2e5147765e632f126b024fa WHIRLPOOL ad71ae96e96fb072adf1d98be080bcb940b2148c1a02d2b8b99974a53f4741295534b0f11b3cbf67dc72ed04495b8a38722e0b28210c84dc9ab80b7b1e042d48
+MISC ChangeLog-2015 9990 SHA256 6b3bc44135f7a32d2dff17625c352c708ce0ef50e6c3ab96a39489d42d32f510 SHA512 279116a9d9e5b768c6cc174e8e799ced46fbf39b48a6a5ff9cd03aacde58fa4500ec6cce788f177bcfd41cf720674c70a7585502bc011652be7c5a63ab8e0da5 WHIRLPOOL 83ab1d8f3541a121736dbc0c546a2580d0db452cc22ef369996c933e98009b1ed005566af773bf469e6905e923fe65d359958e0725432971f302f8f8472b04b3
+MISC metadata.xml 238 SHA256 501d93b0c41ed422505100f002758cd173cd9783ae7fbb53e2ec5f238c868340 SHA512 173efaa53a514acf1e2f0c6681c82a48ec16d505844f551d2cc823ee8685b27837c7461f7956c12182059ee7e83023e2f0bcd5d1afab74beeaf998487193656d WHIRLPOOL 4ca51d994f011a5e7e4939f02a54b5c2f9f3e526665893c9ac2876c9871b7dc80361393d41c5247b3a5520e82d31d0dd10da520e7715c94b806a94ce0fed2a5a
diff --git a/sys-freebsd/freebsd-bin/freebsd-bin-10.3.ebuild b/sys-freebsd/freebsd-bin/freebsd-bin-10.3.ebuild
new file mode 100644
index 000000000000..964c4d64f9e4
--- /dev/null
+++ b/sys-freebsd/freebsd-bin/freebsd-bin-10.3.ebuild
@@ -0,0 +1,41 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD /bin tools"
+SLOT="0"
+
+IUSE=""
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ bin/
+ usr.bin/
+ sbin/
+ lib/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ >=dev-libs/libedit-20120311.3.0-r1
+ sys-libs/ncurses:0=
+ sys-apps/ed
+ !app-misc/realpath
+ !<sys-freebsd/freebsd-ubin-8"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ >=sys-devel/flex-2.5.31-r2"
+
+S=${WORKDIR}/bin
+
+# csh and tcsh are provided by tcsh package, rmail is sendmail stuff.
+REMOVE_SUBDIRS="csh rmail ed freebsd-version"
+
+pkg_setup() {
+ mymakeopts="${mymakeopts} WITHOUT_TCSH= WITHOUT_SENDMAIL= WITHOUT_RCMDS= "
+}
diff --git a/sys-freebsd/freebsd-bin/freebsd-bin-11.0.ebuild b/sys-freebsd/freebsd-bin/freebsd-bin-11.0.ebuild
new file mode 100644
index 000000000000..964c4d64f9e4
--- /dev/null
+++ b/sys-freebsd/freebsd-bin/freebsd-bin-11.0.ebuild
@@ -0,0 +1,41 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD /bin tools"
+SLOT="0"
+
+IUSE=""
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ bin/
+ usr.bin/
+ sbin/
+ lib/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ >=dev-libs/libedit-20120311.3.0-r1
+ sys-libs/ncurses:0=
+ sys-apps/ed
+ !app-misc/realpath
+ !<sys-freebsd/freebsd-ubin-8"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ >=sys-devel/flex-2.5.31-r2"
+
+S=${WORKDIR}/bin
+
+# csh and tcsh are provided by tcsh package, rmail is sendmail stuff.
+REMOVE_SUBDIRS="csh rmail ed freebsd-version"
+
+pkg_setup() {
+ mymakeopts="${mymakeopts} WITHOUT_TCSH= WITHOUT_SENDMAIL= WITHOUT_RCMDS= "
+}
diff --git a/sys-freebsd/freebsd-bin/freebsd-bin-11.1.ebuild b/sys-freebsd/freebsd-bin/freebsd-bin-11.1.ebuild
new file mode 100644
index 000000000000..37b3ce22d25e
--- /dev/null
+++ b/sys-freebsd/freebsd-bin/freebsd-bin-11.1.ebuild
@@ -0,0 +1,41 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD /bin tools"
+SLOT="0"
+
+IUSE=""
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ bin/
+ usr.bin/
+ sbin/
+ lib/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ >=dev-libs/libedit-20120311.3.0-r1
+ sys-libs/ncurses:0=
+ sys-apps/ed
+ !app-misc/realpath
+ !<sys-freebsd/freebsd-ubin-8"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ >=sys-devel/flex-2.5.31-r2"
+
+S=${WORKDIR}/bin
+
+# csh and tcsh are provided by tcsh package, rmail is sendmail stuff.
+REMOVE_SUBDIRS="csh rmail ed freebsd-version"
+
+pkg_setup() {
+ mymakeopts="${mymakeopts} WITHOUT_TCSH= WITHOUT_SENDMAIL= WITHOUT_RCMDS= "
+}
diff --git a/sys-freebsd/freebsd-bin/freebsd-bin-8.2.ebuild b/sys-freebsd/freebsd-bin/freebsd-bin-8.2.ebuild
new file mode 100644
index 000000000000..c23585e5b02b
--- /dev/null
+++ b/sys-freebsd/freebsd-bin/freebsd-bin-8.2.ebuild
@@ -0,0 +1,33 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD /bin tools"
+SLOT="0"
+KEYWORDS="~sparc-fbsd ~x86-fbsd"
+
+IUSE=""
+
+SRC_URI="mirror://gentoo/${BIN}.tar.bz2
+ mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ dev-libs/libedit
+ sys-libs/ncurses
+ sys-apps/ed
+ !app-misc/realpath
+ !<sys-freebsd/freebsd-ubin-8"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ >=sys-devel/flex-2.5.31-r2"
+
+S=${WORKDIR}/bin
+
+# csh and tcsh are provided by tcsh package, rmail is sendmail stuff.
+REMOVE_SUBDIRS="csh rmail ed"
+
+pkg_setup() {
+ mymakeopts="${mymakeopts} WITHOUT_TCSH= WITHOUT_SENDMAIL= WITHOUT_RCMDS= "
+}
diff --git a/sys-freebsd/freebsd-bin/freebsd-bin-9.1.ebuild b/sys-freebsd/freebsd-bin/freebsd-bin-9.1.ebuild
new file mode 100644
index 000000000000..ff05ef637a63
--- /dev/null
+++ b/sys-freebsd/freebsd-bin/freebsd-bin-9.1.ebuild
@@ -0,0 +1,34 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD /bin tools"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+
+IUSE=""
+
+SRC_URI="mirror://gentoo/${BIN}.tar.bz2
+ mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ >=dev-libs/libedit-20120311.3.0-r1
+ sys-libs/ncurses
+ sys-apps/ed
+ !app-misc/realpath
+ !<sys-freebsd/freebsd-ubin-8"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ >=sys-devel/flex-2.5.31-r2"
+
+S=${WORKDIR}/bin
+
+# csh and tcsh are provided by tcsh package, rmail is sendmail stuff.
+REMOVE_SUBDIRS="csh rmail ed"
+
+pkg_setup() {
+ mymakeopts="${mymakeopts} WITHOUT_TCSH= WITHOUT_SENDMAIL= WITHOUT_RCMDS= "
+}
diff --git a/sys-freebsd/freebsd-bin/metadata.xml b/sys-freebsd/freebsd-bin/metadata.xml
new file mode 100644
index 000000000000..a00f3aeb1f81
--- /dev/null
+++ b/sys-freebsd/freebsd-bin/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-cddl/Manifest b/sys-freebsd/freebsd-cddl/Manifest
new file mode 100644
index 000000000000..5994f856a377
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/Manifest
@@ -0,0 +1,37 @@
+AUX freebsd-cddl-10.2-libpaths.patch 9569 SHA256 80350e3493fd667840555d06e453769e02604da8362d6e76280573a30dd9185b SHA512 615caa713eee62030a9f4630578f8f7ae8c4a2df71307237083115e2226734646ba1923f5de46aaf1523ffaa6b4c83b5fc64ceee552b15cb0244583408736ed4 WHIRLPOOL 3fd3f8d42057ab01965b4314f4565009076ea54da83401efdedd838299cf554092717d7795ba7a4dca22420c993d521411021dc4f521a273af4ff894bb938353
+AUX freebsd-cddl-10.3-underlink.patch 437 SHA256 ac486d44bf8ed4dd1b30d6200c59446e552e9e21f30535077533a080a28280ef SHA512 9ef6768be960a0c08cef094ba220e045b434aef6cfdb0be4631a63ea0b233158e927ca32c4f1d47a2f9a1e4a568f3850e61f56dcab35bd26cf1cea49035240fd WHIRLPOOL 8d5de341ceeca0e4a6c22b3bde9ddfdd611b1508344e837d34b926a3f8ac411a9daebaf30198fb323197d0860f102dc5b76172b7213a4cd4d41e623b79111393
+AUX freebsd-cddl-11.0-add-libs.patch 3401 SHA256 d722c667769b403a0b1485d7df23e6b37a5406c2ed3c9b09959e7f0ac1851b19 SHA512 7a3da3a57bde26a79784dcb023961ed0a292da4945c49e07c4a69035fe6cd0773e09cec25eab638a64c6ccc54bb775c169b1553743f7a9b4af60ce49f1fee54c WHIRLPOOL aae94c0c23568359c135db4f3f2745280292fc337c3bf03516182ef38b920b4344049fe260a71d6769f3ecd8b53d7497361e768b7d67fdab3eba126128051cad
+AUX freebsd-cddl-11.0-workaround.patch 576 SHA256 38f7af5e9560ead4ea3cae3a756b73a3d605e7053c944b4ed8abc0a0c9788723 SHA512 0a2280caeb23622454351657d61e8e465c597b82bf49cb534a924758844cd7da2df330434ba6282e159d9bc2e6ade27c2a9db41980ada6370bcab59c6a57da22 WHIRLPOOL 8a6afdbb8f5243822e6040d07af966a45c21c52bb0e916aea2b1be03b3ff6cfec40da5c3b0268881abbf6b2edc8b43bf005fca81714461567a0e6edc15178073
+AUX freebsd-cddl-8.0-libpaths.patch 4418 SHA256 3fa5555254ae38a0e6d4e1385e2dd2b4ea0f84ae326f3941c69726cdcbe3a05c SHA512 dac14bcac23d16ee8acc7a3adfe7de896f6595d98dd3d0c93e39205aa5bdf1a0fc35adf338e05df66b18186da4b10f578cfe2d084b446aeb84eb49d07f5736d5 WHIRLPOOL 0ed3869833b9606ce325b30874f01106c2d288c6bff703398f63abe00602c6d3adf1d2faf2dc629a220dcfeb4c3d819f672875ce3b7bb4ab969977b5ce6920fd
+AUX freebsd-cddl-8.2-libpaths.patch 822 SHA256 f6884f9c471f2d1bf522c26b2f2607e9506d7fea9612c24b4392f1e861a1a5db SHA512 1d335eb70592436941b093c76ad2e7573cb317333f81b11be7a2ef9cc0b3e57e21d797bf43c5ac9154d9817aa136851640f2b7b67bdd66b8abde7a589fd9f567 WHIRLPOOL 3ecdb9ea5050d4309b2561dd37082982450180e6eb8b77373ca3949f62ccd7719e5178a3c3a61346b2820fa827e0bc13075d2266d5500a5f80d8efab16adb414
+AUX freebsd-cddl-9.0-bsdxml.patch 1419 SHA256 0a5c5f5b242e17d0a378778ec39ff43d410e1efed144dd14a46cbd2cf4a44542 SHA512 8ea86f6918b2629c33286c2396226bb4944e373069a423104d96f65e387162e0da94707458fd5caebcab08b9305b435ac66f4207aa6b15ce9571a5fa5878f3c5 WHIRLPOOL 5af01d3ba6e1e4a038de1f3274bf3bd241264db05b021fa374c5a56c805901320a4c30c2234013902eb2f5ca879a4972d3468e0157315dd98e73ce1ee4359e0a
+AUX freebsd-cddl-9.0-libpaths.patch 7621 SHA256 392593d858b1cbd6c5d6a6da25d9fda48f412d4eb75c0dfeba20cd9e8ad6d762 SHA512 87e56647a41262363900ab4ecc6aabd1b4ba4f0d7d5b5011dc2eb9ec312c640bed5aa931495f208110277b2baf6c3625d20d59e62c19a70e7625a6b36b61a278 WHIRLPOOL 1f6798ac319bba9dedb0a0776e09cbce01637e057e38f77d59410c942f68c7051b7ccc10bfed748b72eeabf9254bc52262b5c9cc3fa3a4187f8698ede2d27d4f
+AUX freebsd-cddl-9.0-underlink.patch 755 SHA256 12d2dbbbb19c7b4920d84d01c48b6cc331b8a244eaaabe72081c7a5c6ff2300c SHA512 002c9e6a389140455f9a698dbe47197d795d36ff08e4e5fb096d38525b8cf017672de7f511b2495fdea6f536e07a426e299e0a056cbdd8dae64677299376d2f9 WHIRLPOOL c6403e8e56f2c2e9d67387137eab77eae0f6e1a8c4c4d595c1950ee3ab3bff8d0d8a0f15ca83a7b65aa05d35dafa86ff75ff8fec7ce8f320a2e1d44be38c0995
+AUX zfs.initd 368 SHA256 b24cbadc9bf67b0eba0af43730ff8a24c6fa3b337c26f62f0c9436630f8083e3 SHA512 6b1c0342cbd4dd7e84df58240be3ef8bdc9924a32abe9258d76c87b187be5cb5776125c5989b9dc9bd1210f46216b8f478d2ecb8cc9d165a960157fadc9b5ff8 WHIRLPOOL 0856d73c97f3ac67903d981328c79caa85621f417dcc66d0ee9a04c6590684352395aba72c72fd0427816287f38d03debe0acb962b53b55ce2024ce6517565f7
+AUX zvol.initd 838 SHA256 47a549c68ccedc71c4bcced9304141b7b43356d5190818d34351f3d664427207 SHA512 7a535e3f698bdde4e181ae420d88d76d11f308b0e38d8acfcae41281e05ec05166a2df9df0b3a57844991d166429229ba725561799dc26cbb2e7585094f9783e WHIRLPOOL 6c8873107b71f89618a4cd5ce40cfb55c0c30f48d907d9bb7dc5b53ae96face6bf08ab86b706db964425c1873b9599e1868252a0e28558f78be2d0fad78d2fe2
+AUX zvol.initd-9.0 812 SHA256 d4c083233f2e5c21d57fbc40cc9bd34247540aec9d91c2771d6ad1009efccaf2 SHA512 dbd113cb8f072b001e5f696ddb142df063f12b29a5b16af99f3b00b8c511af87a6094bd210f384ad03a300c2afd7af249cdf278a6179a3f53edc439c3a80f566 WHIRLPOOL bcdfefa27d760b3fe9ea7e953af00eae5d510b2a5e450893d38aab795bf13d08fb204f158a3fda5128e61fd86d3cca7488f3a64c4f003ef51bbff358ba1fc050
+DIST freebsd-cddl-8.2.tar.bz2 823706 SHA256 6d2b2362ce60538bcba4afa47bd6baa98b05292babae4b20d6ba08592ce98698 SHA512 9f9728d9bf0f9fb320a0378186b29133e5e9276494f57ac3cffa9917ec94d3b886708406990107f2fbf742c255f9ac716f35ea14f6a6a835712eb55581421721 WHIRLPOOL 0150d972fc5200efcf22b5baded0bc7d826f03420a8328bc9ce1f53f39d1f3cd07dc367fcb3b0c8bdcc3b33bc9045f262928d76532c91820fd3c6bc8c9ee57c9
+DIST freebsd-cddl-9.1.tar.bz2 899348 SHA256 bcc79fb002052128e9e91b16beb3083ee152be0936494715c6c159bfc8d2ca3a SHA512 ae0a969e710785bbcf36a2ec22cc5b1dcdb25398be951e047a1237d0c977e38fc9e05504db51f8bf9ed83bc1f68b04fc88ce18fc48a93f785b8a3f8ef481bacd WHIRLPOOL 2c4a5baf162dbb698af45b9262f104e27c05e6a2630c3e7b1765e76c8987a330c315f741df69c8771d2509708d2934db2a07f2e0218aa59d0100dfc3f952bf72
+DIST freebsd-contrib-8.2.tar.bz2 40931651 SHA256 8b9cb688e81c2980b3fc66411d00ab277a24dadd50d5bdd5e0e6c63ac687b9b6 SHA512 4f7bf825b579fbb88f2aac531d07e531474179c63fa0b66c4e80821290a8c94bf611bb4dcaef51b762aacd25b11dfae798a4ec3bad3b9e3f6b3490ebfaa72476 WHIRLPOOL edd3d9e26e8d22d9028082e107ec1a44402e206dab8722f34b445676959305996c3f699152af42ace249b7f58498492787823b172fb6bcb273119c6bb50a35f0
+DIST freebsd-contrib-9.1.tar.bz2 54751432 SHA256 e7ffa056d4050ce03ee8e23e276e2a9a494326a98d60c43bee2afcc59576deb8 SHA512 71be13049258c6e6b5e4f63cc16da5d349a89d68f04d87446e4ad33ae8bf2a93ea67d9c256b7bec60b61e65db0487268070cfb77a484c3ac0f8ba368b48c2438 WHIRLPOOL a2a84423175499208d34809e802284d6ba649f317c3a9ad8b7312fa19efe142ebadab0048bac0db8e988e59f9a7468ac7c5d0d25e78b82bdb269a20d18153cee
+DIST freebsd-include-8.2.tar.bz2 138992 SHA256 fade90621a8e4880c9583c1ee49965400c88e53ac6c07cb5dcf320e4f069271d SHA512 6bc820dde866589ef75f9f0d1c469d815439bdd4c79f0e1a2482ec58f938b638cb9106969b321aa72492f933c95c76895ce489727a5e265798c93adc75dd64e3 WHIRLPOOL 64d3160c4ac46a62f5969058e07bd160c92284f08805ed917f2073ba1cb5907cfca16c5893daf30254d39b4fcdf641ab6afb9817607f65e7789d3049e8103947
+DIST freebsd-include-9.1.tar.bz2 146881 SHA256 861dce3f39e6806762b102361017cbe148f0e2b768b3fca152f8426f44a2942f SHA512 779c8315ce2b10b343bb62e331525d510b0d68ce5d665a1672bd6f4d1eff6445bc6b7a0f178b319828aa203c4e4c04c561ce793052703f4f936ce9711280a0c9 WHIRLPOOL e16ba45d380591ba007ca59579d45f61ffc1aa1a4c08fc11ed2794979b0a189a346c81b4f70a44ee199d50a72024930f28587ad62a9cd6854fc937eb466ec115
+DIST freebsd-lib-8.2.tar.bz2 3323878 SHA256 e3590c12794fcb5ba8eb7a1f58b497587cf19f9200b3254c194a793da3b5bfb0 SHA512 c059cfdd1099bb519b2a5c43fb7e7104c500ef8906229ed7eb9e420cb3a217cdaf8655e9e7a9f45cfadc5491f8115e0e738fd49251d9f0c3a83780845b09f007 WHIRLPOOL 95f98a372f44a89bc8ac3029ec065dbbfec338e6f889d057d75644bfcdfb9d27fdc0421d7e392cad5a823712b97f0857297ec3d321580254c63032c22b95792e
+DIST freebsd-lib-9.1.tar.bz2 3206685 SHA256 f31fa8107b4de711c548f6d0c1bb1f81d09f51bcc3b14a1e9e90bb0e7cc4a35d SHA512 40d0c36b6b889c404fa0e0afa38ba4e84a55bc88ffa2f98a70afbd7a32c4f32c158617ba770567d082a986d62c09b3ec8db3dc5ab853ee1c9bbe0b90bb82396e WHIRLPOOL 581878bf9c43184b043b4293409b85901c9ed1f9bd279e965414aca41ba50950848ebda3ee10a503a028135dfd2765e95a11acd4e62a11c528e104392bbbd8d0
+DIST freebsd-sbin-8.2.tar.bz2 1211665 SHA256 8b7e21a66b4696e8763d29b8b02b2d35f29fc51820a194d1e469e7cace84c527 SHA512 c6643c29ab62344c98d8991708798730ee1c17e6478071718beeaa79788300a1f4ed2e6aeb8e39e3c216877d4ed2ac85b2a9531d534f1ac5125a508927898959 WHIRLPOOL 2a21cd0f15f95d66718031680ac87f1fe73f1e1b03cb012e1db1dd1bd2fe2bb7897457a8ba2f5a28c8806775611dca542cbadec16566c47ab9efa673e2cb53f3
+DIST freebsd-sbin-9.1.tar.bz2 1273913 SHA256 45008b0733b232ef03707ef5fa3e5c889e3b3728393d736bd9a869ea83be6447 SHA512 9f186602b7de96f268c352ca386986652fddf5570e7eca1afa8c0d2bdc83b57df1198efe47f36dd5c7a6abf4f9c935f1c8207a4a12a6b2153bd6c3c6292719dc WHIRLPOOL 20920dfa9607a0ce854319cef29bbd77fb1b31f6f6cfd5ac60cbd678169e43929e215743fe636d0c224443f3e6149a8f07c292d647f7f901592795ac292699f9
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+DIST freebsd-sys-8.2.tar.bz2 25835329 SHA256 0c6c7b61aae94db2931f985d5899f3bca78fc8ffab6b598fbaa158142d676f16 SHA512 6ea4516a5c52e25c4f993f7acb875463a5caea93dbdf250c5d48eee95fff226956e9f030cab7e341b5e6a132325bc3dbf93dcb4b1185acb011918e50b1a22be3 WHIRLPOOL 870deeff877c6b9fc812a4260e4fdbb6715a5dc2065cab3bfbf2a42d876f6654703ccb124275a4e2c410cef48f3db02b63cc76059eccf9cf90244826f35b7a15
+DIST freebsd-sys-9.1.tar.bz2 32588103 SHA256 b93a7ac8334ac16cc9f60665048e5ef812c0a6c62f10d0b0a674aec3f56516a8 SHA512 7dc9d9e00dde8f592bb171f4386d02b655b73cb4f153fe5ec063d010a148ef0639eae0dcdb3eeb09ecd1e3653c69e49a2d261329fa6d0381d2ddabe258ddde6d WHIRLPOOL c8348344dfb14bad64bd3a78ee615ddd29203175b292233254f8ba175e7a3fb7218af6f95f7b4dbf394c0354bafe9d8bb0c21cdf0ceaeb697214964b280469b3
+DIST freebsd-ubin-8.2.tar.bz2 1808012 SHA256 6b99554f3ad6ee052069b347eb6e6219b71598d7b222acb90a24cbfc805c7b68 SHA512 48d0103323e820c431aa4f62d3be40cb3b200fb62e3de01f36c88760395bf2ba3367c51f3fa72da4dbccc2812176a051a12ca5cb7e84125c3e0fc78d4cab2c29 WHIRLPOOL ea8f3a29a37b42c2b5bcc0f2c343fa1538522157ef075363c94606a4620a590e9a03f856ce2494e3e727935b62431991d0aa9fde71de699e78b4fe225bdf1c2c
+DIST freebsd-ubin-9.1.tar.bz2 1910472 SHA256 ff6e586f213534b6ec2e65002c0dee64063d76ddad515c12221b1a80a1815e48 SHA512 74ae0aceec8597aa66c3f1ab313f0685a3c63d7273c36ae7baf8794275ad9bca241c60c3f6281cccf6d531d250d7611099977d3b1a27279cef3586401b6af05e WHIRLPOOL c85a3c9cf2bceff2c60ff03556bcc81d3aca22b0bce3c9538990071ac0a907236eee5ae7743ad22c5fd309b047ebf392aaaf2fe177ef5790ea869aff3da7e2fe
+EBUILD freebsd-cddl-10.3.ebuild 1463 SHA256 fcc4ca421df2a326af68a11de8055c4a2da6939b0a11527d616043904ae1a36a SHA512 4effdc2fd7ad27672cc2f3b20ad4612866ab1b6b03f0e30441275b1cfae98bdf55244aba4c9f7c162409d555b40ad78b21a620202f0a291a186e8d39be57be36 WHIRLPOOL bb9c74d2133e2d814b38cc07c679e7a03efce46d9b1bce261a72818e56182c2b9a9a9e127d6882a3cc6d111458ac94747fbe09a311c0338527b85f64183019b1
+EBUILD freebsd-cddl-11.0.ebuild 1701 SHA256 303b70ac8277ad1d27444046241869ba482ca9bdea19e4cb523e1666341f1a5c SHA512 8bca512b17065adb06aa6d64d8911b0d15f989cdef8de9faef92110d38d90ead5182b78cc99e8071b53015882a6859156ce9afcef7454049ddfd9cc0f69408ce WHIRLPOOL 402a1bc0b91fde4b1303d113ff41b4a7617ae209286c44f56f5cbc91b0e29895af1a8bbb6539556b2fa724090930b4f4188444a5b66b6090fd9b9e325213df75
+EBUILD freebsd-cddl-11.1.ebuild 1664 SHA256 b1fa42270e26a6e786df73c2e65a4966586e8e29b63059f2eca7dc5300994963 SHA512 9540e2ab16ffc95451d3439eef6382484a80ea4a06ee1c65b77e9892159a1ddec1ef74bee79222db6e94e17953e65dec6142caae1a6054d10882ddf832dfa3d1 WHIRLPOOL 493e64886d4c340b753b3f9937974b40f6c5a6165086425abab81a3561d33db41fd99d38fd6b3df585f4c66fe7861610840798acc5d69bf442527213e2838f48
+EBUILD freebsd-cddl-8.2.ebuild 1176 SHA256 ae3be474a44060d80627e40167189a822abbd32d20be86693396a875a24a1a97 SHA512 d3c56ea3410338b56db20132f6f4485e60116bb9d959eca263bda5372e007a650dc23c308dc63e10ef53618531ed7d4f7924dfe2326dc2e9093941f749908a60 WHIRLPOOL 45b4431d24722a8c42188f515abe81f9c87df3a4b27cdf5968f531704e4c52f45b396bd5276ee95eb0c328af7d261023fc6102d2fdd00abe2414f2c66b095008
+EBUILD freebsd-cddl-9.1.ebuild 1477 SHA256 d3c121e6f840d333f4be075db9d16ecea976303396678fc8cc7cee6a5b6d6661 SHA512 22724b107c8fe47f3148eb32982e7e46deb9c18fa9f54af2be7cf2733db83cdc1213fd873b62dd425232fa3dbc08f569fcd1edbdd89bc7b86d283327bd1e8883 WHIRLPOOL 4e777664678a82af1bf33e709789dbd80234e91e4068b6e2d98a70b8c71c06bb5a2f8bf2ec3733d1b6c31712a0893784c27bc9959a225699b9a9cb1e9557e092
+MISC ChangeLog 4478 SHA256 b3015626f5dc8f3c09e5f51b9477be34dd77056ab02b24738b3489ed5c241152 SHA512 c230706f2024b0b9eb90e0981047abda54dd2ba49d484e8aa3bebaaf1de52fb8cd884ca7055bf3e2d92d451f2c911e9f61e68f97a5657a11e9774675cf85138d WHIRLPOOL 9d1fdcdea186d08e7e66d7cc0cec1cd6cc35ff093cea999cd7717a0de4b93dd2d8bf9a239e3fcea32174cbde19976b754622fa55921f78f86ae3fac23218c37a
+MISC ChangeLog-2015 7084 SHA256 863266e79f79fbabe3480a98224819bd49ead871630dcadc547a9520ba275e37 SHA512 ac6b61c9733186e2ce9993bea73949d2043739023f62bef501e95cc40e1af1f35a98a87a013031ccb991396d6e4c2fae61624ca49e60c4784b21ba99f1f8b815 WHIRLPOOL 5e00cc04749d6bd051c150002523df4d62ae9fc7e69f7704802dc6e7657a11d4befa64c4791705ede20cba0f977511c4685bb248816b4d9b09c0a50ea7c62d95
+MISC metadata.xml 238 SHA256 501d93b0c41ed422505100f002758cd173cd9783ae7fbb53e2ec5f238c868340 SHA512 173efaa53a514acf1e2f0c6681c82a48ec16d505844f551d2cc823ee8685b27837c7461f7956c12182059ee7e83023e2f0bcd5d1afab74beeaf998487193656d WHIRLPOOL 4ca51d994f011a5e7e4939f02a54b5c2f9f3e526665893c9ac2876c9871b7dc80361393d41c5247b3a5520e82d31d0dd10da520e7715c94b806a94ce0fed2a5a
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.2-libpaths.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.2-libpaths.patch
new file mode 100644
index 000000000000..9af7cfbb8c31
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.2-libpaths.patch
@@ -0,0 +1,220 @@
+diff --git a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile
+index d8bcccb..2cebbcb 100644
+--- a/cddl/lib/libzfs/Makefile
++++ b/cddl/lib/libzfs/Makefile
+@@ -59,6 +59,11 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libnvpair
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs_core/common
+
+diff --git a/cddl/lib/libzfs_core/Makefile b/cddl/lib/libzfs_core/Makefile
+index 262d3e9..9643210 100644
+--- a/cddl/lib/libzfs_core/Makefile
++++ b/cddl/lib/libzfs_core/Makefile
+@@ -34,4 +34,6 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs_core/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++
+ .include <bsd.lib.mk>
+diff --git a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile
+index 83cefca..55c56d5 100644
+--- a/cddl/lib/libzpool/Makefile
++++ b/cddl/lib/libzpool/Makefile
+@@ -56,6 +56,10 @@ CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/thread
+ CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/sys
+ CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_CPUARCH}/include
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++
+ DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ} ${LIBNVPAIR} \
+ ${LIBAVL} ${LIBUMEM}
+ LDADD= -lmd -lpthread -lz -lnvpair -lavl -lumem
+diff --git a/cddl/sbin/zfs/Makefile b/cddl/sbin/zfs/Makefile
+index 1f909aa..2590302 100644
+--- a/cddl/sbin/zfs/Makefile
++++ b/cddl/sbin/zfs/Makefile
+@@ -22,6 +22,12 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBJAIL} ${LIBNVPAIR} ${LIBUMEM} \
+ ${LIBUTIL} ${LIBUUTIL} ${LIBZFS_CORE} ${LIBZFS}
+ LDADD= -lgeom -ljail -lnvpair -lumem -lutil -luutil -lzfs_core -lzfs
+diff --git a/cddl/sbin/zpool/Makefile b/cddl/sbin/zpool/Makefile
+index 4b5b898..f89d010 100644
+--- a/cddl/sbin/zpool/Makefile
++++ b/cddl/sbin/zpool/Makefile
+@@ -27,6 +27,13 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/stat/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBNVPAIR} \
+ ${LIBUMEM} ${LIBUTIL} ${LIBUUTIL} ${LIBZFS_CORE} ${LIBZFS}
+ LDADD= -lavl -lgeom -lnvpair -lumem -lutil -luutil -lzfs_core -lzfs
+diff --git a/cddl/usr.bin/ctfconvert/Makefile b/cddl/usr.bin/ctfconvert/Makefile
+index 6cb9529..e76fbc4 100644
+--- a/cddl/usr.bin/ctfconvert/Makefile
++++ b/cddl/usr.bin/ctfconvert/Makefile
+@@ -36,6 +36,8 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBCTF} ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
+ LDADD= -lctf -ldwarf -lelf -lz -lpthread
+
+diff --git a/cddl/usr.bin/ctfmerge/Makefile b/cddl/usr.bin/ctfmerge/Makefile
+index 673c7e3..5fff940 100644
+--- a/cddl/usr.bin/ctfmerge/Makefile
++++ b/cddl/usr.bin/ctfmerge/Makefile
+@@ -33,6 +33,8 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBCTF} ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
+ LDADD= -lctf -ldwarf -lelf -lz -lpthread
+
+diff --git a/cddl/usr.bin/zinject/Makefile b/cddl/usr.bin/zinject/Makefile
+index b6605cb..7028630 100644
+--- a/cddl/usr.bin/zinject/Makefile
++++ b/cddl/usr.bin/zinject/Makefile
+@@ -21,6 +21,14 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs/
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBUUTIL} \
+ ${LIBZFS_CORE} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lgeom -lm -lnvpair -lumem -luutil -lzfs_core -lzfs -lzpool
+diff --git a/cddl/usr.bin/zstreamdump/Makefile b/cddl/usr.bin/zstreamdump/Makefile
+index 888b9af..523ba44 100644
+--- a/cddl/usr.bin/zstreamdump/Makefile
++++ b/cddl/usr.bin/zstreamdump/Makefile
+@@ -18,6 +18,11 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++
+ DPADD= ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ ${LIBPTHREAD} ${LIBZ} ${LIBAVL}
+ LDADD= -lm -lnvpair -lumem -lzpool -lpthread -lz -lavl
+diff --git a/cddl/usr.bin/ztest/Makefile b/cddl/usr.bin/ztest/Makefile
+index f6f7e03..6fed691 100644
+--- a/cddl/usr.bin/ztest/Makefile
++++ b/cddl/usr.bin/ztest/Makefile
+@@ -18,6 +18,14 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ ${LIBPTHREAD} ${LIBAVL} ${LIBZFS_CORE} ${LIBZFS} ${LIBUUTIL}
+ LDADD= -lgeom -lm -lnvpair -lumem -lzpool -lpthread -lavl -lzfs_core -lzfs \
+diff --git a/cddl/usr.sbin/dtrace/Makefile b/cddl/usr.sbin/dtrace/Makefile
+index fb5729f..ea9a752 100644
+--- a/cddl/usr.sbin/dtrace/Makefile
++++ b/cddl/usr.sbin/dtrace/Makefile
+@@ -25,4 +25,7 @@ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBFL} ${LIBPROC} \
+ LDADD= -lpthread -ldtrace -ly -lfl -lproc -lctf -lelf -lz -lutil \
+ -lrtld_db
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libdtrace
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ .include <bsd.prog.mk>
+diff --git a/cddl/usr.sbin/lockstat/Makefile b/cddl/usr.sbin/lockstat/Makefile
+index ccd8189..827a197 100644
+--- a/cddl/usr.sbin/lockstat/Makefile
++++ b/cddl/usr.sbin/lockstat/Makefile
+@@ -20,6 +20,9 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+
+ CFLAGS+= -DNEED_ERRLOC -g
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libdtrace
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ #YFLAGS+= -d
+
+ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBFL} ${LIBPROC} \
+diff --git a/cddl/usr.sbin/zdb/Makefile b/cddl/usr.sbin/zdb/Makefile
+index c2a6b1d..f411fc0 100644
+--- a/cddl/usr.sbin/zdb/Makefile
++++ b/cddl/usr.sbin/zdb/Makefile
+@@ -24,6 +24,14 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBPTHREAD} ${LIBUMEM} \
+ ${LIBUUTIL} ${LIBZFS_CORE} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lgeom -lm -lnvpair -lpthread -lumem -luutil -lzfs_core -lzfs -lzpool
+diff --git a/cddl/usr.sbin/zhack/Makefile b/cddl/usr.sbin/zhack/Makefile
+index 1957aad..9a5570a 100644
+--- a/cddl/usr.sbin/zhack/Makefile
++++ b/cddl/usr.sbin/zhack/Makefile
+@@ -23,6 +23,13 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs_core
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBPTHREAD} ${LIBUMEM} \
+ ${LIBUUTIL} ${LIBZFS_CORE} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lgeom -lm -lnvpair -lpthread -lumem -luutil -lzfs_core -lzfs -lzpool
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.3-underlink.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.3-underlink.patch
new file mode 100644
index 000000000000..c8ce8e1a2943
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-10.3-underlink.patch
@@ -0,0 +1,12 @@
+diff --git a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile
+index 2a66337..04988d7 100644
+--- a/cddl/lib/libzfs/Makefile
++++ b/cddl/lib/libzfs/Makefile
+@@ -12,6 +12,7 @@ DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBUMEM} ${LIBUTIL} ${LIBM} ${LIBNVPAIR} \
+
+ LDADD= -lmd -lpthread -lumem -lutil -luutil -lm -lnvpair -lavl \
+ -lbsdxml -lgeom -lnvpair -lz -lzfs_core
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
+
+ SRCS= deviceid.c \
+ fsshare.c \
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-11.0-add-libs.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-11.0-add-libs.patch
new file mode 100644
index 000000000000..46f25217bdac
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-11.0-add-libs.patch
@@ -0,0 +1,87 @@
+diff --git a/cddl/sbin/zfs/Makefile b/cddl/sbin/zfs/Makefile
+index 1e386e5..a4c08ee 100644
+--- a/cddl/sbin/zfs/Makefile
++++ b/cddl/sbin/zfs/Makefile
+@@ -22,6 +22,6 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+
+-LIBADD= jail nvpair uutil zfs_core zfs
++LIBADD= jail nvpair uutil zfs_core zfs umem avl
+
+ .include <bsd.prog.mk>
+diff --git a/cddl/sbin/zpool/Makefile b/cddl/sbin/zpool/Makefile
+index ebf0f90..c70a3c4 100644
+--- a/cddl/sbin/zpool/Makefile
++++ b/cddl/sbin/zpool/Makefile
+@@ -27,6 +27,6 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/stat/common
+
+-LIBADD= geom nvpair uutil zfs
++LIBADD= geom nvpair uutil zfs umem avl zfs_core
+
+ .include <bsd.prog.mk>
+diff --git a/cddl/usr.sbin/lockstat/Makefile b/cddl/usr.sbin/lockstat/Makefile
+index fc68904..9af6ff2 100644
+--- a/cddl/usr.sbin/lockstat/Makefile
++++ b/cddl/usr.sbin/lockstat/Makefile
+@@ -21,6 +21,6 @@ CFLAGS+= -DNEED_ERRLOC -g
+
+ #YFLAGS+= -d
+
+-LIBADD= elf dtrace rt
++LIBADD= elf dtrace rt ctf
+
+ .include <bsd.prog.mk>
+diff --git a/cddl/usr.sbin/plockstat/Makefile b/cddl/usr.sbin/plockstat/Makefile
+index 77b6139..7737efd 100644
+--- a/cddl/usr.sbin/plockstat/Makefile
++++ b/cddl/usr.sbin/plockstat/Makefile
+@@ -18,6 +18,6 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
+ -I${.CURDIR}/../../../cddl/lib/libdtrace \
+ -I${.CURDIR}/../../../sys
+
+-LIBADD= dtrace proc
++LIBADD= dtrace proc ctf
+
+ .include <bsd.prog.mk>
+diff --git a/cddl/usr.sbin/zdb/Makefile b/cddl/usr.sbin/zdb/Makefile
+index 3609502..71526f7 100644
+--- a/cddl/usr.sbin/zdb/Makefile
++++ b/cddl/usr.sbin/zdb/Makefile
+@@ -24,7 +24,7 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
+-LIBADD= nvpair umem uutil zfs zpool
++LIBADD= nvpair umem uutil zfs zpool avl zfs_core
+
+ # Since there are many asserts in this program, it makes no sense to compile
+ # it without debugging.
+diff --git a/cddl/usr.sbin/zfsd/Makefile.common b/cddl/usr.sbin/zfsd/Makefile.common
+index a545609..034d418 100644
+--- a/cddl/usr.sbin/zfsd/Makefile.common
++++ b/cddl/usr.sbin/zfsd/Makefile.common
+@@ -35,7 +35,7 @@ CXXFLAGS= -g -DNEED_SOLARIS_BOOLEAN ${INCFLAGS}
+
+ DPADD= ${LIBDEVDCTL} ${LIBZFS} ${LIBZFS_CORE} ${LIBUTIL} ${LIBGEOM} \
+ ${LIBBSDXML} ${LIBSBUF} ${LIBNVPAIR} ${LIBUUTIL}
+-LIBADD= devdctl zfs zfs_core util geom bsdxml sbuf nvpair uutil
++LIBADD= devdctl zfs zfs_core util geom bsdxml sbuf nvpair uutil umem avl
+
+ cscope:
+ find ${.CURDIR} -type f -a \( -name "*.[ch]" -o -name "*.cc" \) \
+diff --git a/cddl/usr.sbin/zhack/Makefile b/cddl/usr.sbin/zhack/Makefile
+index 02c51ac..d9b79a9 100644
+--- a/cddl/usr.sbin/zhack/Makefile
++++ b/cddl/usr.sbin/zhack/Makefile
+@@ -23,7 +23,7 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
+-LIBADD= nvpair zfs zpool
++LIBADD= nvpair zfs zpool umem uutil avl zfs_core
+
+ CFLAGS+= -DDEBUG=1
+ #DEBUG_FLAGS+= -g
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-11.0-workaround.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-11.0-workaround.patch
new file mode 100644
index 000000000000..839b6b5a7924
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-11.0-workaround.patch
@@ -0,0 +1,12 @@
+diff --git a/cddl/usr.sbin/zfsd/Makefile.common b/cddl/usr.sbin/zfsd/Makefile.common
+index 6c71bdf..6b71908 100644
+--- a/cddl/usr.sbin/zfsd/Makefile.common
++++ b/cddl/usr.sbin/zfsd/Makefile.common
+@@ -31,6 +31,7 @@ INCFLAGS+= -I${SRCDIR}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+ INCFLAGS+= -I${SRCDIR}/sys/cddl/contrib/opensolaris/uts/common/sys
+
+ CFLAGS= -g -DNEED_SOLARIS_BOOLEAN ${INCFLAGS}
++CXXFLAGS= -g -DNEED_SOLARIS_BOOLEAN ${INCFLAGS}
+
+ DPADD= ${LIBDEVDCTL} ${LIBZFS} ${LIBZFS_CORE} ${LIBUTIL} ${LIBGEOM} \
+ ${LIBBSDXML} ${LIBSBUF} ${LIBNVPAIR} ${LIBUUTIL}
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.0-libpaths.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.0-libpaths.patch
new file mode 100644
index 000000000000..ad5c83eca3de
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.0-libpaths.patch
@@ -0,0 +1,114 @@
+diff -ru cddl.orig/lib/libctf/Makefile cddl/lib/libctf/Makefile
+--- cddl.orig/lib/libctf/Makefile 2009-01-24 03:36:33 -0200
++++ cddl/lib/libctf/Makefile 2009-01-24 03:55:10 -0200
+@@ -4,6 +4,7 @@
+
+ LIB= ctf
+ SHLIB_MAJOR= 2
++LDADD+=-lz
+
+ SRCS= ctf_create.c \
+ ctf_decl.c \
+diff -ru cddl.orig/lib/libdtrace/Makefile cddl/lib/libdtrace/Makefile
+--- cddl.orig/lib/libdtrace/Makefile 2009-01-24 00:18:47 -0200
++++ cddl/lib/libdtrace/Makefile 2009-01-24 03:31:06 -0200
+@@ -74,7 +74,7 @@
+ .endif
+
+ LFLAGS+=-l
+-
++LDADD+=-lz -lproc
+ YFLAGS+=-d
+
+ CLEANFILES= dt_errtags.c dt_names.c
+diff -ru cddl.orig/lib/libzfs/Makefile cddl/lib/libzfs/Makefile
+--- cddl.orig/lib/libzfs/Makefile 2008-06-22 10:26:18 -0300
++++ cddl/lib/libzfs/Makefile 2008-06-22 10:26:26 -0300
+@@ -7,7 +7,8 @@
+
+ LIB= zfs
+ DPADD= ${LIBUTIL}
+-LDADD= -lutil
++LDADD= -lutil -lgeom -lm -luutil -lumem
++LDFLAGS+= -L${.CURDIR}/../libuutil -L${.CURDIR}/../libumem
+
+ SRCS= deviceid.c \
+ mnttab.c \
+diff -ru cddl.orig/lib/libzpool/Makefile cddl/lib/libzpool/Makefile
+--- cddl.orig/lib/libzpool/Makefile 2008-06-22 10:35:15 -0300
++++ cddl/lib/libzpool/Makefile 2008-06-22 10:37:06 -0300
+@@ -42,7 +42,8 @@
+ CFLAGS+= -I${.CURDIR}/../../../contrib/opensolaris/lib/libnvpair
+
+ DPADD= ${LIBPTHREAD} ${LIBZ}
+-LDADD= -lpthread -lz
++LDADD= -lpthread -lz -lavl -lumem
++LDFLAGS+= -L${.CURDIR}/../libavl -L${.CURDIR}/../libumem
+
+ # atomic.S doesn't like profiling.
+ NO_PROFILE=
+diff -ru cddl.orig/sbin/zfs/Makefile cddl/sbin/zfs/Makefile
+--- cddl.orig/sbin/zfs/Makefile 2008-06-22 10:02:30 -0300
++++ cddl/sbin/zfs/Makefile 2008-06-22 10:14:23 -0300
+@@ -23,5 +23,7 @@
+ ${LIBM} ${LIBNVPAIR} ${LIBUUTIL} ${LIBUTIL}
+ LDADD= -lzfs -lgeom -lbsdxml -lsbuf \
+ -lm -lnvpair -luutil -lutil
++LDFLAGS+=-L${.CURDIR}/../../lib/libzfs -L${.CURDIR}/../../lib/libnvpair \
++ -L${.CURDIR}/../../lib/libuutil -L/lib -L/usr/lib
+
+ .include <bsd.prog.mk>
+diff -ru cddl.orig/sbin/zpool/Makefile cddl/sbin/zpool/Makefile
+--- cddl.orig/sbin/zpool/Makefile 2008-06-22 10:02:30 -0300
++++ cddl/sbin/zpool/Makefile 2008-06-22 10:14:47 -0300
+@@ -23,5 +23,7 @@
+ ${LIBM} ${LIBNVPAIR} ${LIBUUTIL} ${LIBUTIL}
+ LDADD= -lavl -lzfs -lgeom -lbsdxml -lsbuf \
+ -lm -lnvpair -luutil -lutil
++LDFLAGS+=-L${.CURDIR}/../../lib/libzfs -L${.CURDIR}/../../lib/libavl -L/lib -L/usr/lib \
++ -L${.CURDIR}/../../lib/libnvpair -L${.CURDIR}/../../lib/libuutil
+
+ .include <bsd.prog.mk>
+diff -ru cddl.orig/usr.bin/ztest/Makefile cddl/usr.bin/ztest/Makefile
+--- cddl.orig/usr.bin/ztest/Makefile 2008-06-22 10:02:30 -0300
++++ cddl/usr.bin/ztest/Makefile 2008-06-22 10:12:40 -0300
+@@ -18,5 +18,7 @@
+ DPADD= ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ ${LIBPTHREAD} ${LIBZ} ${LIBAVL}
+ LDADD= -lm -lnvpair -lumem -lzpool -lpthread -lz -lavl
++LDFLAGS+=-L${.CURDIR}/../../lib/libnvpair -L${.CURDIR}/../../lib/libumem \
++ -L${.CURDIR}/../../lib/libzpool -L${.CURDIR}/../../lib/libavl -L/lib -L/usr/lib
+
+ .include <bsd.prog.mk>
+diff -ru cddl.orig/usr.bin/Makefile.inc cddl/usr.bin/Makefile.inc
+--- cddl.orig/usr.bin/Makefile.inc 2009-01-10 07:21:10 +0000
++++ cddl/usr.bin/Makefile.inc 2009-01-10 07:18:55 +0000
+@@ -1,5 +1,6 @@
+ # $FreeBSD: src/cddl/usr.bin/Makefile.inc,v 1.1.6.1 2008/11/25 02:59:29 kensmith Exp $
+
+ BINDIR?= /usr/bin
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
+
+ .include "../Makefile.inc"
+--- cddl.orig/usr.sbin/zdb/Makefile 2010-03-11 13:19:48 +0100
++++ cddl/usr.sbin/zdb/Makefile 2010-03-11 13:20:08 +0100
+@@ -22,6 +22,8 @@
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBPTHREAD} ${LIBUMEM} \
+ ${LIBUUTIL} ${LIBZ} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lavl -lgeom -lm -lnvpair -lpthread -lumem -luutil -lz -lzfs -lzpool
++LDFLAGS+=-L${.CURDIR}/../../lib/libnvpair -L${.CURDIR}/../../lib/libumem \
++ -L${.CURDIR}/../../lib/libzpool -L${.CURDIR}/../../lib/libavl -L${.CURDIR}/../../lib/libuutil -L${.CURDIR}/../../lib/libzfs
+
+ CSTD= c99
+
+--- cddl.orig/usr.bin/zinject/Makefile 2010-03-11 13:30:32 +0100
++++ cddl/usr.bin/zinject/Makefile 2010-03-11 13:33:27 +0100
+@@ -21,5 +21,8 @@
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBUUTIL} \
+ ${LIBZFS} ${LIBZPOOL} ${LIBUUTIL}
+ LDADD= -lavl -lgeom -lm -lnvpair -lumem -luutil -lzfs -lzpool
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl -L${.CURDIR}/../../lib/libnvpair \
++ -L${.CURDIR}/../../lib/libumem -L${.CURDIR}/../../lib/libuutil \
++ -L${.CURDIR}/../../lib/libzfs -L${.CURDIR}/../../lib/libzpool
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.2-libpaths.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.2-libpaths.patch
new file mode 100644
index 000000000000..a0e567790473
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-8.2-libpaths.patch
@@ -0,0 +1,22 @@
+--- cddl/usr.sbin/dtrace/Makefile.old 2011-07-06 00:09:01.000000000 +0000
++++ cddl/usr.sbin/dtrace/Makefile 2011-07-06 00:09:48.000000000 +0000
+@@ -24,6 +24,8 @@
+ #CFLAGS+= -DNEED_ERRLOC
+ #YFLAGS+= -d
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libdtrace -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
+ ${LIBCTF} ${LIBELF} ${LIBZ} ${LIBUTIL} ${LIBRTLD_DB}
+ LDADD= -lpthread -ldtrace -ly -lfl -lproc -lctf -lelf -lz -lutil \
+--- cddl/usr.sbin/lockstat/Makefile.old 2011-07-06 00:10:33.000000000 +0000
++++ cddl/usr.sbin/lockstat/Makefile 2011-07-06 00:10:57.000000000 +0000
+@@ -23,6 +23,8 @@
+
+ CFLAGS+= -DNEED_ERRLOC -g
+
++LDFLAGS+=-L${.CURDIR}/../../lib/libdtrace -L${.CURDIR}/../../lib/libctf
++
+ #YFLAGS+= -d
+
+ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-bsdxml.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-bsdxml.patch
new file mode 100644
index 000000000000..b3d95bb7741e
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-bsdxml.patch
@@ -0,0 +1,28 @@
+diff -ur cddl.old/sbin/zfs/Makefile cddl/sbin/zfs/Makefile
+--- cddl.old/sbin/zfs/Makefile 2011-11-04 10:01:46.000000000 +0000
++++ cddl/sbin/zfs/Makefile 2011-11-04 10:07:15.000000000 +0000
+@@ -21,8 +21,8 @@
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+
+-DPADD= ${LIBBSDXML} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBSBUF} ${LIBUMEM} \
++DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBSBUF} ${LIBUMEM} \
+ ${LIBUTIL} ${LIBUUTIL} ${LIBZFS}
+-LDADD= -lbsdxml -lgeom -lm -lnvpair -lsbuf -lumem -lutil -luutil -lzfs
++LDADD= -lgeom -lm -lnvpair -lsbuf -lumem -lutil -luutil -lzfs
+
+ .include <bsd.prog.mk>
+diff -ur cddl.old/sbin/zpool/Makefile cddl/sbin/zpool/Makefile
+--- cddl.old/sbin/zpool/Makefile 2011-11-04 10:01:46.000000000 +0000
++++ cddl/sbin/zpool/Makefile 2011-11-04 10:06:38.000000000 +0000
+@@ -26,8 +26,8 @@
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/stat/common
+
+-DPADD= ${LIBAVL} ${LIBBSDXML} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBSBUF} \
++DPADD= ${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBSBUF} \
+ ${LIBUMEM} ${LIBUTIL} ${LIBUUTIL} ${LIBZFS}
+-LDADD= -lavl -lbsdxml -lgeom -lm -lnvpair -lsbuf -lumem -lutil -luutil -lzfs
++LDADD= -lavl -lgeom -lm -lnvpair -lsbuf -lumem -lutil -luutil -lzfs
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-libpaths.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-libpaths.patch
new file mode 100644
index 000000000000..c81a2c3a9cdf
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-libpaths.patch
@@ -0,0 +1,167 @@
+diff -upNr a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile
+--- a/cddl/lib/libzfs/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/lib/libzfs/Makefile 2012-03-30 19:04:39.904906253 +0000
+@@ -54,4 +54,8 @@ CFLAGS+= -I${.CURDIR}/../../../cddl/cont
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++
+ .include <bsd.lib.mk>
+diff -upNr a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile
+--- a/cddl/lib/libzpool/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/lib/libzpool/Makefile 2012-03-30 19:04:55.839233753 +0000
+@@ -56,6 +56,10 @@ CFLAGS+= -I${.CURDIR}/../../../lib/libpt
+ CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/sys
+ CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_CPUARCH}/include
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++
+ DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ}
+ LDADD= -lmd -lpthread -lz -lumem -lnvpair -lavl
+
+diff -upNr a/cddl/sbin/zfs/Makefile b/cddl/sbin/zfs/Makefile
+--- a/cddl/sbin/zfs/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/sbin/zfs/Makefile 2012-03-30 19:05:11.094859502 +0000
+@@ -21,6 +21,11 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
+ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++
+ DPADD= ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBSBUF} ${LIBUMEM} \
+ ${LIBUTIL} ${LIBUUTIL} ${LIBZFS}
+ LDADD= -lgeom -lm -lnvpair -lsbuf -lumem -lutil -luutil -lzfs
+diff -upNr a/cddl/sbin/zpool/Makefile b/cddl/sbin/zpool/Makefile
+--- a/cddl/sbin/zpool/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/sbin/zpool/Makefile 2012-03-30 19:05:24.830721002 +0000
+@@ -26,6 +26,12 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/stat/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBSBUF} \
+ ${LIBUMEM} ${LIBUTIL} ${LIBUUTIL} ${LIBZFS}
+ LDADD= -lavl -lgeom -lm -lnvpair -lsbuf -lumem -lutil -luutil -lzfs
+diff -upNr a/cddl/usr.bin/ctfconvert/Makefile b/cddl/usr.bin/ctfconvert/Makefile
+--- a/cddl/usr.bin/ctfconvert/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/usr.bin/ctfconvert/Makefile 2012-03-30 19:05:49.454897012 +0000
+@@ -36,6 +36,8 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBCTF} ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
+ LDADD= -lctf -ldwarf -lelf -lz -lpthread
+
+diff -upNr a/cddl/usr.bin/ctfmerge/Makefile b/cddl/usr.bin/ctfmerge/Makefile
+--- a/cddl/usr.bin/ctfmerge/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/usr.bin/ctfmerge/Makefile 2012-03-30 19:06:08.084858412 +0000
+@@ -33,6 +33,8 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
+ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBCTF} ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
+ LDADD= -lctf -ldwarf -lelf -lz -lpthread
+
+diff -upNr a/cddl/usr.bin/zinject/Makefile b/cddl/usr.bin/zinject/Makefile
+--- a/cddl/usr.bin/zinject/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/usr.bin/zinject/Makefile 2012-03-30 19:06:25.084865592 +0000
+@@ -19,6 +19,13 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBUUTIL} \
+ ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lavl -lgeom -lm -lnvpair -lumem -luutil -lzfs -lzpool
+diff -upNr a/cddl/usr.bin/zstreamdump/Makefile b/cddl/usr.bin/zstreamdump/Makefile
+--- a/cddl/usr.bin/zstreamdump/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/usr.bin/zstreamdump/Makefile 2012-03-30 19:06:44.544860132 +0000
+@@ -18,6 +18,11 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++
+ DPADD= ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ ${LIBPTHREAD} ${LIBZ} ${LIBAVL}
+ LDADD= -lm -lnvpair -lumem -lzpool -lpthread -lz -lavl
+diff -upNr a/cddl/usr.bin/ztest/Makefile b/cddl/usr.bin/ztest/Makefile
+--- a/cddl/usr.bin/ztest/Makefile 2012-03-30 18:58:53.174771000 +0000
++++ b/cddl/usr.bin/ztest/Makefile 2012-03-30 19:06:58.344895642 +0000
+@@ -17,6 +17,11 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ CFLAGS+= -I${.CURDIR}/../../contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++
+ DPADD= ${LIBM} ${LIBNVPAIR} ${LIBUMEM} ${LIBZPOOL} \
+ ${LIBPTHREAD} ${LIBZ} ${LIBAVL}
+ LDADD= -lm -lnvpair -lumem -lzpool -lpthread -lz -lavl
+diff -upNr a/cddl/usr.sbin/zdb/Makefile b/cddl/usr.sbin/zdb/Makefile
+--- a/cddl/usr.sbin/zdb/Makefile 2012-03-30 18:58:53.164736000 +0000
++++ b/cddl/usr.sbin/zdb/Makefile 2012-03-30 19:07:17.454861002 +0000
+@@ -23,6 +23,13 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/
+ CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
+ CFLAGS+= -I${.CURDIR}/../../lib/libumem
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libavl
++LDFLAGS+= -L${.CURDIR}/../../lib/libnvpair
++LDFLAGS+= -L${.CURDIR}/../../lib/libumem
++LDFLAGS+= -L${.CURDIR}/../../lib/libuutil
++LDFLAGS+= -L${.CURDIR}/../../lib/libzfs
++LDFLAGS+= -L${.CURDIR}/../../lib/libzpool
++
+ DPADD= ${LIBAVL} ${LIBGEOM} ${LIBM} ${LIBNVPAIR} ${LIBPTHREAD} ${LIBUMEM} \
+ ${LIBUUTIL} ${LIBZ} ${LIBZFS} ${LIBZPOOL}
+ LDADD= -lavl -lgeom -lm -lnvpair -lpthread -lumem -luutil -lz -lzfs -lzpool
+--- a/cddl/usr.sbin/dtrace/Makefile.old 2011-07-06 00:09:01.000000000 +0000
++++ b/cddl/usr.sbin/dtrace/Makefile 2011-07-06 00:09:48.000000000 +0000
+@@ -24,6 +24,8 @@
+ #CFLAGS+= -DNEED_ERRLOC
+ #YFLAGS+= -d
+
++LDFLAGS+= -L${.CURDIR}/../../lib/libdtrace -L${.CURDIR}/../../lib/libctf
++
+ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
+ ${LIBCTF} ${LIBELF} ${LIBZ} ${LIBUTIL} ${LIBRTLD_DB}
+ LDADD= -lpthread -ldtrace -ly -lfl -lproc -lctf -lelf -lz -lutil \
+--- a/cddl/usr.sbin/lockstat/Makefile.old 2011-07-06 00:10:33.000000000 +0000
++++ b/cddl/usr.sbin/lockstat/Makefile 2011-07-06 00:10:57.000000000 +0000
+@@ -23,6 +23,8 @@
+
+ CFLAGS+= -DNEED_ERRLOC -g
+
++LDFLAGS+=-L${.CURDIR}/../../lib/libdtrace -L${.CURDIR}/../../lib/libctf
++
+ #YFLAGS+= -d
+
+ DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
diff --git a/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-underlink.patch b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-underlink.patch
new file mode 100644
index 000000000000..ff87d2c6ef9b
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/freebsd-cddl-9.0-underlink.patch
@@ -0,0 +1,22 @@
+--- cddl/lib/libzfs/Makefile.old 2011-11-04 10:27:30.000000000 +0000
++++ cddl/lib/libzfs/Makefile 2011-11-04 10:28:59.000000000 +0000
+@@ -7,7 +7,7 @@
+
+ LIB= zfs
+ DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBUMEM} ${LIBUTIL}
+-LDADD= -lmd -lpthread -lumem -lutil
++LDADD= -lmd -lpthread -lumem -lutil -luutil -lnvpair -lm -lgeom
+
+ SRCS= deviceid.c \
+ fsshare.c \
+--- cddl/lib/libzpool/Makefile.old 2011-11-04 18:22:28.000000000 +0000
++++ cddl/lib/libzpool/Makefile 2011-11-04 18:24:01.000000000 +0000
+@@ -57,7 +57,7 @@
+ CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_CPUARCH}/include
+
+ DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ}
+-LDADD= -lmd -lpthread -lz
++LDADD= -lmd -lpthread -lz -lumem -lnvpair -lavl
+
+ # atomic.S doesn't like profiling.
+ NO_PROFILE=
diff --git a/sys-freebsd/freebsd-cddl/files/zfs.initd b/sys-freebsd/freebsd-cddl/files/zfs.initd
new file mode 100644
index 000000000000..a62d7fbeb1c2
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/zfs.initd
@@ -0,0 +1,23 @@
+#!/sbin/openrc-run
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need hostid
+ before fsck
+}
+
+start() {
+ einfo "Starting zfs ..."
+ zfs mount -a
+ zfs share -a
+ if [ ! -r /etc/zfs/exports ]; then
+ touch /etc/zfs/exports
+ fi
+}
+
+stop() {
+ einfo "Stopping zfs ..."
+ zfs unshare -a
+ zfs unmount -a
+}
diff --git a/sys-freebsd/freebsd-cddl/files/zvol.initd b/sys-freebsd/freebsd-cddl/files/zvol.initd
new file mode 100644
index 000000000000..28eba8e8c687
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/zvol.initd
@@ -0,0 +1,46 @@
+#!/sbin/openrc-run
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need hostid
+ before fsck
+}
+
+start() {
+ einfo "Starting zfs volumes..."
+ zfs volinit
+ eend $?
+ # Enable swap on ZVOLs that have org.freebsd:swap=on.
+ zfs list -H -o org.freebsd:swap,name -t volume | \
+ while read state name; do
+ case "${state}" in
+ [oO][nN])
+ einfo "Enabling swap on zvol ${name}"
+ swapon /dev/zvol/${name}
+ eend $?
+ ;;
+ esac
+ done
+}
+
+stop() {
+ # Disable what we had enabled before.
+ zfs list -H -o org.freebsd:swap,name -t volume | \
+ while read state name; do
+ case "${state}" in
+ [oO][nN])
+ einfo "Disabling swap on zvol ${name}"
+ swapoff /dev/zvol/${name}
+ eend $?
+ ;;
+ esac
+ done
+ einfo "Stopping zfs volumes..."
+ zfs volfini
+ eend $?
+}
+
+restart() {
+ :
+}
diff --git a/sys-freebsd/freebsd-cddl/files/zvol.initd-9.0 b/sys-freebsd/freebsd-cddl/files/zvol.initd-9.0
new file mode 100644
index 000000000000..c4071474fc2f
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/zvol.initd-9.0
@@ -0,0 +1,44 @@
+#!/sbin/openrc-run
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need hostid
+ before fsck
+}
+
+start() {
+ einfo "Starting zfs volumes..."
+ eend $?
+ # Enable swap on ZVOLs that have org.freebsd:swap=on.
+ zfs list -H -o org.freebsd:swap,name -t volume | \
+ while read state name; do
+ case "${state}" in
+ [oO][nN])
+ einfo "Enabling swap on zvol ${name}"
+ swapon /dev/zvol/${name}
+ eend $?
+ ;;
+ esac
+ done
+}
+
+stop() {
+ # Disable what we had enabled before.
+ zfs list -H -o org.freebsd:swap,name -t volume | \
+ while read state name; do
+ case "${state}" in
+ [oO][nN])
+ einfo "Disabling swap on zvol ${name}"
+ swapoff /dev/zvol/${name}
+ eend $?
+ ;;
+ esac
+ done
+ einfo "Stopping zfs volumes..."
+ eend $?
+}
+
+restart() {
+ :
+}
diff --git a/sys-freebsd/freebsd-cddl/freebsd-cddl-10.3.ebuild b/sys-freebsd/freebsd-cddl/freebsd-cddl-10.3.ebuild
new file mode 100644
index 000000000000..44c9ae6d6386
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/freebsd-cddl-10.3.ebuild
@@ -0,0 +1,74 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd toolchain-funcs multilib
+
+DESCRIPTION="FreeBSD CDDL (opensolaris/zfs) extra software"
+SLOT="0"
+
+IUSE="build"
+LICENSE="CDDL GPL-2"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~x86-fbsd"
+fi
+
+# sys is required.
+EXTRACTONLY="
+ cddl/
+ contrib/
+ usr.bin/
+ lib/
+ sbin/
+ sys/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ =sys-freebsd/freebsd-libexec-${RV}*
+ build? ( sys-apps/baselayout )"
+
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )"
+
+S="${WORKDIR}/cddl"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-10.2-libpaths.patch"
+ "${FILESDIR}/${PN}-10.3-underlink.patch"
+ )
+
+pkg_setup() {
+ # Add the required source files.
+ use build && EXTRACTONLY+="include/ "
+}
+
+src_prepare() {
+ if [[ ! -e "${WORKDIR}/include" ]]; then
+ # Link in include headers.
+ ln -s "/usr/include" "${WORKDIR}/include" || die "Symlinking /usr/include.."
+ fi
+}
+
+src_compile() {
+ # Disable parallel make.
+ freebsd_src_compile -j1
+}
+
+src_install() {
+ # Install libraries proper place
+ local mylibdir=$(get_libdir)
+ mkinstall SHLIBDIR="/usr/${mylibdir}" LIBDIR="/usr/${mylibdir}" || die
+
+ gen_usr_ldscript -a avl nvpair umem uutil zfs zpool zfs_core
+
+ # Install zfs volinit script.
+ newinitd "${FILESDIR}"/zvol.initd-9.0 zvol
+
+ # Install zfs script
+ newinitd "${FILESDIR}"/zfs.initd zfs
+
+ keepdir /etc/zfs
+}
diff --git a/sys-freebsd/freebsd-cddl/freebsd-cddl-11.0.ebuild b/sys-freebsd/freebsd-cddl/freebsd-cddl-11.0.ebuild
new file mode 100644
index 000000000000..cebbb02e7f49
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/freebsd-cddl-11.0.ebuild
@@ -0,0 +1,78 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd toolchain-funcs multilib
+
+DESCRIPTION="FreeBSD CDDL (opensolaris/zfs) extra software"
+SLOT="0"
+
+IUSE="build"
+LICENSE="CDDL GPL-2"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~x86-fbsd"
+fi
+
+# sys is required.
+EXTRACTONLY="
+ cddl/
+ contrib/
+ usr.bin/
+ lib/
+ sbin/
+ sys/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ =sys-freebsd/freebsd-libexec-${RV}*
+ build? ( sys-apps/baselayout )"
+
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )"
+
+S="${WORKDIR}/cddl"
+
+PATCHES=( "${FILESDIR}/${PN}-11.0-workaround.patch"
+ "${FILESDIR}/${PN}-11.0-add-libs.patch" )
+
+pkg_setup() {
+ # Add the required source files.
+ use build && EXTRACTONLY+="include/ "
+ [[ $(tc-getCXX) != *clang++* ]] && REMOVE_SUBDIRS="usr.sbin/zfsd"
+}
+
+src_prepare() {
+ if [[ ! -e "${WORKDIR}/include" ]]; then
+ # Link in include headers.
+ ln -s "/usr/include" "${WORKDIR}/include" || die "Symlinking /usr/include.."
+ fi
+ for d in libavl libctf libdtrace libnvpair libumem libuutil libzfs libzfs_core libzpool; do
+ LDFLAGS="${LDFLAGS} -L${S}/lib/${d}"
+ done
+}
+
+src_compile() {
+ cd "${S}"/lib || die
+ freebsd_src_compile
+ cd "${S}" || die
+ freebsd_src_compile
+}
+
+src_install() {
+ # Install libraries proper place
+ local mylibdir=$(get_libdir)
+ freebsd_src_install SHLIBDIR="/usr/${mylibdir}" LIBDIR="/usr/${mylibdir}"
+
+ gen_usr_ldscript -a avl nvpair umem uutil zfs zpool zfs_core
+
+ # Install zfs volinit script.
+ newinitd "${FILESDIR}"/zvol.initd-9.0 zvol
+
+ # Install zfs script
+ newinitd "${FILESDIR}"/zfs.initd zfs
+
+ keepdir /etc/zfs
+}
diff --git a/sys-freebsd/freebsd-cddl/freebsd-cddl-11.1.ebuild b/sys-freebsd/freebsd-cddl/freebsd-cddl-11.1.ebuild
new file mode 100644
index 000000000000..673b4bd19b29
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/freebsd-cddl-11.1.ebuild
@@ -0,0 +1,77 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd toolchain-funcs multilib
+
+DESCRIPTION="FreeBSD CDDL (opensolaris/zfs) extra software"
+SLOT="0"
+
+IUSE="build"
+LICENSE="CDDL GPL-2"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~x86-fbsd"
+fi
+
+# sys is required.
+EXTRACTONLY="
+ cddl/
+ contrib/
+ usr.bin/
+ lib/
+ sbin/
+ sys/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ build? ( sys-apps/baselayout )"
+
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )"
+
+S="${WORKDIR}/cddl"
+
+PATCHES=( "${FILESDIR}/${PN}-11.0-workaround.patch"
+ "${FILESDIR}/${PN}-11.0-add-libs.patch" )
+
+pkg_setup() {
+ # Add the required source files.
+ use build && EXTRACTONLY+="include/ "
+ [[ $(tc-getCXX) != *clang++* ]] && REMOVE_SUBDIRS="usr.sbin/zfsd"
+}
+
+src_prepare() {
+ if [[ ! -e "${WORKDIR}/include" ]]; then
+ # Link in include headers.
+ ln -s "/usr/include" "${WORKDIR}/include" || die "Symlinking /usr/include.."
+ fi
+ for d in libavl libctf libdtrace libnvpair libumem libuutil libzfs libzfs_core libzpool; do
+ LDFLAGS="${LDFLAGS} -L${S}/lib/${d}"
+ done
+}
+
+src_compile() {
+ cd "${S}"/lib || die
+ freebsd_src_compile
+ cd "${S}" || die
+ freebsd_src_compile
+}
+
+src_install() {
+ # Install libraries proper place
+ local mylibdir=$(get_libdir)
+ freebsd_src_install SHLIBDIR="/usr/${mylibdir}" LIBDIR="/usr/${mylibdir}"
+
+ gen_usr_ldscript -a avl nvpair umem uutil zfs zpool zfs_core
+
+ # Install zfs volinit script.
+ newinitd "${FILESDIR}"/zvol.initd-9.0 zvol
+
+ # Install zfs script
+ newinitd "${FILESDIR}"/zfs.initd zfs
+
+ keepdir /etc/zfs
+}
diff --git a/sys-freebsd/freebsd-cddl/freebsd-cddl-8.2.ebuild b/sys-freebsd/freebsd-cddl/freebsd-cddl-8.2.ebuild
new file mode 100644
index 000000000000..32d09d66b25d
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/freebsd-cddl-8.2.ebuild
@@ -0,0 +1,47 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd flag-o-matic eutils
+
+DESCRIPTION="FreeBSD CDDL (opensolaris/zfs) extra software"
+SLOT="0"
+KEYWORDS="~x86-fbsd"
+
+IUSE="build"
+LICENSE="CDDL GPL-2"
+
+SRC_URI="mirror://gentoo/${P}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${SYS}.tar.bz2
+ build? ( mirror://gentoo/${INCLUDE}.tar.bz2 )"
+
+# sys is required.
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ =sys-freebsd/freebsd-libexec-${RV}*
+ build? ( sys-apps/baselayout )
+ dev-libs/libedit
+ dev-libs/libelf"
+
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )"
+
+S="${WORKDIR}/cddl"
+
+PATCHES=( "${FILESDIR}/${PN}-8.0-libpaths.patch" "${FILESDIR}/${PN}-8.2-libpaths.patch" )
+
+src_unpack() {
+ freebsd_src_unpack
+ # Link in include headers.
+ ln -s "/usr/include" "${WORKDIR}/include" || die "Symlinking /usr/include.."
+}
+
+src_install() {
+ freebsd_src_install
+ # Install zfs volinit script.
+ newinitd "${FILESDIR}"/zvol.initd zvol
+}
diff --git a/sys-freebsd/freebsd-cddl/freebsd-cddl-9.1.ebuild b/sys-freebsd/freebsd-cddl/freebsd-cddl-9.1.ebuild
new file mode 100644
index 000000000000..9191274069da
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/freebsd-cddl-9.1.ebuild
@@ -0,0 +1,60 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=4
+
+inherit bsdmk freebsd toolchain-funcs multilib
+
+DESCRIPTION="FreeBSD CDDL (opensolaris/zfs) extra software"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~x86-fbsd"
+
+IUSE="build"
+LICENSE="CDDL GPL-2"
+
+SRC_URI="mirror://gentoo/${P}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${SYS}.tar.bz2
+ build? ( mirror://gentoo/${INCLUDE}.tar.bz2 )"
+
+# sys is required.
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ =sys-freebsd/freebsd-libexec-${RV}*
+ build? ( sys-apps/baselayout )
+ dev-libs/libelf"
+
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )"
+
+S="${WORKDIR}/cddl"
+
+PATCHES=( "${FILESDIR}/${PN}-9.0-bsdxml.patch"
+ "${FILESDIR}/${PN}-9.0-underlink.patch"
+ "${FILESDIR}/${PN}-9.0-libpaths.patch" )
+
+src_unpack() {
+ freebsd_src_unpack
+ # Link in include headers.
+ ln -s "/usr/include" "${WORKDIR}/include" || die "Symlinking /usr/include.."
+}
+
+src_install() {
+ # Install libraries proper place
+ local mylibdir=$(get_libdir)
+ mkinstall SHLIBDIR="/usr/${mylibdir}" LIBDIR="/usr/${mylibdir}" || die
+
+ gen_usr_ldscript -a avl nvpair umem uutil zfs zpool
+
+ # Install zfs volinit script.
+ newinitd "${FILESDIR}"/zvol.initd-9.0 zvol
+
+ # Install zfs script
+ newinitd "${FILESDIR}"/zfs.initd zfs
+
+ keepdir /etc/zfs
+}
diff --git a/sys-freebsd/freebsd-cddl/metadata.xml b/sys-freebsd/freebsd-cddl/metadata.xml
new file mode 100644
index 000000000000..a00f3aeb1f81
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-contrib/Manifest b/sys-freebsd/freebsd-contrib/Manifest
new file mode 100644
index 000000000000..4184466ee2dc
--- /dev/null
+++ b/sys-freebsd/freebsd-contrib/Manifest
@@ -0,0 +1,9 @@
+DIST freebsd-contrib-8.2.tar.bz2 40931651 SHA256 8b9cb688e81c2980b3fc66411d00ab277a24dadd50d5bdd5e0e6c63ac687b9b6 SHA512 4f7bf825b579fbb88f2aac531d07e531474179c63fa0b66c4e80821290a8c94bf611bb4dcaef51b762aacd25b11dfae798a4ec3bad3b9e3f6b3490ebfaa72476 WHIRLPOOL edd3d9e26e8d22d9028082e107ec1a44402e206dab8722f34b445676959305996c3f699152af42ace249b7f58498492787823b172fb6bcb273119c6bb50a35f0
+DIST freebsd-contrib-9.1.tar.bz2 54751432 SHA256 e7ffa056d4050ce03ee8e23e276e2a9a494326a98d60c43bee2afcc59576deb8 SHA512 71be13049258c6e6b5e4f63cc16da5d349a89d68f04d87446e4ad33ae8bf2a93ea67d9c256b7bec60b61e65db0487268070cfb77a484c3ac0f8ba368b48c2438 WHIRLPOOL a2a84423175499208d34809e802284d6ba649f317c3a9ad8b7312fa19efe142ebadab0048bac0db8e988e59f9a7468ac7c5d0d25e78b82bdb269a20d18153cee
+DIST freebsd-gnu-8.2.tar.bz2 815379 SHA256 34be1326b8e188427ea4a59de5dd24049f99adb5e172d61a645db1b7124f7876 SHA512 8b278e386b22b22658eef18341073c1c757b86ecdef5c5b543fb781cfee295d71cef599544eda5f8cf273fc22d28a1ab14d912086ff8398c36ee2b71281617d4 WHIRLPOOL aaf91562f147095e09a9f6aa2d4c33494f430cbe7340377edff1b8a44cc60edfe4af7ef90350018f0c80e82f5518110689cb582bb227d2360488dfbdd7bcb7c8
+DIST freebsd-gnu-9.1.tar.bz2 795778 SHA256 3b99c1fa1087bf69549e0990a0d7997954533ac9d7938c4760ec2b01aa509a5f SHA512 b05f2a5a10bdaeef19dfd0e962bc09f1571288a831e9345f404b920037f47db5c0ca3d620d1cbdd138b18bca1c3feab5b211b57e3041727341e5238cb9feb4fd WHIRLPOOL 4f776b99296c4fcc0d6f4d30a12b0773f6704292e1361826b260ce34dcc8e537ef7eb7c6332c4988e0e03bc84ca07fb18e6b2785fe4c6f175c08865b72d6bb0b
+EBUILD freebsd-contrib-8.2.ebuild 1372 SHA256 0b449e555cadcd3c27a10a5963d1af627ead9f10be91386ad07882e376936648 SHA512 68fc03d8548e7fcc7689b9a80213dcfe4ee804b42fbee1cab8e1d5cf7659f0f68b6922c5134fc09d8ba01e5b2285383cb3222503ec1fe45f0ae2dfa9f3cd265c WHIRLPOOL c57384f21b319c33f8a0940d53e757bd05708c78b1a0b6e4f1bb456382460226785eb77880b497123a3820106ace2481854b6f66a859612c01e3dd8d2d8af5e0
+EBUILD freebsd-contrib-9.1.ebuild 1398 SHA256 649b5457034e125c262931c74f06e2e3ff9a8244ab66270ec242f34833940b71 SHA512 96875155a5ce72b8b96215eb8145b20b67069dc06c0daa0d9d6ec6ceeb227e35a5db112ea4397e2cc810f208bc7e99bdcbbfddcb662365b6d782654f79aebb97 WHIRLPOOL e41a97c115bd536cf8ebaf1d400e2fd1981cafd7921a4586d8d0abbda37d34b029b39dab08e7b6c90d99a1a61b8c0dd1b3b495c36bd3dcfca9785feb19960500
+MISC ChangeLog 2514 SHA256 3fcf51f64c9dd0523b255312306e3eae66efff5407dd8569e841a13029591194 SHA512 069ea35a60c61b4f4bba5f8f6c1c1cfe3edd4bef5233c83bf81473058aa80558a79c99a4f55b8502ecff012e5b9e4c76c1baf2fc4585cd868c68c95b6b6544ca WHIRLPOOL 33aa2f6c89399500318890d0dd8363bd905bdb6da158210430834a742135ccfc12bd392fd02e0419cfaba8c943daefbc1834fb9e64e00507a1c85224669debb9
+MISC ChangeLog-2015 9506 SHA256 a3ccdd8ab148a166ec40535cedd2b4736103efd809d7677e57abbd37d4673b43 SHA512 65394a896dac81781b79d752a7676f4d534b236bb6a4a43c7ba6564057ba01ea2cfb3f52baf2337893493c131e5d38c0f868854899186ec55bfc1adcdc4e0987 WHIRLPOOL 33a5b9d80182d9ae8460bd6a182a13d896c5af722ed21ae16ddfd05598a4a8a991318baad819522869b3e9411e34207ed9f490122aaa338ebf3cefcd4372915b
+MISC metadata.xml 238 SHA256 501d93b0c41ed422505100f002758cd173cd9783ae7fbb53e2ec5f238c868340 SHA512 173efaa53a514acf1e2f0c6681c82a48ec16d505844f551d2cc823ee8685b27837c7461f7956c12182059ee7e83023e2f0bcd5d1afab74beeaf998487193656d WHIRLPOOL 4ca51d994f011a5e7e4939f02a54b5c2f9f3e526665893c9ac2876c9871b7dc80361393d41c5247b3a5520e82d31d0dd10da520e7715c94b806a94ce0fed2a5a
diff --git a/sys-freebsd/freebsd-contrib/freebsd-contrib-8.2.ebuild b/sys-freebsd/freebsd-contrib/freebsd-contrib-8.2.ebuild
new file mode 100644
index 000000000000..dbb13edb4b59
--- /dev/null
+++ b/sys-freebsd/freebsd-contrib/freebsd-contrib-8.2.ebuild
@@ -0,0 +1,55 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd flag-o-matic
+
+DESCRIPTION="Contributed sources for FreeBSD"
+SRC_URI="mirror://gentoo/${GNU}.tar.bz2
+ mirror://gentoo/${P}.tar.bz2"
+
+LICENSE="BSD GPL-2+ libodialog"
+SLOT="0"
+KEYWORDS="~sparc-fbsd ~x86-fbsd"
+IUSE=""
+
+RDEPEND=""
+DEPEND="=sys-freebsd/freebsd-sources-${RV}*
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ !dev-util/dialog"
+
+S="${WORKDIR}/gnu"
+
+src_unpack() {
+ echo ">>> Unpacking needed parts of ${GNU}.tar.bz2 to ${WORKDIR}"
+ tar -jxpf "${DISTDIR}/${GNU}.tar.bz2" gnu/lib/libdialog gnu/usr.bin/sort gnu/usr.bin/patch
+ echo ">>> Unpacking needed parts of ${CONTRIB}.tar.bz2 to ${WORKDIR}"
+ tar -jxpf "${DISTDIR}/${CONTRIB}.tar.bz2" contrib/gnu-sort
+
+ freebsd_do_patches
+ freebsd_rename_libraries
+}
+
+src_compile() {
+ cd "${S}/lib/libdialog"
+ freebsd_src_compile
+
+ cd "${S}/usr.bin/sort"
+ freebsd_src_compile
+
+ cd "${S}/usr.bin/patch"
+ freebsd_src_compile
+}
+
+src_install() {
+ use profile || mymakeopts="${mymakeopts} NO_PROFILE= "
+ mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= "
+
+ cd "${S}/lib/libdialog"
+ mkinstall || die "libdialog install failed"
+
+ cd "${S}/usr.bin/sort"
+ mkinstall BINDIR="/bin/" || die "libdialog install failed"
+
+ cd "${S}/usr.bin/patch"
+ mkinstall BINDIR="/usr/bin/" || die "libdialog install failed"
+}
diff --git a/sys-freebsd/freebsd-contrib/freebsd-contrib-9.1.ebuild b/sys-freebsd/freebsd-contrib/freebsd-contrib-9.1.ebuild
new file mode 100644
index 000000000000..0a810660b414
--- /dev/null
+++ b/sys-freebsd/freebsd-contrib/freebsd-contrib-9.1.ebuild
@@ -0,0 +1,54 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd flag-o-matic multilib
+
+DESCRIPTION="Contributed sources for FreeBSD"
+SRC_URI="mirror://gentoo/${GNU}.tar.bz2
+ mirror://gentoo/${P}.tar.bz2"
+
+LICENSE="BSD GPL-2+ libodialog"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+IUSE=""
+
+RDEPEND=""
+DEPEND="=sys-freebsd/freebsd-sources-${RV}*
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/gnu"
+
+src_unpack() {
+ echo ">>> Unpacking needed parts of ${GNU}.tar.bz2 to ${WORKDIR}"
+ tar -jxpf "${DISTDIR}/${GNU}.tar.bz2" gnu/lib/libodialog gnu/usr.bin/sort gnu/usr.bin/patch
+ echo ">>> Unpacking needed parts of ${CONTRIB}.tar.bz2 to ${WORKDIR}"
+ tar -jxpf "${DISTDIR}/${CONTRIB}.tar.bz2" contrib/gnu-sort
+
+ freebsd_do_patches
+ freebsd_rename_libraries
+}
+
+src_compile() {
+ cd "${S}/lib/libodialog"
+ freebsd_src_compile
+
+ cd "${S}/usr.bin/sort"
+ freebsd_src_compile
+
+ cd "${S}/usr.bin/patch"
+ freebsd_src_compile
+}
+
+src_install() {
+ use profile || mymakeopts="${mymakeopts} NO_PROFILE= "
+ mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= "
+
+ cd "${S}/lib/libodialog"
+ mkinstall LIBDIR="/usr/$(get_libdir)" || die "libodialog install failed"
+
+ cd "${S}/usr.bin/sort"
+ mkinstall BINDIR="/bin/" || die "sort install failed"
+
+ cd "${S}/usr.bin/patch"
+ mkinstall BINDIR="/usr/bin/" || die "patch install failed"
+}
diff --git a/sys-freebsd/freebsd-contrib/metadata.xml b/sys-freebsd/freebsd-contrib/metadata.xml
new file mode 100644
index 000000000000..a00f3aeb1f81
--- /dev/null
+++ b/sys-freebsd/freebsd-contrib/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-lib/Manifest b/sys-freebsd/freebsd-lib/Manifest
new file mode 100644
index 000000000000..162c3090e7a9
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/Manifest
@@ -0,0 +1,77 @@
+AUX bootpd.confd 183 SHA256 c70c6a7a99470354a5f61bfe5c0f71325f4896e41da150e782223a30f07a275c SHA512 3f097c1acb5547add8d12fcee0b4b55b03896cb3ba473214d1634804f3683e0dea4b3c9559b61b2366b7f264d7a3d878695e16f29acff076b8060ca1fd79757f WHIRLPOOL c6721ac9b3ba70268fdba8c81ad9225e26049a5eb5ef8ea9bccc5fbbe7a110defe15df1d27b1c4b54f92e19d7d8b2099f87e7972faa0e5ddf17b66d30e26e0ad
+AUX bootpd.initd 554 SHA256 a1b1160a3e3d8f068a446ba5c9210737e120130fe173e68026263b7d057efb7e SHA512 69bc8dc708d955e41d3e0cfb997f96b589e8a3d33b11b2728541082fc5ab0844d753ca036a6c70ddd23a2a0085c39a89340b0f7d332b1384c94671cf3fe09b66 WHIRLPOOL 4764e746340fa0ace0310880a8ac13852df14ca14ba077610b5bfea09a45c093d064b5a534ed6e3dd839c869cf0c8013bcfe022814793ecc5f6e38cc08335f92
+AUX freebsd-lib-10.0-atfcxx.patch 1545 SHA256 eef9680da13fb24adc01fab170d83787e8b9926ec2bbb89cd7933b3dd8b35306 SHA512 37d8fc83b97addef48807196738be511fdc74b002dce321c2eaf38db5b618ff4a2f8e8447677c60b96b8add8f1dc586a66a30992289fa95e20e2005589e83953 WHIRLPOOL 78096c4064b98cbb05617355c8c65c306f9d6ceb2a2c8f772cf39f20c81395da9a2d1e128f5b1382bdd65d7e6d7df2d08606933ac5fa8a9aa3d55ec8b76363e2
+AUX freebsd-lib-10.0-liblink.patch 2448 SHA256 cbdcca5cc893b0d0b1ff98d1c1046519cebe9877b4cddd180340cfafbbbd2726 SHA512 c77049fa170d08d6ce035a8b9ae799f6d8e0b899371c1644a7493543fc07511515f68d54c82c618064954e48023c09bfcff452bd93e69ac07b7f8c6fc0e5089d WHIRLPOOL 12a22aeb74491960bf12da6d0db67504f1f804e732d332fd607cf58a78f0fc291af7d6a3d9f65744fedc36daa9326b463b2ebbe545d88deccc29135b6be60dbf
+AUX freebsd-lib-10.0-libproc-libcxx.patch 393 SHA256 da065c458716e8a56a3c3aab87c9e5135287d6c8fa46eb26092c197e167b7acd SHA512 086d71467dcaccefdb2d9d31deab1905407aadca625853ff222610ea713e80dd8dd61caae3765107045b376f4162f73d12407d1d27aad29603b45b108c09cd8f WHIRLPOOL 3bed09ac5887736dcb15583b4d6cde50419d156bc12f1e1a55668ed85bfb0f502c79c760e8cde3db7172b72775786bb8968df811980ad046c677ff0aff176b33
+AUX freebsd-lib-10.2-bsdxml2expat.patch 982 SHA256 0dab6d4525cee88eb1d6ce6c1176100ff9271222d6c6cde20f894781c02eb075 SHA512 b65fd732825e2813d499bd519bc5ef69b4c603ad57b047d2716405cc47a221c6e137a1f2e890b79a23bc26036834f7696dc9ac5953400f26975a0139fedad7c5 WHIRLPOOL dd2bd2384e12ee5e978dfb284ecdee73ce07f32d16dd67302a8cfc0ca324d078ab8b6153e170753a2fbe22993e07a4240e848d7b00aad78b58a4fa5cd27d0c26
+AUX freebsd-lib-10.2-liblink.patch 653 SHA256 a252201ec74f0cf0940b28b626e72f909cfab04addcb86b8f9abe984265c074e SHA512 c75c1fd81bd826685db5258ce0cd2407e385990dd576973fad361206271eda678d1fbe95a406909904bfee22890c79eb0f4cbfab09ddbee579552d003df2e6b1 WHIRLPOOL 3a579e65e07d7b8b558004eae9923c249d9dbd13983e3e263cb5384734d4e8c739440baa95a67953a56d2c6b7ff0a2cb8d2d7d8f7a0fbb4366001d0ea990cc4d
+AUX freebsd-lib-10.3-libusb.patch 339 SHA256 64c737051839e430108c96914485bc200e83ea951832033ace683470da823791 SHA512 15ad67c805c34e5a67f21de0db9ec3826aa96fadb880f2cca8110d4b26ed3722eea8aa9ee2c8e1976288b5e9be5e6046e4bd60d515305fff283ad50cc01d3d0f WHIRLPOOL 59ad6cb93295a95f8bb94fb7d2b13e1a8bd83267a96bc816142f9254bbdf494fd17670a0e8634eaeebe93f7535467c1b388f044eb459e222eecb84a7e21745bc
+AUX freebsd-lib-11.0-bsdxml2expat.patch 1103 SHA256 fea5f9bb3f59bcf9277253d41763ccf415dcb5fb6fa88e49459102cecbb43e18 SHA512 a0e9d99ff47ce813a98a5c1fd3605dd757ceb6c4f68e3784f1b48192c9f0966cbf1c769387a808ae4511f004b00242fc47f7fd3a2971e371de587cac6827533e WHIRLPOOL 9d7cac8b4b1cc575ddb0a74657e3e228a2d9439d43e5a69b4863247838d9224fa7d26818992629fda0f6db07d08da433e012cb63f4516c62206f2d9d71bda1c1
+AUX freebsd-lib-11.0-libproc-libcxx.patch 350 SHA256 23f5d80d5fb5cf683f3b7990e4899612a82ab878af450423a0da4179d846ad40 SHA512 c9ace882ac2fb2a077839a02a4307ce7df1dd0699cef081e6a99f12f9c2b443e4a4e4f85415a59d208859442dc665d7b9cae22de8d61f80ab8a5875d423c5795 WHIRLPOOL f1dc721386c698c50e69b4b4bd4b82be0ac47ae63546b15ba421a5a7784ee3af33e852484bf8cf763897d646857924bdae5a6551e4585740ce06deb628bc8653
+AUX freebsd-lib-11.0-libsysdecode.patch 680 SHA256 7f458085c5cddaec8fb94053150803058f444513ba0f3bb528e0e654022e653b SHA512 2601924267ea0efc1fee4bb582fa22918aa83964cbe519eec69c6e6bf09b6943b025d65833982fdfea01b74726ee5fba3f78ecf6ed2877f22965141c78074fd8 WHIRLPOOL d5ec768349e1524a3416c522f0d108fc5f2f0c1622bfefbf7c2a5a3530bf452f1163d038a5416fe8607c3af6282ee0db45d864ab21586f6f7a48fe0a3ed3b7fe
+AUX freebsd-lib-11.0-workaround.patch 295 SHA256 5f09d646d7137649b8dc0e1736a81a4ab7f2599fc48f4f75ac3341a9cd817773 SHA512 5c7559dc1876e833f440bc85e23e601eaa5dd26484b1905a5a59e29345f83438208770671c248b4dfb5138c4dded1f08234c77070afadb5c6b54e2b6dc35e24a WHIRLPOOL 165245510300f2b5f75d4a0cbeefee4b56971da5ddb70324885506d8223a86ee0c866921f008225674d520bbdd9c9bc22c43bfc32d55cc2f6a1094e7d48bc7f9
+AUX freebsd-lib-11.1-liblink.patch 4233 SHA256 f9681e76d585709b22e80006641d041d53ae2423a8f703fa46a39bc9feb336fa SHA512 23a875fa84685c7a98ddb08b1bcf831613239a6079c1711362bbbd19f27b67e61eb203bafc48c9ad06b9344258005e4d04756d4f8caba7c9545f3f86dcb52830 WHIRLPOOL f239f9fa184066087c459209d0d3b59fc2f2ff43ff0036da6d0dfb9d6052e57ae880d6450582c4cb65a5b13877c82f09e4df62ca66c32719d9d8b81b1086d5d0
+AUX freebsd-lib-6.0-flex-2.5.31.patch 421 SHA256 1d46cf13e1059ae3731ba5555764e020fcf4de7db5abf039fac83423e05d53c4 SHA512 c16a99b85e7908e77915796245741cbfcfb30ab1f4f0a8d565c28256b25d1532209ed27328d8b1571f61677251830f1fb6bbec17a8104686f56afd87f3226dec WHIRLPOOL 177f7ee5764f79fcdab768b13016e809f677cfd57a06ebb5e1bbafc6520f309b328908716ee02a8155f35566faefa95b67b064dafa8de9a7d2a19bde92b386b0
+AUX freebsd-lib-6.0-gccfloat.patch 542 SHA256 d549125f174c86c2d5e7e1f1c99cf1303b84e91ce8ee51db8c962be48b7a7951 SHA512 810745085c601757397b6d0338dba1631e4f623c3bae8a588e9f0b5c7cd9a9416d832093f97925fcef27ffcf20929bef8a5bcbeecf7a583c0a7eb6ce71f39495 WHIRLPOOL dee1bcf99935ae9ead0d5f498049a46ee89416f06eb7361901c69f40d0151ae1d3647a7dbb1c58b1aca7f541169b20d622019bc20b12953ba0c06fba56fd375e
+AUX freebsd-lib-6.0-pmc.patch 338 SHA256 36ca464f0aa1ed8784c8f1edc4a3580704c9a7813963684305250d806000075f SHA512 33187ec853ddf0c39680af60b669e60d3e213eba20a2e1ba995c991f04c053c5adcc5169b92c5d1d4cfbc7e03b72af2df4a5349361b41c56ca4a9b91e81bb327 WHIRLPOOL 1744ed829c1775c01b5d1b827b5677b6b5d731cff376da4d8e7ab8facbb0c465131a34157d77186bfcf1a1097f515e3909d1e753aa2b8e72efaf7feae319361f
+AUX freebsd-lib-6.1-csu.patch 655 SHA256 e6fe72a4183227b275815a75eec9639321046dc1e02b80c507ae6bf902a58cf1 SHA512 926d8aafd6f517a0fb97af61746d53bafab7fe7003f71181c43b4f9b31e7652624d060a350cc23d83ca7da7c1be2dcc048bb00a581c3524f0f2b7b06de6100b4 WHIRLPOOL fada1ac622c48e1e5af34245bdb17507b2b317938265f722c8cbdbbce3d14bbe76f39a231c0e7237bd229a8c0687952643c6f56e65ffc56b18508969fad837f7
+AUX freebsd-lib-6.2-bluetooth.patch 243 SHA256 4c90cb6d45fa24a07e21255949f219cc561a94011f645c58bce2a68027db6658 SHA512 60d938a6f1162f106ec93c4122707a4dd9ca6afc73be4d90871db745ad084ca1d229e7460f4faa9885c4f6d192a41cb8be7cf671b0c8ec720eccd1c7af994bbc WHIRLPOOL df2ab6e6d9223c7e2369fb8baf19638cb897343b6ba571c7b9294be7d335068b7978690b2cd50174b4ee0215f2409322a9cc2a374140fc14dff460e181c05578
+AUX freebsd-lib-7.1-types.h-fix.patch 371 SHA256 9e745fcfe046c405a365d8d0db8763867f0a618952f7d6bab4c76a8c82273473 SHA512 133ab13e98c3f2dc5f96cd5e45cd11c4da9757f4ea64831a6e17b309bc4692e4213b48c7ab6dd634f1feb069ca2dfc3a8afe1585d0d1425b5304fd7494cd342f WHIRLPOOL d284dd82244a108e4677be143cfc302c18f18e5b39c39fcaa8915c61053d94bf7171e48028f40d25f8058f8ec910c3e55a3753ccecb46bbabbb0e5ba86e808e3
+AUX freebsd-lib-8.0-gcc45.patch 1264 SHA256 5288e313beffa0e50fc0301e859c59f1a95302d546d27eae50b97c4a98c81c4d SHA512 12b81def4e7690cf5b910f31466b06c3fdf58f38a41f63dd359582d8f480e8081b54fd4997c6595e9e1a8912f991ba1b8d04989e270f242dd547d72c9ad5ea57 WHIRLPOOL 0cb37d909a02492a1ca700a5b990e4b6ce42a7f7d55e14a5a3fe685d28f360a10e95d97bd489f1dae0b152e168e9d901bfc13bf08bc91d8dfa1d263d4dba9abf
+AUX freebsd-lib-8.0-log2.patch 667 SHA256 dc421c3d92790da46360225de2dd4d707c314e962ecb95650799ee12f166a214 SHA512 72f99ecc4632ba9b5ea8f26cbe7311a2ada1822c1c3ccf2c6690d72fb91748e7e70915f33e0f29087125c4027ef084c1d37638fc423bde533595e8d4910084c3 WHIRLPOOL dbe9a686efa26dab9ca129ed39ddab49556490fee22b43f6aa07bd9cbebfa24bd8ccb6e30f0d213bab857571a022bcd1b110d47bd85c6f70462441772bfeb243
+AUX freebsd-lib-8.0-rpcsec_gss.patch 298 SHA256 775ec2ee12c49f134938fa8264c04c6b2bf95f8001371f20b85058c25ff1c472 SHA512 2dd63be1a31a1e78fff38a3061469148b673423d958223a459d157accd3a2d1b1f4e568910c49979b0a214322c4e7371f2710ef78fab7d161545fec2a78dc702 WHIRLPOOL 884b76cd6d5d01f801b2fb13f53cfa6ed26dd0b9b2a5062ac9dbe63a6813bfe737e4c3f98b3d94c32dfb6ce3cc19cd5c8760c81250f4b2d5980a4f084d7dc54b
+AUX freebsd-lib-8.2-liblink.patch 510 SHA256 38f967683e9d335ff7860150b2e6ae4d749266937ba195c6747d42d64c8e31ee SHA512 52a050078dc71163709e6dbe6d1c3177adbc51cb9b30a6990194ddd32f5b54e107b758801f0ff5632c4fe800c6734d63d42e53378a78caa0072847060fbb0dee WHIRLPOOL c0b95cb074ff6fd7699a03dfe31572a5edbde2b59c8aac3431fb85a0a0d71ad28566500951e0fb96ed9a8d3081abca7ec507c26e12e988f0ff2ece51bb0df2d1
+AUX freebsd-lib-8.2-nlm_syscall.patch 385 SHA256 4b26be44718cb3deb7fb295d403e892ed73ceba7ba43499a889bd49a5e43852b SHA512 1c871dc00da4b6d1106720954014f60933c99508dfc34fe08ae37b2f67ca05f70ac5e1bb75d0d1d119c7750405871ee3fb6e95ebd3ec378fc84e819cc0c4c9fd WHIRLPOOL 4d335910c00f21d2d8d5f80cd99c5316e5c485f935eefb782398e2e308e20a2cd4da0e1acf74c07a2c6d8ff446b3757cc416c0bee7e1be9d9cae0843a45e0748
+AUX freebsd-lib-9.0-bluetooth.patch 318 SHA256 5b8810471bd57e1100cc7ee6eee3ed92799e1a5c0244f5ae42f3715189fb06c3 SHA512 71cba168c1530407840dde9e25ce374abb7e0d69800e85bf6f5aff28d1a777ff31f47a84ab763e1518d3492f604d1c09ca95cf8ec5b4e05e8bd5b85267ca4488 WHIRLPOOL eccb54dd10a01358aa7e8267e64f103b89c2981ab2475f27282d5ea0bfe8adb8a106c869ca661553c3d2eda0c1d3d9dec669da6cfe61c23d5749535bdcc8c28b
+AUX freebsd-lib-9.0-cve-2010-2632.patch 6963 SHA256 a6383bd3b59bb6a8989ba7746f89115b91e5082768d914bab169842144569c45 SHA512 bb7090a0acbf8ab431334245b1e767da60dcf8f2d23de97a4690e879ae5d528065f5462e2ad3647313662a906f139cfff04f15bce80efede2d2174f74792a07b WHIRLPOOL 6df4a824cd657e79cce984f9181f3e6b20e998f9b9bc1a233bbc5dd7f2e40c055e9f9d401453b49bffb3cc8ef6bb541400f486a966339e56584569c08b358ee4
+AUX freebsd-lib-9.0-liblink.patch 627 SHA256 41f0b7f92f2a8f0a3e422447b830d7dec70a068573086484d5efd6826b7c4c3c SHA512 0c570fea9cc386afe4b742985cf7de4d49370be3f34b2059dee76869d8e64bd52db0a07e61fac8924848d12d0e6d510ad6a266ce8ef76e2be885d81d909ab616 WHIRLPOOL b59e3bb0aaede34492d1940a77b11c7e5192643122f18ee6ad363053f9dec2600218ca416dd153e1d0b3bb6621d6f9e2ec50621e6e7f4b610abbd69993dc428a
+AUX freebsd-lib-9.0-netware.patch 400 SHA256 e83d43f5bf9461c3d332365cca12db7b041b765c79eef392970665740411c382 SHA512 07ebde5797480f37502e60db2a8c9ce9459bd55b176e79c0f20a859cf737f619559cb27706fb0e83fb501493677a3ffeaa9a98d45db3c0c539b71d2f18140246 WHIRLPOOL 2d78565fe0bc0dcdd61d028ba24b20d2db94f32b40536e7e8e1d5e7f485e0e2f3125807dbb6607d26e4366a6aa8ee89a8f0af7c9498f1fba9431f652c181a8f1
+AUX freebsd-lib-9.0-opieincludes.patch 4495 SHA256 0868e7454053170c3399f1a03a68f3e70410c79db865e7e2f2b51f5961b5718b SHA512 a3828985f7da9e72ad44d88640952d56079693024bc11b4e3cca86b6f455a9e4756ba76f9e6d4c15960898f39e1dac7bc833e3241082f532c7fbd6d7d6f9418b WHIRLPOOL e0180dd0086c054e9f6895ecfe34bfb21d0e1db483dfc63ad411c651954c4703996d9b537a9566133a01770f2cf0f331727865013413181728c3b21740735473
+AUX freebsd-lib-9.1-.eh_frame_hdr-fix.patch 695 SHA256 6c6d7a958c989edc6ee76c5b9c2146fa449adda11c3b89b550780c7a78d93190 SHA512 c40270e8890a1152a6f2e705461ac64f8cc44e6d0306d895a0d146017d4fe3553853de88178e0744fc1be4197a4eb35b578c68593c80467dd8cf15c35720413d WHIRLPOOL 1fa3c5cdba333951b918eb5c1eb793ab49921268a6a397e38f2adad383c2c03ccf382892ed8d44e2480f8ca891ce3c3a0b122a026cbf232058ac3bcf2f2d5133
+AUX freebsd-lib-9.1-aligned_alloc.patch 1355 SHA256 379880b3e1be34a145d6388481645af5212eea7830285a7660a56a02e47dc608 SHA512 d9ac6008650efcd02ff1a0f64ac486e413c926681082d4ab9c1cb5abfbf1070e44b723e685a0b5b0e7159ab9071d85c5ee08c9063c9dcda470dfaa06a29391bc WHIRLPOOL fd80089b4b31f0a0d4dcb912d5dde74b3eb9e0530a3dc145f40ac476ef89ae256a0847123b44a0a59966c28f7f7529c401ce0dab493400a7aa24513989853e36
+AUX freebsd-lib-9.1-rmgssapi.patch 699 SHA256 0dc94a565f140beca0800446c72bd874f99c56125181f7a037154dcd898d2615 SHA512 cb0b292cca0c321ed72b1a792a3975be239303b3990efc6665b0c960dfe17fdbb4529405286c0a956c4b4711462d2ee9d7d1c9d343ad3246b43c49edfc87dae0 WHIRLPOOL 55adff8c3436959b4545ba54c0eff3cd640dd4f0d0871bd66dad2501c04e84eb24f27b882dde9050b088dadecc9af6049493e848a1d508646149075180c8c414
+AUX freebsd-lib-add-nossp-cflags.patch 1193 SHA256 53a844511feca44a9db4ac19de336320398335d18617b39cbc4e66db3f88e861 SHA512 fcb290527381df5b91355ca7f36bb4c770378b014890e7a4d129b7cc28e7c18cb1f87ef9e1b308e0de61b54d767677865969c77a9877d8874f2bec223331f9f8 WHIRLPOOL 20e4a0cd017f9aee59f0e4fa809ae74c855fcb7c7a794e1e71b1e5900390d08a9bdfaf5a36a45b057d6211c056a5fb69adfc688fa2adb0586f115be0aea40219
+AUX freebsd-lib-bsdxml2expat.patch 708 SHA256 0c3ec3657155c5032479181119c488d43a479ab0dfe7a7d7ed0dabce16853e85 SHA512 d3b321062886ee636a09af4b8714ae90317c17eb954a3d491cd21ca90605e26491033df4d6f02a517eda423783db74dad16adf7ee1bdc5557392cc70218ee9c7 WHIRLPOOL 5c262c59aee9e642d3a8929a453b56c7a55ba60f3011d6ac07b750a30297eb992a564ba4db18714b7eac58bbe3ded1ff4249150128947d25dd1344e59e16c9cb
+AUX freebsd-lib-includes.patch 316 SHA256 be4dd4c905715c2d165be282cf377f799b32ccb76986947bc0bf1b5730b57b06 SHA512 31b7f368a4d3998e42486cb944a001a8371c365276eac94fa8712e29dbe9a13a7756a2fd77fbff87a1f7f4c19b32721c74bbb099f611d46a8c78b73f92d9255e WHIRLPOOL 8c4c2c6d1e9556303520c4cd8f6996f0f24c8b45985d4326db880c187b6db30e914a6e47b40ea4a79d7a309fdd579b39232329daf74758412ac518b0a9d0a317
+AUX freebsd-sources-9.0-sysctluint.patch 403 SHA256 884fbc5d6d3766ea3d4609946f56072f36f95368dc13ee316c330a46d42f0c9e SHA512 f3a87cb187858bc6fd1bafda3c3bd7bbda52b07239a50a7c1aa201df2c52a58d4809e196b8799b1949c8ca1a556519d454ad1789358540e3a96cd480fc0a504c WHIRLPOOL 1fd9852d59378b3fa8682886085f4f63ccd2a57806161b9a3ccb0cbe0c465be2e5620ed57942a8687656859e1a9df17c7d298ea66ec037514bbe7707783aa9f8
+AUX ftpd.pamd 192 SHA256 4b789fb18bc0d1f9b0a9b0f1bf5dac6d86166a7106e966e5f65ffd4faf5ce024 SHA512 d7e7f08ef05ccc63e63ddc65d79f96106dfa0ec2421ee9fbbb83966aaccb73d9868cb14467c1bdfaa9d12299a8ad27cbc725a33fec58e47b5b8212e52a7c18eb WHIRLPOOL 1d418e336dec5b6c34541c11068fd19ffe7546d338851f47359c50c18bc382c84230c0d751fa8185d48ca1c67250ba320fec895fc92f96c1d6909647db67a54a
+AUX libusb-1.0.pc.in 207 SHA256 edf35e887cbfed2df288825434c467e0a946eeb21e0d631f55940bb177c2ba15 SHA512 93289cecfc298a31fd4fd0848bf25a63048a7549bd81792d7bd158731246221c24ec9f469a918430da56873a0936fb2b372cedaaa32a38ccd5323de0f9a89b93 WHIRLPOOL 7c81b0df4548a9391b4e1420186f1e970aa9e2e73a89e817adbff9de52b8797cbd8a4d8b3ca01f782f86e4b1e48fad72a08b5bff49d5ee6ffaa5135c015ca5ae
+AUX libusb.pc.in 208 SHA256 9bfe398a335f8b9b1c3dd167ab0c9206fe3bdd4e1da318ece977e20f3c2d7c56 SHA512 e9c6d5f04057cf8c13f69a3d8e07bdd517fdb01d572a69a1beb397766311b3c53894b108caaaea740bfc27b227a9620621dac5846bff1a367fbf9954f38bb40c WHIRLPOOL e80e76a8a564655d924a7148a841c7c7cf0be0ea3bdbd76e95e5004124543826e5d925dfe791f4b040e042a10923865bb517499d9f5be39611fedbcceebe32d8
+AUX rquotad.xinetd 162 SHA256 3f73f86e5a6ab3b6d25698f6179cdbe169b2fd01c682b45a9c8711f36bb317e5 SHA512 2cf16514f18abe2aeaa273fabc2dc94b09f31d02001ece5c82d9336c02d921e03dff6f82a613a4bffe57b5e415add2b82ef883a306907dd20ffe1bbe332b011f WHIRLPOOL 237667cbff4807d703a3c4c4eb8c2c5863d024a6263e3addf8d96ffa1461a8d1cda6318deee1de72146d27305b670b501da9ad4035880551dee5138b6798f6c6
+AUX rstatd.xinetd 218 SHA256 7bf526babdd46f03a6ea9ed12b5df16e5c2abc8aeb567214c8edb8ac327d4381 SHA512 febca8ab8248b1c103dd7be0806e3d678c5b5cf165a7b3bd0305bc905da228bf92392d65d44a765b7692f772befeedcbc3df205d32bb62ad5aa307f71a1c1011 WHIRLPOOL 76f8b1f3f85e97f27950549f62dc411e0620b25eba68c161c96a5252617c7c4beb0fecf94af9bc9cf931dff8fc4c750e780c41143a50b39d7538a30b7c0bd322
+AUX rusersd.xinetd 220 SHA256 271de1cad33a65a2a0e81e8983cbb1b7ab6e2e75bbf4c6e99181408067a49cd3 SHA512 fdf4ef4e0b0dd11c64fb38d32c9fca2d378a69e4cff87523127089d7dc0db12b26f6399c7a61fc43d62ca8083b116440f6fffff9e3329f0548bf54f0f26699cd WHIRLPOOL 7517089e5ab5b3925b46908c22a929cb04c8390387ad075f17c2fa0213ab38cae833d9280cfe289915afe4c2ee0b3e0299cee42daa871c23507f5f96cc22f227
+AUX sprayd.xinetd 216 SHA256 5b2c0e14c40c3d14f16f6fbe7b1f00d133bbae8ea27e548273a16d104afea24e SHA512 a49824ab0421560699901f54d9faf3f38fb6f8d8f63f05e33eb11da053278838e80eaabf5963b1c2a7292ba2d2118e1efd90954b2f3b2dc01b945fbadc6ce101 WHIRLPOOL 3869a0e4a9f03aa3654729e611a020421ec0beef2686ca8857b5ac3d50f8db26d7c1a5eb16e90aaf5b2b33e992915f7e9e504ce6bca9fd5862c2051a7172495f
+AUX walld.xinetd 215 SHA256 b7d8cb4b69809a2ea2f479f942c3d7752c5cb1e4b3b4b7b7b590f15616a774f0 SHA512 ab78d32e48d660649d3415a4432a5f3e98f8a6a8854791d1d828b0dc678f58e9f24532c264c5f5b039ccd706e0bb70c369ba9fb55fc9af9d3ed9b28e10b9e830 WHIRLPOOL 013b60056a8f5fe46eb4e00182fe0f391a2dc915312fe7e47eb372697526ed05a53e156159fd5dd3dcbf3db44a6591461c789af31ca0e1dd967537b785462802
+DIST freebsd-cddl-9.1.tar.bz2 899348 SHA256 bcc79fb002052128e9e91b16beb3083ee152be0936494715c6c159bfc8d2ca3a SHA512 ae0a969e710785bbcf36a2ec22cc5b1dcdb25398be951e047a1237d0c977e38fc9e05504db51f8bf9ed83bc1f68b04fc88ce18fc48a93f785b8a3f8ef481bacd WHIRLPOOL 2c4a5baf162dbb698af45b9262f104e27c05e6a2630c3e7b1765e76c8987a330c315f741df69c8771d2509708d2934db2a07f2e0218aa59d0100dfc3f952bf72
+DIST freebsd-contrib-8.2.tar.bz2 40931651 SHA256 8b9cb688e81c2980b3fc66411d00ab277a24dadd50d5bdd5e0e6c63ac687b9b6 SHA512 4f7bf825b579fbb88f2aac531d07e531474179c63fa0b66c4e80821290a8c94bf611bb4dcaef51b762aacd25b11dfae798a4ec3bad3b9e3f6b3490ebfaa72476 WHIRLPOOL edd3d9e26e8d22d9028082e107ec1a44402e206dab8722f34b445676959305996c3f699152af42ace249b7f58498492787823b172fb6bcb273119c6bb50a35f0
+DIST freebsd-contrib-9.1.tar.bz2 54751432 SHA256 e7ffa056d4050ce03ee8e23e276e2a9a494326a98d60c43bee2afcc59576deb8 SHA512 71be13049258c6e6b5e4f63cc16da5d349a89d68f04d87446e4ad33ae8bf2a93ea67d9c256b7bec60b61e65db0487268070cfb77a484c3ac0f8ba368b48c2438 WHIRLPOOL a2a84423175499208d34809e802284d6ba649f317c3a9ad8b7312fa19efe142ebadab0048bac0db8e988e59f9a7468ac7c5d0d25e78b82bdb269a20d18153cee
+DIST freebsd-crypto-8.2.tar.bz2 5561428 SHA256 89ddda3dfad2d46abacc27c296d7d58c18463e0fe1ce2fac2c7a8fcafe181890 SHA512 3c8ed329f6ed67d6db622e2713e9a7b65f54f4d99191e00b133c0afb3dec94c5426542719002e9bd2d83a9a1856a5cb29f2117f1db250f3794e1b2234a1e8e08 WHIRLPOOL 4df14a825a888f925e66599b1a0d6a35981e4eea357da03fccfe50426def5da97ead21ffc782b4e3e45aec047549f11b6d5385cfafcc271d0d6293cdce8a9ad3
+DIST freebsd-crypto-9.1.tar.bz2 5682828 SHA256 5165156c52f21318634611e8a3965134f3b34c83f9aba23db5a93b37627c5c74 SHA512 40c7a8150fb3ddd93488502a976ce03e992e6f4fb28aa3e5e102d4915f8ff49fe9085995ccfecacefc3b665e23c85cc3a0cdeec20a32c79e04458f7cc88630d9 WHIRLPOOL 72db3b27a6bf3abec47525fa31dd3bd459d4da36b787dbf57ed11b4e676c0c200ec5a549d7e27cb0c66e1feead8fa8257c712fdd5b5568eba2b8ae8323228043
+DIST freebsd-etc-8.2.tar.bz2 188629 SHA256 6bc745fa259f9fa2b65df865d45443a7b23c24445195e33a4ac50bf1040ae238 SHA512 3e5c106754a6a1ac806bd46b711fba7ee9cb31a4eab5262c995a5d59dbeb02f756dd8b495640dda94189d204a5d2c5218de2bd23467172d6a4ebe1048986e89c WHIRLPOOL 23b658a214f1a64c43420351020e32b1182e9aac3ed5253f49ee86f9cee9166ce32bd556cd2a2b3c0e60a165462a8700f37dea19e57ad5716415e17f61da912e
+DIST freebsd-etc-9.1.tar.bz2 207776 SHA256 a317bf85532d6192f5506e8d7bd5d5c201fe24017700e3a974a7712c2c69cdb8 SHA512 4fbe56fde519cf2f44e39a8869efa26c34f703cf540f4a83389da8d170873d7c6fb18e4010e643b8d793cfc5c55d15eeb198057a5b2a8da9d9e8f791801bf314 WHIRLPOOL 0c27019fe140fe96f870697acbaa89ac2f281f55b892c5791b08abf1cfa4da94d9d42a1df1c2091317573ed7234253857aecb797065f911a0a5d57bbf64349a5
+DIST freebsd-gnu-8.2.tar.bz2 815379 SHA256 34be1326b8e188427ea4a59de5dd24049f99adb5e172d61a645db1b7124f7876 SHA512 8b278e386b22b22658eef18341073c1c757b86ecdef5c5b543fb781cfee295d71cef599544eda5f8cf273fc22d28a1ab14d912086ff8398c36ee2b71281617d4 WHIRLPOOL aaf91562f147095e09a9f6aa2d4c33494f430cbe7340377edff1b8a44cc60edfe4af7ef90350018f0c80e82f5518110689cb582bb227d2360488dfbdd7bcb7c8
+DIST freebsd-gnu-9.1.tar.bz2 795778 SHA256 3b99c1fa1087bf69549e0990a0d7997954533ac9d7938c4760ec2b01aa509a5f SHA512 b05f2a5a10bdaeef19dfd0e962bc09f1571288a831e9345f404b920037f47db5c0ca3d620d1cbdd138b18bca1c3feab5b211b57e3041727341e5238cb9feb4fd WHIRLPOOL 4f776b99296c4fcc0d6f4d30a12b0773f6704292e1361826b260ce34dcc8e537ef7eb7c6332c4988e0e03bc84ca07fb18e6b2785fe4c6f175c08865b72d6bb0b
+DIST freebsd-include-8.2.tar.bz2 138992 SHA256 fade90621a8e4880c9583c1ee49965400c88e53ac6c07cb5dcf320e4f069271d SHA512 6bc820dde866589ef75f9f0d1c469d815439bdd4c79f0e1a2482ec58f938b638cb9106969b321aa72492f933c95c76895ce489727a5e265798c93adc75dd64e3 WHIRLPOOL 64d3160c4ac46a62f5969058e07bd160c92284f08805ed917f2073ba1cb5907cfca16c5893daf30254d39b4fcdf641ab6afb9817607f65e7789d3049e8103947
+DIST freebsd-include-9.1.tar.bz2 146881 SHA256 861dce3f39e6806762b102361017cbe148f0e2b768b3fca152f8426f44a2942f SHA512 779c8315ce2b10b343bb62e331525d510b0d68ce5d665a1672bd6f4d1eff6445bc6b7a0f178b319828aa203c4e4c04c561ce793052703f4f936ce9711280a0c9 WHIRLPOOL e16ba45d380591ba007ca59579d45f61ffc1aa1a4c08fc11ed2794979b0a189a346c81b4f70a44ee199d50a72024930f28587ad62a9cd6854fc937eb466ec115
+DIST freebsd-lib-8.2.tar.bz2 3323878 SHA256 e3590c12794fcb5ba8eb7a1f58b497587cf19f9200b3254c194a793da3b5bfb0 SHA512 c059cfdd1099bb519b2a5c43fb7e7104c500ef8906229ed7eb9e420cb3a217cdaf8655e9e7a9f45cfadc5491f8115e0e738fd49251d9f0c3a83780845b09f007 WHIRLPOOL 95f98a372f44a89bc8ac3029ec065dbbfec338e6f889d057d75644bfcdfb9d27fdc0421d7e392cad5a823712b97f0857297ec3d321580254c63032c22b95792e
+DIST freebsd-lib-9.1.tar.bz2 3206685 SHA256 f31fa8107b4de711c548f6d0c1bb1f81d09f51bcc3b14a1e9e90bb0e7cc4a35d SHA512 40d0c36b6b889c404fa0e0afa38ba4e84a55bc88ffa2f98a70afbd7a32c4f32c158617ba770567d082a986d62c09b3ec8db3dc5ab853ee1c9bbe0b90bb82396e WHIRLPOOL 581878bf9c43184b043b4293409b85901c9ed1f9bd279e965414aca41ba50950848ebda3ee10a503a028135dfd2765e95a11acd4e62a11c528e104392bbbd8d0
+DIST freebsd-lib-EN-1606-libc.patch 249 SHA256 5ad0e95c5418ebd3edb06dc3f287b3fd84476a57766ca9984ffd98108e6930e6 SHA512 6dcfd00e646da0d3d8ad231786a8e422d319d8a1755e9f1d55f555999c5ccc0fdb7dca62fc1ced8686f6c3206044e75cd197d75843b1e9e6e83bef276c01d3d9 WHIRLPOOL e8d1c9f0e070e1b30443942543bcb6b0963a9566e3ff32e4d4592a268217547019ab133f1b477b3d772a206c4a275b01b1bb9784f16c4233894a7ad4dfc71ece
+DIST freebsd-lib-SA-1637-libc.patch 1567 SHA256 77923f6f7c754507db76e6ee13aed1a36b0e58691369baf8f2c9bff819787f0e SHA512 8eaea9e01a7b224138da2cec559d8e925af3ecda4bf7d29340394f57204cd2460c7418a33dcca3db445436ac2985dba42478ad5595c25b9d83305552a04965f7 WHIRLPOOL b15495b71aa72f56494e9efb55b7641224672f93442a075212269a180aac6ac705802afd90f40e192af72a975f05aa8d516355339722c741d565444cbc076a95
+DIST freebsd-lib-SA-1638-bhyve.patch 637 SHA256 e90962f3ad1f42c85cd251fc7af3400991acbecf262a0499ab07da53fce3c005 SHA512 4d8c45f4e2d729998a874023bf5bc8ca2904d3fd71e681180c3b4b2eabe2a34c086b806b86debcbc9ab24c6b5ab637f6ddae00fb577994359ed14edc3cac5aa4 WHIRLPOOL f30895ed4478165c914cd0a95a5e31f0e3175580ea753af39810cc9e2c6f5d0202fd771bac8f789ce52b73d88d536f95cd322e851c397f0087e66146cd412fbb
+DIST freebsd-libexec-8.2.tar.bz2 289147 SHA256 10b996d1d8cd044ee2e7a877e5e6ad2bf050cce9b3bd402a5e0dea7d290b595d SHA512 abe6cf5a268675d7dcb1c214c46fef47a3fb09b31947f5d8a0b938d352295efe0249beb5007649c52187bf4c221b6ebf074d18dfe9bafd168cae09ee02ab608d WHIRLPOOL 27e854fe465eb933dd8e27c5a09b063e4d3798b54e0914c79a9120dcdc34cc5d525a0c92da7b645ff7ab2ab4f34c7f7b2783012dfa5004407acd11150062b7ad
+DIST freebsd-libexec-9.1.tar.bz2 304592 SHA256 71e6e9e41328c2148c54b81ad9b59f912a1d5f0d52e17ac07f223aa7a94b82be SHA512 7baa4160dda2610250dd52f445e24478e0f1ea10bce21fcd0e5d1b856f399b896adc334114de0c7f61a5637e4349bb1688fdbe5c72798d8568ae791114710b92 WHIRLPOOL d800f477ac5c9ad6dae3e0091c83e107609b5a1e3aa79e9533fcd10a8dd34ff7733ab9523eae7c292310fe94f6a529209cae6b9e8bac6b47244e59834593e74b
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+DIST freebsd-sys-8.2.tar.bz2 25835329 SHA256 0c6c7b61aae94db2931f985d5899f3bca78fc8ffab6b598fbaa158142d676f16 SHA512 6ea4516a5c52e25c4f993f7acb875463a5caea93dbdf250c5d48eee95fff226956e9f030cab7e341b5e6a132325bc3dbf93dcb4b1185acb011918e50b1a22be3 WHIRLPOOL 870deeff877c6b9fc812a4260e4fdbb6715a5dc2065cab3bfbf2a42d876f6654703ccb124275a4e2c410cef48f3db02b63cc76059eccf9cf90244826f35b7a15
+DIST freebsd-sys-9.1.tar.bz2 32588103 SHA256 b93a7ac8334ac16cc9f60665048e5ef812c0a6c62f10d0b0a674aec3f56516a8 SHA512 7dc9d9e00dde8f592bb171f4386d02b655b73cb4f153fe5ec063d010a148ef0639eae0dcdb3eeb09ecd1e3653c69e49a2d261329fa6d0381d2ddabe258ddde6d WHIRLPOOL c8348344dfb14bad64bd3a78ee615ddd29203175b292233254f8ba175e7a3fb7218af6f95f7b4dbf394c0354bafe9d8bb0c21cdf0ceaeb697214964b280469b3
+DIST freebsd-usbin-8.2.tar.bz2 2443024 SHA256 aa7cabf10f5c3a9daabea32e4de24d04ec312247842981476da666eff5054603 SHA512 bcb8ff3df54848b9107bbb52e5ced7a91e24bb181f06769b6997221729b8064ec17652eaf7500de3268cbcb63ff5760beb54d15fc78c27b02687b5b1067c74a6 WHIRLPOOL 20f5278e2a1dd387a75b44f10507958d6c0e84a2faa1bddbf808c14ab86d8dd14a956192911bbc1880f5f5f7bd05972dcbb4aec85d241f0dcf91bf4246883f0a
+DIST freebsd-usbin-9.1.tar.bz2 2670916 SHA256 b938c20b8c09aa9a610e13b69b9afeea72f561ab3636a59fba2bdac290f4db75 SHA512 21c234312f70eb35cd2926519efc1f61592892f5d0940786dbeb959c3c5ec7819a51ae95c6e8a1a06aa01f669350fe0fd3dd7c4ec8a84dd6b90f24cb192356ca WHIRLPOOL 7f6ad2eb5410cc5e685881654a788807848af026b1277a974682755ab7c9db28f576bfd1576441ea10c5f1e9edb7d30a4a23fb8eccd6d69d86ecc9ce4c9adc7e
+EBUILD freebsd-lib-10.3-r3.ebuild 19468 SHA256 c9090f8098ed06d2defa7ea1ca989cc2f76cf84bf28f9aa8b39acaafc745ee76 SHA512 f908c3e6c7cfb2f7e87481eaf10f0ad19e7e45eb0c12498a138a43244e82a103ff1387f2c34984aa3b659daaeefb9228562e1bae8049fdf5a7a9016dda5f82aa WHIRLPOOL 26fcc8b6fb61ffb1d4f9ab925d1de0f236d2e81295f4a6b64457d9aee7be2a8e91ac337531c3de59087cf1daeb046af6113103283416d17ac3aea37ac8ea2635
+EBUILD freebsd-lib-11.0-r1.ebuild 19438 SHA256 515d09d9cd660c2654cb2f853dcd160b09e6fdcbf1c8571bd80028b23639ce1a SHA512 9e2651c1a3b3e781c291fe9c8627b6fb6f5549431ffc1f680f146ee5fb34680d2edaba7e50364e4aa2dabe2f34c4aa7a224f9cce2ad8e10e7dbb06677f7bd5c6 WHIRLPOOL bf728b0f0c4b7229a215e52b24ca098b300e21ed0a83c7f06d9438817439efb36dc604d02c26cf0166e296919da4304b50adbc9fbf3d284ea9c5e35b0452e852
+EBUILD freebsd-lib-11.1.ebuild 21778 SHA256 1f452c4e83293dba64903a1dc129b28d883ff03d760987e6b77f9aeb0f1c1bbf SHA512 d8a34d01ead4cca49c288f1604cda6dbbca57c2949d3f1eb48c1264f8b0f079fa77743f36c7212fdf1a67bf15ff57241ecd69d3c85469505847709ad9b87436e WHIRLPOOL 38c8816b84b6cf152bb9aa1de155ddf07c19a139ee469c1891a47f48650ee77a274ef90a33256683284caa5335a20a3c11cdd8f20b948ba8fe7e78165b47ae11
+EBUILD freebsd-lib-8.2-r1.ebuild 15675 SHA256 af261adc6e95b153ef279a0238faa93681f538918344711233796e3454aa15e1 SHA512 8ee3e2562a96f64cc2264bd315e0fc6faead639541fcb61c95a180f6d6283c8dee7d2289ee7efa477eb1324e0353be94f220c7909c34ac67bc5487892e007364 WHIRLPOOL 00b5d5f9936d82f521bb600db23b11bc35e8a34ee79760efef0de4b8a59b5241e6b0dbb879938cb2890e72610814255c618c16d482d0787df00a5e0e6fef4f43
+EBUILD freebsd-lib-9.1-r11.ebuild 18831 SHA256 2eab3f156521683e3970a23c6caa041501cb185551b727c1f7940d75d0211485 SHA512 5deb3676f9b97adf1a68dc252e4d7e7294f3eca8ff359492ec0a3ba7f5edf547270386d591be2df15935a96df7bbd2e7a4e0f8c59c13885ed224da30ef617b95 WHIRLPOOL 58a6b949bad4e99d0675575b96ed4affca9629eef0549970ac379455f43d1893464b45e7efc25e5b07d5687c5c49c67bb29145d5b5ba3fcba3bd029580b94a5b
+MISC ChangeLog 8745 SHA256 8fe13e4e710f1872870da000d3a19a06d77fabe8925a152b542a94abc0719b68 SHA512 4d9863368b4efebd94400c5a6d635957790257459ec2c2a2b156ad2c22f31d6b56157eac11e06302ab957db0a1eb5a028ef5f76bc718fc1437d5d8dbb67e6842 WHIRLPOOL 6abcbb36d1d79642c249ddcb84c4aeeb8721d1a34accee05ab986865fa959b38d238745e0d83200e55505f7e9210da08fc0e2bae331548043243eb07974ee27f
+MISC ChangeLog-2015 43636 SHA256 4b2a4210a8d2481a95500fe185baa3308c46691ec87e045a1767725e4ddd81c4 SHA512 6941a261fc0350dc78f402bb2dc8e0685c20aa3b80eca81dcf3fdfe5b20e05eb78806bdb79282dc15025594674e4d27606e2beba0d4cbba48029b0f5b954e117 WHIRLPOOL 89fe5175adcc0849537ee7501ec0a74a33c1ae518066f08fafcbd97a2277f8e1fe7078af05f9da75db06dd8e774876507ddf971b284f9f1d1f04e1bda66c6adf
+MISC metadata.xml 500 SHA256 82c704031ba7ec4dec7348c15d1188fad5e9df804c12f90c04afcb0a46eb5dd6 SHA512 a164ccc254879d798007a4fb1db376b0dd807b3b6ef628c7f65ff05560d92d742f315226fe4935eb8b142d6937d6cfb01f515d21664f171e94f1549b40815470 WHIRLPOOL 0837f442d3673e9bac470774a9868ad4992056a4edae8e07759248ec58830cb1a596cf39b347d04a3e33b16d88329084571df30f33bdc9c9e73073f32ca015ae
diff --git a/sys-freebsd/freebsd-lib/files/bootpd.confd b/sys-freebsd/freebsd-lib/files/bootpd.confd
new file mode 100644
index 000000000000..6d238e4d4853
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/bootpd.confd
@@ -0,0 +1,7 @@
+# Configuration file for /etc/init.d/bootpd
+
+# Name of the configuration file for bootpd
+# bootptab_file="/etc/bootptab"
+
+# Options to pass to bootpd. See bootpd(8).
+# bootpd_opts=""
diff --git a/sys-freebsd/freebsd-lib/files/bootpd.initd b/sys-freebsd/freebsd-lib/files/bootpd.initd
new file mode 100644
index 000000000000..82288ebf19c3
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/bootpd.initd
@@ -0,0 +1,27 @@
+#!/sbin/openrc-run
+# Copyright 2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net
+}
+
+start() {
+ local bootptab=${bootptab_file:-/etc/bootptab}
+
+ if ! [ -f "${bootptab}" ]; then
+ eerror "Unable to find the bootptab file: ${bootptab}"
+ eend 1
+ return 1
+ fi
+
+ ebegin "Starting BOOTP server"
+ start-stop-daemon --start --exec /usr/libexec/bootpd -- ${bootpd_opts} ${bootptab}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping BOOTP server"
+ start-stop-daemon --stop --exec /usr/libexec/bootpd
+ eend $?
+}
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-atfcxx.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-atfcxx.patch
new file mode 100644
index 000000000000..42b64b572322
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-atfcxx.patch
@@ -0,0 +1,49 @@
+diff --git a/lib/atf/Makefile.inc b/lib/atf/Makefile.inc
+index 937187a..d5277f3 100644
+--- a/lib/atf/Makefile.inc
++++ b/lib/atf/Makefile.inc
+@@ -49,6 +49,24 @@ CFLAGS+= -DATF_PKGDATADIR='"${SHAREDIR}/atf"'
+ CFLAGS+= -DATF_SHELL='"/bin/sh"'
+ CFLAGS+= -DATF_WORKDIR='"/tmp"'
+
++CXXFLAGS+= -DHAVE_CONFIG_H
++CXXFLAGS+= -DATF_ARCH='"${MACHINE}"'
++CXXFLAGS+= -DATF_BUILD_CC='"${CC}"'
++CXXFLAGS+= -DATF_BUILD_CXXFLAGS='"${_CXXFLAGS}"'
++CXXFLAGS+= -DATF_BUILD_CPP='"${CPP}"'
++CXXFLAGS+= -DATF_BUILD_CPPFLAGS='"${_CPPFLAGS}"'
++CXXFLAGS+= -DATF_BUILD_CXX='"${CXX}"'
++CXXFLAGS+= -DATF_BUILD_CXXFLAGS='"${_CXXFLAGS}"'
++CXXFLAGS+= -DATF_CONFDIR='"${CONFDIR}/atf"'
++CXXFLAGS+= -DATF_INCLUDEDIR='"${INCLUDEDIR}"'
++CXXFLAGS+= -DATF_LIBDIR='"${LIBDIR}"'
++CXXFLAGS+= -DATF_LIBEXECDIR='"${LIBEXECDIR}"'
++CXXFLAGS+= -DATF_MACHINE='"${MACHINE_ARCH}"'
++CXXFLAGS+= -DATF_M4='"/usr/bin/m4"'
++CXXFLAGS+= -DATF_PKGDATADIR='"${SHAREDIR}/atf"'
++CXXFLAGS+= -DATF_SHELL='"/bin/sh"'
++CXXFLAGS+= -DATF_WORKDIR='"/tmp"'
++
+ WARNS?= 3
+
+ # vim: syntax=make
+diff --git a/lib/atf/libatf-c++/Makefile b/lib/atf/libatf-c++/Makefile
+index 37d6073..90a2687 100644
+--- a/lib/atf/libatf-c++/Makefile
++++ b/lib/atf/libatf-c++/Makefile
+@@ -40,11 +40,11 @@ LDFLAGS+= -L${.OBJDIR}/../libatf-c
+ .PATH: ${ATF}/atf-c++
+ .PATH: ${ATF}/atf-c++/detail
+
+-CFLAGS+= -I${ATF}
+-CFLAGS+= -I${.CURDIR}/../libatf-c
+-CFLAGS+= -I.
++CXXFLAGS+= -I${ATF}
++CXXFLAGS+= -I${.CURDIR}/../libatf-c
++CXXFLAGS+= -I.
+
+-CFLAGS+= -DHAVE_CONFIG_H
++CXXFLAGS+= -DHAVE_CONFIG_H
+
+ SRCS= application.cpp \
+ build.cpp \
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-liblink.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-liblink.patch
new file mode 100644
index 000000000000..6ef3f07de0fd
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-liblink.patch
@@ -0,0 +1,98 @@
+diff --git a/lib/libcam/Makefile b/lib/libcam/Makefile
+index 9a21dde..0815f0a 100644
+--- a/lib/libcam/Makefile
++++ b/lib/libcam/Makefile
+@@ -8,6 +8,7 @@ INCS= camlib.h
+
+ DPADD= ${LIBSBUF}
+ LDADD= -lsbuf
++LDFLAGS+= -L${.OBJDIR}/../libsbuf
+
+ MAN= cam.3 cam_cdbparse.3
+
+diff --git a/lib/libdwarf/Makefile b/lib/libdwarf/Makefile
+index dbd7895..607b1f6 100644
+--- a/lib/libdwarf/Makefile
++++ b/lib/libdwarf/Makefile
+@@ -21,6 +21,7 @@ SRCS= \
+ INCS= dwarf.h libdwarf.h
+
+ CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR}/../libelf
+
+ SHLIB_MAJOR= 3
+
+diff --git a/lib/libproc/Makefile b/lib/libproc/Makefile
+index 4449c06..f024cf0 100644
+--- a/lib/libproc/Makefile
++++ b/lib/libproc/Makefile
+@@ -14,6 +14,7 @@ SRCS= proc_bkpt.c \
+ INCS= libproc.h
+
+ CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR}/../libelf
+
+ .if ${MK_LIBCPLUSPLUS} != "no"
+ LDADD+= -lcxxrt
+@@ -27,4 +28,7 @@ SHLIB_MAJOR= 2
+
+ WITHOUT_MAN=
+
++LDADD+= -lelf
++LDFLAGS+= -L${.OBJDIR}/../libelf
++
+ .include <bsd.lib.mk>
+diff --git a/lib/libprocstat/Makefile b/lib/libprocstat/Makefile
+index af5a775..c01aa05 100644
+--- a/lib/libprocstat/Makefile
++++ b/lib/libprocstat/Makefile
+@@ -16,6 +16,8 @@ VERSION_DEF= ${.CURDIR}/Versions.def
+ SYMBOL_MAPS= ${.CURDIR}/Symbol.map
+
+ INCS= libprocstat.h
++CFLAGS+= -I${.CURDIR}/../libelf
++LDFLAGS+= -L${.OBJDIR}/../libelf
+ CFLAGS+= -I. -I${.CURDIR} -D_KVM_VNODE
+ SHLIB_MAJOR= 1
+
+diff --git a/lib/librtld_db/Makefile b/lib/librtld_db/Makefile
+index 2815a07..e992662 100644
+--- a/lib/librtld_db/Makefile
++++ b/lib/librtld_db/Makefile
+@@ -10,5 +10,8 @@ SRCS= rtld_db.c
+ INCS= rtld_db.h
+
+ CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR}/../libelf
++LDADD+= -lutil -lproc
++LDFLAGS+= -L${.OBJDIR}/../libutil -L${.OBJDIR}/../libproc
+
+ .include <bsd.lib.mk>
+diff --git a/lib/libtelnet/Makefile b/lib/libtelnet/Makefile
+index 1cf52a0..3d25fae 100644
+--- a/lib/libtelnet/Makefile
++++ b/lib/libtelnet/Makefile
+@@ -13,6 +13,8 @@ INTERNALLIB=
+ SRCS= genget.c getent.c misc.c
+ CFLAGS+= -I${TELNETDIR}
+
++CFLAGS+= -I${.CURDIR}/../libmp
++
+ WARNS?= 2
+
+ .if !defined(RELEASE_CRUNCH)
+diff --git a/lib/libexecinfo/Makefile b/lib/libexecinfo/Makefile
+index 30a1dfb..9f8a99c 100644
+--- a/lib/libexecinfo/Makefile
++++ b/lib/libexecinfo/Makefile
+@@ -10,8 +10,10 @@ SHLIB_MAJOR= 1
+ INCS= execinfo.h
+ SRCS= backtrace.c symtab.c unwind.c
+
++CFLAGS+= -I${.CURDIR}/../libelf
+ DPADD= ${LIBELF}
+ LDADD= -lelf
++LDFLAGS+= -L${.OBJDIR}/../libelf
+
+ MAN= backtrace.3
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-libproc-libcxx.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-libproc-libcxx.patch
new file mode 100644
index 000000000000..55987aa44fa1
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.0-libproc-libcxx.patch
@@ -0,0 +1,16 @@
+diff --git a/lib/libproc/Makefile b/lib/libproc/Makefile
+index f9e01ab..15b27d8 100644
+--- a/lib/libproc/Makefile
++++ b/lib/libproc/Makefile
+@@ -15,7 +15,10 @@ INCS= libproc.h
+
+ CFLAGS+= -I${.CURDIR}
+
+-.if ${MK_LIBCPLUSPLUS} != "no"
++.if ${CXX:T:M*-stdlib=libc++*}
++LDADD+= -lcxxrt
++DPADD+= ${LIBCXXRT}
++.elif ${CXXFLAGS:T:M*-stdlib=libc++*}
+ LDADD+= -lcxxrt
+ DPADD+= ${LIBCXXRT}
+ .else
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-bsdxml2expat.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-bsdxml2expat.patch
new file mode 100644
index 000000000000..303f422651f3
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-bsdxml2expat.patch
@@ -0,0 +1,39 @@
+diff --git a/lib/libgeom/Makefile b/lib/libgeom/Makefile
+index bbfb57b..a7c17e3 100644
+--- a/lib/libgeom/Makefile
++++ b/lib/libgeom/Makefile
+@@ -13,7 +13,7 @@ CFLAGS += -I${.CURDIR}
+
+ WARNS?= 3
+
+-DPADD= ${LIBBSDXML} ${LIBSBUF}
++DPADD= ${LIBSBUF}
+ LDADD= -lbsdxml -lsbuf
+
+ MAN= libgeom.3
+diff --git a/lib/libgeom/geom_xml2tree.c b/lib/libgeom/geom_xml2tree.c
+index 9dedb8e..d96420c 100644
+--- a/lib/libgeom/geom_xml2tree.c
++++ b/lib/libgeom/geom_xml2tree.c
+@@ -43,7 +43,7 @@
+ #include <sys/sbuf.h>
+ #include <sys/sysctl.h>
+ #include <err.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <libgeom.h>
+
+ struct mystate {
+diff --git a/lib/libmt/mtlib.c b/lib/libmt/mtlib.c
+index d1fc0b1..89ac55e 100644
+--- a/lib/libmt/mtlib.c
++++ b/lib/libmt/mtlib.c
+@@ -48,7 +48,7 @@ __FBSDID("$FreeBSD: stable/10/lib/libmt/mtlib.c 280438 2015-03-24 14:36:10Z ken
+ #include <unistd.h>
+ #include <stdint.h>
+ #include <errno.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <mtlib.h>
+
+ /*
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-liblink.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-liblink.patch
new file mode 100644
index 000000000000..b08d95f714f3
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.2-liblink.patch
@@ -0,0 +1,26 @@
+diff --git a/lib/libmt/Makefile b/lib/libmt/Makefile
+index cb1da71..43de5a5 100644
+--- a/lib/libmt/Makefile
++++ b/lib/libmt/Makefile
+@@ -5,6 +5,7 @@ SHLIBDIR?= /lib
+ SRCS= mtlib.c
+ INCS= mtlib.h
+
++CFLAGS+= -I${.CURDIR}
+ DPADD= ${LIBSBUF}
+ LDADD= -lsbuf
+
+diff --git a/lib/libdpv/Makefile b/lib/libdpv/Makefile
+index e9384b7..085ef62 100644
+--- a/lib/libdpv/Makefile
++++ b/lib/libdpv/Makefile
+@@ -11,7 +11,8 @@ LDADD= -ldialog -lfigpar -lncursesw -lutil
+
+ SRCS= dialog_util.c dialogrc.c dprompt.c dpv.c status.c util.c
+
+-CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libfigpar
++LDFLAGS+= -L${.OBJDIR}/../libfigpar
+
+ WARNS?= 6
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-10.3-libusb.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.3-libusb.patch
new file mode 100644
index 000000000000..813a42b50171
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-10.3-libusb.patch
@@ -0,0 +1,13 @@
+diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile
+index 88ec3fe..076b8d4 100644
+--- a/lib/libusb/Makefile
++++ b/lib/libusb/Makefile
+@@ -38,7 +38,7 @@ SRCS+= libusb10_io.c
+ CFLAGS+= -DCOMPAT_32BIT
+ .else
+ FILES= libusb-0.1.pc libusb-1.0.pc libusb-2.0.pc
+-FILESDIR= ${LIBDATADIR}/pkgconfig
++FILESDIR= ${LIBDIR}/pkgconfig
+ .endif
+
+ #
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-bsdxml2expat.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-bsdxml2expat.patch
new file mode 100644
index 000000000000..41a394b815a0
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-bsdxml2expat.patch
@@ -0,0 +1,39 @@
+diff --git a/lib/libgeom/geom_xml2tree.c b/lib/libgeom/geom_xml2tree.c
+index 9dedb8e..d96420c 100644
+--- a/lib/libgeom/geom_xml2tree.c
++++ b/lib/libgeom/geom_xml2tree.c
+@@ -43,7 +43,7 @@
+ #include <sys/sbuf.h>
+ #include <sys/sysctl.h>
+ #include <err.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <libgeom.h>
+
+ struct mystate {
+diff --git a/lib/libmt/mtlib.c b/lib/libmt/mtlib.c
+index d1fc0b1..89ac55e 100644
+--- a/lib/libmt/mtlib.c
++++ b/lib/libmt/mtlib.c
+@@ -48,7 +48,7 @@ __FBSDID("$FreeBSD: stable/10/lib/libmt/mtlib.c 280438 2015-03-24 14:36:10Z ken
+ #include <unistd.h>
+ #include <stdint.h>
+ #include <errno.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <mtlib.h>
+
+ /*
+diff --git a/lib/lib80211/lib80211_regdomain.c b/lib/lib80211/lib80211_regdomain.c
+index c500d3f..fe1d37e 100644
+--- a/lib/lib80211/lib80211_regdomain.c
++++ b/lib/lib80211/lib80211_regdomain.c
+@@ -40,7 +40,7 @@ static const char rcsid[] = "$FreeBSD: stable/11/lib/lib80211/lib80211_regdomain
+ #include <err.h>
+ #include <unistd.h>
+
+-#include <bsdxml.h>
++#include <expat.h>
+
+ #include "lib80211_regdomain.h"
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-libproc-libcxx.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-libproc-libcxx.patch
new file mode 100644
index 000000000000..013ad20619e5
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-libproc-libcxx.patch
@@ -0,0 +1,13 @@
+diff --git a/lib/libproc/Makefile b/lib/libproc/Makefile
+index e3b2578..acd76e8 100644
+--- a/lib/libproc/Makefile
++++ b/lib/libproc/Makefile
+@@ -18,7 +18,7 @@ CFLAGS+= -I${.CURDIR}
+
+ .if ${MK_CXX} == "no"
+ CFLAGS+= -DNO_CXA_DEMANGLE
+-.elif ${MK_LIBCPLUSPLUS} != "no"
++.elif ${COMPILER_TYPE} == "clang"
+ LIBADD+= cxxrt
+ .else
+ LIBADD+= supcplusplus
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-libsysdecode.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-libsysdecode.patch
new file mode 100644
index 000000000000..d90aa3163dae
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-libsysdecode.patch
@@ -0,0 +1,22 @@
+diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile
+index e3bfe00..51fc5f0 100644
+--- a/lib/libsysdecode/Makefile
++++ b/lib/libsysdecode/Makefile
+@@ -8,7 +8,7 @@ LIB= sysdecode
+ SRCS= errno.c ioctl.c syscallnames.c utrace.c
+ INCS= sysdecode.h
+
+-CFLAGS+= -I${.CURDIR}/../../sys
++CFLAGS+= -I${.CURDIR}/../../sys -I${.CURDIR}
+
+ MAN+= sysdecode.3 \
+ sysdecode_abi_to_freebsd_errno.3 \
+@@ -37,7 +37,7 @@ CFLAGS.gcc+= ${CFLAGS.gcc.${.IMPSRC}}
+
+ ioctl.c: mkioctls
+ env MACHINE=${MACHINE} CPP="${CPP}" \
+- /bin/sh ${.CURDIR}/mkioctls ${DESTDIR}${INCLUDEDIR} > ${.TARGET}
++ /bin/sh ${.CURDIR}/mkioctls ${.CURDIR}/../../include > ${.TARGET}
+
+ beforedepend: ioctl.c
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-workaround.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-workaround.patch
new file mode 100644
index 000000000000..05f817eeb032
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-11.0-workaround.patch
@@ -0,0 +1,12 @@
+diff --git a/lib/libdevdctl/event.cc b/lib/libdevdctl/event.cc
+index a8cb447..d56df2e 100644
+--- a/lib/libdevdctl/event.cc
++++ b/lib/libdevdctl/event.cc
+@@ -50,6 +50,7 @@
+ #include <syslog.h>
+ #include <unistd.h>
+
++#include <cstdio>
+ #include <cstdarg>
+ #include <cstring>
+ #include <iostream>
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-11.1-liblink.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-11.1-liblink.patch
new file mode 100644
index 000000000000..b1fe7035b120
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-11.1-liblink.patch
@@ -0,0 +1,142 @@
+diff --git a/lib/libmt/Makefile b/lib/libmt/Makefile
+index a6efe28..f60919a 100644
+--- a/lib/libmt/Makefile
++++ b/lib/libmt/Makefile
+@@ -6,6 +6,7 @@ SHLIBDIR?= /lib
+ SRCS= mtlib.c
+ INCS= mtlib.h
+
++CFLAGS+= -I${.CURDIR}
+ LIBADD= sbuf bsdxml
+
+ MAN= mt.3
+diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile
+index ce89201..ba78ae4 100644
+--- a/lib/libsysdecode/Makefile
++++ b/lib/libsysdecode/Makefile
+@@ -9,7 +9,7 @@ SRCS= errno.c flags.c ioctl.c signal.c syscallnames.c utrace.c
+ INCS= sysdecode.h
+
+ CFLAGS+= -I${.OBJDIR}
+-CFLAGS+= -I${SRCTOP}/sys
++CFLAGS+= -I${SRCTOP}/sys -I${.CURDIR}
+ CFLAGS+= -I${SRCTOP}/libexec/rtld-elf
+
+ MAN= sysdecode.3 \
+
+diff --git a/lib/libdpv/Makefile b/lib/libdpv/Makefile
+index 280f7de..d0663b0 100644
+--- a/lib/libdpv/Makefile
++++ b/lib/libdpv/Makefile
+@@ -11,6 +11,7 @@ LIBADD= dialog figpar util ncursesw
+
+ SRCS= dialog_util.c dialogrc.c dprompt.c dpv.c status.c util.c
+
+-CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libfigpar
++LDFLAGS+= -L${.OBJDIR}/../libfigpar
+
+ .include <bsd.lib.mk>
+diff --git a/lib/libcasper/libcasper/Makefile b/lib/libcasper/libcasper/Makefile
+index 1064ada..32a2e66 100644
+--- a/lib/libcasper/libcasper/Makefile
++++ b/lib/libcasper/libcasper/Makefile
+@@ -18,6 +18,7 @@ INCS+= libcasper_service.h
+ LIBADD= nv
+
+ CFLAGS+=-I${.CURDIR}
++LDFLAGS+=-L${.OBJDIR}/../../libnv
+
+ MAN+= libcasper.3
+
+diff --git a/lib/libcasper/services/cap_dns/Makefile b/lib/libcasper/services/cap_dns/Makefile
+index bf6bed5..baeecbe 100644
+--- a/lib/libcasper/services/cap_dns/Makefile
++++ b/lib/libcasper/services/cap_dns/Makefile
+@@ -14,5 +14,6 @@ INCS= cap_dns.h
+ LIBADD= nv
+
+ CFLAGS+=-I${.CURDIR}
++LDFLAGS+=-L${.OBJDIR}/../../../libnv
+
+ .include <bsd.lib.mk>
+diff --git a/lib/libcasper/services/cap_grp/Makefile b/lib/libcasper/services/cap_grp/Makefile
+index 78a860a..dfb4911 100644
+--- a/lib/libcasper/services/cap_grp/Makefile
++++ b/lib/libcasper/services/cap_grp/Makefile
+@@ -14,5 +14,6 @@ INCS= cap_grp.h
+ LIBADD= nv
+
+ CFLAGS+=-I${.CURDIR}
++LDFLAGS+=-L${.OBJDIR}/../../../libnv
+
+ .include <bsd.lib.mk>
+diff --git a/lib/libcasper/services/cap_pwd/Makefile b/lib/libcasper/services/cap_pwd/Makefile
+index e4df38b..64d7709 100644
+--- a/lib/libcasper/services/cap_pwd/Makefile
++++ b/lib/libcasper/services/cap_pwd/Makefile
+@@ -14,5 +14,6 @@ INCS= cap_pwd.h
+ LIBADD= nv
+
+ CFLAGS+=-I${.CURDIR}
++LDFLAGS+=-L${.OBJDIR}/../../../libnv
+
+ .include <bsd.lib.mk>
+diff --git a/lib/libcasper/services/cap_random/Makefile b/lib/libcasper/services/cap_random/Makefile
+index d69c160..658be9c 100644
+--- a/lib/libcasper/services/cap_random/Makefile
++++ b/lib/libcasper/services/cap_random/Makefile
+@@ -14,5 +14,6 @@ INCS= cap_random.h
+ LIBADD= nv
+
+ CFLAGS+=-I${.CURDIR}
++LDFLAGS+=-L${.OBJDIR}/../../../libnv
+
+ .include <bsd.lib.mk>
+diff --git a/lib/libcasper/services/cap_sysctl/Makefile b/lib/libcasper/services/cap_sysctl/Makefile
+index 2471e65..b20a342 100644
+--- a/lib/libcasper/services/cap_sysctl/Makefile
++++ b/lib/libcasper/services/cap_sysctl/Makefile
+@@ -14,5 +14,6 @@ INCS= cap_sysctl.h
+ LIBADD= nv
+
+ CFLAGS+=-I${.CURDIR}
++LDFLAGS+=-L${.OBJDIR}/../../../libnv
+
+ .include <bsd.lib.mk>
+diff --git a/lib/libc/Makefile b/lib/libc/Makefile
+index 1cf73a7..f1c2bc8 100644
+--- a/lib/libc/Makefile
++++ b/lib/libc/Makefile
+@@ -51,6 +51,7 @@ CFLAGS+=${CANCELPOINTS_CFLAGS}
+ #
+ LDFLAGS+= -nodefaultlibs
+ LIBADD+= compiler_rt
++LDFLAGS+= -L${.OBJDIR}/../libcompiler_rt
+
+ .if ${MK_SSP} != "no"
+ LIBADD+= ssp_nonshared
+diff --git a/lib/libcompiler_rt/Makefile b/lib/libcompiler_rt/Makefile
+index 4da1166..b34297a 100644
+--- a/lib/libcompiler_rt/Makefile
++++ b/lib/libcompiler_rt/Makefile
+@@ -11,6 +11,7 @@ CFLAGS+= ${PICFLAG}
+ CFLAGS+= -fvisibility=hidden
+ CFLAGS+= -DVISIBILITY_HIDDEN
+ CFLAGS+= -I${SRCTOP}/contrib/libcxxrt
++LDFLAGS+= -L${.OBJDIR}/../libc
+
+ .if ${COMPILER_TYPE} == "clang"
+ CWARNFLAGS.gcc_personality_v0.c+= -Wno-typedef-redefinition
+diff --git a/lib/libcam/Makefile b/lib/libcam/Makefile
+index 310c9a2..86a5e8c 100644
+--- a/lib/libcam/Makefile
++++ b/lib/libcam/Makefile
+@@ -40,6 +40,7 @@ MLINKS+= cam.3 cam_open_device.3 \
+ ${SRCTOP}/sys/cam
+
+ CFLAGS+= -I${.CURDIR} -I${SRCTOP}/sys
++LDFLAGS+= -L${.OBJDIR}/../libsbuf
+
+ SHLIB_MAJOR= 7
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-flex-2.5.31.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-flex-2.5.31.patch
new file mode 100644
index 000000000000..00de8a6debb8
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-flex-2.5.31.patch
@@ -0,0 +1,13 @@
+Index: fbsd-6/lib/libipsec/policy_token.l
+===================================================================
+--- fbsd-6.orig/lib/libipsec/policy_token.l
++++ fbsd-6/lib/libipsec/policy_token.l
+@@ -138,8 +138,6 @@ void
+ __policy__strbuffer__init__(msg)
+ char *msg;
+ {
+- if (yy_current_buffer)
+- yy_delete_buffer(yy_current_buffer);
+ strbuffer = (YY_BUFFER_STATE)yy_scan_string(msg);
+ yy_switch_to_buffer(strbuffer);
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-gccfloat.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-gccfloat.patch
new file mode 100644
index 000000000000..a3e7d5e1b63c
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-gccfloat.patch
@@ -0,0 +1,16 @@
+This patch is needed to avoid inclusion of GCC's float.h that defines
+LDBL_MANT_DIG at 53 (while the source file checks for 113 or 64.
+
+Index: freebsd-6.0_beta4/lib/msun/src/s_fmal.c
+===================================================================
+--- freebsd-6.0_beta4.orig/lib/msun/src/s_fmal.c
++++ freebsd-6.0_beta4/lib/msun/src/s_fmal.c
+@@ -28,7 +28,7 @@
+ __FBSDID("$FreeBSD: src/lib/msun/src/s_fmal.c,v 1.2 2005/03/18 02:27:59 das Exp $");
+
+ #include <fenv.h>
+-#include <float.h>
++#include <machine/float.h>
+ #include <math.h>
+
+ /*
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-pmc.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-pmc.patch
new file mode 100644
index 000000000000..2f6de4652822
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.0-pmc.patch
@@ -0,0 +1,13 @@
+Index: freebsd-6.0_beta4/lib/libpmc/Makefile
+===================================================================
+--- freebsd-6.0_beta4.orig/lib/libpmc/Makefile
++++ freebsd-6.0_beta4/lib/libpmc/Makefile
+@@ -9,6 +9,8 @@ WARNS?= 6
+
+ MAN= pmc.3 pmclog.3
+
++CFLAGS+= -I${.CURDIR}
++
+ MLINKS+= \
+ pmc.3 pmc_allocate.3 \
+ pmc.3 pmc_attach.3 \
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-6.1-csu.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.1-csu.patch
new file mode 100644
index 000000000000..075f2780e693
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.1-csu.patch
@@ -0,0 +1,20 @@
+--- lib/csu/amd64/Makefile.orig 2006-07-04 07:49:58 -0300
++++ lib/csu/amd64/Makefile 2006-07-04 07:50:15 -0300
+@@ -16,6 +16,7 @@
+ ${CC} ${CFLAGS} -DGCRT -c -o gcrt1.o ${.CURDIR}/crt1.c
+
+ realinstall:
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${OBJS} ${DESTDIR}${LIBDIR}
+
+--- lib/csu/sparc64/Makefile.orig 2006-10-06 15:13:55 +0100
++++ lib/csu/sparc64/Makefile 2006-10-06 15:15:06 +0100
+@@ -15,6 +15,7 @@
+ ${CC} ${CFLAGS} -DGCRT -c -o gcrt1.o ${.ALLSRC}
+
+ realinstall:
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${OBJS} ${DESTDIR}${LIBDIR}
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-6.2-bluetooth.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.2-bluetooth.patch
new file mode 100644
index 000000000000..a9b8435eff66
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-6.2-bluetooth.patch
@@ -0,0 +1,11 @@
+--- lib/libsdp/Makefile 2007-06-15 12:04:37 +0200
++++ lib.sdp/libsdp/Makefile 2007-06-15 12:26:14 +0200
+@@ -5,7 +5,7 @@
+ MAN= sdp.3
+
+ WARNS?= 2
+-CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libbluetooth
+
+ SHLIB_MAJOR= 2
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-7.1-types.h-fix.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-7.1-types.h-fix.patch
new file mode 100644
index 000000000000..8de5df2d16a6
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-7.1-types.h-fix.patch
@@ -0,0 +1,15 @@
+Fixes a compile error if XOPEN_SOURCE 600 is defined.
+
+See: http://www.mailinglistarchive.com/freebsd-current@freebsd.org/msg15011.html
+
+--- sys/sys/types.h.orig
++++ sys/sys/types.h
+@@ -46,7 +46,7 @@
+
+ #include <sys/_pthreadtypes.h>
+
+-#if __BSD_VISIBLE
++#ifndef _POSIX_SOURCE
+ typedef unsigned char u_char;
+ typedef unsigned short u_short;
+ typedef unsigned int u_int;
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-gcc45.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-gcc45.patch
new file mode 100644
index 000000000000..2ddb9eadb909
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-gcc45.patch
@@ -0,0 +1,28 @@
+diff -Nur work.orig/include/rpcsvc/nis.x work/include/rpcsvc/nis.x
+--- work.orig/include/rpcsvc/nis.x 2009-10-25 10:10:29.000000000 +0900
++++ work/include/rpcsvc/nis.x 2011-04-13 21:25:13.000000000 +0900
+@@ -399,10 +399,7 @@
+ %#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights)
+ %#define WORLD_DEFAULT (NIS_READ_ACC)
+ %#define GROUP_DEFAULT (NIS_READ_ACC << 8)
+-%#define OWNER_DEFAULT ((NIS_READ_ACC +\
+- NIS_MODIFY_ACC +\
+- NIS_CREATE_ACC +\
+- NIS_DESTROY_ACC) << 16)
++%#define OWNER_DEFAULT ((NIS_READ_ACC + NIS_MODIFY_ACC + NIS_CREATE_ACC + NIS_DESTROY_ACC) << 16)
+ %#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT)
+ %
+ %/* Result manipulation defines ... */
+@@ -431,10 +428,8 @@
+ % * these definitions they take an nis_object *, and an int and return
+ % * a u_char * for Value, and an int for length.
+ % */
+-%#define ENTRY_VAL(obj, col) \
+- (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
+-%#define ENTRY_LEN(obj, col) \
+- (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len
++%#define ENTRY_VAL(obj, col) (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
++%#define ENTRY_LEN(obj, col) (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len
+ %
+ %#ifdef __cplusplus
+ %}
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-log2.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-log2.patch
new file mode 100644
index 000000000000..a9fd18998287
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-log2.patch
@@ -0,0 +1,21 @@
+log2 and log2f are required by C99 and are not implemented.
+Workaround the deficiency.
+
+--- lib/msun/src/math.h.old 2010-03-14 17:02:25.000000000 +0100
++++ lib/msun/src/math.h 2010-03-14 17:07:03.000000000 +0100
+@@ -203,6 +203,7 @@
+ double frexp(double, int *); /* fundamentally !__pure2 */
+ double ldexp(double, int);
+ double log(double);
++#define log2(x) log(x)/log(2.0)
+ double log10(double);
+ double modf(double, double *); /* fundamentally !__pure2 */
+
+@@ -319,6 +320,7 @@
+ float log10f(float);
+ float log1pf(float);
+ float logf(float);
++#define log2f(x) logf(x)/logf(2.0)
+ float modff(float, float *); /* fundamentally !__pure2 */
+
+ float powf(float, float);
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-rpcsec_gss.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-rpcsec_gss.patch
new file mode 100644
index 000000000000..a7de06fadf56
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.0-rpcsec_gss.patch
@@ -0,0 +1,12 @@
+Without this linking fails during a stage3 build.
+
+--- lib/librpcsec_gss/Makefile.orig
++++ lib/librpcsec_gss/Makefile
+@@ -8,6 +8,7 @@
+
+ DPADD+= ${LIBGSSAPI}
+ LDADD+= -lgssapi
++LDFLAGS+= -L${.OBJDIR}/../libgssapi
+
+ VERSION_DEF= ${.CURDIR}/../libc/Versions.def
+ SYMBOL_MAPS= ${.CURDIR}/Symbol.map
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-liblink.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-liblink.patch
new file mode 100644
index 000000000000..c8be7f48472e
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-liblink.patch
@@ -0,0 +1,19 @@
+--- lib/libproc/Makefile.old 2011-07-06 00:58:04.000000000 +0000
++++ lib/libproc/Makefile 2011-07-06 00:58:58.000000000 +0000
+@@ -18,5 +18,6 @@
+ WARNS?= 6
+
+ WITHOUT_MAN= yes
++LDADD=-lelf
+
+ .include <bsd.lib.mk>
+--- lib/librtld_db/Makefile.old 2011-07-06 00:58:12.000000000 +0000
++++ lib/librtld_db/Makefile 2011-07-06 00:59:27.000000000 +0000
+@@ -10,5 +10,7 @@
+ INCS= rtld_db.h
+
+ CFLAGS+= -I${.CURDIR}
++LDADD=-lutil -lproc
++LDFLAGS+=-L${.CURDIR}/../libutil -L${.CURDIR}/../libproc
+
+ .include <bsd.lib.mk>
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-nlm_syscall.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-nlm_syscall.patch
new file mode 100644
index 000000000000..556ade50b033
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-8.2-nlm_syscall.patch
@@ -0,0 +1,10 @@
+--- include/unistd.h 2010/12/20 20:39:49 216602
++++ include/unistd.h 2010/12/20 21:12:18 216603
+@@ -529,6 +529,7 @@
+ #define _MKTEMP_DECLARED
+ #endif
+ int nfssvc(int, void *);
++int nlm_syscall(int, int, int, char **);
+ int profil(char *, size_t, vm_offset_t, int);
+ int rcmd(char **, int, const char *, const char *, const char *, int *);
+ int rcmd_af(char **, int, const char *,
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-bluetooth.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-bluetooth.patch
new file mode 100644
index 000000000000..cf1172ab6335
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-bluetooth.patch
@@ -0,0 +1,12 @@
+diff -Nur lib.orig/libsdp/Makefile lib/libsdp/Makefile
+--- lib.orig/libsdp/Makefile 2012-12-25 20:28:50.000000000 +0900
++++ lib/libsdp/Makefile 2012-12-25 20:31:19.000000000 +0900
+@@ -5,7 +5,7 @@
+ MAN= sdp.3
+
+ WARNS?= 2
+-CFLAGS+= -I${.CURDIR}
++CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libbluetooth
+
+ SHLIB_MAJOR= 4
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-cve-2010-2632.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-cve-2010-2632.patch
new file mode 100644
index 000000000000..ad9b9608f42c
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-cve-2010-2632.patch
@@ -0,0 +1,215 @@
+Index: lib/libc/gen/glob.c
+===================================================================
+--- lib/libc/gen/glob.c (revision 246357)
++++ lib/libc/gen/glob.c (working copy)
+@@ -94,6 +94,25 @@ __FBSDID("$FreeBSD$");
+
+ #include "collate.h"
+
++/*
++ * glob(3) expansion limits. Stop the expansion if any of these limits
++ * is reached. This caps the runtime in the face of DoS attacks. See
++ * also CVE-2010-2632
++ */
++#define GLOB_LIMIT_BRACE 128 /* number of brace calls */
++#define GLOB_LIMIT_PATH 65536 /* number of path elements */
++#define GLOB_LIMIT_READDIR 16384 /* number of readdirs */
++#define GLOB_LIMIT_STAT 1024 /* number of stat system calls */
++#define GLOB_LIMIT_STRING ARG_MAX /* maximum total size for paths */
++
++struct glob_limit {
++ size_t l_brace_cnt;
++ size_t l_path_lim;
++ size_t l_readdir_cnt;
++ size_t l_stat_cnt;
++ size_t l_string_cnt;
++};
++
+ #define DOLLAR '$'
+ #define DOT '.'
+ #define EOS '\0'
+@@ -153,15 +172,18 @@ static const Char *g_strchr(const Char *, wchar_t)
+ static Char *g_strcat(Char *, const Char *);
+ #endif
+ static int g_stat(Char *, struct stat *, glob_t *);
+-static int glob0(const Char *, glob_t *, size_t *);
+-static int glob1(Char *, glob_t *, size_t *);
+-static int glob2(Char *, Char *, Char *, Char *, glob_t *, size_t *);
+-static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *, size_t *);
+-static int globextend(const Char *, glob_t *, size_t *);
+-static const Char *
++static int glob0(const Char *, glob_t *, struct glob_limit *);
++static int glob1(Char *, glob_t *, struct glob_limit *);
++static int glob2(Char *, Char *, Char *, Char *, glob_t *,
++ struct glob_limit *);
++static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *,
++ struct glob_limit *);
++static int globextend(const Char *, glob_t *, struct glob_limit *);
++static const Char *
+ globtilde(const Char *, Char *, size_t, glob_t *);
+-static int globexp1(const Char *, glob_t *, size_t *);
+-static int globexp2(const Char *, const Char *, glob_t *, int *, size_t *);
++static int globexp1(const Char *, glob_t *, struct glob_limit *);
++static int globexp2(const Char *, const Char *, glob_t *, int *,
++ struct glob_limit *);
+ static int match(Char *, Char *, Char *);
+ #ifdef DEBUG
+ static void qprintf(const char *, Char *);
+@@ -171,8 +193,8 @@ int
+ glob(const char * __restrict pattern, int flags,
+ int (*errfunc)(const char *, int), glob_t * __restrict pglob)
+ {
++ struct glob_limit limit = { 0, 0, 0, 0, 0 };
+ const char *patnext;
+- size_t limit;
+ Char *bufnext, *bufend, patbuf[MAXPATHLEN], prot;
+ mbstate_t mbs;
+ wchar_t wc;
+@@ -186,11 +208,10 @@ glob(const char * __restrict pattern, int flags,
+ pglob->gl_offs = 0;
+ }
+ if (flags & GLOB_LIMIT) {
+- limit = pglob->gl_matchc;
+- if (limit == 0)
+- limit = ARG_MAX;
+- } else
+- limit = 0;
++ limit.l_path_lim = pglob->gl_matchc;
++ if (limit.l_path_lim == 0)
++ limit.l_path_lim = GLOB_LIMIT_PATH;
++ }
+ pglob->gl_flags = flags & ~GLOB_MAGCHAR;
+ pglob->gl_errfunc = errfunc;
+ pglob->gl_matchc = 0;
+@@ -243,11 +264,17 @@ glob(const char * __restrict pattern, int flags,
+ * characters
+ */
+ static int
+-globexp1(const Char *pattern, glob_t *pglob, size_t *limit)
++globexp1(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
+ {
+ const Char* ptr = pattern;
+ int rv;
+
++ if ((pglob->gl_flags & GLOB_LIMIT) &&
++ limit->l_brace_cnt++ >= GLOB_LIMIT_BRACE) {
++ errno = 0;
++ return (GLOB_NOSPACE);
++ }
++
+ /* Protect a single {}, for find(1), like csh */
+ if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)
+ return glob0(pattern, pglob, limit);
+@@ -266,7 +293,8 @@ static int
+ * If it fails then it tries to glob the rest of the pattern and returns.
+ */
+ static int
+-globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv, size_t *limit)
++globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv,
++ struct glob_limit *limit)
+ {
+ int i;
+ Char *lm, *ls;
+@@ -436,7 +464,7 @@ globtilde(const Char *pattern, Char *patbuf, size_
+ * if things went well, nonzero if errors occurred.
+ */
+ static int
+-glob0(const Char *pattern, glob_t *pglob, size_t *limit)
++glob0(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
+ {
+ const Char *qpatnext;
+ int err;
+@@ -529,7 +557,7 @@ compare(const void *p, const void *q)
+ }
+
+ static int
+-glob1(Char *pattern, glob_t *pglob, size_t *limit)
++glob1(Char *pattern, glob_t *pglob, struct glob_limit *limit)
+ {
+ Char pathbuf[MAXPATHLEN];
+
+@@ -547,7 +575,7 @@ static int
+ */
+ static int
+ glob2(Char *pathbuf, Char *pathend, Char *pathend_last, Char *pattern,
+- glob_t *pglob, size_t *limit)
++ glob_t *pglob, struct glob_limit *limit)
+ {
+ struct stat sb;
+ Char *p, *q;
+@@ -563,6 +591,15 @@ glob2(Char *pathbuf, Char *pathend, Char *pathend_
+ if (g_lstat(pathbuf, &sb, pglob))
+ return(0);
+
++ if ((pglob->gl_flags & GLOB_LIMIT) &&
++ limit->l_stat_cnt++ >= GLOB_LIMIT_STAT) {
++ errno = 0;
++ if (pathend + 1 > pathend_last)
++ return (GLOB_ABORTED);
++ *pathend++ = SEP;
++ *pathend = EOS;
++ return (GLOB_NOSPACE);
++ }
+ if (((pglob->gl_flags & GLOB_MARK) &&
+ pathend[-1] != SEP) && (S_ISDIR(sb.st_mode)
+ || (S_ISLNK(sb.st_mode) &&
+@@ -606,7 +643,7 @@ glob2(Char *pathbuf, Char *pathend, Char *pathend_
+ static int
+ glob3(Char *pathbuf, Char *pathend, Char *pathend_last,
+ Char *pattern, Char *restpattern,
+- glob_t *pglob, size_t *limit)
++ glob_t *pglob, struct glob_limit *limit)
+ {
+ struct dirent *dp;
+ DIR *dirp;
+@@ -652,6 +689,19 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_
+ size_t clen;
+ mbstate_t mbs;
+
++ if ((pglob->gl_flags & GLOB_LIMIT) &&
++ limit->l_readdir_cnt++ >= GLOB_LIMIT_READDIR) {
++ errno = 0;
++ if (pathend + 1 > pathend_last)
++ err = GLOB_ABORTED;
++ else {
++ *pathend++ = SEP;
++ *pathend = EOS;
++ err = GLOB_NOSPACE;
++ }
++ break;
++ }
++
+ /* Initial DOT must be matched literally. */
+ if (dp->d_name[0] == DOT && *pattern != DOT)
+ continue;
+@@ -702,14 +752,15 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_
+ * gl_pathv points to (gl_offs + gl_pathc + 1) items.
+ */
+ static int
+-globextend(const Char *path, glob_t *pglob, size_t *limit)
++globextend(const Char *path, glob_t *pglob, struct glob_limit *limit)
+ {
+ char **pathv;
+ size_t i, newsize, len;
+ char *copy;
+ const Char *p;
+
+- if (*limit && pglob->gl_pathc > *limit) {
++ if ((pglob->gl_flags & GLOB_LIMIT) &&
++ pglob->gl_matchc > limit->l_path_lim) {
+ errno = 0;
+ return (GLOB_NOSPACE);
+ }
+@@ -737,6 +788,12 @@ static int
+ for (p = path; *p++;)
+ continue;
+ len = MB_CUR_MAX * (size_t)(p - path); /* XXX overallocation */
++ limit->l_string_cnt += len;
++ if ((pglob->gl_flags & GLOB_LIMIT) &&
++ limit->l_string_cnt >= GLOB_LIMIT_STRING) {
++ errno = 0;
++ return (GLOB_NOSPACE);
++ }
+ if ((copy = malloc(len)) != NULL) {
+ if (g_Ctoc(path, copy, len)) {
+ free(copy);
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-liblink.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-liblink.patch
new file mode 100644
index 000000000000..f8e470736c64
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-liblink.patch
@@ -0,0 +1,21 @@
+diff -uNr lib.ol/libproc/Makefile lib/libproc/Makefile
+--- lib.ol/libproc/Makefile 2011-11-02 14:02:17.000000000 +0000
++++ lib/libproc/Makefile 2011-11-02 14:03:09.000000000 +0000
+@@ -16,5 +16,6 @@
+ SHLIB_MAJOR= 2
+
+ WITHOUT_MAN=
++LDADD+=-lelf
+
+ .include <bsd.lib.mk>
+diff -uNr lib.ol/librtld_db/Makefile lib/librtld_db/Makefile
+--- lib.ol/librtld_db/Makefile 2011-11-02 14:02:13.000000000 +0000
++++ lib/librtld_db/Makefile 2011-11-02 14:04:00.000000000 +0000
+@@ -10,5 +10,7 @@
+ INCS= rtld_db.h
+
+ CFLAGS+= -I${.CURDIR}
++LDADD+=-lutil -lproc
++LDFLAGS+=-L${.OBJDIR}/../libutil -L${.OBJDIR}/../libproc
+
+ .include <bsd.lib.mk>
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-netware.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-netware.patch
new file mode 100644
index 000000000000..c1c2a0e04560
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-netware.patch
@@ -0,0 +1,11 @@
+diff -Nur lib.orig/libncp/Makefile lib/libncp/Makefile
+--- lib.orig/libncp/Makefile 2012-12-25 20:35:16.000000000 +0900
++++ lib/libncp/Makefile 2012-12-25 20:36:23.000000000 +0900
+@@ -6,6 +6,7 @@
+
+ DPADD= ${LIBIPX}
+ LDADD= -lipx
++LDFLAGS+=-L${.OBJDIR}/../libipx
+
+ SRCS= ncpl_subr.c ncpl_bind.c ncpl_queue.c ncpl_file.c ncpl_misc.c \
+ ncpl_net.c ncpl_rcfile.c ncpl_conn.c ncpl_nls.c ncpl_msg.c \
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-opieincludes.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-opieincludes.patch
new file mode 100644
index 000000000000..bf77a0a5219f
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.0-opieincludes.patch
@@ -0,0 +1,122 @@
+Fixes warnings like:
+/var/tmp/portage/sys-freebsd/freebsd-lib-9.0-r2/work/lib/libopie/../../contrib/opie/libopie/randomchallenge.c:43:5:
+warning: incompatible implicit declaration of built-in function ‘strcpy’
+
+diff -uNr contrib.old/opie/libopie/accessfile.c contrib/opie/libopie/accessfile.c
+--- contrib.old/opie/libopie/accessfile.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/accessfile.c 2012-05-25 09:12:34.000000000 -0400
+@@ -46,6 +46,7 @@
+ #ifdef DEBUG
+ #include <syslog.h>
+ #endif /* DEBUG */
++#include <ctype.h>
+
+ #include "opie.h"
+
+diff -uNr contrib.old/opie/libopie/generator.c contrib/opie/libopie/generator.c
+--- contrib.old/opie/libopie/generator.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/generator.c 2012-05-25 08:58:10.000000000 -0400
+@@ -50,6 +50,7 @@
+ #include <syslog.h>
+ #endif /* DEBUG */
+ #include "opie.h"
++#include <stdio.h>
+
+ static char *algids[] = { NULL, NULL, NULL, "sha1", "md4", "md5" };
+
+diff -uNr contrib.old/opie/libopie/lookup.c contrib/opie/libopie/lookup.c
+--- contrib.old/opie/libopie/lookup.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/lookup.c 2012-05-25 09:15:08.000000000 -0400
+@@ -14,6 +14,7 @@
+ #include "opie_cfg.h"
+ #include <stdio.h>
+ #include "opie.h"
++#include <string.h>
+
+ int opielookup FUNCTION((opie, principal), struct opie *opie AND char *principal)
+ {
+diff -uNr contrib.old/opie/libopie/newseed.c contrib/opie/libopie/newseed.c
+--- contrib.old/opie/libopie/newseed.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/newseed.c 2012-05-25 09:14:37.000000000 -0400
+@@ -36,6 +36,9 @@
+ #include <syslog.h>
+ #endif /* DEBUG */
+ #include "opie.h"
++#include <stdio.h>
++#include <stdlib.h>
++#include <time.h>
+
+ int opienewseed FUNCTION((seed), char *seed)
+ {
+diff -uNr contrib.old/opie/libopie/parsechallenge.c contrib/opie/libopie/parsechallenge.c
+--- contrib.old/opie/libopie/parsechallenge.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/parsechallenge.c 2012-05-25 09:15:54.000000000 -0400
+@@ -20,6 +20,8 @@
+ #include <string.h>
+ #endif /* HAVE_STRING_H */
+ #include "opie.h"
++#include <stdlib.h>
++#include <ctype.h>
+
+ struct algorithm {
+ char *name;
+diff -uNr contrib.old/opie/libopie/passwd.c contrib/opie/libopie/passwd.c
+--- contrib.old/opie/libopie/passwd.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/passwd.c 2012-05-25 09:13:45.000000000 -0400
+@@ -22,6 +22,7 @@
+
+ #include "opie_cfg.h"
+ #include "opie.h"
++#include <string.h>
+
+ int opiepasswd FUNCTION((old, flags, principal, n, seed, ks), struct opie *old AND int flags AND char *principal AND int n AND char *seed AND char *ks)
+ {
+diff -uNr contrib.old/opie/libopie/randomchallenge.c contrib/opie/libopie/randomchallenge.c
+--- contrib.old/opie/libopie/randomchallenge.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/randomchallenge.c 2012-05-25 09:00:27.000000000 -0400
+@@ -28,6 +28,9 @@
+
+ #include "opie_cfg.h"
+ #include "opie.h"
++#include <stdio.h>
++#include <string.h>
++#include <stdlib.h>
+
+ static char *algids[] = { 0, 0, 0, "sha1", "md4", "md5" };
+
+diff -uNr contrib.old/opie/libopie/verify.c contrib/opie/libopie/verify.c
+--- contrib.old/opie/libopie/verify.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/verify.c 2012-05-25 09:12:09.000000000 -0400
+@@ -25,6 +25,7 @@
+ #include <string.h>
+ #endif /* HAVE_STRING_H */
+ #include "opie.h"
++#include <ctype.h>
+
+ #define RESPONSE_STANDARD 0
+ #define RESPONSE_WORD 1
+diff -uNr contrib.old/opie/libopie/version.c contrib/opie/libopie/version.c
+--- contrib.old/opie/libopie/version.c 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/libopie/version.c 2012-05-25 09:13:15.000000000 -0400
+@@ -19,6 +19,8 @@
+ */
+ #include "opie_cfg.h"
+ #include "opie.h"
++#include <stdio.h>
++#include <stdlib.h>
+
+ VOIDRET opieversion FUNCTION_NOARGS
+ {
+diff -uNr contrib.old/opie/opie.h contrib/opie/opie.h
+--- contrib.old/opie/opie.h 2012-05-25 08:54:33.000000000 -0400
++++ contrib/opie/opie.h 2012-05-25 09:21:28.000000000 -0400
+@@ -158,6 +158,9 @@
+ int __opiereadrec __P((struct opie *));
+ int __opiewriterec __P((struct opie *));
+ int __opieparsechallenge __P((char *buffer, int *algorithm, int *sequence, char **seed, int *exts));
++VOIDRET opiehashlen FUNCTION((algorithm, in, out, n), int algorithm AND VOIDPTR in AND struct opie_otpkey *out AND int n);
++int opieinsecure FUNCTION_NOARGS;
++int opienewseed FUNCTION((seed), char *seed);
+ __END_DECLS
+
+ #define opiestrncpy(dst, src, n) \
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-.eh_frame_hdr-fix.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-.eh_frame_hdr-fix.patch
new file mode 100644
index 000000000000..fdb7e16f6e08
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-.eh_frame_hdr-fix.patch
@@ -0,0 +1,17 @@
+Fix "no .eh_frame_hdr table will be created" error.
+
+http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47829
+http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/4a0e0cd7377c45dc21d5c71bcab931b5e5727e74
+
+diff -Nur lib.orig/csu/i386-elf/Makefile lib/csu/i386-elf/Makefile
+--- lib.orig/csu/i386-elf/Makefile 2013-03-06 01:07:57.000000000 +0900
++++ lib/csu/i386-elf/Makefile 2013-03-06 01:10:09.000000000 +0900
+@@ -10,6 +10,8 @@
+ FILESDIR= ${LIBDIR}
+ CFLAGS+= -I${.CURDIR}/../common \
+ -I${.CURDIR}/../../libc/include
++CFLAGS+= -fno-omit-frame-pointer
++CFLAGS+= -fno-asynchronous-unwind-tables
+ CLEANFILES= ${FILES} crt1_c.o crt1_s.o gcrt1_c.o Scrt1_c.o
+ CLEANFILES+= crt1_c.s gcrt1_c.s Scrt1_c.s
+
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-aligned_alloc.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-aligned_alloc.patch
new file mode 100644
index 000000000000..97ac14160b87
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-aligned_alloc.patch
@@ -0,0 +1,51 @@
+Backport aligned_alloc for C++11 support.
+
+http://lists.freebsd.org/pipermail/svn-src-stable-9/2012-November/003313.html
+
+diff -uNr lib.old/libc/stdlib/Symbol.map lib/libc/stdlib/Symbol.map
+--- lib.old/libc/stdlib/Symbol.map 2013-05-24 17:03:55.000000000 -0400
++++ lib/libc/stdlib/Symbol.map 2013-05-24 17:06:03.000000000 -0400
+@@ -97,6 +97,7 @@
+ atoi_l;
+ atol_l;
+ atoll_l;
++ aligned_alloc;
+ at_quick_exit;
+ quick_exit;
+ strtod_l;
+diff -uNr lib.old/libc/stdlib/malloc.c lib/libc/stdlib/malloc.c
+--- lib.old/libc/stdlib/malloc.c 2013-05-24 17:03:55.000000000 -0400
++++ lib/libc/stdlib/malloc.c 2013-05-24 17:05:40.000000000 -0400
+@@ -6046,6 +6046,21 @@
+ }
+
+ void *
++aligned_alloc(size_t alignment, size_t size)
++{
++ void *memptr;
++ int ret;
++
++ ret = posix_memalign(&memptr, alignment, size);
++ if (ret != 0) {
++ errno = ret;
++ return (NULL);
++ }
++ return (memptr);
++}
++
++
++void *
+ calloc(size_t num, size_t size)
+ {
+ void *ret;
+diff -uNr includeold/stdlib.h include/stdlib.h
+--- includeold/stdlib.h 2013-05-24 17:03:46.000000000 -0400
++++ include/stdlib.h 2013-05-24 17:04:46.000000000 -0400
+@@ -155,6 +155,7 @@
+ * If we're in a mode greater than C99, expose C1x functions.
+ */
+ #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
++void * aligned_alloc(size_t, size_t);
+ _Noreturn void
+ quick_exit(int);
+ int at_quick_exit(void (*)(void));
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-rmgssapi.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-rmgssapi.patch
new file mode 100644
index 000000000000..62357e0830db
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-rmgssapi.patch
@@ -0,0 +1,16 @@
+--- include/Makefile.orig 2013-06-16 10:47:52.000000000 +0200
++++ include/Makefile 2013-06-16 10:47:37.000000000 +0200
+@@ -6,11 +6,11 @@
+ .include <bsd.own.mk>
+
+ CLEANFILES= osreldate.h version vers.c
++SUBDIR= arpa protocols rpcsvc rpc xlocale
+-SUBDIR= arpa gssapi protocols rpcsvc rpc xlocale
+ INCS= a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
+ db.h \
+ dirent.h dlfcn.h elf.h elf-hints.h err.h fmtmsg.h fnmatch.h fstab.h \
++ fts.h ftw.h getopt.h glob.h grp.h \
+- fts.h ftw.h getopt.h glob.h grp.h gssapi.h \
+ ieeefp.h ifaddrs.h \
+ inttypes.h iso646.h kenv.h langinfo.h libgen.h limits.h link.h \
+ locale.h malloc.h malloc_np.h memory.h monetary.h mpool.h mqueue.h \
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-add-nossp-cflags.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-add-nossp-cflags.patch
new file mode 100644
index 000000000000..00b39f750ec1
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-add-nossp-cflags.patch
@@ -0,0 +1,30 @@
+Please do not disable this patch.
+All commands will be non-executable.
+Abort trap: 6 (core dumped) is displayed...
+
+Details see Gentoo Bug #511698.
+https://bugs.gentoo.org/show_bug.cgi?id=511698
+
+diff --git a/lib/libc/Makefile b/lib/libc/Makefile
+index 1cc23b7..7dd458e 100644
+--- a/lib/libc/Makefile
++++ b/lib/libc/Makefile
+@@ -149,6 +149,6 @@ CWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}
+ # in the future to circumvent this.
+ SSP_CFLAGS:= ${SSP_CFLAGS:S/^-fstack-protector-all$/-fstack-protector/}
+ # Disable stack protection for SSP symbols.
+-SSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
++SSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/:C/^$/-fno-stack-protector/}
+ # Generate stack unwinding tables for cancellation points
+ CANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//}
+diff --git a/lib/csu/Makefile.inc b/lib/csu/Makefile.inc
+index f92d87d..7a3a2f3 100644
+--- a/lib/csu/Makefile.inc
++++ b/lib/csu/Makefile.inc
+@@ -1,5 +1,5 @@
+ # $FreeBSD: release/9.1.0/lib/csu/Makefile.inc 204757 2010-03-05 13:29:05Z uqs $
+
+-SSP_CFLAGS=
++SSP_CFLAGS= -fno-stack-protector
+
+ .include "../Makefile.inc"
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-bsdxml2expat.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-bsdxml2expat.patch
new file mode 100644
index 000000000000..1b4e79129bfc
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-bsdxml2expat.patch
@@ -0,0 +1,26 @@
+diff -ur lib/libgeom.old/Makefile lib/libgeom/Makefile
+--- lib/libgeom.old/Makefile 2011-07-10 14:23:51.000000000 +0000
++++ lib/libgeom/Makefile 2011-07-10 15:12:39.000000000 +0000
+@@ -13,8 +13,8 @@
+
+ WARNS?= 3
+
+-DPADD= ${LIBBSDXML} ${LIBSBUF}
+-LDADD= -lbsdxml -lsbuf
++DPADD= ${LIBSBUF}
++LDADD= -lexpat -lsbuf
+
+ MAN= libgeom.3
+
+diff -ur lib/libgeom.old/geom_xml2tree.c lib/libgeom/geom_xml2tree.c
+--- lib/libgeom.old/geom_xml2tree.c 2010-12-21 17:09:25.000000000 +0000
++++ lib/libgeom/geom_xml2tree.c 2011-07-10 15:12:52.000000000 +0000
+@@ -43,7 +43,7 @@
+ #include <sys/sbuf.h>
+ #include <sys/sysctl.h>
+ #include <err.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <libgeom.h>
+
+ struct mystate {
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-lib-includes.patch b/sys-freebsd/freebsd-lib/files/freebsd-lib-includes.patch
new file mode 100644
index 000000000000..c2cf1421ea9e
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-lib-includes.patch
@@ -0,0 +1,13 @@
+Fix headers dependencies so that they can be included alone.
+
+--- include/ifaddrs.h.old 2009-05-15 13:50:10 +0000
++++ include/ifaddrs.h 2009-05-15 13:50:23 +0000
+@@ -28,6 +28,8 @@
+ #ifndef _IFADDRS_H_
+ #define _IFADDRS_H_
+
++#include <sys/types.h>
++
+ struct ifaddrs {
+ struct ifaddrs *ifa_next;
+ char *ifa_name;
diff --git a/sys-freebsd/freebsd-lib/files/freebsd-sources-9.0-sysctluint.patch b/sys-freebsd/freebsd-lib/files/freebsd-sources-9.0-sysctluint.patch
new file mode 100644
index 000000000000..751a77c843bb
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/freebsd-sources-9.0-sysctluint.patch
@@ -0,0 +1,13 @@
+u_int is defined in sys/types.h
+makes header usable alone.
+
+--- sys/sys/sysctl.h.old 2012-05-25 11:08:53.000000000 -0400
++++ sys/sys/sysctl.h 2012-05-25 11:09:16.000000000 -0400
+@@ -788,6 +788,7 @@
+ struct sysctl_req *);
+ #else /* !_KERNEL */
+ #include <sys/cdefs.h>
++#include <sys/types.h> /* for u_int */
+
+ __BEGIN_DECLS
+ int sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
diff --git a/sys-freebsd/freebsd-lib/files/ftpd.pamd b/sys-freebsd/freebsd-lib/files/ftpd.pamd
new file mode 100644
index 000000000000..8e9082373f8f
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/ftpd.pamd
@@ -0,0 +1,8 @@
+# PAM configuration for the "ftpd" service
+#
+
+auth include system-auth
+account include system-auth
+password include system-auth
+session include system-auth
+
diff --git a/sys-freebsd/freebsd-lib/files/libusb-1.0.pc.in b/sys-freebsd/freebsd-lib/files/libusb-1.0.pc.in
new file mode 100644
index 000000000000..058ecb4384a3
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/libusb-1.0.pc.in
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=@LIBDIR@
+includedir=${prefix}/include
+
+Name: libusb
+Description: USB access library (FreeBSD version)
+Version: 1.0.1
+Libs: -L${libdir} -lusb
+Cflags: -I${includedir}
+
diff --git a/sys-freebsd/freebsd-lib/files/libusb.pc.in b/sys-freebsd/freebsd-lib/files/libusb.pc.in
new file mode 100644
index 000000000000..f63c6e399816
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/libusb.pc.in
@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=@LIBDIR@
+includedir=${prefix}/include
+
+Name: libusb
+Description: USB access library (FreeBSD version)
+Version: 0.1.12
+Libs: -L${libdir} -lusb
+Cflags: -I${includedir}
+
diff --git a/sys-freebsd/freebsd-lib/files/rquotad.xinetd b/sys-freebsd/freebsd-lib/files/rquotad.xinetd
new file mode 100644
index 000000000000..876cd16c53c2
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/rquotad.xinetd
@@ -0,0 +1,11 @@
+service rquotad
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.rquotad
+ rpc_version = 1
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-lib/files/rstatd.xinetd b/sys-freebsd/freebsd-lib/files/rstatd.xinetd
new file mode 100644
index 000000000000..ba1b819851eb
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/rstatd.xinetd
@@ -0,0 +1,11 @@
+service rstatd
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.rstatd
+ rpc_version = 1-3
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-lib/files/rusersd.xinetd b/sys-freebsd/freebsd-lib/files/rusersd.xinetd
new file mode 100644
index 000000000000..5cbe091881e8
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/rusersd.xinetd
@@ -0,0 +1,11 @@
+service rusersd
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.rusersd
+ rpc_version = 1-2
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-lib/files/sprayd.xinetd b/sys-freebsd/freebsd-lib/files/sprayd.xinetd
new file mode 100644
index 000000000000..7be55771ac22
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/sprayd.xinetd
@@ -0,0 +1,11 @@
+service sprayd
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.sprayd
+ rpc_version = 1
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-lib/files/walld.xinetd b/sys-freebsd/freebsd-lib/files/walld.xinetd
new file mode 100644
index 000000000000..800b84fa21e6
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/files/walld.xinetd
@@ -0,0 +1,11 @@
+service walld
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.rwalld
+ rpc_version = 1
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-lib/freebsd-lib-10.3-r3.ebuild b/sys-freebsd/freebsd-lib/freebsd-lib-10.3-r3.ebuild
new file mode 100644
index 000000000000..96b625022684
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/freebsd-lib-10.3-r3.ebuild
@@ -0,0 +1,648 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic multilib toolchain-funcs eutils multibuild multilib-build
+
+DESCRIPTION="FreeBSD's base system libraries"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "EN-16:06/libc.patch"
+ "SA-16:37/libc.patch"
+ "SA-16:38/bhyve.patch" )
+
+# Crypto is needed to have an internal OpenSSL header
+# sys is needed for libalias, probably we can just extract that instead of
+# extracting the whole tarball
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ lib/
+ contrib/
+ crypto/
+ libexec/
+ etc/
+ include/
+ usr.sbin/
+ gnu/
+ secure/
+"
+
+if [ "${CATEGORY#*cross-}" = "${CATEGORY}" ]; then
+ RDEPEND="ssl? ( dev-libs/openssl:0= )
+ hesiod? ( net-dns/hesiod )
+ kerberos? ( app-crypt/heimdal )
+ usb? ( !dev-libs/libusb )
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )
+ >=dev-libs/expat-2.0.1
+ >=dev-util/dialog-1.2.20150225
+ =sys-freebsd/freebsd-libexec-${RV}*
+ !sys-libs/libutempter
+ !dev-libs/libelf
+ !dev-libs/libexecinfo
+ !dev-libs/libiconv
+ !sys-freebsd/freebsd-headers"
+ DEPEND="${RDEPEND}
+ >=sys-devel/flex-2.5.31-r2
+ >=sys-freebsd/freebsd-sources-10.3-r5"
+ RDEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-share-${RV}*
+ >=virtual/libiconv-0-r2"
+else
+ EXTRACTONLY+="sys/ "
+fi
+
+DEPEND="${DEPEND}
+ userland_GNU? ( sys-apps/mtree )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/lib"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [ "${CTARGET}" = "${CHOST}" -a "${CATEGORY#*cross-}" != "${CATEGORY}" ]; then
+ export CTARGET=${CATEGORY/cross-}
+fi
+
+IUSE="atm bluetooth ssl hesiod ipv6 kerberos usb netware
+ build crosscompile_opts_headers-only zfs
+ userland_GNU userland_BSD"
+
+QA_DT_NEEDED="lib/libc.so.7 usr/lib32/libc.so.7"
+
+pkg_setup() {
+ # Add the required source files.
+ use build && EXTRACTONLY+="sys/ "
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ [ -c /dev/zero ] || \
+ die "You forgot to mount /dev; the compiled libc would break."
+
+ if ! use ssl && use kerberos; then
+ eerror "If you want kerberos support you need to enable ssl support, too."
+ fi
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use hesiod || mymakeopts="${mymakeopts} WITHOUT_HESIOD= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= WITHOUT_GSSAPI= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_CLANG= WITHOUT_LIBCPLUSPLUS= WITHOUT_LDNS= WITHOUT_UNBOUND= "
+
+ if [ "${CTARGET}" != "${CHOST}" ]; then
+ mymakeopts="${mymakeopts} MACHINE=$(tc-arch-kernel ${CTARGET})"
+ mymakeopts="${mymakeopts} MACHINE_ARCH=$(tc-arch-kernel ${CTARGET})"
+ fi
+}
+
+PATCHES=(
+ "${FILESDIR}/${PN}-6.0-pmc.patch"
+ "${FILESDIR}/${PN}-6.1-csu.patch"
+ "${FILESDIR}/${PN}-10.0-liblink.patch"
+ "${FILESDIR}/${PN}-10.2-liblink.patch"
+ "${FILESDIR}/${PN}-10.0-atfcxx.patch"
+ "${FILESDIR}/${PN}-10.3-libusb.patch"
+ "${FILESDIR}/${PN}-10.0-libproc-libcxx.patch"
+ "${FILESDIR}/${PN}-10.2-bsdxml2expat.patch"
+ "${FILESDIR}/${PN}-9.0-bluetooth.patch"
+ "${FILESDIR}/${PN}-9.1-.eh_frame_hdr-fix.patch"
+ "${FILESDIR}/${PN}-add-nossp-cflags.patch"
+ )
+# Here we disable and remove source which we don't need or want
+# In order:
+# - ncurses stuff
+# - libexpat creates a bsdxml library which is the same as expat
+# - archiving libraries (have their own ebuild)
+# - sendmail libraries (they are installed by sendmail)
+# - SNMP library and dependency (have their own ebuilds)
+# - libstand: static library, 32bits on amd64 used for boot0, we build it from
+# boot0 instead.
+#
+# The rest are libraries we already have somewhere else because
+# they are contribution.
+REMOVE_SUBDIRS="ncurses \
+ libexpat \
+ libz libbz2 libarchive liblzma \
+ libsm libsmdb libsmutil \
+ libbegemot libbsnmp \
+ libpam libpcap libwrap libmagic \
+ libcom_err
+ libedit
+ libstand
+ libgssapi"
+
+# Are we building a cross-compiler?
+is_crosscompile() {
+ [ "${CATEGORY#*cross-}" != "${CATEGORY}" ]
+}
+
+src_prepare() {
+ # gcc-5.0 or later, Workaround for critical issue. bug 573358.
+ use x86-fbsd && [[ "$(gcc-major-version)" -ge 5 ]] && replace-flags -O? -O1
+
+ sed -i.bak -e 's:-o/dev/stdout:-t:' "${S}/libc/net/Makefile.inc"
+
+ # Upstream Display Managers default to using VT7
+ # We should make FreeBSD allow this by default
+ local x=
+ for x in "${WORKDIR}"/etc/etc.*/ttys ; do
+ sed -i.bak \
+ -e '/ttyv5[[:space:]]/ a\
+# Display Managers default to VT7.\
+# If you use the xdm init script, keep ttyv6 commented out\
+# unless you force a different VT for the DM being used.' \
+ -e '/^ttyv[678][[:space:]]/ s/^/# /' "${x}" \
+ || die "Failed to sed ${x}"
+ rm "${x}".bak
+ done
+
+ # This one is here because it also
+ # patches "${WORKDIR}/include"
+ cd "${WORKDIR}"
+ epatch "${FILESDIR}/${PN}-includes.patch"
+ epatch "${FILESDIR}/${PN}-8.0-gcc45.patch"
+ epatch "${FILESDIR}/${PN}-9.0-opieincludes.patch"
+
+ # Don't install the hesiod man page or header
+ rm "${WORKDIR}"/include/hesiod.h || die
+ sed -i.bak -e 's:hesiod.h::' "${WORKDIR}"/include/Makefile || die
+ sed -i.bak -e 's:hesiod.c::' -e 's:hesiod.3::' \
+ "${WORKDIR}"/lib/libc/net/Makefile.inc || die
+
+ # Fix the Makefiles of these few libraries that will overwrite our LDADD.
+ cd "${S}"
+ for dir in libradius libtacplus libcam libdevstat libfetch libgeom libmemstat libopie \
+ libsmb libprocstat libulog; do sed -i.bak -e 's:LDADD=:LDADD+=:g' "${dir}/Makefile" || \
+ die "Problem fixing \"${dir}/Makefile"
+ done
+ # Call LD with LDFLAGS, rename them to RAW_LDFLAGS
+ sed -e 's/LDFLAGS/RAW_LDFLAGS/g' \
+ -i "${S}/csu/i386-elf/Makefile" \
+ -i "${S}/csu/ia64/Makefile" || die
+
+ if install --version 2> /dev/null | grep -q GNU; then
+ sed -i.bak -e 's:${INSTALL} -C:${INSTALL}:' "${WORKDIR}/include/Makefile"
+ fi
+
+ # Try to fix sed calls for GNU sed. Do it only with GNU userland and force
+ # BSD's sed on BSD.
+ cd "${S}"
+ if [[ ${CBUILD:-${CHOST}} != *bsd* ]]; then
+ find . -name Makefile -exec sed -ibak 's/sed -i /sed -i/' {} \;
+ sed -i -e 's/-i ""/-i""/' "${S}/csu/Makefile.inc" || die
+ fi
+
+ if use build; then
+ cd "${WORKDIR}"
+ # This patch has to be applied on ${WORKDIR}/sys, so we do it here since it
+ # shouldn't be a symlink to /usr/src/sys (which should be already patched)
+ epatch "${FILESDIR}"/freebsd-sources-9.0-sysctluint.patch
+ return 0
+ fi
+
+ if ! is_crosscompile ; then
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ ln -s "${SYSROOT}/usr/src/sys" "${WORKDIR}/sys" || die "Couldn't make sys symlink!"
+ fi
+ else
+ sed -i.bak -e "s:/usr/include:/usr/${CTARGET}/usr/include:g" \
+ "${S}/libc/rpc/Makefile.inc" \
+ "${S}/libc/yp/Makefile.inc"
+ fi
+}
+
+bootstrap_lib() {
+ for i ; do
+ cd "${WORKDIR}/${i}" || die "missing ${i}"
+ freebsd_src_compile
+ append-ldflags "-L${MAKEOBJDIRPREFIX}/${WORKDIR}/${i}"
+ done
+}
+
+get_csudir() {
+ if [ -d "${WORKDIR}/lib/csu/$1-elf" ]; then
+ echo "lib/csu/$1-elf"
+ else
+ echo "lib/csu/$1"
+ fi
+}
+
+bootstrap_csu() {
+ local csudir="$(get_csudir $(tc-arch-kernel ${CTARGET}))"
+ export RAW_LDFLAGS=$(raw-ldflags)
+ bootstrap_lib "${csudir}"
+
+ CFLAGS="${CFLAGS} -B ${MAKEOBJDIRPREFIX}/${WORKDIR}/${csudir}"
+ append-ldflags "-B ${MAKEOBJDIRPREFIX}/${WORKDIR}/${csudir}"
+
+ bootstrap_lib "gnu/lib/csu"
+
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+ for i in *.So ; do
+ ln -s $i ${i%.So}S.o
+ done
+ CFLAGS="${CFLAGS} -B ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+ append-ldflags "-B ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+}
+
+# Compile libssp_nonshared.a and add it's path to LDFLAGS.
+bootstrap_libssp_nonshared() {
+ bootstrap_lib "gnu/lib/libssp/libssp_nonshared"
+ export LDADD="-lssp_nonshared"
+}
+
+bootstrap_libgcc() {
+ bootstrap_lib "lib/libcompiler_rt"
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libcompiler_rt" || die
+ ln -s libcompiler_rt.a libgcc.a || die
+
+ bootstrap_lib "lib/libc" "gnu/lib/libgcc"
+}
+
+bootstrap_libthr() {
+ bootstrap_lib "lib/libthr"
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libthr" || die
+ ln -s libthr.so libpthread.so
+}
+
+# What to build for a cross-compiler.
+# We also need the csu but this has to be handled separately.
+CROSS_SUBDIRS="lib/libc lib/msun gnu/lib/libssp/libssp_nonshared lib/libthr lib/libutil lib/librt lib/libc_nonshared"
+
+# What to build for non-default ABIs.
+NON_NATIVE_SUBDIRS="${CROSS_SUBDIRS} gnu/lib/csu lib/libcompiler_rt gnu/lib/libgcc lib/libmd lib/libcrypt lib/libsbuf lib/libcam lib/libelf lib/libiconv_modules"
+
+# Subdirs for a native build:
+NATIVE_SUBDIRS="lib gnu/lib/libssp/libssp_nonshared gnu/lib/libregex gnu/lib/csu gnu/lib/libgcc lib/libiconv_modules"
+
+# Is my $ABI native ?
+is_native_abi() {
+ is_crosscompile && return 1
+ multilib_is_native_abi
+}
+
+# Do we need to bootstrap the csu and libssp_nonshared?
+need_bootstrap() {
+ is_crosscompile || use build || { ! is_native_abi && ! has_version '>=sys-freebsd/freebsd-lib-9.1-r8[multilib]' && ! has_version ">=sys-freebsd/freebsd-lib-9.1-r11[${MULTILIB_USEDEP}]" ; } || has_version "<${CATEGORY}/${P}"
+}
+
+# Get the subdirs we are building.
+get_subdirs() {
+ local ret=""
+ if is_native_abi ; then
+ # If we are building for the native ABI, build everything
+ ret="${NATIVE_SUBDIRS}"
+ elif is_crosscompile ; then
+ # With a cross-compiler we only build the very core parts.
+ ret="${CROSS_SUBDIRS}"
+ if [ "${EBUILD_PHASE}" = "install" ]; then
+ # Add the csu dir first when installing. We treat it separately for
+ # compiling.
+ ret="$(get_csudir $(tc-arch-kernel ${CTARGET})) ${ret}"
+ fi
+ else
+ # For the non-native ABIs we only build the csu parts and very core
+ # libraries for now.
+ ret="${NON_NATIVE_SUBDIRS} $(get_csudir $(tc-arch-kernel ${CHOST}))"
+ fi
+ echo "${ret}"
+}
+
+# Bootstrap the core libraries and setup the flags so that the other parts can
+# build against it.
+do_bootstrap() {
+ einfo "Bootstrapping on ${CHOST} for ${CTARGET}"
+ if ! is_crosscompile ; then
+ # Pre-install headers, but not when building a cross-compiler since we
+ # assume they have been installed in the previous pass.
+ einfo "Pre-installing includes in include_proper_${ABI}"
+ mkdir "${WORKDIR}/include_proper_${ABI}" || die
+ CTARGET="${CHOST}" install_includes "/include_proper_${ABI}"
+ CFLAGS="${CFLAGS} -isystem ${WORKDIR}/include_proper_${ABI}"
+ CXXFLAGS="${CXXFLAGS} -isystem ${WORKDIR}/include_proper_${ABI}"
+ mymakeopts="${mymakeopts} RPCDIR=${WORKDIR}/include_proper_${ABI}/rpcsvc"
+ fi
+ bootstrap_csu
+ bootstrap_libssp_nonshared
+ is_crosscompile && bootstrap_lib "lib/libc"
+ is_crosscompile || is_native_abi || bootstrap_libgcc
+ is_native_abi || bootstrap_libthr
+}
+
+# Compile it. Assume we have the toolchain setup correctly.
+do_compile() {
+ # Bootstrap if needed, otherwise assume the system headers are in
+ # /usr/include.
+ if need_bootstrap ; then
+ do_bootstrap
+ else
+ CFLAGS="${CFLAGS} -isystem /usr/include"
+ CXXFLAGS="${CXXFLAGS} -isystem /usr/include"
+ fi
+
+ export RAW_LDFLAGS=$(raw-ldflags)
+
+ # Everything is now setup, build it!
+ for i in $(get_subdirs) ; do
+ einfo "Building in ${i}... with CC=${CC} and CFLAGS=${CFLAGS}"
+ cd "${WORKDIR}/${i}/" || die "missing ${i}."
+ freebsd_src_compile || die "make ${i} failed"
+ done
+}
+
+src_compile() {
+ # Does not work with GNU sed
+ # Force BSD's sed on BSD.
+ if [[ ${CBUILD:-${CHOST}} == *bsd* ]]; then
+ export ESED=/usr/bin/sed
+ unalias sed
+ fi
+
+ use usb && export NON_NATIVE_SUBDIRS="${NON_NATIVE_SUBDIRS} lib/libusb lib/libusbhid"
+
+ cd "${WORKDIR}/include"
+ $(freebsd_get_bmake) CC="$(tc-getCC)" || die "make include failed"
+
+ use crosscompile_opts_headers-only && return 0
+
+ # Bug #270098
+ append-flags $(test-flags -fno-strict-aliasing)
+
+ # Bug #324445
+ append-flags $(test-flags -fno-strict-overflow)
+
+ # strip flags and do not do it later, we only add safe, and in fact
+ # needed flags after all
+ strip-flags
+ export NOFLAGSTRIP=yes
+ if is_crosscompile ; then
+ export YACC='yacc -by'
+ CHOST=${CTARGET} tc-export CC LD CXX RANLIB
+ mymakeopts="${mymakeopts} NLS="
+ CFLAGS="${CFLAGS} -isystem /usr/${CTARGET}/usr/include"
+ CXXFLAGS="${CXXFLAGS} -isystem /usr/${CTARGET}/usr/include"
+ append-ldflags "-L${WORKDIR}/${CHOST}/${WORKDIR}/lib/libc"
+ fi
+
+ if is_crosscompile ; then
+ do_compile
+ else
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper do_compile
+ fi
+}
+
+gen_libc_ldscript() {
+ # Parameters:
+ # $1 = target libdir
+ # $2 = source libc dir
+ # $3 = source libssp_nonshared dir
+
+ # Clear the symlink.
+ rm -f "${DESTDIR}/$2/libc.so" || die
+
+ # Move the library if needed
+ if [ "$1" != "$2" ] ; then
+ mv "${DESTDIR}/$2/libc.so.7" "${DESTDIR}/$1/" || die
+ fi
+
+ # Generate libc.so ldscript for inclusion of libssp_nonshared.a when linking
+ # this is done to avoid having to touch gcc spec file as it is currently
+ # done on FreeBSD upstream, mostly because their binutils aren't able to
+ # cope with linker scripts yet.
+ # Taken from toolchain-funcs.eclass:
+ local output_format
+ output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
+ [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
+
+ # iconv symbol provided by libc_nonshared.a.
+ # http://svnweb.freebsd.org/base?view=revision&amp;revision=258283
+ cat > "${DESTDIR}/$2/libc.so" <<-END_LDSCRIPT
+/* GNU ld script
+ SSP (-fstack-protector) requires __stack_chk_fail_local to be local.
+ GCC invokes this symbol in a non-PIC way, which results in TEXTRELs if
+ this symbol was provided by a shared libc. So we link in
+ libssp_nonshared.a from here.
+ */
+${output_format}
+GROUP ( /$1/libc.so.7 /$3/libc_nonshared.a /$3/libssp_nonshared.a )
+END_LDSCRIPT
+}
+
+header_list=""
+
+move_header() {
+ local dirname=$(dirname ${1})
+ local filename=$(basename ${1})
+
+ if [ ! -d "${dirname}/${ABI}" ] ; then
+ mkdir "${dirname}/${ABI}" || die
+ fi
+
+ mv "${1}" "${dirname}/${ABI}/" || die
+
+ export header_list="${header_list} ${1}"
+}
+
+make_header_template() {
+ cat <<-END_HEADER
+/*
+ * Wrapped header for multilib support.
+ * See the real headers included below.
+ */
+
+#if defined(__x86_64__)
+ @ABI_amd64_fbsd@
+#elif defined(__i386__)
+ @ABI_x86_fbsd@
+#else
+ @ABI_${DEFAULT_ABI}@
+#endif
+END_HEADER
+}
+
+wrap_header() {
+ local dirname=$(dirname ${1})
+ local filename=$(basename ${1})
+
+ if [ -n "${dirname#.}" ] ; then
+ dirname="${dirname}/${2}"
+ else
+ dirname="${2}"
+ fi
+
+ if [ -f "${dirname}/${filename}" ] ; then
+ sed -e "s:@ABI_${2}@:#include <${dirname}/${filename}>:" ${1}
+ else
+ cat ${1}
+ fi
+}
+
+wrap_header_end() {
+ sed -e "s:@ABI_.*@:#error \"Sorry, no support for your ABI.\":" ${1}
+}
+
+do_install() {
+ if is_crosscompile ; then
+ INCLUDEDIR="/usr/${CTARGET}/usr/include"
+ else
+ INCLUDEDIR="/usr/include"
+ fi
+
+ dodir ${INCLUDEDIR}
+ CTARGET="${CHOST}" \
+ install_includes ${INCLUDEDIR}
+
+ is_crosscompile && use crosscompile_opts_headers-only && return 0
+
+ # Install a libusb.pc for better compat with Linux's libusb
+ if use usb ; then
+ dodir /usr/$(get_libdir)/pkgconfig
+ sed -i.bkp "s:^libdir=.*:libdir=/usr/$(get_libdir):g" "${S}"/libusb/libusb-*.pc
+ fi
+
+ for i in $(get_subdirs) ; do
+ if [[ ${i} != *libiconv_modules* ]] ; then
+ einfo "Installing in ${i}..."
+ cd "${WORKDIR}/${i}/" || die "missing ${i}."
+ freebsd_src_install || die "Install ${i} failed"
+ fi
+ done
+
+ if ! is_crosscompile; then
+ local mymakeopts_save="${mymakeopts}"
+ mymakeopts="${mymakeopts} SHLIBDIR=/usr/$(get_libdir)/i18n LIBDIR=/usr/$(get_libdir)/i18n"
+
+ einfo "Installing in lib/libiconv_modules..."
+ cd "${WORKDIR}/lib/libiconv_modules/" || die "missing libiconv_modules."
+ freebsd_src_install || die "Install lib/libiconv_modules failed"
+
+ mymakeopts="${mymakeopts_save}"
+ fi
+
+ if ! is_crosscompile ; then
+ if ! multilib_is_native_abi ; then
+ DESTDIR="${D}" gen_libc_ldscript "usr/$(get_libdir)" "usr/$(get_libdir)" "usr/$(get_libdir)"
+ else
+ dodir "$(get_libdir)"
+ DESTDIR="${D}" gen_libc_ldscript "$(get_libdir)" "usr/$(get_libdir)" "usr/$(get_libdir)"
+ fi
+ else
+ CHOST=${CTARGET} DESTDIR="${D}/usr/${CTARGET}/" gen_libc_ldscript "usr/lib" "usr/lib" "usr/lib"
+ # We're done for the cross libc here.
+ return 0
+ fi
+
+ # Generate ldscripts for core libraries that will go in /
+ multilib_is_native_abi && \
+ gen_usr_ldscript -a alias cam geom ipsec jail kiconv \
+ kvm m md procstat sbuf thr ufs util elf
+
+ if [[ ${#MULTIBUILD_VARIANTS[@]} -gt 1 ]] ; then
+ cd "${D}/usr/include"
+ for i in machine/*.h fenv.h ; do
+ move_header ${i}
+ done
+ if multilib_is_native_abi ; then
+ # Supposedly the last one!
+ local uniq_headers="$(echo ${header_list} | tr ' ' '\n' | sort | uniq | tr '\n' ' ')"
+ for j in ${uniq_headers} ; do
+ make_header_template > ${j}
+ for i in $(get_all_abis) ; do
+ wrap_header ${j} ${i} > ${j}.new
+ cp ${j}.new ${j}
+ rm -f ${j}.new
+ done
+ wrap_header_end ${j} > ${j}.new
+ cp ${j}.new ${j}
+ rm -f ${j}.new
+ done
+ fi
+ fi
+}
+
+src_install() {
+ if is_crosscompile ; then
+ einfo "Installing for ${CTARGET} in ${CHOST}.."
+ # From this point we need to force: get stripped with the correct tools,
+ # get tc-arch-kernel to return the right value, etc.
+ export CHOST=${CTARGET}
+
+ mymakeopts="${mymakeopts} NO_MAN= \
+ INCLUDEDIR=/usr/${CTARGET}/usr/include \
+ SHLIBDIR=/usr/${CTARGET}/usr/lib \
+ LIBDIR=/usr/${CTARGET}/usr/lib"
+
+ dosym "usr/include" "/usr/${CTARGET}/sys-include"
+ do_install
+
+ return 0
+ else
+ export STRIP_MASK="*/usr/lib*/*crt*.o"
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper do_install
+ fi
+
+ cd "${WORKDIR}/etc/"
+ insinto /etc
+ doins nls.alias mac.conf netconfig
+
+ # Install ttys file
+ local MACHINE="$(tc-arch-kernel)"
+ doins "etc.${MACHINE}"/*
+}
+
+install_includes()
+{
+ local INCLUDEDIR="$1"
+
+ # The idea is to be called from either install or unpack.
+ # During unpack it's required to install them as portage's user.
+ if [[ "${EBUILD_PHASE}" == "install" ]]; then
+ local DESTDIR="${D}"
+ BINOWN="root"
+ BINGRP="wheel"
+ else
+ local DESTDIR="${WORKDIR}"
+ [[ -z "${USER}" ]] && USER="portage"
+ BINOWN="${USER}"
+ [[ -z "${GROUPS}" ]] && GROUPS="portage"
+ BINGRP="${GROUPS}"
+ fi
+
+ # Must exist before we use it.
+ [[ -d "${DESTDIR}${INCLUDEDIR}" ]] || die "dodir or mkdir ${INCLUDEDIR} before using install_includes."
+ cd "${WORKDIR}/include"
+
+ local MACHINE="$(tc-arch-kernel)"
+
+ einfo "Installing includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ $(freebsd_get_bmake) installincludes \
+ MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE} \
+ DESTDIR="${DESTDIR}" \
+ INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" \
+ WITHOUT_GSSAPI= || die "install_includes() failed"
+ einfo "includes installed ok."
+ EXTRA_INCLUDES="lib/librtld_db lib/libutil lib/msun gnu/lib/libregex"
+ for i in $EXTRA_INCLUDES; do
+ einfo "Installing $i includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ cd "${WORKDIR}/$i" || die
+ $(freebsd_get_bmake) installincludes DESTDIR="${DESTDIR}" \
+ MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE} \
+ INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" || die "problem installing $i includes."
+ einfo "$i includes installed ok."
+ done
+}
diff --git a/sys-freebsd/freebsd-lib/freebsd-lib-11.0-r1.ebuild b/sys-freebsd/freebsd-lib/freebsd-lib-11.0-r1.ebuild
new file mode 100644
index 000000000000..24c62627e2a2
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/freebsd-lib-11.0-r1.ebuild
@@ -0,0 +1,644 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic multilib toolchain-funcs eutils multibuild multilib-build
+
+DESCRIPTION="FreeBSD's base system libraries"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "SA-16:37/libc.patch"
+ "SA-16:38/bhyve.patch" )
+
+# Crypto is needed to have an internal OpenSSL header
+# sys is needed for libalias, probably we can just extract that instead of
+# extracting the whole tarball
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ lib/
+ contrib/
+ crypto/
+ libexec/
+ etc/
+ include/
+ usr.sbin/
+ gnu/
+ secure/
+"
+
+if [ "${CATEGORY#*cross-}" = "${CATEGORY}" ]; then
+ RDEPEND="ssl? ( dev-libs/openssl:0= )
+ hesiod? ( net-dns/hesiod )
+ kerberos? ( app-crypt/heimdal )
+ usb? ( !dev-libs/libusb )
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )
+ >=dev-libs/expat-2.0.1
+ >=dev-util/dialog-1.2.20150225
+ =sys-freebsd/freebsd-libexec-${RV}*
+ !sys-libs/libutempter
+ !dev-libs/libelf
+ !dev-libs/libexecinfo
+ !dev-libs/libiconv
+ !sys-freebsd/freebsd-headers"
+ DEPEND="${RDEPEND}
+ >=sys-devel/flex-2.5.31-r2
+ =sys-freebsd/freebsd-sources-${RV}*"
+ RDEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-share-${RV}*
+ >=virtual/libiconv-0-r2"
+else
+ EXTRACTONLY+="sys/ "
+fi
+
+DEPEND="${DEPEND}
+ userland_GNU? ( sys-apps/mtree )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/lib"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [ "${CTARGET}" = "${CHOST}" -a "${CATEGORY#*cross-}" != "${CATEGORY}" ]; then
+ export CTARGET=${CATEGORY/cross-}
+fi
+
+IUSE="atm bluetooth ssl hesiod ipv6 kerberos usb netware
+ build crosscompile_opts_headers-only zfs
+ userland_GNU userland_BSD"
+
+QA_DT_NEEDED="lib/libc.so.7 usr/lib32/libc.so.7"
+
+pkg_setup() {
+ # Add the required source files.
+ use build && EXTRACTONLY+="sys/ "
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ [ -c /dev/zero ] || \
+ die "You forgot to mount /dev; the compiled libc would break."
+
+ if ! use ssl && use kerberos; then
+ eerror "If you want kerberos support you need to enable ssl support, too."
+ fi
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use hesiod || mymakeopts="${mymakeopts} WITHOUT_HESIOD= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= WITHOUT_GSSAPI= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_CLANG= WITHOUT_LIBCPLUSPLUS= WITHOUT_LDNS= WITHOUT_UNBOUND= "
+
+ if [ "${CTARGET}" != "${CHOST}" ]; then
+ mymakeopts="${mymakeopts} MACHINE=$(tc-arch-kernel ${CTARGET})"
+ mymakeopts="${mymakeopts} MACHINE_ARCH=$(tc-arch-kernel ${CTARGET})"
+ fi
+}
+
+PATCHES=(
+ "${FILESDIR}/${PN}-6.0-pmc.patch"
+ "${FILESDIR}/${PN}-10.0-atfcxx.patch"
+ "${FILESDIR}/${PN}-9.0-bluetooth.patch"
+ "${FILESDIR}/${PN}-11.0-workaround.patch"
+ "${FILESDIR}/${PN}-11.0-bsdxml2expat.patch"
+ "${FILESDIR}/${PN}-11.0-libsysdecode.patch"
+ "${FILESDIR}/${PN}-11.0-libproc-libcxx.patch"
+ "${FILESDIR}/${PN}-add-nossp-cflags.patch"
+ )
+# Here we disable and remove source which we don't need or want
+# In order:
+# - ncurses stuff
+# - libexpat creates a bsdxml library which is the same as expat
+# - archiving libraries (have their own ebuild)
+# - sendmail libraries (they are installed by sendmail)
+# - SNMP library and dependency (have their own ebuilds)
+# - libstand: static library, 32bits on amd64 used for boot0, we build it from
+# boot0 instead.
+#
+# The rest are libraries we already have somewhere else because
+# they are contribution.
+REMOVE_SUBDIRS="ncurses \
+ libexpat \
+ libz libbz2 libarchive liblzma \
+ libsm libsmdb libsmutil \
+ libbegemot libbsnmp \
+ libpam libpcap libwrap libmagic \
+ libcom_err
+ libedit
+ libstand
+ libgssapi"
+
+# Are we building a cross-compiler?
+is_crosscompile() {
+ [ "${CATEGORY#*cross-}" != "${CATEGORY}" ]
+}
+
+src_prepare() {
+ # gcc-5.0 or later, Workaround for critical issue. bug 573358.
+ use x86-fbsd && [[ "$(gcc-major-version)" -ge 5 ]] && replace-flags -O? -O1
+
+ sed -i.bak -e 's:-o/dev/stdout:-t:' "${S}/libc/net/Makefile.inc"
+
+ # Upstream Display Managers default to using VT7
+ # We should make FreeBSD allow this by default
+ local x=
+ for x in "${WORKDIR}"/etc/etc.*/ttys ; do
+ sed -i.bak \
+ -e '/ttyv5[[:space:]]/ a\
+# Display Managers default to VT7.\
+# If you use the xdm init script, keep ttyv6 commented out\
+# unless you force a different VT for the DM being used.' \
+ -e '/^ttyv[678][[:space:]]/ s/^/# /' "${x}" \
+ || die "Failed to sed ${x}"
+ rm "${x}".bak
+ done
+
+ # This one is here because it also
+ # patches "${WORKDIR}/include"
+ cd "${WORKDIR}"
+ epatch "${FILESDIR}/${PN}-includes.patch"
+
+ # Don't install the hesiod man page or header
+ rm "${WORKDIR}"/include/hesiod.h || die
+ sed -i.bak -e 's:hesiod.h::' "${WORKDIR}"/include/Makefile || die
+ sed -i.bak -e 's:hesiod.c::' -e 's:hesiod.3::' \
+ "${WORKDIR}"/lib/libc/net/Makefile.inc || die
+
+ # Fix the Makefiles of these few libraries that will overwrite our LDADD.
+ cd "${S}"
+ for dir in libradius libtacplus libcam libdevstat libfetch libgeom libmemstat libopie \
+ libsmb libprocstat libulog; do sed -i.bak -e 's:LDADD=:LDADD+=:g' "${dir}/Makefile" || \
+ die "Problem fixing \"${dir}/Makefile"
+ done
+ # Call LD with LDFLAGS, rename them to RAW_LDFLAGS
+ sed -e 's/LDFLAGS/RAW_LDFLAGS/g' \
+ -i "${S}/csu/i386/Makefile" || die
+
+ if install --version 2> /dev/null | grep -q GNU; then
+ sed -i.bak -e 's:${INSTALL} -C:${INSTALL}:' "${WORKDIR}/include/Makefile"
+ fi
+
+ # Try to fix sed calls for GNU sed. Do it only with GNU userland and force
+ # BSD's sed on BSD.
+ cd "${S}"
+ if [[ ${CBUILD:-${CHOST}} != *bsd* ]]; then
+ find . -name Makefile -exec sed -ibak 's/sed -i /sed -i/' {} \;
+ sed -i -e 's/-i ""/-i""/' "${S}/csu/Makefile.inc" || die
+ fi
+
+ if use build; then
+ cd "${WORKDIR}"
+ # This patch has to be applied on ${WORKDIR}/sys, so we do it here since it
+ # shouldn't be a symlink to /usr/src/sys (which should be already patched)
+ epatch "${FILESDIR}"/freebsd-sources-9.0-sysctluint.patch
+ return 0
+ fi
+
+ if ! is_crosscompile ; then
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ ln -s "${SYSROOT}/usr/src/sys" "${WORKDIR}/sys" || die "Couldn't make sys symlink!"
+ fi
+ else
+ sed -i.bak -e "s:/usr/include:/usr/${CTARGET}/usr/include:g" \
+ "${S}/libc/rpc/Makefile.inc" \
+ "${S}/libc/yp/Makefile.inc"
+ fi
+}
+
+bootstrap_lib() {
+ for i ; do
+ cd "${WORKDIR}/${i}" || die "missing ${i}"
+ freebsd_src_compile
+ append-ldflags "-L${MAKEOBJDIRPREFIX}/${WORKDIR}/${i}"
+ done
+}
+
+get_csudir() {
+ if [ -d "${WORKDIR}/lib/csu/$1-elf" ]; then
+ echo "lib/csu/$1-elf"
+ else
+ echo "lib/csu/$1"
+ fi
+}
+
+bootstrap_csu() {
+ local csudir="$(get_csudir $(tc-arch-kernel ${CTARGET}))"
+ export RAW_LDFLAGS=$(raw-ldflags)
+ bootstrap_lib "${csudir}"
+
+ CFLAGS="${CFLAGS} -B ${MAKEOBJDIRPREFIX}/${WORKDIR}/${csudir}"
+ append-ldflags "-B ${MAKEOBJDIRPREFIX}/${WORKDIR}/${csudir}"
+
+ bootstrap_lib "gnu/lib/csu"
+
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+ for i in *.So ; do
+ ln -s $i ${i%.So}S.o
+ done
+ CFLAGS="${CFLAGS} -B ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+ append-ldflags "-B ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+}
+
+# Compile libssp_nonshared.a and add it's path to LDFLAGS.
+bootstrap_libssp_nonshared() {
+ bootstrap_lib "gnu/lib/libssp/libssp_nonshared"
+}
+
+bootstrap_libgcc() {
+ bootstrap_lib "lib/libcompiler_rt"
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libcompiler_rt" || die
+ ln -s libcompiler_rt.a libgcc.a || die
+
+ bootstrap_lib "lib/libc" "gnu/lib/libgcc"
+}
+
+bootstrap_libthr() {
+ bootstrap_lib "lib/libthr"
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libthr" || die
+ ln -s libthr.so libpthread.so
+}
+
+# What to build for a cross-compiler.
+# We also need the csu but this has to be handled separately.
+CROSS_SUBDIRS="lib/libc lib/msun gnu/lib/libssp/libssp_nonshared lib/libthr lib/libutil lib/librt lib/libc_nonshared"
+
+# What to build for non-default ABIs.
+NON_NATIVE_SUBDIRS="${CROSS_SUBDIRS} gnu/lib/csu lib/libcompiler_rt gnu/lib/libgcc lib/libmd lib/libcrypt lib/libsbuf lib/libcam lib/libelf lib/libiconv_modules"
+
+# Subdirs for a native build:
+NATIVE_SUBDIRS="lib gnu/lib/libssp/libssp_nonshared gnu/lib/libregex gnu/lib/csu gnu/lib/libgcc lib/libiconv_modules"
+
+# Is my $ABI native ?
+is_native_abi() {
+ is_crosscompile && return 1
+ multilib_is_native_abi
+}
+
+# Do we need to bootstrap the csu and libssp_nonshared?
+need_bootstrap() {
+ is_crosscompile || use build || { ! is_native_abi && ! has_version '>=sys-freebsd/freebsd-lib-9.1-r8[multilib]' && ! has_version ">=sys-freebsd/freebsd-lib-9.1-r11[${MULTILIB_USEDEP}]" ; } || has_version "<${CATEGORY}/${P}"
+}
+
+# Get the subdirs we are building.
+get_subdirs() {
+ local ret=""
+ if is_native_abi ; then
+ # If we are building for the native ABI, build everything
+ ret="${NATIVE_SUBDIRS}"
+ elif is_crosscompile ; then
+ # With a cross-compiler we only build the very core parts.
+ ret="${CROSS_SUBDIRS}"
+ if [ "${EBUILD_PHASE}" = "install" ]; then
+ # Add the csu dir first when installing. We treat it separately for
+ # compiling.
+ ret="$(get_csudir $(tc-arch-kernel ${CTARGET})) ${ret}"
+ fi
+ else
+ # For the non-native ABIs we only build the csu parts and very core
+ # libraries for now.
+ ret="${NON_NATIVE_SUBDIRS} $(get_csudir $(tc-arch-kernel ${CHOST}))"
+ fi
+ echo "${ret}"
+}
+
+# Bootstrap the core libraries and setup the flags so that the other parts can
+# build against it.
+do_bootstrap() {
+ einfo "Bootstrapping on ${CHOST} for ${CTARGET}"
+ if ! is_crosscompile ; then
+ # Pre-install headers, but not when building a cross-compiler since we
+ # assume they have been installed in the previous pass.
+ einfo "Pre-installing includes in include_proper_${ABI}"
+ mkdir "${WORKDIR}/include_proper_${ABI}" || die
+ CTARGET="${CHOST}" install_includes "/include_proper_${ABI}"
+ CFLAGS="${CFLAGS} -isystem ${WORKDIR}/include_proper_${ABI}"
+ [[ $(tc-getCXX) = *clang++* ]] && CXXFLAGS="${CXXFLAGS} -isystem /usr/include/c++/v1"
+ CXXFLAGS="${CXXFLAGS} -isystem ${WORKDIR}/include_proper_${ABI}"
+ mymakeopts="${mymakeopts} RPCDIR=${WORKDIR}/include_proper_${ABI}/rpcsvc"
+ fi
+ bootstrap_csu
+ bootstrap_libssp_nonshared
+ is_crosscompile && bootstrap_lib "lib/libc"
+ is_crosscompile || is_native_abi || bootstrap_libgcc
+ is_native_abi || bootstrap_libthr
+}
+
+# Compile it. Assume we have the toolchain setup correctly.
+do_compile() {
+ # Bootstrap if needed, otherwise assume the system headers are in
+ # /usr/include.
+ if need_bootstrap ; then
+ do_bootstrap
+ else
+ CFLAGS="${CFLAGS} -isystem /usr/include"
+ [[ $(tc-getCXX) = *clang++* ]] && CXXFLAGS="${CXXFLAGS} -isystem /usr/include/c++/v1"
+ CXXFLAGS="${CXXFLAGS} -isystem /usr/include"
+ fi
+
+ export RAW_LDFLAGS=$(raw-ldflags)
+
+ # Everything is now setup, build it!
+ for i in $(get_subdirs) ; do
+ einfo "Building in ${i}... with CC=${CC} and CFLAGS=${CFLAGS}"
+ cd "${WORKDIR}/${i}/" || die "missing ${i}."
+ freebsd_src_compile || die "make ${i} failed"
+ done
+}
+
+src_compile() {
+ # Does not work with GNU sed
+ # Force BSD's sed on BSD.
+ if [[ ${CBUILD:-${CHOST}} == *bsd* ]]; then
+ export ESED=/usr/bin/sed
+ unalias sed
+ fi
+
+ use usb && export NON_NATIVE_SUBDIRS="${NON_NATIVE_SUBDIRS} lib/libusb lib/libusbhid"
+
+ cd "${WORKDIR}/include"
+ $(freebsd_get_bmake) CC="$(tc-getCC)" SRCTOP="${WORKDIR}" || die "make include failed"
+
+ use crosscompile_opts_headers-only && return 0
+
+ # Bug #270098
+ append-flags $(test-flags -fno-strict-aliasing)
+
+ # Bug #324445
+ append-flags $(test-flags -fno-strict-overflow)
+
+ # strip flags and do not do it later, we only add safe, and in fact
+ # needed flags after all
+ strip-flags
+ export NOFLAGSTRIP=yes
+ if is_crosscompile ; then
+ export YACC='yacc -by'
+ CHOST=${CTARGET} tc-export CC LD CXX RANLIB
+ mymakeopts="${mymakeopts} NLS="
+ CFLAGS="${CFLAGS} -isystem /usr/${CTARGET}/usr/include"
+ CXXFLAGS="${CXXFLAGS} -isystem /usr/${CTARGET}/usr/include"
+ append-ldflags "-L${WORKDIR}/${CHOST}/${WORKDIR}/lib/libc"
+ fi
+
+ if is_crosscompile ; then
+ do_compile
+ else
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper do_compile
+ fi
+}
+
+gen_libc_ldscript() {
+ # Parameters:
+ # $1 = target libdir
+ # $2 = source libc dir
+ # $3 = source libssp_nonshared dir
+
+ # Clear the symlink.
+ rm -f "${DESTDIR}/$2/libc.so" || die
+
+ # Move the library if needed
+ if [ "$1" != "$2" ] ; then
+ mv "${DESTDIR}/$2/libc.so.7" "${DESTDIR}/$1/" || die
+ fi
+
+ # Generate libc.so ldscript for inclusion of libssp_nonshared.a when linking
+ # this is done to avoid having to touch gcc spec file as it is currently
+ # done on FreeBSD upstream, mostly because their binutils aren't able to
+ # cope with linker scripts yet.
+ # Taken from toolchain-funcs.eclass:
+ local output_format
+ output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
+ [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
+
+ # iconv symbol provided by libc_nonshared.a.
+ # http://svnweb.freebsd.org/base?view=revision&amp;revision=258283
+ cat > "${DESTDIR}/$2/libc.so" <<-END_LDSCRIPT
+/* GNU ld script
+ SSP (-fstack-protector) requires __stack_chk_fail_local to be local.
+ GCC invokes this symbol in a non-PIC way, which results in TEXTRELs if
+ this symbol was provided by a shared libc. So we link in
+ libssp_nonshared.a from here.
+ */
+${output_format}
+GROUP ( /$1/libc.so.7 /$3/libc_nonshared.a /$3/libssp_nonshared.a )
+END_LDSCRIPT
+}
+
+header_list=""
+
+move_header() {
+ local dirname=$(dirname ${1})
+ local filename=$(basename ${1})
+
+ if [ ! -d "${dirname}/${ABI}" ] ; then
+ mkdir "${dirname}/${ABI}" || die
+ fi
+
+ mv "${1}" "${dirname}/${ABI}/" || die
+
+ export header_list="${header_list} ${1}"
+}
+
+make_header_template() {
+ cat <<-END_HEADER
+/*
+ * Wrapped header for multilib support.
+ * See the real headers included below.
+ */
+
+#if defined(__x86_64__)
+ @ABI_amd64_fbsd@
+#elif defined(__i386__)
+ @ABI_x86_fbsd@
+#else
+ @ABI_${DEFAULT_ABI}@
+#endif
+END_HEADER
+}
+
+wrap_header() {
+ local dirname=$(dirname ${1})
+ local filename=$(basename ${1})
+
+ if [ -n "${dirname#.}" ] ; then
+ dirname="${dirname}/${2}"
+ else
+ dirname="${2}"
+ fi
+
+ if [ -f "${dirname}/${filename}" ] ; then
+ sed -e "s:@ABI_${2}@:#include <${dirname}/${filename}>:" ${1}
+ else
+ cat ${1}
+ fi
+}
+
+wrap_header_end() {
+ sed -e "s:@ABI_.*@:#error \"Sorry, no support for your ABI.\":" ${1}
+}
+
+do_install() {
+ if is_crosscompile ; then
+ INCLUDEDIR="/usr/${CTARGET}/usr/include"
+ else
+ INCLUDEDIR="/usr/include"
+ fi
+
+ dodir ${INCLUDEDIR}
+ CTARGET="${CHOST}" \
+ install_includes ${INCLUDEDIR}
+
+ is_crosscompile && use crosscompile_opts_headers-only && return 0
+
+ # Install a libusb.pc for better compat with Linux's libusb
+ if use usb ; then
+ dodir /usr/$(get_libdir)/pkgconfig
+ sed -i.bkp "s:^libdir=.*:libdir=/usr/$(get_libdir):g" "${S}"/libusb/libusb-*.pc
+ fi
+
+ for i in $(get_subdirs) ; do
+ if [[ ${i} != *libiconv_modules* ]] ; then
+ einfo "Installing in ${i}..."
+ cd "${WORKDIR}/${i}/" || die "missing ${i}."
+ freebsd_src_install || die "Install ${i} failed"
+ fi
+ done
+
+ if ! is_crosscompile; then
+ local mymakeopts_save="${mymakeopts}"
+ mymakeopts="${mymakeopts} SHLIBDIR=/usr/$(get_libdir)/i18n LIBDIR=/usr/$(get_libdir)/i18n"
+
+ einfo "Installing in lib/libiconv_modules..."
+ cd "${WORKDIR}/lib/libiconv_modules/" || die "missing libiconv_modules."
+ freebsd_src_install || die "Install lib/libiconv_modules failed"
+
+ mymakeopts="${mymakeopts_save}"
+ fi
+
+ if ! is_crosscompile ; then
+ if ! multilib_is_native_abi ; then
+ DESTDIR="${D}" gen_libc_ldscript "usr/$(get_libdir)" "usr/$(get_libdir)" "usr/$(get_libdir)"
+ else
+ dodir "$(get_libdir)"
+ DESTDIR="${D}" gen_libc_ldscript "$(get_libdir)" "usr/$(get_libdir)" "usr/$(get_libdir)"
+ fi
+ else
+ CHOST=${CTARGET} DESTDIR="${D}/usr/${CTARGET}/" gen_libc_ldscript "usr/lib" "usr/lib" "usr/lib"
+ # We're done for the cross libc here.
+ return 0
+ fi
+
+ # Generate ldscripts for core libraries that will go in /
+ multilib_is_native_abi && \
+ gen_usr_ldscript -a alias cam geom ipsec jail kiconv \
+ kvm m md procstat sbuf thr ufs util elf
+
+ if [[ ${#MULTIBUILD_VARIANTS[@]} -gt 1 ]] ; then
+ cd "${D}/usr/include"
+ for i in machine/*.h fenv.h ; do
+ move_header ${i}
+ done
+ if multilib_is_native_abi ; then
+ # Supposedly the last one!
+ local uniq_headers="$(echo ${header_list} | tr ' ' '\n' | sort | uniq | tr '\n' ' ')"
+ for j in ${uniq_headers} ; do
+ make_header_template > ${j}
+ for i in $(get_all_abis) ; do
+ wrap_header ${j} ${i} > ${j}.new
+ cp ${j}.new ${j}
+ rm -f ${j}.new
+ done
+ wrap_header_end ${j} > ${j}.new
+ cp ${j}.new ${j}
+ rm -f ${j}.new
+ done
+ fi
+ fi
+}
+
+src_install() {
+ if is_crosscompile ; then
+ einfo "Installing for ${CTARGET} in ${CHOST}.."
+ # From this point we need to force: get stripped with the correct tools,
+ # get tc-arch-kernel to return the right value, etc.
+ export CHOST=${CTARGET}
+
+ mymakeopts="${mymakeopts} WITHOUT_MAN= \
+ INCLUDEDIR=/usr/${CTARGET}/usr/include \
+ SHLIBDIR=/usr/${CTARGET}/usr/lib \
+ LIBDIR=/usr/${CTARGET}/usr/lib"
+
+ dosym "usr/include" "/usr/${CTARGET}/sys-include"
+ do_install
+
+ return 0
+ else
+ export STRIP_MASK="*/usr/lib*/*crt*.o"
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper do_install
+ fi
+
+ cd "${WORKDIR}/etc/"
+ insinto /etc
+ doins nls.alias mac.conf netconfig
+
+ # Install ttys file
+ local MACHINE="$(tc-arch-kernel)"
+ doins "etc.${MACHINE}"/*
+}
+
+install_includes()
+{
+ local INCLUDEDIR="$1"
+
+ # The idea is to be called from either install or unpack.
+ # During unpack it's required to install them as portage's user.
+ if [[ "${EBUILD_PHASE}" == "install" ]]; then
+ local DESTDIR="${D}"
+ BINOWN="root"
+ BINGRP="wheel"
+ else
+ local DESTDIR="${WORKDIR}"
+ [[ -z "${USER}" ]] && USER="portage"
+ BINOWN="${USER}"
+ [[ -z "${GROUPS}" ]] && GROUPS="portage"
+ BINGRP="${GROUPS}"
+ fi
+
+ # Must exist before we use it.
+ [[ -d "${DESTDIR}${INCLUDEDIR}" ]] || die "dodir or mkdir ${INCLUDEDIR} before using install_includes."
+ cd "${WORKDIR}/include"
+
+ local MACHINE="$(tc-arch-kernel)"
+
+ einfo "Installing includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ $(freebsd_get_bmake) installincludes \
+ MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE} \
+ DESTDIR="${DESTDIR}" \
+ INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" \
+ WITHOUT_GSSAPI= \
+ SRCTOP="${WORKDIR}"|| die "install_includes() failed"
+ einfo "includes installed ok."
+ EXTRA_INCLUDES="lib/librtld_db lib/libutil lib/msun gnu/lib/libregex lib/libcasper lib/libmp"
+ for i in $EXTRA_INCLUDES; do
+ einfo "Installing $i includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ cd "${WORKDIR}/$i" || die
+ $(freebsd_get_bmake) installincludes DESTDIR="${DESTDIR}" \
+ MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE} \
+ INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" \
+ SRCTOP="${WORKDIR}" || die "problem installing $i includes."
+ einfo "$i includes installed ok."
+ done
+}
diff --git a/sys-freebsd/freebsd-lib/freebsd-lib-11.1.ebuild b/sys-freebsd/freebsd-lib/freebsd-lib-11.1.ebuild
new file mode 100644
index 000000000000..a1e2b461df4b
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/freebsd-lib-11.1.ebuild
@@ -0,0 +1,708 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic multilib toolchain-funcs eutils multibuild multilib-build
+
+DESCRIPTION="FreeBSD's base system libraries"
+SLOT="0"
+LICENSE="BSD GPL-2 zfs? ( CDDL )"
+
+# Security Advisory and Errata patches.
+# UPSTREAM_PATCHES=()
+
+# Crypto is needed to have an internal OpenSSL header
+# sys is needed for libalias, probably we can just extract that instead of
+# extracting the whole tarball
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ lib/
+ contrib/
+ crypto/
+ libexec/
+ etc/
+ include/
+ usr.bin/
+ usr.sbin/
+ gnu/
+ secure/
+"
+
+if [ "${CATEGORY#*cross-}" = "${CATEGORY}" ]; then
+ RDEPEND="ssl? ( dev-libs/openssl:0= )
+ hesiod? ( net-dns/hesiod )
+ kerberos? ( app-crypt/heimdal )
+ pam? ( virtual/pam )
+ usb? ( !dev-libs/libusb )
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )
+ >=dev-libs/expat-2.0.1
+ >=dev-util/dialog-1.2.20150225
+ !sys-freebsd/freebsd-libexec
+ !sys-libs/libutempter
+ !dev-libs/libelf
+ !dev-libs/libexecinfo
+ !dev-libs/libiconv
+ !sys-freebsd/freebsd-headers"
+ DEPEND="${RDEPEND}
+ >=sys-devel/flex-2.5.31-r2
+ =sys-freebsd/freebsd-sources-${RV}*"
+ RDEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-share-${RV}*
+ xinetd? ( sys-apps/xinetd )
+ >=virtual/libiconv-0-r2"
+else
+ EXTRACTONLY+="sys/ "
+fi
+
+DEPEND="${DEPEND}
+ userland_GNU? ( sys-apps/mtree )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/lib"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [ "${CTARGET}" = "${CHOST}" -a "${CATEGORY#*cross-}" != "${CATEGORY}" ]; then
+ export CTARGET=${CATEGORY/cross-}
+fi
+
+IUSE="atm bluetooth ssl hesiod ipv6 kerberos usb netware
+ build crosscompile_opts_headers-only zfs pam xinetd
+ userland_GNU userland_BSD"
+
+QA_DT_NEEDED="lib/libc.so.7 usr/lib32/libc.so.7"
+
+pkg_setup() {
+ # Add the required source files.
+ use build && EXTRACTONLY+="sys/ "
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ [ -c /dev/zero ] || \
+ die "You forgot to mount /dev; the compiled libc would break."
+
+ if ! use ssl && use kerberos; then
+ eerror "If you want kerberos support you need to enable ssl support, too."
+ fi
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use hesiod || mymakeopts="${mymakeopts} WITHOUT_HESIOD= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= WITHOUT_GSSAPI= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_CLANG= WITHOUT_LIBCPLUSPLUS= WITHOUT_LDNS= WITHOUT_UNBOUND= WITHOUT_BSNMP= "
+
+ if [ "${CTARGET}" != "${CHOST}" ]; then
+ mymakeopts="${mymakeopts} MACHINE=$(tc-arch-kernel ${CTARGET})"
+ mymakeopts="${mymakeopts} MACHINE_ARCH=$(tc-arch-kernel ${CTARGET})"
+ fi
+
+ # Taken from freebsd-libexec.
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ if has_version "<sys-freebsd/freebsd-ubin-11.0"; then
+ mymakeopts="${mymakeopts} WITHOUT_MAN_UTILS= "
+ fi
+}
+
+PATCHES=(
+ "${FILESDIR}/${PN}-6.0-pmc.patch"
+ "${FILESDIR}/${PN}-9.0-bluetooth.patch"
+ "${FILESDIR}/${PN}-11.0-workaround.patch"
+ "${FILESDIR}/${PN}-11.0-bsdxml2expat.patch"
+ "${FILESDIR}/${PN}-11.0-libproc-libcxx.patch"
+ "${FILESDIR}/${PN}-11.1-liblink.patch"
+ "${FILESDIR}/${PN}-add-nossp-cflags.patch"
+ )
+# Here we disable and remove source which we don't need or want
+# In order:
+# - ncurses stuff
+# - libexpat creates a bsdxml library which is the same as expat
+# - archiving libraries (have their own ebuild)
+# - sendmail libraries (they are installed by sendmail)
+# - SNMP library and dependency (have their own ebuilds)
+# - libstand: static library, 32bits on amd64 used for boot0, we build it from
+# boot0 instead.
+#
+# The rest are libraries we already have somewhere else because
+# they are contribution.
+REMOVE_SUBDIRS="ncurses \
+ libexpat \
+ libz libbz2 libarchive liblzma \
+ libsm libsmdb libsmutil \
+ libbegemot libbsnmp \
+ libpam libpcap libwrap libmagic \
+ libcom_err
+ libedit
+ libstand
+ libgssapi"
+
+# Are we building a cross-compiler?
+is_crosscompile() {
+ [ "${CATEGORY#*cross-}" != "${CATEGORY}" ]
+}
+
+src_prepare() {
+ # If gcc-5.0 or later, apply a workaround to fix a critical issue. bug 573358
+ [[ "$(gcc-major-version)" -ge 5 ]] && replace-flags -O? -O1
+
+ sed -i.bak -e 's:-o/dev/stdout:-t:' "${S}/libc/net/Makefile.inc"
+
+ # Upstream Display Managers default to using VT7
+ # We should make FreeBSD allow this by default
+ local x=
+ for x in "${WORKDIR}"/etc/etc.*/ttys ; do
+ sed -i.bak \
+ -e '/ttyv5[[:space:]]/ a\
+# Display Managers default to VT7.\
+# If you use the xdm init script, keep ttyv6 commented out\
+# unless you force a different VT for the DM being used.' \
+ -e '/^ttyv[678][[:space:]]/ s/^/# /' "${x}" \
+ || die "Failed to sed ${x}"
+ rm "${x}".bak
+ done
+
+ # This one is here because it also
+ # patches "${WORKDIR}/include"
+ cd "${WORKDIR}"
+ epatch "${FILESDIR}/${PN}-includes.patch"
+
+ # Don't install the hesiod man page or header
+ rm "${WORKDIR}"/include/hesiod.h || die
+ sed -i.bak -e 's:hesiod.h::' "${WORKDIR}"/include/Makefile || die
+ sed -i.bak -e 's:hesiod.c::' -e 's:hesiod.3::' \
+ "${WORKDIR}"/lib/libc/net/Makefile.inc || die
+
+ # Fix the Makefiles of these few libraries that will overwrite our LDADD.
+ cd "${S}"
+ for dir in libradius libtacplus libcam libdevstat libfetch libgeom libmemstat libopie \
+ libsmb libprocstat libulog; do sed -i.bak -e 's:LDADD=:LDADD+=:g' "${dir}/Makefile" || \
+ die "Problem fixing \"${dir}/Makefile"
+ done
+ # Call LD with LDFLAGS, rename them to RAW_LDFLAGS
+ sed -e 's/LDFLAGS/RAW_LDFLAGS/g' \
+ -i "${S}/csu/i386/Makefile" || die
+
+ if install --version 2> /dev/null | grep -q GNU; then
+ sed -i.bak -e 's:${INSTALL} -C:${INSTALL}:' "${WORKDIR}/include/Makefile"
+ fi
+
+ # libsysdecode requires the latest headers.
+ need_bootstrap && \
+ sed -i "s:\${DESTDIR}\${INCLUDEDIR}:${WORKDIR}/include_proper_${ABI}:g" "${S}/libsysdecode/Makefile"
+
+ # Taken from freebsd-libexec.
+ cd "${WORKDIR}/libexec"
+ dummy_mk smrsh mail.local tcpd telnetd rshd rlogind ftpd
+ # The old version of yacc doesn't support YFLAGS="-i".
+ if has_version "<sys-freebsd/freebsd-ubin-11.0"; then
+ sed -i -e '/^YFLAGS/d' "${WORKDIR}/libexec/dma/dmagent/Makefile"
+ fi
+
+ # Try to fix sed calls for GNU sed. Do it only with GNU userland and force
+ # BSD's sed on BSD.
+ cd "${S}"
+ if [[ ${CBUILD:-${CHOST}} != *bsd* ]]; then
+ find . -name Makefile -exec sed -ibak 's/sed -i /sed -i/' {} \;
+ sed -i -e 's/-i ""/-i""/' "${S}/csu/Makefile.inc" || die
+ fi
+
+ if use build; then
+ cd "${WORKDIR}"
+ # This patch has to be applied on ${WORKDIR}/sys, so we do it here since it
+ # shouldn't be a symlink to /usr/src/sys (which should be already patched)
+ epatch "${FILESDIR}"/freebsd-sources-9.0-sysctluint.patch
+ return 0
+ fi
+
+ if ! is_crosscompile ; then
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ ln -s "${SYSROOT}/usr/src/sys" "${WORKDIR}/sys" || die "Couldn't make sys symlink!"
+ fi
+ else
+ sed -i.bak -e "s:/usr/include:/usr/${CTARGET}/usr/include:g" \
+ "${S}/libc/rpc/Makefile.inc" \
+ "${S}/libc/yp/Makefile.inc"
+ fi
+}
+
+bootstrap_lib() {
+ for i ; do
+ cd "${WORKDIR}/${i}" || die "missing ${i}"
+ freebsd_src_compile
+ append-ldflags "-L${MAKEOBJDIRPREFIX}/${WORKDIR}/${i}"
+ done
+}
+
+get_csudir() {
+ if [ -d "${WORKDIR}/lib/csu/$1-elf" ]; then
+ echo "lib/csu/$1-elf"
+ else
+ echo "lib/csu/$1"
+ fi
+}
+
+bootstrap_csu() {
+ local csudir="$(get_csudir $(tc-arch-kernel ${CTARGET}))"
+ export RAW_LDFLAGS=$(raw-ldflags)
+ bootstrap_lib "${csudir}"
+
+ CFLAGS="${CFLAGS} -B ${MAKEOBJDIRPREFIX}/${WORKDIR}/${csudir}"
+ append-ldflags "-B ${MAKEOBJDIRPREFIX}/${WORKDIR}/${csudir}"
+
+ bootstrap_lib "gnu/lib/csu"
+
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+ for i in *.So ; do
+ ln -s $i ${i%.So}S.o
+ done
+ CFLAGS="${CFLAGS} -B ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+ append-ldflags "-B ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+}
+
+# Compile libssp_nonshared.a and add it's path to LDFLAGS.
+bootstrap_libssp_nonshared() {
+ bootstrap_lib "gnu/lib/libssp/libssp_nonshared"
+}
+
+# We should call this function to compile itself correctly.
+# A better solution is very welcome.
+bootstrap_libc() {
+ mkdir "${WORKDIR}/bootstrap_libc_${ABI}" || die
+ append-ldflags "-L${WORKDIR}/bootstrap_libc_${ABI}"
+
+ bootstrap_lib "lib/libc" "lib/libc_nonshared"
+ echo "GROUP ( ${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libc/libc.so.7 ${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libc_nonshared/libc_nonshared.a ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/libssp/libssp_nonshared/libssp_nonshared.a )" > "${WORKDIR}/bootstrap_libc_${ABI}/libc.so" || die
+}
+
+bootstrap_libgcc() {
+ bootstrap_lib "lib/libcompiler_rt"
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libcompiler_rt" || die
+ ln -s libcompiler_rt.a libgcc.a || die
+
+ bootstrap_libc
+ bootstrap_lib "gnu/lib/libgcc"
+}
+
+bootstrap_libthr() {
+ bootstrap_lib "lib/libthr"
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libthr" || die
+ ln -s libthr.so libpthread.so
+}
+
+# What to build for a cross-compiler.
+# We also need the csu but this has to be handled separately.
+CROSS_SUBDIRS="lib/libc lib/msun gnu/lib/libssp/libssp_nonshared lib/libthr lib/libutil lib/librt lib/libc_nonshared lib/libcompiler_rt"
+
+# What to build for non-default ABIs.
+NON_NATIVE_SUBDIRS="${CROSS_SUBDIRS} gnu/lib/csu gnu/lib/libgcc lib/libmd lib/libcrypt lib/libsbuf lib/libcam lib/libelf lib/libiconv_modules"
+
+# Subdirs for a native build:
+NATIVE_SUBDIRS="lib gnu/lib/libssp/libssp_nonshared gnu/lib/libregex gnu/lib/csu gnu/lib/libgcc lib/libiconv_modules"
+
+# Is my $ABI native ?
+is_native_abi() {
+ is_crosscompile && return 1
+ multilib_is_native_abi
+}
+
+# Do we need to bootstrap the csu and libssp_nonshared?
+need_bootstrap() {
+ is_crosscompile || use build || { ! is_native_abi && ! has_version '>=sys-freebsd/freebsd-lib-9.1-r8[multilib]' && ! has_version ">=sys-freebsd/freebsd-lib-9.1-r11[${MULTILIB_USEDEP}]" ; } || has_version "<${CATEGORY}/${P}"
+}
+
+# Get the subdirs we are building.
+get_subdirs() {
+ local ret=""
+ if is_native_abi ; then
+ # If we are building for the native ABI, build everything
+ ret="${NATIVE_SUBDIRS}"
+ elif is_crosscompile ; then
+ # With a cross-compiler we only build the very core parts.
+ ret="${CROSS_SUBDIRS}"
+ if [ "${EBUILD_PHASE}" = "install" ]; then
+ # Add the csu dir first when installing. We treat it separately for
+ # compiling.
+ ret="$(get_csudir $(tc-arch-kernel ${CTARGET})) ${ret}"
+ fi
+ else
+ # For the non-native ABIs we only build the csu parts and very core
+ # libraries for now.
+ ret="${NON_NATIVE_SUBDIRS} $(get_csudir $(tc-arch-kernel ${CHOST}))"
+ fi
+ echo "${ret}"
+}
+
+# Bootstrap the core libraries and setup the flags so that the other parts can
+# build against it.
+do_bootstrap() {
+ einfo "Bootstrapping on ${CHOST} for ${CTARGET}"
+ if ! is_crosscompile ; then
+ # Pre-install headers, but not when building a cross-compiler since we
+ # assume they have been installed in the previous pass.
+ einfo "Pre-installing includes in include_proper_${ABI}"
+ mkdir "${WORKDIR}/include_proper_${ABI}" || die
+ CTARGET="${CHOST}" install_includes "/include_proper_${ABI}"
+ CFLAGS="${CFLAGS} -isystem ${WORKDIR}/include_proper_${ABI}"
+ [[ $(tc-getCXX) = *clang++* ]] && CXXFLAGS="${CXXFLAGS} -isystem /usr/include/c++/v1"
+ CXXFLAGS="${CXXFLAGS} -isystem ${WORKDIR}/include_proper_${ABI}"
+ mymakeopts="${mymakeopts} RPCDIR=${WORKDIR}/include_proper_${ABI}/rpcsvc"
+ fi
+ bootstrap_csu
+ bootstrap_libssp_nonshared
+ if is_crosscompile ; then
+ bootstrap_lib "lib/libcompiler_rt"
+ bootstrap_libc
+ else
+ is_native_abi || bootstrap_libgcc
+ is_native_abi && has_version "<=sys-freebsd/freebsd-lib-10.0" && bootstrap_libgcc
+ fi
+ is_native_abi || bootstrap_libthr
+}
+
+# Taken from freebsd-libexec.
+libexec_setup_multilib_vars() {
+ export mymakeopts="${mymakeopts} WITHOUT_RCMDS= WITHOUT_PF= "
+ need_bootstrap && CFLAGS="${CFLAGS} -isystem ${WORKDIR}/include_proper_${ABI}"
+ append-ldflags "-L${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libc"
+ if ! multilib_is_native_abi ; then
+ cd "${WORKDIR}/libexec/rtld-elf" || die
+ export mymakeopts="${mymakeopts} PROG=ld-elf32.so.1 "
+ else
+ cd "${WORKDIR}/libexec" || die
+ fi
+ "$@"
+}
+
+# Compile it. Assume we have the toolchain setup correctly.
+do_compile() {
+ # Bootstrap if needed, otherwise assume the system headers are in
+ # /usr/include.
+ if need_bootstrap ; then
+ do_bootstrap
+ else
+ CFLAGS="${CFLAGS} -isystem /usr/include"
+ [[ $(tc-getCXX) = *clang++* ]] && CXXFLAGS="${CXXFLAGS} -isystem /usr/include/c++/v1"
+ fi
+
+ export RAW_LDFLAGS=$(raw-ldflags)
+
+ # Everything is now setup, build it!
+ for i in $(get_subdirs) ; do
+ einfo "Building in ${i}... with CC=${CC} and CFLAGS=${CFLAGS}"
+ cd "${WORKDIR}/${i}/" || die "missing ${i}."
+ freebsd_src_compile || die "make ${i} failed"
+ done
+}
+
+src_compile() {
+ # Does not work with GNU sed
+ # Force BSD's sed on BSD.
+ if [[ ${CBUILD:-${CHOST}} == *bsd* ]]; then
+ export ESED=/usr/bin/sed
+ unalias sed
+ fi
+
+ use usb && export NON_NATIVE_SUBDIRS="${NON_NATIVE_SUBDIRS} lib/libusb lib/libusbhid"
+
+ cd "${WORKDIR}/include"
+ $(freebsd_get_bmake) CC="$(tc-getCC)" SRCTOP="${WORKDIR}" || die "make include failed"
+
+ use crosscompile_opts_headers-only && return 0
+
+ # Bug #270098
+ append-flags $(test-flags -fno-strict-aliasing)
+
+ # Bug #324445
+ append-flags $(test-flags -fno-strict-overflow)
+
+ # strip flags and do not do it later, we only add safe, and in fact
+ # needed flags after all
+ strip-flags
+ export NOFLAGSTRIP=yes
+ if is_crosscompile ; then
+ export YACC='yacc -by'
+ CHOST=${CTARGET} tc-export CC LD CXX RANLIB
+ mymakeopts="${mymakeopts} NLS="
+ CFLAGS="${CFLAGS} -isystem /usr/${CTARGET}/usr/include"
+ CXXFLAGS="${CXXFLAGS} -isystem /usr/${CTARGET}/usr/include"
+ append-ldflags "-L${WORKDIR}/${CHOST}/${WORKDIR}/lib/libc"
+ fi
+
+ if is_crosscompile ; then
+ do_compile
+ else
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper do_compile
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper libexec_setup_multilib_vars freebsd_src_compile
+ fi
+}
+
+gen_libc_ldscript() {
+ # Parameters:
+ # $1 = target libdir
+ # $2 = source libc dir
+ # $3 = source libssp_nonshared dir
+
+ # Clear the symlink.
+ rm -f "${DESTDIR}/$2/libc.so" || die
+
+ # Move the library if needed
+ if [ "$1" != "$2" ] ; then
+ mv "${DESTDIR}/$2/libc.so.7" "${DESTDIR}/$1/" || die
+ fi
+
+ # Generate libc.so ldscript for inclusion of libssp_nonshared.a when linking
+ # this is done to avoid having to touch gcc spec file as it is currently
+ # done on FreeBSD upstream, mostly because their binutils aren't able to
+ # cope with linker scripts yet.
+ # Taken from toolchain-funcs.eclass:
+ local output_format
+ output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
+ [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
+
+ # The iconv symbol is provided by libc_nonshared.a.
+ # http://svnweb.freebsd.org/base?view=revision&amp;revision=258283
+ cat > "${DESTDIR}/$2/libc.so" <<-END_LDSCRIPT
+/* GNU ld script
+ SSP (-fstack-protector) requires __stack_chk_fail_local to be local.
+ GCC invokes this symbol in a non-PIC way, which results in TEXTRELs if
+ this symbol was provided by a shared libc. So we link in
+ libssp_nonshared.a from here.
+ */
+${output_format}
+GROUP ( /$1/libc.so.7 /$3/libc_nonshared.a /$3/libssp_nonshared.a )
+END_LDSCRIPT
+}
+
+header_list=""
+
+move_header() {
+ local dirname=$(dirname ${1})
+ local filename=$(basename ${1})
+
+ if [ ! -d "${dirname}/${ABI}" ] ; then
+ mkdir "${dirname}/${ABI}" || die
+ fi
+
+ mv "${1}" "${dirname}/${ABI}/" || die
+
+ export header_list="${header_list} ${1}"
+}
+
+make_header_template() {
+ cat <<-END_HEADER
+/*
+ * Wrapped header for multilib support.
+ * See the real headers included below.
+ */
+
+#if defined(__x86_64__)
+ @ABI_amd64_fbsd@
+#elif defined(__i386__)
+ @ABI_x86_fbsd@
+#else
+ @ABI_${DEFAULT_ABI}@
+#endif
+END_HEADER
+}
+
+wrap_header() {
+ local dirname=$(dirname ${1})
+ local filename=$(basename ${1})
+
+ if [ -n "${dirname#.}" ] ; then
+ dirname="${dirname}/${2}"
+ else
+ dirname="${2}"
+ fi
+
+ if [ -f "${dirname}/${filename}" ] ; then
+ sed -e "s:@ABI_${2}@:#include <${dirname}/${filename}>:" ${1}
+ else
+ cat ${1}
+ fi
+}
+
+wrap_header_end() {
+ sed -e "s:@ABI_.*@:#error \"Sorry, no support for your ABI.\":" ${1}
+}
+
+do_install() {
+ if is_crosscompile ; then
+ INCLUDEDIR="/usr/${CTARGET}/usr/include"
+ else
+ INCLUDEDIR="/usr/include"
+ fi
+
+ dodir ${INCLUDEDIR}
+ CTARGET="${CHOST}" \
+ install_includes ${INCLUDEDIR}
+
+ is_crosscompile && use crosscompile_opts_headers-only && return 0
+
+ # Install a libusb.pc for better compat with Linux's libusb
+ if use usb ; then
+ dodir /usr/$(get_libdir)/pkgconfig
+ sed -i.bkp "s:^libdir=.*:libdir=/usr/$(get_libdir):g" "${S}"/libusb/libusb-*.pc
+ fi
+
+ for i in $(get_subdirs) ; do
+ if [[ ${i} != *libiconv_modules* ]] ; then
+ einfo "Installing in ${i}..."
+ cd "${WORKDIR}/${i}/" || die "missing ${i}."
+ freebsd_src_install || die "Install ${i} failed"
+ fi
+ done
+
+ if ! is_crosscompile; then
+ local mymakeopts_save="${mymakeopts}"
+ mymakeopts="${mymakeopts} SHLIBDIR=/usr/$(get_libdir)/i18n LIBDIR=/usr/$(get_libdir)/i18n"
+
+ einfo "Installing in lib/libiconv_modules..."
+ cd "${WORKDIR}/lib/libiconv_modules/" || die "missing libiconv_modules."
+ freebsd_src_install || die "Install lib/libiconv_modules failed"
+
+ mymakeopts="${mymakeopts_save}"
+ fi
+
+ if ! is_crosscompile ; then
+ if ! multilib_is_native_abi ; then
+ DESTDIR="${D}" gen_libc_ldscript "usr/$(get_libdir)" "usr/$(get_libdir)" "usr/$(get_libdir)"
+ else
+ dodir "$(get_libdir)"
+ DESTDIR="${D}" gen_libc_ldscript "$(get_libdir)" "usr/$(get_libdir)" "usr/$(get_libdir)"
+ fi
+ else
+ CHOST=${CTARGET} DESTDIR="${D}/usr/${CTARGET}/" gen_libc_ldscript "usr/lib" "usr/lib" "usr/lib"
+ # We're done for the cross libc here.
+ return 0
+ fi
+
+ # Generate ldscripts for core libraries that will go in /
+ multilib_is_native_abi && \
+ gen_usr_ldscript -a alias cam geom ipsec jail kiconv \
+ kvm m md procstat sbuf thr ufs util elf
+
+ if [[ ${#MULTIBUILD_VARIANTS[@]} -gt 1 ]] ; then
+ cd "${D}/usr/include"
+ for i in machine/*.h fenv.h ; do
+ move_header ${i}
+ done
+ if multilib_is_native_abi ; then
+ # Supposedly the last one!
+ local uniq_headers="$(echo ${header_list} | tr ' ' '\n' | sort | uniq | tr '\n' ' ')"
+ for j in ${uniq_headers} ; do
+ make_header_template > ${j}
+ for i in $(get_all_abis) ; do
+ wrap_header ${j} ${i} > ${j}.new
+ cp ${j}.new ${j}
+ rm -f ${j}.new
+ done
+ wrap_header_end ${j} > ${j}.new
+ cp ${j}.new ${j}
+ rm -f ${j}.new
+ done
+ fi
+ fi
+}
+
+src_install() {
+ if is_crosscompile ; then
+ einfo "Installing for ${CTARGET} in ${CHOST}.."
+ # From this point we need to force: get stripped with the correct tools,
+ # get tc-arch-kernel to return the right value, etc.
+ export CHOST=${CTARGET}
+
+ mymakeopts="${mymakeopts} WITHOUT_MAN= \
+ INCLUDEDIR=/usr/${CTARGET}/usr/include \
+ SHLIBDIR=/usr/${CTARGET}/usr/lib \
+ LIBDIR=/usr/${CTARGET}/usr/lib"
+
+ dosym "usr/include" "/usr/${CTARGET}/sys-include"
+ do_install
+
+ return 0
+ else
+ export STRIP_MASK="*/usr/lib*/*crt*.o"
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper do_install
+
+ # Taken from freebsd-libexec.
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper libexec_setup_multilib_vars freebsd_src_install
+ insinto /etc
+ doins "${WORKDIR}/etc/gettytab"
+ newinitd "${FILESDIR}/bootpd.initd" bootpd
+ newconfd "${FILESDIR}/bootpd.confd" bootpd
+
+ if use xinetd; then
+ for rpcd in rstatd rusersd walld rquotad sprayd; do
+ insinto /etc/xinetd.d
+ newins "${FILESDIR}/${rpcd}.xinetd" ${rpcd}
+ done
+ fi
+ fi
+
+ cd "${WORKDIR}/etc/"
+ insinto /etc
+ doins nls.alias mac.conf netconfig
+
+ # Install ttys file
+ local MACHINE="$(tc-arch-kernel)"
+ doins "etc.${MACHINE}"/*
+}
+
+install_includes()
+{
+ local INCLUDEDIR="$1"
+
+ # The idea is to be called from either install or unpack.
+ # During unpack it's required to install them as portage's user.
+ if [[ "${EBUILD_PHASE}" == "install" ]]; then
+ local DESTDIR="${D}"
+ BINOWN="root"
+ BINGRP="wheel"
+ else
+ local DESTDIR="${WORKDIR}"
+ [[ -z "${USER}" ]] && USER="portage"
+ BINOWN="${USER}"
+ [[ -z "${GROUPS}" ]] && GROUPS="portage"
+ BINGRP="${GROUPS}"
+ fi
+
+ # Must exist before we use it.
+ [[ -d "${DESTDIR}${INCLUDEDIR}" ]] || die "dodir or mkdir ${INCLUDEDIR} before using install_includes."
+ cd "${WORKDIR}/include"
+
+ local MACHINE="$(tc-arch-kernel)"
+
+ einfo "Installing includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ $(freebsd_get_bmake) installincludes \
+ MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE} \
+ DESTDIR="${DESTDIR}" \
+ INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" \
+ WITHOUT_GSSAPI= \
+ $(usex zfs "WITH_CDDL=" "WITHOUT_CDDL=") \
+ SRCTOP="${WORKDIR}"|| die "install_includes() failed"
+ einfo "includes installed ok."
+ EXTRA_INCLUDES="lib/librtld_db lib/libutil lib/msun gnu/lib/libregex lib/libcasper lib/libmp"
+ for i in $EXTRA_INCLUDES; do
+ einfo "Installing $i includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ cd "${WORKDIR}/$i" || die
+ $(freebsd_get_bmake) installincludes DESTDIR="${DESTDIR}" \
+ MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE} \
+ INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" \
+ SRCTOP="${WORKDIR}" || die "problem installing $i includes."
+ einfo "$i includes installed ok."
+ done
+}
diff --git a/sys-freebsd/freebsd-lib/freebsd-lib-8.2-r1.ebuild b/sys-freebsd/freebsd-lib/freebsd-lib-8.2-r1.ebuild
new file mode 100644
index 000000000000..755c53b84971
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/freebsd-lib-8.2-r1.ebuild
@@ -0,0 +1,438 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=2
+
+inherit bsdmk freebsd flag-o-matic multilib toolchain-funcs eutils
+
+DESCRIPTION="FreeBSD's base system libraries"
+SLOT="0"
+KEYWORDS="~sparc-fbsd ~x86-fbsd"
+
+# Crypto is needed to have an internal OpenSSL header
+# sys is needed for libalias, probably we can just extract that instead of
+# extracting the whole tarball
+SRC_URI="mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${CRYPTO}.tar.bz2
+ mirror://gentoo/${LIBEXEC}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2
+ mirror://gentoo/${INCLUDE}.tar.bz2
+ mirror://gentoo/${USBIN}.tar.bz2
+ mirror://gentoo/${GNU}.tar.bz2
+ build? (
+ mirror://gentoo/${SYS}.tar.bz2 )"
+
+if [ "${CATEGORY#*cross-}" = "${CATEGORY}" ]; then
+ RDEPEND="ssl? ( dev-libs/openssl )
+ hesiod? ( net-dns/hesiod )
+ kerberos? ( virtual/krb5 )
+ usb? ( !dev-libs/libusb )
+ userland_GNU? ( sys-apps/mtree )
+ >=dev-libs/expat-2.0.1
+ !sys-freebsd/freebsd-headers"
+ DEPEND="${RDEPEND}
+ >=sys-devel/flex-2.5.31-r2
+ =sys-freebsd/freebsd-sources-${RV}*
+ !bootstrap? ( app-arch/bzip2 )"
+else
+ SRC_URI="${SRC_URI}
+ mirror://gentoo/${SYS}.tar.bz2"
+fi
+
+DEPEND="${DEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/lib"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [ "${CTARGET}" = "${CHOST}" -a "${CATEGORY#*cross-}" != "${CATEGORY}" ]; then
+ export CTARGET=${CATEGORY/cross-}
+fi
+
+IUSE="atm bluetooth ssl hesiod ipv6 kerberos usb netware
+ build bootstrap crosscompile_opts_headers-only"
+
+pkg_setup() {
+ [ -c /dev/zero ] || \
+ die "You forgot to mount /dev; the compiled libc would break."
+
+ if ! use ssl && use kerberos; then
+ eerror "If you want kerberos support you need to enable ssl support, too."
+ fi
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use hesiod || mymakeopts="${mymakeopts} WITHOUT_HESIOD= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+
+ mymakeopts="${mymakeopts} WITHOUT_BIND= WITHOUT_BIND_LIBS= WITHOUT_SENDMAIL="
+
+ if [ "${CTARGET}" != "${CHOST}" ]; then
+ mymakeopts="${mymakeopts} MACHINE=$(tc-arch-kernel ${CTARGET})"
+ mymakeopts="${mymakeopts} MACHINE_ARCH=$(tc-arch-kernel ${CTARGET})"
+ fi
+}
+
+PATCHES=(
+ "${FILESDIR}/${PN}-6.0-pmc.patch"
+ "${FILESDIR}/${PN}-6.0-gccfloat.patch"
+ "${FILESDIR}/${PN}-6.0-flex-2.5.31.patch"
+ "${FILESDIR}/${PN}-6.1-csu.patch"
+ "${FILESDIR}/${PN}-6.2-bluetooth.patch"
+ "${FILESDIR}/${PN}-8.0-log2.patch"
+ "${FILESDIR}/${PN}-8.0-rpcsec_gss.patch"
+ "${FILESDIR}/${PN}-8.2-liblink.patch"
+ "${FILESDIR}/${PN}-bsdxml2expat.patch" )
+
+# Here we disable and remove source which we don't need or want
+# In order:
+# - ncurses stuff
+# - libexpat creates a bsdxml library which is the same as expat
+# - archiving libraries (have their own ebuild)
+# - sendmail libraries (they are installed by sendmail)
+# - SNMP library and dependency (have their own ebuilds)
+#
+# The rest are libraries we already have somewhere else because
+# they are contribution.
+# Note: libtelnet is an internal lib used by telnet and telnetd programs
+# as it's not used in freebsd-lib package itself, it's pointless building
+# it here.
+REMOVE_SUBDIRS="ncurses \
+ libexpat \
+ libz libbz2 libarchive liblzma \
+ libsm libsmdb libsmutil \
+ libbegemot libbsnmp \
+ libpam libpcap bind libwrap libmagic \
+ libcom_err libtelnet
+ libedit libelf"
+
+src_prepare() {
+ sed -i.bak -e 's:-o/dev/stdout:-t:' "${S}/libc/net/Makefile.inc"
+ sed -i.bak -e 's:histedit.h::' "${WORKDIR}/include/Makefile"
+
+ # Upstream Display Managers default to using VT7
+ # We should make FreeBSD allow this by default
+ local x=
+ for x in "${WORKDIR}"/etc/etc.*/ttys ; do
+ sed -i.bak \
+ -e '/ttyv5[[:space:]]/ a\
+# Display Managers default to VT7.\
+# If you use the xdm init script, keep ttyv6 commented out\
+# unless you force a different VT for the DM being used.' \
+ -e '/^ttyv[678][[:space:]]/ s/^/# /' "${x}" \
+ || die "Failed to sed ${x}"
+ rm "${x}".bak
+ done
+
+ # This one is here because it also
+ # patches "${WORKDIR}/include"
+ cd "${WORKDIR}"
+ epatch "${FILESDIR}/${PN}-includes.patch"
+ epatch "${FILESDIR}/${PN}-8.0-gcc45.patch"
+ epatch "${FILESDIR}/${PN}-8.2-nlm_syscall.patch"
+
+ # Don't install the hesiod man page or header
+ rm "${WORKDIR}"/include/hesiod.h || die
+ sed -i.bak -e 's:hesiod.h::' "${WORKDIR}"/include/Makefile || die
+ sed -i.bak -e 's:hesiod.c::' -e 's:hesiod.3::' \
+ "${WORKDIR}"/lib/libc/net/Makefile.inc || die
+
+ # Fix the Makefiles of these few libraries that will overwrite our LDADD.
+ cd "${S}"
+ for dir in libradius libtacplus libcam libdevstat libfetch libgeom libmemstat libopie \
+ libsmb; do sed -i.bak -e 's:LDADD=:LDADD+=:g' "${dir}/Makefile" || \
+ die "Problem fixing \"${dir}/Makefile"
+ done
+ if use build; then
+ cd "${WORKDIR}"
+ # This patch has to be applied on ${WORKDIR}/sys, so we do it here since it
+ # shouldn't be a symlink to /usr/src/sys (which should be already patched)
+ epatch "${FILESDIR}"/${PN}-7.1-types.h-fix.patch
+ # Preinstall includes so we don't use the system's ones.
+ mkdir "${WORKDIR}/include_proper" || die "Couldn't create ${WORKDIR}/include_proper"
+ install_includes "/include_proper"
+ return 0
+ fi
+
+ if [ "${CTARGET}" = "${CHOST}" ]; then
+ ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys" || die "Couldn't make sys symlink!"
+ else
+ sed -i.bak -e "s:/usr/include:/usr/${CTARGET}/usr/include:g" \
+ "${S}/libc/rpc/Makefile.inc" \
+ "${S}/libc/yp/Makefile.inc"
+ fi
+
+ if install --version 2> /dev/null | grep -q GNU; then
+ sed -i.bak -e 's:${INSTALL} -C:${INSTALL}:' "${WORKDIR}/include/Makefile"
+ fi
+
+ # Preinstall includes so we don't use the system's ones.
+ mkdir "${WORKDIR}/include_proper" || die "Couldn't create ${WORKDIR}/include_proper"
+ install_includes "/include_proper"
+
+ # Let arch-specific includes to be found
+ local machine
+ machine=$(tc-arch-kernel ${CTARGET})
+ ln -s "${WORKDIR}/sys/${machine}/include" "${WORKDIR}/include/machine" || \
+ die "Couldn't make ${machine}/include symlink."
+
+ cd "${S}"
+ use bootstrap && dummy_mk libstand
+ # Call LD with LDFLAGS, rename them to RAW_LDFLAGS
+ sed -e 's/LDFLAGS/RAW_LDFLAGS/g' \
+ -i "${S}/csu/i386-elf/Makefile" \
+ -i "${S}/csu/ia64/Makefile" || die
+}
+
+src_compile() {
+ cd "${WORKDIR}/include"
+ $(freebsd_get_bmake) CC="$(tc-getCC)" || die "make include failed"
+
+ use crosscompile_opts_headers-only && return 0
+
+ # Bug #270098
+ append-flags $(test-flags -fno-strict-aliasing)
+
+ # Bug #324445
+ append-flags $(test-flags -fno-strict-overflow)
+
+ strip-flags
+ if [ "${CTARGET}" != "${CHOST}" ]; then
+ export YACC='yacc -by'
+ CHOST=${CTARGET} tc-export CC LD CXX RANLIB
+ mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= NLS="
+
+ local machine
+ machine=$(tc-arch-kernel ${CTARGET})
+
+ local csudir
+ if [ -d "${S}/csu/${machine}-elf" ]; then
+ csudir="${S}/csu/${machine}-elf"
+ else
+ csudir="${S}/csu/${machine}"
+ fi
+ export RAW_LDFLAGS=$(raw-ldflags)
+ cd "${csudir}"
+ $(freebsd_get_bmake) ${mymakeopts} || die "make csu failed"
+
+ append-flags "-isystem /usr/${CTARGET}/usr/include"
+ append-flags "-isystem ${WORKDIR}/lib/libutil"
+ append-flags "-isystem ${WORKDIR}/lib/msun/${machine/i386/i387}"
+ append-flags "-B ${csudir}"
+ append-ldflags "-B ${csudir}"
+
+ # First compile libssp_nonshared.a and add it's path to LDFLAGS.
+ cd "${WORKDIR}/gnu/lib/libssp/libssp_nonshared/" || die "missing libssp."
+ $(freebsd_get_bmake) ${mymakeopts} || die "make libssp failed"
+ append-ldflags "-L${WORKDIR}/gnu/lib/libssp/libssp_nonshared/"
+
+ export RAW_LDFLAGS=$(raw-ldflags)
+ cd "${S}/libc"
+ $(freebsd_get_bmake) ${mymakeopts} || die "make libc failed"
+ cd "${S}/msun"
+ append-ldflags "-L${WORKDIR}/lib/libc"
+ export RAW_LDFLAGS=$(raw-ldflags)
+ LDADD="-lssp_nonshared" $(freebsd_get_bmake) ${mymakeopts} || die "make libc failed"
+ cd "${WORKDIR}/gnu/lib/libssp/" || die "missing libssp."
+ $(freebsd_get_bmake) ${mymakeopts} || die "make libssp failed"
+ cd "${WORKDIR}/lib/libthr/" || die "missing libthr"
+ $(freebsd_get_bmake) ${mymakeopts} || die "make libthr failed"
+ else
+ # Forces to use the local copy of headers as they might be outdated in
+ # the system
+ append-flags "-isystem '${WORKDIR}/include_proper'"
+
+ # First compile libssp_nonshared.a and add it's path to LDFLAGS.
+ einfo "Compiling libssp in \"${WORKDIR}/gnu/lib/libssp/\"."
+ cd "${WORKDIR}/gnu/lib/libssp/" || die "missing libssp."
+ NOFLAGSTRIP=yes freebsd_src_compile
+ # Hack libssp_nonshared.a into libc & others since we don't have
+ # the linker script in place yet.
+ append-ldflags "-L${WORKDIR}/gnu/lib/libssp/libssp_nonshared/"
+ einfo "Compiling libc."
+ cd "${S}"
+ export RAW_LDFLAGS=$(raw-ldflags)
+ NOFLAGSTRIP=yes LDADD="-lssp_nonshared" freebsd_src_compile
+ fi
+}
+
+src_install() {
+ [ "${CTARGET}" = "${CHOST}" ] \
+ && INCLUDEDIR="/usr/include" \
+ || INCLUDEDIR="/usr/${CTARGET}/usr/include"
+ dodir ${INCLUDEDIR}
+ einfo "Installing for ${CTARGET} in ${CHOST}.."
+ install_includes ${INCLUDEDIR}
+
+ # Install math.h when crosscompiling, at this point
+ if [ "${CHOST}" != "${CTARGET}" ]; then
+ insinto "/usr/${CTARGET}/usr/include"
+ doins "${S}/msun/src/math.h"
+ fi
+
+ use crosscompile_opts_headers-only && return 0
+ local mylibdir=$(get_libdir)
+
+ if [ "${CTARGET}" != "${CHOST}" ]; then
+ local csudir
+ if [ -d "${S}/csu/$(tc-arch-kernel ${CTARGET})-elf" ]; then
+ csudir="${S}/csu/$(tc-arch-kernel ${CTARGET})-elf"
+ else
+ csudir="${S}/csu/$(tc-arch-kernel ${CTARGET})"
+ fi
+ cd "${csudir}"
+ $(freebsd_get_bmake) ${mymakeopts} DESTDIR="${D}" install \
+ FILESDIR="/usr/${CTARGET}/usr/lib" LIBDIR="/usr/${CTARGET}/usr/lib" || die "Install csu failed"
+
+ cd "${S}/libc"
+ $(freebsd_get_bmake) ${mymakeopts} DESTDIR="${D}" install NO_MAN= \
+ SHLIBDIR="/usr/${CTARGET}/lib" LIBDIR="/usr/${CTARGET}/usr/lib" || die "Install libc failed"
+
+ cd "${S}/msun"
+ $(freebsd_get_bmake) ${mymakeopts} DESTDIR="${D}" install NO_MAN= \
+ INCLUDEDIR="/usr/${CTARGET}/usr/include" \
+ SHLIBDIR="/usr/${CTARGET}/lib" LIBDIR="/usr/${CTARGET}/usr/lib" || die "Install msun failed"
+
+ cd "${WORKDIR}/gnu/lib/libssp/"
+ $(freebsd_get_bmake) ${mymakeopts} DESTDIR="${D}" install NO_MAN= \
+ INCLUDEDIR="/usr/${CTARGET}/usr/include" \
+ SHLIBDIR="/usr/${CTARGET}/lib" LIBDIR="/usr/${CTARGET}/usr/lib" || die "Install ssp failed"
+
+ cd "${WORKDIR}/lib/libthr/"
+ $(freebsd_get_bmake) ${mymakeopts} DESTDIR="${D}" install NO_MAN= \
+ INCLUDEDIR="/usr/${CTARGET}/usr/include" \
+ SHLIBDIR="/usr/${CTARGET}/lib" LIBDIR="/usr/${CTARGET}/usr/lib" || die "Install libthr failed"
+
+ dosym "usr/include" "/usr/${CTARGET}/sys-include"
+ else
+ # Set SHLIBDIR and LIBDIR for multilib
+ cd "${WORKDIR}/gnu/lib/libssp"
+ SHLIBDIR="/${mylibdir}" LIBDIR="/usr/${mylibdir}" mkinstall || die "Install ssp failed."
+ cd "${S}"
+ SHLIBDIR="/${mylibdir}" LIBDIR="/usr/${mylibdir}" mkinstall || die "Install failed"
+ fi
+
+ # Don't install the rest of the configuration files if crosscompiling
+ if [ "${CTARGET}" != "${CHOST}" ] ; then
+ # This is to get it stripped with the correct tools, otherwise it gets
+ # stripped with the host strip.
+ export CHOST=${CTARGET}
+ return 0
+ fi
+
+ # Symlink libbsdxml to libexpat as we use expat in favor of the renaming done
+ # on FreeBSD.
+ dosym libexpat.so /usr/${mylibdir}/libbsdxml.so
+
+ # install libstand files
+ dodir /usr/include/libstand
+ insinto /usr/include/libstand
+ doins "${S}"/libstand/*.h
+
+ cd "${WORKDIR}/etc/"
+ insinto /etc
+ doins auth.conf nls.alias mac.conf netconfig
+
+ # Install ttys file
+ local MACHINE="$(tc-arch-kernel)"
+ doins "etc.${MACHINE}"/*
+
+ # Generate ldscripts, otherwise bad thigs are supposed to happen
+ gen_usr_ldscript libalias_cuseeme.so libalias_dummy.so libalias_ftp.so \
+ libalias_irc.so libalias_nbt.so libalias_pptp.so libalias_skinny.so \
+ libalias_smedia.so libssp.so
+ # These show on QA warnings too, however they're pretty much bsd only,
+ # aka, no autotools for them.
+ # libbsdxml.so libcam.so libcrypt.so libdevstat.so libgeom.so \
+ # libipsec.so libipx.so libkiconv.so libkvm.so libmd.so libsbuf.so libufs.so \
+ # libutil.so
+
+ # Generate libc.so ldscript for inclusion of libssp_nonshared.a when linking
+ # this is done to avoid having to touch gcc spec file as it is currently
+ # done on FreeBSD upstream, mostly because their binutils aren't able to
+ # cope with linker scripts yet.
+ # Taken from toolchain-funcs.eclass:
+ local output_format
+ output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
+ [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
+ # Clear the symlink.
+ rm -f "${D}/usr/${mylibdir}/libc.so"
+ cat > "${D}/usr/${mylibdir}/libc.so" <<-END_LDSCRIPT
+/* GNU ld script
+ SSP (-fstack-protector) requires __stack_chk_fail_local to be local.
+ GCC invokes this symbol in a non-PIC way, which results in TEXTRELs if
+ this symbol was provided by a shared libc. So we link in
+ libssp_nonshared.a from here.
+ */
+${output_format}
+GROUP ( /${mylibdir}/libc.so.7 /usr/${mylibdir}/libssp_nonshared.a )
+END_LDSCRIPT
+
+ dodir /etc/sandbox.d
+ cat - > "${D}"/etc/sandbox.d/00freebsd <<EOF
+# /dev/crypto is used mostly by OpenSSL on *BSD platforms
+# leave it available as packages might use OpenSSL commands
+# during compile or install phase.
+SANDBOX_PREDICT="/dev/crypto"
+EOF
+
+ # Install a libusb.pc for better compat with Linux's libusb
+ if use usb ; then
+ dodir /usr/$(get_libdir)/pkgconfig
+ sed -e "s:@LIBDIR@:/usr/$(get_libdir):" "${FILESDIR}/libusb.pc.in" > "${D}/usr/$(get_libdir)/pkgconfig/libusb.pc" || die
+ fi
+}
+
+install_includes()
+{
+ local INCLUDEDIR="$1"
+
+ # The idea is to be called from either install or unpack.
+ # During unpack it's required to install them as portage's user.
+ if [[ "${EBUILD_PHASE}" == "install" ]]; then
+ local DESTDIR="${D}"
+ BINOWN="root"
+ BINGRP="wheel"
+ else
+ local DESTDIR="${WORKDIR}"
+ [[ -z "${USER}" ]] && USER="portage"
+ BINOWN="${USER}"
+ [[ -z "${GROUPS}" ]] && GROUPS="portage"
+ BINGRP="${GROUPS}"
+ fi
+
+ # This is for ssp/ssp.h.
+ einfo "Building ssp.h"
+ cd "${WORKDIR}/gnu/lib/libssp/" || die "missing libssp"
+ $(freebsd_get_bmake) ssp.h || die "problem building ssp.h"
+
+ # Must exist before we use it.
+ [[ -d "${DESTDIR}${INCLUDEDIR}" ]] || die "dodir or mkdir ${INCLUDEDIR} before using install_includes."
+ cd "${WORKDIR}/include"
+
+ local MACHINE="$(tc-arch-kernel)"
+
+ einfo "Installing includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ $(freebsd_get_bmake) installincludes \
+ MACHINE=${MACHINE} DESTDIR="${DESTDIR}" \
+ INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" || die "install_includes() failed"
+ einfo "includes installed ok."
+ einfo "Installing ssp includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ cd "${WORKDIR}/gnu/lib/libssp"
+ $(freebsd_get_bmake) installincludes DESTDIR="${DESTDIR}" \
+ MACHINE=${MACHINE} INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" || die "problem installing ssp includes."
+ einfo "ssp includes installed ok."
+ einfo "Installing librtld_db includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ cd "${S}/librtld_db" || die "missing librtld_db"
+ $(freebsd_get_bmake) installincludes DESTDIR="${DESTDIR}" \
+ MACHINE=${MACHINE} INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" || die "problem installing librtld_db includes."
+ einfo "librtld_db includes installed ok."
+}
diff --git a/sys-freebsd/freebsd-lib/freebsd-lib-9.1-r11.ebuild b/sys-freebsd/freebsd-lib/freebsd-lib-9.1-r11.ebuild
new file mode 100644
index 000000000000..8eee4f7d190c
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/freebsd-lib-9.1-r11.ebuild
@@ -0,0 +1,617 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic multilib toolchain-funcs eutils multibuild multilib-build
+
+DESCRIPTION="FreeBSD's base system libraries"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+
+# Crypto is needed to have an internal OpenSSL header
+# sys is needed for libalias, probably we can just extract that instead of
+# extracting the whole tarball
+SRC_URI="mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${CRYPTO}.tar.bz2
+ mirror://gentoo/${LIBEXEC}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2
+ mirror://gentoo/${INCLUDE}.tar.bz2
+ mirror://gentoo/${USBIN}.tar.bz2
+ mirror://gentoo/${GNU}.tar.bz2
+ build? (
+ mirror://gentoo/${SYS}.tar.bz2 )
+ zfs? (
+ mirror://gentoo/${CDDL}.tar.bz2 )"
+
+if [ "${CATEGORY#*cross-}" = "${CATEGORY}" ]; then
+ RDEPEND="ssl? ( dev-libs/openssl )
+ hesiod? ( net-dns/hesiod )
+ kerberos? ( app-crypt/heimdal )
+ usb? ( !dev-libs/libusb )
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )
+ >=dev-libs/expat-2.0.1
+ !sys-libs/libutempter
+ !sys-freebsd/freebsd-headers"
+ DEPEND="${RDEPEND}
+ >=sys-devel/flex-2.5.31-r2
+ =sys-freebsd/freebsd-sources-${RV}*"
+else
+ SRC_URI="${SRC_URI}
+ mirror://gentoo/${SYS}.tar.bz2"
+fi
+
+DEPEND="${DEPEND}
+ userland_GNU? ( sys-apps/mtree )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/lib"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [ "${CTARGET}" = "${CHOST}" -a "${CATEGORY#*cross-}" != "${CATEGORY}" ]; then
+ export CTARGET=${CATEGORY/cross-}
+fi
+
+IUSE="atm bluetooth ssl hesiod ipv6 kerberos usb netware
+ build crosscompile_opts_headers-only zfs
+ userland_GNU userland_BSD"
+
+QA_DT_NEEDED="lib/libc.so.7 usr/lib32/libc.so.7"
+
+pkg_setup() {
+ [ -c /dev/zero ] || \
+ die "You forgot to mount /dev; the compiled libc would break."
+
+ if ! use ssl && use kerberos; then
+ eerror "If you want kerberos support you need to enable ssl support, too."
+ fi
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use hesiod || mymakeopts="${mymakeopts} WITHOUT_HESIOD= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= WITHOUT_GSSAPI= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_BIND= WITHOUT_BIND_LIBS= WITHOUT_SENDMAIL= WITHOUT_CLANG= "
+
+ if [ "${CTARGET}" != "${CHOST}" ]; then
+ mymakeopts="${mymakeopts} MACHINE=$(tc-arch-kernel ${CTARGET})"
+ mymakeopts="${mymakeopts} MACHINE_ARCH=$(tc-arch-kernel ${CTARGET})"
+ fi
+}
+
+PATCHES=(
+ "${FILESDIR}/${PN}-6.0-pmc.patch"
+ "${FILESDIR}/${PN}-6.0-flex-2.5.31.patch"
+ "${FILESDIR}/${PN}-6.1-csu.patch"
+ "${FILESDIR}/${PN}-9.0-liblink.patch"
+ "${FILESDIR}/${PN}-bsdxml2expat.patch"
+ "${FILESDIR}/${PN}-9.0-netware.patch"
+ "${FILESDIR}/${PN}-9.0-cve-2010-2632.patch"
+ "${FILESDIR}/${PN}-9.0-bluetooth.patch"
+ "${FILESDIR}/${PN}-9.1-.eh_frame_hdr-fix.patch"
+ "${FILESDIR}/${PN}-add-nossp-cflags.patch"
+ )
+
+# Here we disable and remove source which we don't need or want
+# In order:
+# - ncurses stuff
+# - libexpat creates a bsdxml library which is the same as expat
+# - archiving libraries (have their own ebuild)
+# - sendmail libraries (they are installed by sendmail)
+# - SNMP library and dependency (have their own ebuilds)
+# - libstand: static library, 32bits on amd64 used for boot0, we build it from
+# boot0 instead.
+#
+# The rest are libraries we already have somewhere else because
+# they are contribution.
+# Note: libtelnet is an internal lib used by telnet and telnetd programs
+# as it's not used in freebsd-lib package itself, it's pointless building
+# it here.
+REMOVE_SUBDIRS="ncurses \
+ libexpat \
+ libz libbz2 libarchive liblzma \
+ libsm libsmdb libsmutil \
+ libbegemot libbsnmp \
+ libpam libpcap bind libwrap libmagic \
+ libcom_err libtelnet
+ libelf libedit
+ libstand
+ libgssapi"
+
+# Are we building a cross-compiler?
+is_crosscompile() {
+ [ "${CATEGORY#*cross-}" != "${CATEGORY}" ]
+}
+
+src_prepare() {
+ sed -i.bak -e 's:-o/dev/stdout:-t:' "${S}/libc/net/Makefile.inc"
+
+ # Upstream Display Managers default to using VT7
+ # We should make FreeBSD allow this by default
+ local x=
+ for x in "${WORKDIR}"/etc/etc.*/ttys ; do
+ sed -i.bak \
+ -e '/ttyv5[[:space:]]/ a\
+# Display Managers default to VT7.\
+# If you use the xdm init script, keep ttyv6 commented out\
+# unless you force a different VT for the DM being used.' \
+ -e '/^ttyv[678][[:space:]]/ s/^/# /' "${x}" \
+ || die "Failed to sed ${x}"
+ rm "${x}".bak
+ done
+
+ # This one is here because it also
+ # patches "${WORKDIR}/include"
+ cd "${WORKDIR}"
+ epatch "${FILESDIR}/${PN}-includes.patch"
+ epatch "${FILESDIR}/${PN}-8.0-gcc45.patch"
+ epatch "${FILESDIR}/${PN}-9.0-opieincludes.patch"
+ epatch "${FILESDIR}/${PN}-9.1-aligned_alloc.patch"
+ epatch "${FILESDIR}/${PN}-9.1-rmgssapi.patch"
+
+ # Don't install the hesiod man page or header
+ rm "${WORKDIR}"/include/hesiod.h || die
+ sed -i.bak -e 's:hesiod.h::' "${WORKDIR}"/include/Makefile || die
+ sed -i.bak -e 's:hesiod.c::' -e 's:hesiod.3::' \
+ "${WORKDIR}"/lib/libc/net/Makefile.inc || die
+
+ # Fix the Makefiles of these few libraries that will overwrite our LDADD.
+ cd "${S}"
+ for dir in libradius libtacplus libcam libdevstat libfetch libgeom libmemstat libopie \
+ libsmb libprocstat libulog; do sed -i.bak -e 's:LDADD=:LDADD+=:g' "${dir}/Makefile" || \
+ die "Problem fixing \"${dir}/Makefile"
+ done
+ # Call LD with LDFLAGS, rename them to RAW_LDFLAGS
+ sed -e 's/LDFLAGS/RAW_LDFLAGS/g' \
+ -i "${S}/csu/i386-elf/Makefile" \
+ -i "${S}/csu/ia64/Makefile" || die
+ if use build; then
+ cd "${WORKDIR}"
+ # This patch has to be applied on ${WORKDIR}/sys, so we do it here since it
+ # shouldn't be a symlink to /usr/src/sys (which should be already patched)
+ epatch "${FILESDIR}"/${PN}-7.1-types.h-fix.patch
+ epatch "${FILESDIR}"/freebsd-sources-9.0-sysctluint.patch
+ return 0
+ fi
+
+ if ! is_crosscompile ; then
+ ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys" || die "Couldn't make sys symlink!"
+ else
+ sed -i.bak -e "s:/usr/include:/usr/${CTARGET}/usr/include:g" \
+ "${S}/libc/rpc/Makefile.inc" \
+ "${S}/libc/yp/Makefile.inc"
+ fi
+
+ if install --version 2> /dev/null | grep -q GNU; then
+ sed -i.bak -e 's:${INSTALL} -C:${INSTALL}:' "${WORKDIR}/include/Makefile"
+ fi
+
+ # Try to fix sed calls for GNU sed. Do it only with GNU userland and force
+ # BSD's sed on BSD.
+ cd "${S}"
+ if use userland_GNU; then
+ find . -name Makefile -exec sed -ibak 's/sed -i /sed -i/' {} \;
+ fi
+}
+
+get_csudir() {
+ if [ -d "${WORKDIR}/lib/csu/$1-elf" ]; then
+ echo "lib/csu/$1-elf"
+ else
+ echo "lib/csu/$1"
+ fi
+}
+
+bootstrap_csu() {
+ local csudir="$(get_csudir $(tc-arch-kernel ${CTARGET}))"
+ export RAW_LDFLAGS=$(raw-ldflags)
+ cd "${WORKDIR}/${csudir}" || die "Missing ${csudir}."
+ freebsd_src_compile
+
+ CFLAGS="${CFLAGS} -B ${MAKEOBJDIRPREFIX}/${WORKDIR}/${csudir}"
+ append-ldflags "-B ${MAKEOBJDIRPREFIX}/${WORKDIR}/${csudir}"
+
+ cd "${WORKDIR}/gnu/lib/csu" || die
+ freebsd_src_compile
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+ for i in *.So ; do
+ ln -s $i ${i%.So}S.o
+ done
+ CFLAGS="${CFLAGS} -B ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+ append-ldflags "-B ${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/csu"
+}
+
+# Compile libssp_nonshared.a and add it's path to LDFLAGS.
+bootstrap_libssp_nonshared() {
+ cd "${WORKDIR}/gnu/lib/libssp/libssp_nonshared/" || die "missing libssp."
+ freebsd_src_compile
+ append-ldflags "-L${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/libssp/libssp_nonshared/"
+ export LDADD="-lssp_nonshared"
+}
+
+bootstrap_libc() {
+ cd "${WORKDIR}/lib/libc" || die
+ freebsd_src_compile
+ append-ldflags "-L${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libc"
+}
+
+bootstrap_libgcc() {
+ cd "${WORKDIR}/lib/libcompiler_rt" || die
+ freebsd_src_compile
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libcompiler_rt" || die
+ ln -s libcompiler_rt.a libgcc.a || die
+ append-ldflags "-L${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libcompiler_rt"
+
+ bootstrap_libc
+
+ cd "${WORKDIR}/gnu/lib/libgcc" || die
+ freebsd_src_compile
+ append-ldflags "-L${MAKEOBJDIRPREFIX}/${WORKDIR}/gnu/lib/libgcc"
+}
+
+bootstrap_libthr() {
+ cd "${WORKDIR}/lib/libthr" || die
+ freebsd_src_compile
+ append-ldflags "-L${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libthr"
+ cd "${MAKEOBJDIRPREFIX}/${WORKDIR}/lib/libthr" || die
+ ln -s libthr.so libpthread.so
+}
+
+# What to build for a cross-compiler.
+# We also need the csu but this has to be handled separately.
+CROSS_SUBDIRS="lib/libc lib/msun gnu/lib/libssp/libssp_nonshared lib/libthr lib/libutil lib/librt"
+
+# What to build for non-default ABIs.
+NON_NATIVE_SUBDIRS="${CROSS_SUBDIRS} gnu/lib/csu lib/libcompiler_rt gnu/lib/libgcc lib/libmd lib/libcrypt"
+
+# Subdirs for a native build:
+NATIVE_SUBDIRS="lib gnu/lib/libssp/libssp_nonshared gnu/lib/libregex gnu/lib/csu gnu/lib/libgcc"
+
+# Is my $ABI native ?
+is_native_abi() {
+ is_crosscompile && return 1
+ multilib_is_native_abi
+}
+
+# Do we need to bootstrap the csu and libssp_nonshared?
+need_bootstrap() {
+ is_crosscompile || use build || { ! is_native_abi && ! has_version '>=sys-freebsd/freebsd-lib-9.1-r8[multilib]' && ! has_version ">=sys-freebsd/freebsd-lib-9.1-r11[${MULTILIB_USEDEP}]" ; } || has_version "<${CATEGORY}/${P}"
+}
+
+# Get the subdirs we are building.
+get_subdirs() {
+ local ret=""
+ if is_native_abi ; then
+ # If we are building for the native ABI, build everything
+ ret="${NATIVE_SUBDIRS}"
+ elif is_crosscompile ; then
+ # With a cross-compiler we only build the very core parts.
+ ret="${CROSS_SUBDIRS}"
+ if [ "${EBUILD_PHASE}" = "install" ]; then
+ # Add the csu dir first when installing. We treat it separately for
+ # compiling.
+ ret="$(get_csudir $(tc-arch-kernel ${CTARGET})) ${ret}"
+ fi
+ else
+ # For the non-native ABIs we only build the csu parts and very core
+ # libraries for now.
+ ret="${NON_NATIVE_SUBDIRS} $(get_csudir $(tc-arch-kernel ${CHOST}))"
+ fi
+ echo "${ret}"
+}
+
+# Bootstrap the core libraries and setup the flags so that the other parts can
+# build against it.
+do_bootstrap() {
+ einfo "Bootstrapping on ${CHOST} for ${CTARGET}"
+ if ! is_crosscompile ; then
+ # Pre-install headers, but not when building a cross-compiler since we
+ # assume they have been installed in the previous pass.
+ einfo "Pre-installing includes in include_proper_${ABI}"
+ mkdir "${WORKDIR}/include_proper_${ABI}" || die
+ CTARGET="${CHOST}" install_includes "/include_proper_${ABI}"
+ CFLAGS="${CFLAGS} -isystem ${WORKDIR}/include_proper_${ABI}"
+ fi
+ bootstrap_csu
+ bootstrap_libssp_nonshared
+ is_crosscompile && bootstrap_libc
+ is_crosscompile || is_native_abi || bootstrap_libgcc
+ is_native_abi || bootstrap_libthr
+}
+
+# Compile it. Assume we have the toolchain setup correctly.
+do_compile() {
+ # Bootstrap if needed, otherwise assume the system headers are in
+ # /usr/include.
+ if need_bootstrap ; then
+ do_bootstrap
+ else
+ CFLAGS="${CFLAGS} -isystem /usr/include"
+ fi
+
+ export RAW_LDFLAGS=$(raw-ldflags)
+
+ # Everything is now setup, build it!
+ for i in $(get_subdirs) ; do
+ einfo "Building in ${i}... with CC=${CC} and CFLAGS=${CFLAGS}"
+ cd "${WORKDIR}/${i}/" || die "missing ${i}."
+ freebsd_src_compile || die "make ${i} failed"
+ done
+}
+
+src_compile() {
+ # Does not work with GNU sed
+ # Force BSD's sed on BSD.
+ if use userland_BSD ; then
+ export ESED=/usr/bin/sed
+ unalias sed
+ fi
+
+ use usb && export NON_NATIVE_SUBDIRS="${NON_NATIVE_SUBDIRS} lib/libusb lib/libusbhid"
+
+ cd "${WORKDIR}/include"
+ $(freebsd_get_bmake) CC="$(tc-getCC)" || die "make include failed"
+
+ use crosscompile_opts_headers-only && return 0
+
+ # Bug #270098
+ append-flags $(test-flags -fno-strict-aliasing)
+
+ # Bug #324445
+ append-flags $(test-flags -fno-strict-overflow)
+
+ # strip flags and do not do it later, we only add safe, and in fact
+ # needed flags after all
+ strip-flags
+ export NOFLAGSTRIP=yes
+ if is_crosscompile ; then
+ export YACC='yacc -by'
+ CHOST=${CTARGET} tc-export CC LD CXX RANLIB
+ mymakeopts="${mymakeopts} NLS="
+ CFLAGS="${CFLAGS} -isystem /usr/${CTARGET}/usr/include"
+ append-ldflags "-L${WORKDIR}/${CHOST}/${WORKDIR}/lib/libc"
+ fi
+
+ if is_crosscompile ; then
+ do_compile
+ else
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper do_compile
+ fi
+}
+
+gen_libc_ldscript() {
+ # Parameters:
+ # $1 = target libdir
+ # $2 = source libc dir
+ # $3 = source libssp_nonshared dir
+
+ # Clear the symlink.
+ rm -f "${D}/$2/libc.so" || die
+
+ # Move the library if needed
+ if [ "$1" != "$2" ] ; then
+ mv "${D}/$2/libc.so.7" "${D}/$1/" || die
+ fi
+
+ # Generate libc.so ldscript for inclusion of libssp_nonshared.a when linking
+ # this is done to avoid having to touch gcc spec file as it is currently
+ # done on FreeBSD upstream, mostly because their binutils aren't able to
+ # cope with linker scripts yet.
+ # Taken from toolchain-funcs.eclass:
+ local output_format
+ output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p')
+ [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )"
+
+ cat > "${D}/$2/libc.so" <<-END_LDSCRIPT
+/* GNU ld script
+ SSP (-fstack-protector) requires __stack_chk_fail_local to be local.
+ GCC invokes this symbol in a non-PIC way, which results in TEXTRELs if
+ this symbol was provided by a shared libc. So we link in
+ libssp_nonshared.a from here.
+ */
+${output_format}
+GROUP ( /$1/libc.so.7 /$3/libssp_nonshared.a )
+END_LDSCRIPT
+}
+
+header_list=""
+
+move_header() {
+ local dirname=$(dirname ${1})
+ local filename=$(basename ${1})
+
+ if [ ! -d "${dirname}/${ABI}" ] ; then
+ mkdir "${dirname}/${ABI}" || die
+ fi
+
+ mv "${1}" "${dirname}/${ABI}/" || die
+
+ export header_list="${header_list} ${1}"
+}
+
+make_header_template() {
+ cat <<-END_HEADER
+/*
+ * Wrapped header for multilib support.
+ * See the real headers included below.
+ */
+
+#if defined(__x86_64__)
+ @ABI_amd64_fbsd@
+#elif defined(__i386__)
+ @ABI_x86_fbsd@
+#else
+ @ABI_${DEFAULT_ABI}@
+#endif
+END_HEADER
+}
+
+wrap_header() {
+ local dirname=$(dirname ${1})
+ local filename=$(basename ${1})
+
+ if [ -n "${dirname#.}" ] ; then
+ dirname="${dirname}/${2}"
+ else
+ dirname="${2}"
+ fi
+
+ if [ -f "${dirname}/${filename}" ] ; then
+ sed -e "s:@ABI_${2}@:#include <${dirname}/${filename}>:" ${1}
+ else
+ cat ${1}
+ fi
+}
+
+wrap_header_end() {
+ sed -e "s:@ABI_.*@:#error \"Sorry, no support for your ABI.\":" ${1}
+}
+
+do_install() {
+ if is_crosscompile ; then
+ INCLUDEDIR="/usr/${CTARGET}/usr/include"
+ else
+ INCLUDEDIR="/usr/include"
+ fi
+
+ dodir ${INCLUDEDIR}
+ CTARGET="${CHOST}" \
+ install_includes ${INCLUDEDIR}
+
+ is_crosscompile && use crosscompile_opts_headers-only && return 0
+
+ for i in $(get_subdirs) ; do
+ einfo "Installing in ${i}..."
+ cd "${WORKDIR}/${i}/" || die "missing ${i}."
+ freebsd_src_install || die "Install ${i} failed"
+ done
+
+ if ! is_crosscompile ; then
+ if ! multilib_is_native_abi ; then
+ gen_libc_ldscript "usr/$(get_libdir)" "usr/$(get_libdir)" "usr/$(get_libdir)"
+ else
+ dodir "$(get_libdir)"
+ gen_libc_ldscript "$(get_libdir)" "usr/$(get_libdir)" "usr/$(get_libdir)"
+ fi
+ else
+ CHOST=${CTARGET} gen_libc_ldscript "usr/${CTARGET}/usr/lib" "usr/${CTARGET}/usr/lib" "usr/${CTARGET}/usr/lib"
+ fi
+
+ # Install a libusb.pc for better compat with Linux's libusb
+ if use usb ; then
+ dodir /usr/$(get_libdir)/pkgconfig
+ sed -e "s:@LIBDIR@:/usr/$(get_libdir):" "${FILESDIR}/libusb.pc.in" > "${D}/usr/$(get_libdir)/pkgconfig/libusb.pc" || die
+ sed -e "s:@LIBDIR@:/usr/$(get_libdir):" "${FILESDIR}/libusb-1.0.pc.in" > "${D}/usr/$(get_libdir)/pkgconfig/libusb-1.0.pc" || die
+ fi
+
+ # Generate ldscripts for core libraries that will go in /
+ multilib_is_native_abi && \
+ gen_usr_ldscript -a alias cam geom ipsec jail kiconv \
+ kvm m md procstat sbuf thr ufs util
+
+ if [[ ${#MULTIBUILD_VARIANTS[@]} -gt 1 ]] ; then
+ cd "${D}/usr/include"
+ for i in machine/*.h fenv.h ; do
+ move_header ${i}
+ done
+ if multilib_is_native_abi ; then
+ # Supposedly the last one!
+ local uniq_headers="$(echo ${header_list} | tr ' ' '\n' | sort | uniq | tr '\n' ' ')"
+ for j in ${uniq_headers} ; do
+ make_header_template > ${j}
+ for i in $(get_all_abis) ; do
+ wrap_header ${j} ${i} > ${j}.new
+ cp ${j}.new ${j}
+ rm -f ${j}.new
+ done
+ wrap_header_end ${j} > ${j}.new
+ cp ${j}.new ${j}
+ rm -f ${j}.new
+ done
+ fi
+ fi
+}
+
+src_install() {
+ if is_crosscompile ; then
+ einfo "Installing for ${CTARGET} in ${CHOST}.."
+ # From this point we need to force: get stripped with the correct tools,
+ # get tc-arch-kernel to return the right value, etc.
+ export CHOST=${CTARGET}
+
+ mymakeopts="${mymakeopts} NO_MAN= \
+ INCLUDEDIR=/usr/${CTARGET}/usr/include \
+ SHLIBDIR=/usr/${CTARGET}/usr/lib \
+ LIBDIR=/usr/${CTARGET}/usr/lib"
+
+ dosym "usr/include" "/usr/${CTARGET}/sys-include"
+ do_install
+
+ return 0
+ else
+ export STRIP_MASK="*/usr/lib*/*crt*.o"
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper do_install
+ fi
+
+ cd "${WORKDIR}/etc/"
+ insinto /etc
+ doins nls.alias mac.conf netconfig
+
+ # Install ttys file
+ local MACHINE="$(tc-arch-kernel)"
+ doins "etc.${MACHINE}"/*
+
+ # unset to run QA check properly
+ unset ESED
+}
+
+install_includes()
+{
+ local INCLUDEDIR="$1"
+
+ # The idea is to be called from either install or unpack.
+ # During unpack it's required to install them as portage's user.
+ if [[ "${EBUILD_PHASE}" == "install" ]]; then
+ local DESTDIR="${D}"
+ BINOWN="root"
+ BINGRP="wheel"
+ else
+ local DESTDIR="${WORKDIR}"
+ [[ -z "${USER}" ]] && USER="portage"
+ BINOWN="${USER}"
+ [[ -z "${GROUPS}" ]] && GROUPS="portage"
+ BINGRP="${GROUPS}"
+ fi
+
+ # Must exist before we use it.
+ [[ -d "${DESTDIR}${INCLUDEDIR}" ]] || die "dodir or mkdir ${INCLUDEDIR} before using install_includes."
+ cd "${WORKDIR}/include"
+
+ local MACHINE="$(tc-arch-kernel)"
+
+ einfo "Installing includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ $(freebsd_get_bmake) installincludes \
+ MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE} \
+ DESTDIR="${DESTDIR}" \
+ INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" || die "install_includes() failed"
+ einfo "includes installed ok."
+ EXTRA_INCLUDES="lib/librtld_db lib/libutil lib/msun gnu/lib/libregex"
+ for i in $EXTRA_INCLUDES; do
+ einfo "Installing $i includes into ${INCLUDEDIR} as ${BINOWN}:${BINGRP}..."
+ cd "${WORKDIR}/$i" || die
+ $(freebsd_get_bmake) installincludes DESTDIR="${DESTDIR}" \
+ MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE} \
+ INCLUDEDIR="${INCLUDEDIR}" BINOWN="${BINOWN}" \
+ BINGRP="${BINGRP}" || die "problem installing $i includes."
+ einfo "$i includes installed ok."
+ done
+}
diff --git a/sys-freebsd/freebsd-lib/metadata.xml b/sys-freebsd/freebsd-lib/metadata.xml
new file mode 100644
index 000000000000..24ca54034a3f
--- /dev/null
+++ b/sys-freebsd/freebsd-lib/metadata.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="hesiod">Enable support for net-dns/hesiod</flag>
+ <flag name="netware">
+ Build libraries and tools to work with NetWare protocols (IPX
+ and NCP).
+ </flag>
+ <flag name="zfs">Enable ZFS support.</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-libexec/Manifest b/sys-freebsd/freebsd-libexec/Manifest
new file mode 100644
index 000000000000..2042d69fa0c3
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/Manifest
@@ -0,0 +1,36 @@
+AUX bootpd.confd 183 SHA256 c70c6a7a99470354a5f61bfe5c0f71325f4896e41da150e782223a30f07a275c SHA512 3f097c1acb5547add8d12fcee0b4b55b03896cb3ba473214d1634804f3683e0dea4b3c9559b61b2366b7f264d7a3d878695e16f29acff076b8060ca1fd79757f WHIRLPOOL c6721ac9b3ba70268fdba8c81ad9225e26049a5eb5ef8ea9bccc5fbbe7a110defe15df1d27b1c4b54f92e19d7d8b2099f87e7972faa0e5ddf17b66d30e26e0ad
+AUX bootpd.initd 554 SHA256 a1b1160a3e3d8f068a446ba5c9210737e120130fe173e68026263b7d057efb7e SHA512 69bc8dc708d955e41d3e0cfb997f96b589e8a3d33b11b2728541082fc5ab0844d753ca036a6c70ddd23a2a0085c39a89340b0f7d332b1384c94671cf3fe09b66 WHIRLPOOL 4764e746340fa0ace0310880a8ac13852df14ca14ba077610b5bfea09a45c093d064b5a534ed6e3dd839c869cf0c8013bcfe022814793ecc5f6e38cc08335f92
+AUX freebsd-libexec-10.2-atf-check.patch 809 SHA256 75cddd83ece1a3be8c10c0e2fd335180738d5b6a6b01b89e51d5c53243e54f46 SHA512 46b265db484d707e9e65906e8d5b3dbb06223c1c229c78b6cb92864f4a4a017b61cfd2de35e5533bae2eb8867adea5e1732c279bc5d90e60d07646b9a4b06681 WHIRLPOOL 77f069b1c649dd6f37ed4b0343c43609c7bc9efb09ebd0e22449a5db7d8eabbb9a870127974639108ceb3bf272bca64a3358809ea2a6a89296ac2097125cefc2
+AUX freebsd-libexec-7.2-pic.patch 348 SHA256 424ed7b69067d3a3a77ad387026548b77d41412f52ae17c737e96e57b6cb3b0f SHA512 c77297582efccd799f6d0e67c0976f1ee5551617abf2df9ccd0e2fc0abd7fb76ecaf7f5e019356034fb47d3cc39590a5eecd9b9868d2c356467e43e845638ab5 WHIRLPOOL 6407b4f3781b56aeb62252f87f7522e38930e24952610938a05cad24c0b56c62dac8b8b517c5805699432f3d3b4b59e31784def6aa38ca6b8a6c8aabace40712
+AUX freebsd-libexec-8.2-rtld.patch 1332 SHA256 0f0dc285b4797ab3be266db02f905ca72ffb39589c927311f74678acd9517e4d SHA512 9abbac7dfb703a05b3f6f1d3dc96db7df106355e3641eeb6fb446ea5f9ba15cfb9375e00bfa02b5ae26e4c9cdb52e14e2260981908c40e2c44549a43a2865ad6 WHIRLPOOL 41489254c1f800208bc0ff2548d109cd34a84c025f5428f85c7aada69c5cbbe3f165410cc58dff773b7e792c9c9145580423f55f120f0e29159b251fc7e99d0c
+AUX freebsd-libexec-9.2-no_ld32.patch 634 SHA256 ee5568c2ffbff4cf73c87401e5eb93165e813a2ff252d953a95fc4294dd2ace8 SHA512 df5421ad4d07d9f3d5f8dfd110eca588848ff55a63c70adf76f90746c1156ac50004a79bb626783ada8f96060fdd37e153e64da6ed43148c02a8eae4493c18d8 WHIRLPOOL d11ddc097a8ff171d143c655c1f2c9dd4ee3ff5e7bd6693bbd7c5d065e72c4d9e2c5a3521b9701ea0a3c7f5234fb174675373e68fb65cbb41c95133db6eb53f5
+AUX ftpd.pamd 192 SHA256 4b789fb18bc0d1f9b0a9b0f1bf5dac6d86166a7106e966e5f65ffd4faf5ce024 SHA512 d7e7f08ef05ccc63e63ddc65d79f96106dfa0ec2421ee9fbbb83966aaccb73d9868cb14467c1bdfaa9d12299a8ad27cbc725a33fec58e47b5b8212e52a7c18eb WHIRLPOOL 1d418e336dec5b6c34541c11068fd19ffe7546d338851f47359c50c18bc382c84230c0d751fa8185d48ca1c67250ba320fec895fc92f96c1d6909647db67a54a
+AUX rquotad.xinetd 162 SHA256 3f73f86e5a6ab3b6d25698f6179cdbe169b2fd01c682b45a9c8711f36bb317e5 SHA512 2cf16514f18abe2aeaa273fabc2dc94b09f31d02001ece5c82d9336c02d921e03dff6f82a613a4bffe57b5e415add2b82ef883a306907dd20ffe1bbe332b011f WHIRLPOOL 237667cbff4807d703a3c4c4eb8c2c5863d024a6263e3addf8d96ffa1461a8d1cda6318deee1de72146d27305b670b501da9ad4035880551dee5138b6798f6c6
+AUX rstatd.xinetd 218 SHA256 7bf526babdd46f03a6ea9ed12b5df16e5c2abc8aeb567214c8edb8ac327d4381 SHA512 febca8ab8248b1c103dd7be0806e3d678c5b5cf165a7b3bd0305bc905da228bf92392d65d44a765b7692f772befeedcbc3df205d32bb62ad5aa307f71a1c1011 WHIRLPOOL 76f8b1f3f85e97f27950549f62dc411e0620b25eba68c161c96a5252617c7c4beb0fecf94af9bc9cf931dff8fc4c750e780c41143a50b39d7538a30b7c0bd322
+AUX rusersd.xinetd 220 SHA256 271de1cad33a65a2a0e81e8983cbb1b7ab6e2e75bbf4c6e99181408067a49cd3 SHA512 fdf4ef4e0b0dd11c64fb38d32c9fca2d378a69e4cff87523127089d7dc0db12b26f6399c7a61fc43d62ca8083b116440f6fffff9e3329f0548bf54f0f26699cd WHIRLPOOL 7517089e5ab5b3925b46908c22a929cb04c8390387ad075f17c2fa0213ab38cae833d9280cfe289915afe4c2ee0b3e0299cee42daa871c23507f5f96cc22f227
+AUX sprayd.xinetd 216 SHA256 5b2c0e14c40c3d14f16f6fbe7b1f00d133bbae8ea27e548273a16d104afea24e SHA512 a49824ab0421560699901f54d9faf3f38fb6f8d8f63f05e33eb11da053278838e80eaabf5963b1c2a7292ba2d2118e1efd90954b2f3b2dc01b945fbadc6ce101 WHIRLPOOL 3869a0e4a9f03aa3654729e611a020421ec0beef2686ca8857b5ac3d50f8db26d7c1a5eb16e90aaf5b2b33e992915f7e9e504ce6bca9fd5862c2051a7172495f
+AUX walld.xinetd 215 SHA256 b7d8cb4b69809a2ea2f479f942c3d7752c5cb1e4b3b4b7b7b590f15616a774f0 SHA512 ab78d32e48d660649d3415a4432a5f3e98f8a6a8854791d1d828b0dc678f58e9f24532c264c5f5b039ccd706e0bb70c369ba9fb55fc9af9d3ed9b28e10b9e830 WHIRLPOOL 013b60056a8f5fe46eb4e00182fe0f391a2dc915312fe7e47eb372697526ed05a53e156159fd5dd3dcbf3db44a6591461c789af31ca0e1dd967537b785462802
+DIST freebsd-bin-8.2.tar.bz2 415900 SHA256 fb31b7fab259bda8396e615246f85dc99c3c9f7e98f4e4a613e20b6a394c4921 SHA512 c39b26f75f7d812f46e907acabd8dfaf45c97adf4488bcafa35fd46c805d821e177609d403cf5e677f3674020290199ac97059a0609f7705bce58a7aab3ee8e3 WHIRLPOOL 49e70b1c09c4b72b3f23850e8c9873556571ec02d70ade8f18f683eff6fa92dc8f6d02d58473fe7b4d8d1f3de96c63df41150b2091caafbc9a0e92e6055b43fd
+DIST freebsd-bin-9.1.tar.bz2 385664 SHA256 0a9524d75a8cb4c9c2654f2f9843087b09e8599bba97b9b59f00bc2e92b87e00 SHA512 fa0571a705befe1cb9c07285d3df55c9b5f4f295760511d668d80fec8cd4d59b70c676f07164f2aa44911decef0fb54fa6d78405ac2ceec822b6b8920abc5ca8 WHIRLPOOL 6f2bfe17604339e8260c49582bc941d255932b5c0a7b604e58187626a3a38766cd1e4aed9fc93a737ec9b4fa661f88aac23769b3542f35eb20da8b260216e985
+DIST freebsd-contrib-8.2.tar.bz2 40931651 SHA256 8b9cb688e81c2980b3fc66411d00ab277a24dadd50d5bdd5e0e6c63ac687b9b6 SHA512 4f7bf825b579fbb88f2aac531d07e531474179c63fa0b66c4e80821290a8c94bf611bb4dcaef51b762aacd25b11dfae798a4ec3bad3b9e3f6b3490ebfaa72476 WHIRLPOOL edd3d9e26e8d22d9028082e107ec1a44402e206dab8722f34b445676959305996c3f699152af42ace249b7f58498492787823b172fb6bcb273119c6bb50a35f0
+DIST freebsd-contrib-9.1.tar.bz2 54751432 SHA256 e7ffa056d4050ce03ee8e23e276e2a9a494326a98d60c43bee2afcc59576deb8 SHA512 71be13049258c6e6b5e4f63cc16da5d349a89d68f04d87446e4ad33ae8bf2a93ea67d9c256b7bec60b61e65db0487268070cfb77a484c3ac0f8ba368b48c2438 WHIRLPOOL a2a84423175499208d34809e802284d6ba649f317c3a9ad8b7312fa19efe142ebadab0048bac0db8e988e59f9a7468ac7c5d0d25e78b82bdb269a20d18153cee
+DIST freebsd-etc-8.2.tar.bz2 188629 SHA256 6bc745fa259f9fa2b65df865d45443a7b23c24445195e33a4ac50bf1040ae238 SHA512 3e5c106754a6a1ac806bd46b711fba7ee9cb31a4eab5262c995a5d59dbeb02f756dd8b495640dda94189d204a5d2c5218de2bd23467172d6a4ebe1048986e89c WHIRLPOOL 23b658a214f1a64c43420351020e32b1182e9aac3ed5253f49ee86f9cee9166ce32bd556cd2a2b3c0e60a165462a8700f37dea19e57ad5716415e17f61da912e
+DIST freebsd-etc-9.1.tar.bz2 207776 SHA256 a317bf85532d6192f5506e8d7bd5d5c201fe24017700e3a974a7712c2c69cdb8 SHA512 4fbe56fde519cf2f44e39a8869efa26c34f703cf540f4a83389da8d170873d7c6fb18e4010e643b8d793cfc5c55d15eeb198057a5b2a8da9d9e8f791801bf314 WHIRLPOOL 0c27019fe140fe96f870697acbaa89ac2f281f55b892c5791b08abf1cfa4da94d9d42a1df1c2091317573ed7234253857aecb797065f911a0a5d57bbf64349a5
+DIST freebsd-lib-8.2.tar.bz2 3323878 SHA256 e3590c12794fcb5ba8eb7a1f58b497587cf19f9200b3254c194a793da3b5bfb0 SHA512 c059cfdd1099bb519b2a5c43fb7e7104c500ef8906229ed7eb9e420cb3a217cdaf8655e9e7a9f45cfadc5491f8115e0e738fd49251d9f0c3a83780845b09f007 WHIRLPOOL 95f98a372f44a89bc8ac3029ec065dbbfec338e6f889d057d75644bfcdfb9d27fdc0421d7e392cad5a823712b97f0857297ec3d321580254c63032c22b95792e
+DIST freebsd-lib-9.1.tar.bz2 3206685 SHA256 f31fa8107b4de711c548f6d0c1bb1f81d09f51bcc3b14a1e9e90bb0e7cc4a35d SHA512 40d0c36b6b889c404fa0e0afa38ba4e84a55bc88ffa2f98a70afbd7a32c4f32c158617ba770567d082a986d62c09b3ec8db3dc5ab853ee1c9bbe0b90bb82396e WHIRLPOOL 581878bf9c43184b043b4293409b85901c9ed1f9bd279e965414aca41ba50950848ebda3ee10a503a028135dfd2765e95a11acd4e62a11c528e104392bbbd8d0
+DIST freebsd-libexec-8.2.tar.bz2 289147 SHA256 10b996d1d8cd044ee2e7a877e5e6ad2bf050cce9b3bd402a5e0dea7d290b595d SHA512 abe6cf5a268675d7dcb1c214c46fef47a3fb09b31947f5d8a0b938d352295efe0249beb5007649c52187bf4c221b6ebf074d18dfe9bafd168cae09ee02ab608d WHIRLPOOL 27e854fe465eb933dd8e27c5a09b063e4d3798b54e0914c79a9120dcdc34cc5d525a0c92da7b645ff7ab2ab4f34c7f7b2783012dfa5004407acd11150062b7ad
+DIST freebsd-libexec-9.1.tar.bz2 304592 SHA256 71e6e9e41328c2148c54b81ad9b59f912a1d5f0d52e17ac07f223aa7a94b82be SHA512 7baa4160dda2610250dd52f445e24478e0f1ea10bce21fcd0e5d1b856f399b896adc334114de0c7f61a5637e4349bb1688fdbe5c72798d8568ae791114710b92 WHIRLPOOL d800f477ac5c9ad6dae3e0091c83e107609b5a1e3aa79e9533fcd10a8dd34ff7733ab9523eae7c292310fe94f6a529209cae6b9e8bac6b47244e59834593e74b
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-ubin-8.2.tar.bz2 1808012 SHA256 6b99554f3ad6ee052069b347eb6e6219b71598d7b222acb90a24cbfc805c7b68 SHA512 48d0103323e820c431aa4f62d3be40cb3b200fb62e3de01f36c88760395bf2ba3367c51f3fa72da4dbccc2812176a051a12ca5cb7e84125c3e0fc78d4cab2c29 WHIRLPOOL ea8f3a29a37b42c2b5bcc0f2c343fa1538522157ef075363c94606a4620a590e9a03f856ce2494e3e727935b62431991d0aa9fde71de699e78b4fe225bdf1c2c
+DIST freebsd-ubin-9.1.tar.bz2 1910472 SHA256 ff6e586f213534b6ec2e65002c0dee64063d76ddad515c12221b1a80a1815e48 SHA512 74ae0aceec8597aa66c3f1ab313f0685a3c63d7273c36ae7baf8794275ad9bca241c60c3f6281cccf6d531d250d7611099977d3b1a27279cef3586401b6af05e WHIRLPOOL c85a3c9cf2bceff2c60ff03556bcc81d3aca22b0bce3c9538990071ac0a907236eee5ae7743ad22c5fd309b047ebf392aaaf2fe177ef5790ea869aff3da7e2fe
+DIST freebsd-usbin-8.2.tar.bz2 2443024 SHA256 aa7cabf10f5c3a9daabea32e4de24d04ec312247842981476da666eff5054603 SHA512 bcb8ff3df54848b9107bbb52e5ced7a91e24bb181f06769b6997221729b8064ec17652eaf7500de3268cbcb63ff5760beb54d15fc78c27b02687b5b1067c74a6 WHIRLPOOL 20f5278e2a1dd387a75b44f10507958d6c0e84a2faa1bddbf808c14ab86d8dd14a956192911bbc1880f5f5f7bd05972dcbb4aec85d241f0dcf91bf4246883f0a
+DIST freebsd-usbin-9.1.tar.bz2 2670916 SHA256 b938c20b8c09aa9a610e13b69b9afeea72f561ab3636a59fba2bdac290f4db75 SHA512 21c234312f70eb35cd2926519efc1f61592892f5d0940786dbeb959c3c5ec7819a51ae95c6e8a1a06aa01f669350fe0fd3dd7c4ec8a84dd6b90f24cb192356ca WHIRLPOOL 7f6ad2eb5410cc5e685881654a788807848af026b1277a974682755ab7c9db28f576bfd1576441ea10c5f1e9edb7d30a4a23fb8eccd6d69d86ecc9ce4c9adc7e
+EBUILD freebsd-libexec-10.3.ebuild 3513 SHA256 0f41d388b702070cbf2a59b10b8f770166dd93a64f59eeba8208314c52216b7c SHA512 73d96f63e2c1a7e1f3d24e7bbca68777d69e5647a3e3bf5e4911df55ae53bc26e05459799d64413a31121d4dfbf438791339608cb41bf72df551f42b3738197c WHIRLPOOL 5880f70b92f6b3c54334d1b0fb1fdcd0181f8f057cf18e4ea374cf8f809efa8c6c13878733022b062b114e41c825b40c19a6bbc13343267344f1003f2e0b8489
+EBUILD freebsd-libexec-11.0.ebuild 4149 SHA256 1f76377527adf1a072a2e4573a8968539a78c565e1df01232638dc964ba8179b SHA512 75668b5ded29355db9f7e595a7cff32210ede67ca8ed29c8e5fd677d4ed66febcdaf003e841873ad8acbb69e3e85078653c421bde7ac724387f37704df540fe8 WHIRLPOOL 8f261841ccc0ce258d235c66eda53c162eea8d12e74ce707565a3132ece108b6786e0ff16be739466362571cee1940bf697fbafdcaaf7224420200f12af46770
+EBUILD freebsd-libexec-8.2-r1.ebuild 1762 SHA256 87366419d5ba8ce08e1fdf9693e42756537a7e02438ccf099d6cdf0f18a59bab SHA512 b5ff14afff032ebe2fc43fb4045d7705d6d0cf4b2853ef788ad0cc47dab343a19a655d881dd2965e4743d4c4212dc6ef7e5b3929885851fc2041ec97fc641cb8 WHIRLPOOL 7d8f90cf37a00db2889083fc81ea0037473a2e7c9a29d20a6553c028267be1d3c28ebc6d6e4d44476a0ef4de8ccf80fad4ed50c50688cba8a4d7e619915c4f38
+EBUILD freebsd-libexec-8.2.ebuild 1726 SHA256 d9e0598fca555b5be83dc88b087bd759bd1834f52afbf1d79c2800496460855c SHA512 3b825ac1c7d44a3f288483b5b7a212a60800a36c326a29dca90cbfe1898735fc4a43c13866bc95b4cbbfdf3eaaf845e9bd191933ec63f807a3bf6b43887dd8f4 WHIRLPOOL c6e9bbfe377e9be1249fdd88ba7125f8d24093837fe318c34b72a42488b46564846da9e788017a62a1eaff858cd5f0f4b7b861be87219632cb177f641a99465e
+EBUILD freebsd-libexec-9.1-r2.ebuild 2296 SHA256 ca75df479e1e449eb201303bab223c157dedcd02ec13d277414c12372c609f1b SHA512 e099494395ac06088175df3717f7936b2b41c4b98d176cecd6f345ce31c42e02401e60642f9919418fb0ef3f4944bebb7935432c920a080b503ef9fc2fef92c7 WHIRLPOOL e5e9095f930ddac591e7d98c488e5aa9bd3525ee14cd402e5576fec3829aaf8aaab67a688c9b3588570abded3f541c12cfbb53cb0891dbbd8bfa1d96bece9465
+MISC ChangeLog 4412 SHA256 17b14a2a302225ee124ee9769484fd1dba0df0769b0ccbdf6a65bb027e02f9ec SHA512 ce29259e295e534e0fad0f54454f54a89cf16a2580c4336c2fe7a49e0a11695728db7467f2b964701fd0706f3aaa0114b0ed536a8e315f1d1d94948bde619505 WHIRLPOOL ddb7527b013f8802ede6f7596259b0724f1ec1f53af854684cfcf89d9a1ae61d8988f89e25500828daead5adf8228e7b4adf0efec1a88473dabb50fa7ca90715
+MISC ChangeLog-2015 13816 SHA256 f5f0d228481038260811189591dd324e6aa19e746bf407945f88a78e0fb1c9f7 SHA512 6938b705b54ebf8bc283f3c349bd61efd518e9114a378d2313e7a806bc346c0483f27f0fc9530fadf187971f8359c5f7e794aea276f1a340d4a5ad6f19297623 WHIRLPOOL b34299a0c63d4649ca1fc96ae70ab85ddccf0503e425b1c8a38be6489eaec7e65ae7fd591c95231175a02f1bd5b0060a382f2348d622e438845d0c566638956c
+MISC metadata.xml 238 SHA256 501d93b0c41ed422505100f002758cd173cd9783ae7fbb53e2ec5f238c868340 SHA512 173efaa53a514acf1e2f0c6681c82a48ec16d505844f551d2cc823ee8685b27837c7461f7956c12182059ee7e83023e2f0bcd5d1afab74beeaf998487193656d WHIRLPOOL 4ca51d994f011a5e7e4939f02a54b5c2f9f3e526665893c9ac2876c9871b7dc80361393d41c5247b3a5520e82d31d0dd10da520e7715c94b806a94ce0fed2a5a
diff --git a/sys-freebsd/freebsd-libexec/files/bootpd.confd b/sys-freebsd/freebsd-libexec/files/bootpd.confd
new file mode 100644
index 000000000000..6d238e4d4853
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/bootpd.confd
@@ -0,0 +1,7 @@
+# Configuration file for /etc/init.d/bootpd
+
+# Name of the configuration file for bootpd
+# bootptab_file="/etc/bootptab"
+
+# Options to pass to bootpd. See bootpd(8).
+# bootpd_opts=""
diff --git a/sys-freebsd/freebsd-libexec/files/bootpd.initd b/sys-freebsd/freebsd-libexec/files/bootpd.initd
new file mode 100644
index 000000000000..82288ebf19c3
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/bootpd.initd
@@ -0,0 +1,27 @@
+#!/sbin/openrc-run
+# Copyright 2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net
+}
+
+start() {
+ local bootptab=${bootptab_file:-/etc/bootptab}
+
+ if ! [ -f "${bootptab}" ]; then
+ eerror "Unable to find the bootptab file: ${bootptab}"
+ eend 1
+ return 1
+ fi
+
+ ebegin "Starting BOOTP server"
+ start-stop-daemon --start --exec /usr/libexec/bootpd -- ${bootpd_opts} ${bootptab}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping BOOTP server"
+ start-stop-daemon --stop --exec /usr/libexec/bootpd
+ eend $?
+}
diff --git a/sys-freebsd/freebsd-libexec/files/freebsd-libexec-10.2-atf-check.patch b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-10.2-atf-check.patch
new file mode 100644
index 000000000000..e9c092566303
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-10.2-atf-check.patch
@@ -0,0 +1,28 @@
+diff --git a/libexec/atf/Makefile.inc b/libexec/atf/Makefile.inc
+index b50e14e..e59a413 100644
+--- a/libexec/atf/Makefile.inc
++++ b/libexec/atf/Makefile.inc
+@@ -25,7 +25,7 @@
+ #
+ # $FreeBSD: stable/10/libexec/atf/Makefile.inc 271298 2014-09-09 04:00:30Z ngie $
+
+-CFLAGS+= -DHAVE_CONFIG_H
++CXXFLAGS+= -DHAVE_CONFIG_H
+
+ WARNS?= 3
+
+diff --git a/libexec/atf/atf-check/Makefile b/libexec/atf/atf-check/Makefile
+index 77c11db..7449ddb 100644
+--- a/libexec/atf/atf-check/Makefile
++++ b/libexec/atf/atf-check/Makefile
+@@ -34,8 +34,8 @@ PROG_CXX= atf-check
+ SRCS= atf-check.cpp
+ MAN= atf-check.1
+
+-CFLAGS+= -I${ATF}
+-CFLAGS+= -DATF_SHELL='"/bin/sh"'
++CXXFLAGS+= -I${ATF}
++CXXFLAGS+= -DATF_SHELL='"/bin/sh"'
+
+ LDFLAGS+= -L${.OBJDIR}/../../../lib/atf/libatf-c++
+ LDFLAGS+= -L${.OBJDIR}/../../../lib/atf/libatf-c
diff --git a/sys-freebsd/freebsd-libexec/files/freebsd-libexec-7.2-pic.patch b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-7.2-pic.patch
new file mode 100644
index 000000000000..22d5658394dd
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-7.2-pic.patch
@@ -0,0 +1,13 @@
+Fails to build on sparc without using -fPIC
+
+--- libexec/rtld-elf/Makefile.old 2010-01-09 17:17:21 +0100
++++ libexec/rtld-elf/Makefile 2010-01-09 17:17:33 +0100
+@@ -19,7 +19,7 @@
+ MLINKS= rtld.1 ld-elf.so.1.1 \
+ rtld.1 ld.so.1
+
+-CFLAGS+= -fpic -DPIC
++CFLAGS+= -fPIC -DPIC
+ LDFLAGS+= -shared -Wl,-Bsymbolic
+ DPADD= ${LIBC_PIC}
+ LDADD= -lc_pic
diff --git a/sys-freebsd/freebsd-libexec/files/freebsd-libexec-8.2-rtld.patch b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-8.2-rtld.patch
new file mode 100644
index 000000000000..c60b2fec102c
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-8.2-rtld.patch
@@ -0,0 +1,40 @@
+--- head/libexec/rtld-elf/rtld.c 2011/09/15 11:50:09 225582
++++ head/libexec/rtld-elf/rtld.c 2011/10/08 12:39:47 226155
+@@ -495,8 +495,12 @@
+ exit (0);
+ }
+
+- /* setup TLS for main thread */
+- dbg("initializing initial thread local storage");
++ /*
++ * Processing tls relocations requires having the tls offsets
++ * initialized. Prepare offsets before starting initial
++ * relocation processing.
++ */
++ dbg("initializing initial thread local storage offsets");
+ STAILQ_FOREACH(entry, &list_main, link) {
+ /*
+ * Allocate all the initial objects out of the static TLS
+@@ -504,7 +508,6 @@
+ */
+ allocate_tls_offset(entry->obj);
+ }
+- allocate_initial_tls(obj_list);
+
+ if (relocate_objects(obj_main,
+ ld_bind_now != NULL && *ld_bind_now != '\0', &obj_rtld, NULL) == -1)
+@@ -519,6 +522,14 @@
+ exit (0);
+ }
+
++ /*
++ * Setup TLS for main thread. This must be done after the
++ * relocations are processed, since tls initialization section
++ * might be the subject for relocations.
++ */
++ dbg("initializing initial thread local storage");
++ allocate_initial_tls(obj_list);
++
+ dbg("initializing key program variables");
+ set_program_var("__progname", argv[0] != NULL ? basename(argv[0]) : "");
+ set_program_var("environ", env);
diff --git a/sys-freebsd/freebsd-libexec/files/freebsd-libexec-9.2-no_ld32.patch b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-9.2-no_ld32.patch
new file mode 100644
index 000000000000..d33000927424
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/freebsd-libexec-9.2-no_ld32.patch
@@ -0,0 +1,15 @@
+Use LD_* variables for 32bits too instead of the FreeBSD invention LD_32_*.
+We use LD_* everywhere on Gentoo and things like libtool wrappers have no clue
+about LD_32_* and thus fail to run from the build directory.
+
+diff -uNr libexec.old/rtld-elf/rtld.h libexec/rtld-elf/rtld.h
+--- libexec.old/rtld-elf/rtld.h 2013-08-24 12:30:26.000000000 -0400
++++ libexec/rtld-elf/rtld.h 2013-08-26 17:10:19.000000000 -0400
+@@ -47,7 +47,6 @@
+ #define _PATH_ELF_HINTS "/var/run/ld-elf32.so.hints"
+ /* For running 32 bit binaries */
+ #define STANDARD_LIBRARY_PATH "/lib32:/usr/lib32"
+-#define LD_ "LD_32_"
+ #endif
+
+ #ifndef STANDARD_LIBRARY_PATH
diff --git a/sys-freebsd/freebsd-libexec/files/ftpd.pamd b/sys-freebsd/freebsd-libexec/files/ftpd.pamd
new file mode 100644
index 000000000000..8e9082373f8f
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/ftpd.pamd
@@ -0,0 +1,8 @@
+# PAM configuration for the "ftpd" service
+#
+
+auth include system-auth
+account include system-auth
+password include system-auth
+session include system-auth
+
diff --git a/sys-freebsd/freebsd-libexec/files/rquotad.xinetd b/sys-freebsd/freebsd-libexec/files/rquotad.xinetd
new file mode 100644
index 000000000000..876cd16c53c2
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/rquotad.xinetd
@@ -0,0 +1,11 @@
+service rquotad
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.rquotad
+ rpc_version = 1
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-libexec/files/rstatd.xinetd b/sys-freebsd/freebsd-libexec/files/rstatd.xinetd
new file mode 100644
index 000000000000..ba1b819851eb
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/rstatd.xinetd
@@ -0,0 +1,11 @@
+service rstatd
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.rstatd
+ rpc_version = 1-3
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-libexec/files/rusersd.xinetd b/sys-freebsd/freebsd-libexec/files/rusersd.xinetd
new file mode 100644
index 000000000000..5cbe091881e8
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/rusersd.xinetd
@@ -0,0 +1,11 @@
+service rusersd
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.rusersd
+ rpc_version = 1-2
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-libexec/files/sprayd.xinetd b/sys-freebsd/freebsd-libexec/files/sprayd.xinetd
new file mode 100644
index 000000000000..7be55771ac22
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/sprayd.xinetd
@@ -0,0 +1,11 @@
+service sprayd
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.sprayd
+ rpc_version = 1
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-libexec/files/walld.xinetd b/sys-freebsd/freebsd-libexec/files/walld.xinetd
new file mode 100644
index 000000000000..800b84fa21e6
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/files/walld.xinetd
@@ -0,0 +1,11 @@
+service walld
+{
+ type = rpc
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/libexec/rpc.rwalld
+ rpc_version = 1
+ disabled = yes
+}
diff --git a/sys-freebsd/freebsd-libexec/freebsd-libexec-10.3.ebuild b/sys-freebsd/freebsd-libexec/freebsd-libexec-10.3.ebuild
new file mode 100644
index 000000000000..e915c5115503
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/freebsd-libexec-10.3.ebuild
@@ -0,0 +1,111 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd pam multilib multibuild multilib-build toolchain-funcs
+
+DESCRIPTION="FreeBSD libexec things"
+SLOT="0"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ libexec/
+ usr.bin/
+ bin/
+ contrib/hyperv/
+ lib/
+ etc/
+ usr.sbin/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ >=sys-freebsd/freebsd-lib-9.1-r11[${MULTILIB_USEDEP}]
+ pam? ( virtual/pam )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+RDEPEND="${RDEPEND}
+ xinetd? ( sys-apps/xinetd )"
+
+S="${WORKDIR}/libexec"
+
+# Remove sendmail, tcp_wrapper and other useless stuff
+REMOVE_SUBDIRS="smrsh mail.local tcpd telnetd rshd rlogind ftpd"
+
+IUSE="pam ssl kerberos ipv6 nis xinetd"
+
+PATCHES=( "${FILESDIR}/${PN}-9.2-no_ld32.patch"
+ "${FILESDIR}/${PN}-10.2-atf-check.patch" )
+
+pkg_setup() {
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_PF= WITHOUT_RCMDS= "
+}
+
+src_prepare() {
+ # gcc-5.0 or later, Workaround for critical issue. bug 573358.
+ [[ "$(gcc-major-version)" -ge 5 ]] && replace-flags -O? -O1
+
+ if [[ ! -e "${WORKDIR}/include" ]]; then
+ ln -s /usr/include "${WORKDIR}/include" || die "Symlinking /usr/include.."
+ fi
+ # allow upgrade directly from 9.x to 10.2.
+ if has_version "<sys-freebsd/freebsd-lib-${RV}"; then
+ # taken from sys/sys/elf_common.h
+ echo "#define DF_1_INTERPOSE 0x00000400" >> "${S}"/rtld-elf/rtld.h
+ echo "#define STT_GNU_IFUNC 10" >> "${S}"/rtld-elf/rtld.h
+ echo "#define R_386_IRELATIVE 42" >> "${S}"/rtld-elf/rtld.h
+ echo "#define PT_GNU_RELRO 0x6474e552" >> "${S}"/rtld-elf/rtld.h
+ echo "#define DF_1_NODEFLIB 0x00000800" >> "${S}"/rtld-elf/rtld.h
+ # taken from sys/sys/fcntl.h
+ echo "#define F_DUPFD_CLOEXEC 17" >> "${S}"/rtld-elf/rtld.h
+ # taken from sys/sys/cdefs.h
+ echo '#define __compiler_membar() __asm __volatile(" " : : : "memory")' >> "${S}"/rtld-elf/rtld.h
+ # taken from sys/sys/mman.h
+ echo '#define MAP_ALIGNED(n) ((n) << MAP_ALIGNMENT_SHIFT)' >> "${S}"/rtld-elf/rtld.h
+ echo '#define MAP_ALIGNMENT_SHIFT 24' >> "${S}"/rtld-elf/rtld.h
+ echo '#define MAP_ALIGNMENT_MASK MAP_ALIGNED(0xff)' >> "${S}"/rtld-elf/rtld.h
+ echo '#define MAP_ALIGNED_SUPER MAP_ALIGNED(1)' >> "${S}"/rtld-elf/rtld.h
+ fi
+}
+
+setup_multilib_vars() {
+ if ! multilib_is_native_abi ; then
+ cd "${WORKDIR}/libexec/rtld-elf" || die
+ export mymakeopts="${mymakeopts} PROG=ld-elf32.so.1"
+ else
+ cd "${S}" || die
+ fi
+ "$@"
+}
+
+src_compile() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_compile
+}
+
+src_install() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_install
+
+ insinto /etc
+ doins "${WORKDIR}/etc/gettytab"
+ newinitd "${FILESDIR}/bootpd.initd" bootpd
+ newconfd "${FILESDIR}/bootpd.confd" bootpd
+
+ if use xinetd; then
+ for rpcd in rstatd rusersd walld rquotad sprayd; do
+ insinto /etc/xinetd.d
+ newins "${FILESDIR}/${rpcd}.xinetd" ${rpcd}
+ done
+ fi
+}
diff --git a/sys-freebsd/freebsd-libexec/freebsd-libexec-11.0.ebuild b/sys-freebsd/freebsd-libexec/freebsd-libexec-11.0.ebuild
new file mode 100644
index 000000000000..59376c1713b0
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/freebsd-libexec-11.0.ebuild
@@ -0,0 +1,130 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd pam multilib multibuild multilib-build toolchain-funcs
+
+DESCRIPTION="FreeBSD libexec things"
+SLOT="0"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ libexec/
+ usr.bin/
+ bin/
+ contrib/blacklist/
+ contrib/dma/
+ contrib/hyperv/
+ contrib/telnet/
+ lib/
+ etc/
+ usr.sbin/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ >=sys-freebsd/freebsd-lib-9.1-r11[${MULTILIB_USEDEP}]
+ pam? ( virtual/pam )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+RDEPEND="${RDEPEND}
+ xinetd? ( sys-apps/xinetd )"
+
+S="${WORKDIR}/libexec"
+
+# Remove sendmail, tcp_wrapper and other useless stuff
+REMOVE_SUBDIRS="smrsh mail.local tcpd telnetd rshd rlogind ftpd"
+
+IUSE="pam ssl kerberos ipv6 nis xinetd"
+
+PATCHES=( "${FILESDIR}/${PN}-10.2-atf-check.patch" )
+
+pkg_setup() {
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_PF= WITHOUT_RCMDS= "
+
+ if has_version "<sys-freebsd/freebsd-libexec-11.0"; then
+ REMOVE_SUBDIRS="${REMOVE_SUBDIRS} rpc.rstatd ulog-helper"
+ fi
+
+ if has_version "<sys-freebsd/freebsd-ubin-11.0"; then
+ mymakeopts="${mymakeopts} WITHOUT_MAN_UTILS= "
+ fi
+
+ if has_version "<sys-freebsd/freebsd-share-${RV}"; then
+ die ">=sys-freebsd/freebsd-share-${RV} is required."
+ fi
+}
+
+src_prepare() {
+ # gcc-5.0 or later, Workaround for critical issue. bug 573358.
+ [[ "$(gcc-major-version)" -ge 5 ]] && replace-flags -O? -O1
+
+ if [[ ! -e "${WORKDIR}/include" ]]; then
+ ln -s /usr/include "${WORKDIR}/include" || die "Symlinking /usr/include.."
+ fi
+ # allow upgrade directly from 9.x to 10.2.
+ if has_version "<sys-freebsd/freebsd-lib-${RV}"; then
+ # taken from sys/sys/elf_common.h
+ echo "#define DF_1_INTERPOSE 0x00000400" >> "${S}"/rtld-elf/rtld.h
+ echo "#define STT_GNU_IFUNC 10" >> "${S}"/rtld-elf/rtld.h
+ echo "#define R_386_IRELATIVE 42" >> "${S}"/rtld-elf/rtld.h
+ echo "#define PT_GNU_RELRO 0x6474e552" >> "${S}"/rtld-elf/rtld.h
+ echo "#define DF_1_NODEFLIB 0x00000800" >> "${S}"/rtld-elf/rtld.h
+ echo "#define NT_FREEBSD_ABI_TAG 1" >> "${S}"/rtld-elf/rtld.h
+ echo "#define NT_FREEBSD_NOINIT_TAG 2" >> "${S}"/rtld-elf/rtld.h
+ # taken from sys/sys/fcntl.h
+ echo "#define F_DUPFD_CLOEXEC 17" >> "${S}"/rtld-elf/rtld.h
+ echo "#define O_VERIFY 0x00200000" >> "${S}"/rtld-elf/rtld.h
+ # taken from sys/sys/cdefs.h
+ echo '#define __compiler_membar() __asm __volatile(" " : : : "memory")' >> "${S}"/rtld-elf/rtld.h
+ # taken from sys/sys/mman.h
+ echo '#define MAP_ALIGNED(n) ((n) << MAP_ALIGNMENT_SHIFT)' >> "${S}"/rtld-elf/rtld.h
+ echo '#define MAP_ALIGNMENT_SHIFT 24' >> "${S}"/rtld-elf/rtld.h
+ echo '#define MAP_ALIGNMENT_MASK MAP_ALIGNED(0xff)' >> "${S}"/rtld-elf/rtld.h
+ echo '#define MAP_ALIGNED_SUPER MAP_ALIGNED(1)' >> "${S}"/rtld-elf/rtld.h
+
+ export mymakeopts="${mymakeopts} WITHOUT_SYMVER= WITHOUT_BLACKLIST_SUPPORT= "
+ fi
+}
+
+setup_multilib_vars() {
+ if ! multilib_is_native_abi ; then
+ cd "${WORKDIR}/libexec/rtld-elf" || die
+ export mymakeopts="${mymakeopts} PROG=ld-elf32.so.1"
+ else
+ cd "${S}" || die
+ fi
+ "$@"
+}
+
+src_compile() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_compile
+}
+
+src_install() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_install
+
+ insinto /etc
+ doins "${WORKDIR}/etc/gettytab"
+ newinitd "${FILESDIR}/bootpd.initd" bootpd
+ newconfd "${FILESDIR}/bootpd.confd" bootpd
+
+ if use xinetd; then
+ for rpcd in rstatd rusersd walld rquotad sprayd; do
+ insinto /etc/xinetd.d
+ newins "${FILESDIR}/${rpcd}.xinetd" ${rpcd}
+ done
+ fi
+}
diff --git a/sys-freebsd/freebsd-libexec/freebsd-libexec-8.2-r1.ebuild b/sys-freebsd/freebsd-libexec/freebsd-libexec-8.2-r1.ebuild
new file mode 100644
index 000000000000..0bf7ac9e4631
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/freebsd-libexec-8.2-r1.ebuild
@@ -0,0 +1,65 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=2
+
+inherit bsdmk freebsd pam
+
+DESCRIPTION="FreeBSD libexec things"
+SLOT="0"
+KEYWORDS="~sparc-fbsd ~x86-fbsd"
+
+SRC_URI="mirror://gentoo/${LIBEXEC}.tar.bz2
+ mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${BIN}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2
+ mirror://gentoo/${USBIN}.tar.bz2"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ pam? ( virtual/pam )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+RDEPEND="${RDEPEND}
+ xinetd? ( sys-apps/xinetd )"
+
+S="${WORKDIR}/libexec"
+
+PATCHES=( "${FILESDIR}/${PN}-7.2-pic.patch"
+ "${FILESDIR}/${PN}-8.2-rtld.patch" )
+# Remove sendmail, tcp_wrapper and other useless stuff
+REMOVE_SUBDIRS="smrsh mail.local tcpd telnetd rshd rlogind lukemftpd ftpd"
+
+IUSE="pam ssl kerberos ipv6 nis xinetd"
+
+pkg_setup() {
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_PF= WITHOUT_RCMDS= "
+}
+
+src_prepare() {
+ ln -s /usr/include "${WORKDIR}/include"
+}
+
+src_install() {
+ freebsd_src_install
+
+ insinto /etc
+ doins "${WORKDIR}/etc/gettytab"
+ newinitd "${FILESDIR}/bootpd.initd" bootpd
+ newconfd "${FILESDIR}/bootpd.confd" bootpd
+
+ if use xinetd; then
+ for rpcd in rstatd rusersd walld rquotad sprayd; do
+ insinto /etc/xinetd.d
+ newins "${FILESDIR}/${rpcd}.xinetd" ${rpcd}
+ done
+ fi
+}
diff --git a/sys-freebsd/freebsd-libexec/freebsd-libexec-8.2.ebuild b/sys-freebsd/freebsd-libexec/freebsd-libexec-8.2.ebuild
new file mode 100644
index 000000000000..59841db7cba0
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/freebsd-libexec-8.2.ebuild
@@ -0,0 +1,64 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=2
+
+inherit bsdmk freebsd pam
+
+DESCRIPTION="FreeBSD libexec things"
+SLOT="0"
+KEYWORDS="~sparc-fbsd ~x86-fbsd"
+
+SRC_URI="mirror://gentoo/${LIBEXEC}.tar.bz2
+ mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${BIN}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2
+ mirror://gentoo/${USBIN}.tar.bz2"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ pam? ( virtual/pam )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+RDEPEND="${RDEPEND}
+ xinetd? ( sys-apps/xinetd )"
+
+S="${WORKDIR}/libexec"
+
+PATCHES=( "${FILESDIR}/${PN}-7.2-pic.patch" )
+# Remove sendmail, tcp_wrapper and other useless stuff
+REMOVE_SUBDIRS="smrsh mail.local tcpd telnetd rshd rlogind lukemftpd ftpd"
+
+IUSE="pam ssl kerberos ipv6 nis xinetd"
+
+pkg_setup() {
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_PF= WITHOUT_RCMDS= "
+}
+
+src_prepare() {
+ ln -s /usr/include "${WORKDIR}/include"
+}
+
+src_install() {
+ freebsd_src_install
+
+ insinto /etc
+ doins "${WORKDIR}/etc/gettytab"
+ newinitd "${FILESDIR}/bootpd.initd" bootpd
+ newconfd "${FILESDIR}/bootpd.confd" bootpd
+
+ if use xinetd; then
+ for rpcd in rstatd rusersd walld rquotad sprayd; do
+ insinto /etc/xinetd.d
+ newins "${FILESDIR}/${rpcd}.xinetd" ${rpcd}
+ done
+ fi
+}
diff --git a/sys-freebsd/freebsd-libexec/freebsd-libexec-9.1-r2.ebuild b/sys-freebsd/freebsd-libexec/freebsd-libexec-9.1-r2.ebuild
new file mode 100644
index 000000000000..a1331fb143ff
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/freebsd-libexec-9.1-r2.ebuild
@@ -0,0 +1,80 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd pam multilib multibuild multilib-build
+
+DESCRIPTION="FreeBSD libexec things"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+
+SRC_URI="mirror://gentoo/${LIBEXEC}.tar.bz2
+ mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${BIN}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2
+ mirror://gentoo/${USBIN}.tar.bz2"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*
+ >=sys-freebsd/freebsd-lib-9.1-r11[${MULTILIB_USEDEP}]
+ pam? ( virtual/pam )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+RDEPEND="${RDEPEND}
+ xinetd? ( sys-apps/xinetd )"
+
+S="${WORKDIR}/libexec"
+
+# Remove sendmail, tcp_wrapper and other useless stuff
+REMOVE_SUBDIRS="smrsh mail.local tcpd telnetd rshd rlogind lukemftpd ftpd"
+
+IUSE="pam ssl kerberos ipv6 nis xinetd"
+
+pkg_setup() {
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_PF= WITHOUT_RCMDS= "
+}
+
+src_prepare() {
+ ln -s /usr/include "${WORKDIR}/include"
+}
+
+setup_multilib_vars() {
+ if ! multilib_is_native_abi ; then
+ cd "${WORKDIR}/libexec/rtld-elf" || die
+ export mymakeopts="${mymakeopts} PROG=ld-elf32.so.1"
+ else
+ cd "${S}"
+ fi
+ "$@"
+}
+
+src_compile() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_compile
+}
+
+src_install() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_install
+
+ insinto /etc
+ doins "${WORKDIR}/etc/gettytab"
+ newinitd "${FILESDIR}/bootpd.initd" bootpd
+ newconfd "${FILESDIR}/bootpd.confd" bootpd
+
+ if use xinetd; then
+ for rpcd in rstatd rusersd walld rquotad sprayd; do
+ insinto /etc/xinetd.d
+ newins "${FILESDIR}/${rpcd}.xinetd" ${rpcd}
+ done
+ fi
+}
diff --git a/sys-freebsd/freebsd-libexec/metadata.xml b/sys-freebsd/freebsd-libexec/metadata.xml
new file mode 100644
index 000000000000..a00f3aeb1f81
--- /dev/null
+++ b/sys-freebsd/freebsd-libexec/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-mk-defs/Manifest b/sys-freebsd/freebsd-mk-defs/Manifest
new file mode 100644
index 000000000000..7b7ee7e18c95
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/Manifest
@@ -0,0 +1,26 @@
+AUX freebsd-mk-defs-10.2-gnu.patch 1853 SHA256 acc69cba0617496e6dcef543198bf5023fb1799b81a458451f58ea2fe63e46a1 SHA512 3913287e294a09bf17a06b8878de40995c27e63c64e79711112c8fc60bb1630e757e8df2ba4ee41720270776ed5df06d7f1cfb9c09e20b566653023466e01a1e WHIRLPOOL 1db20b2a7e39da3b86a4fb09c42980c6c028b1b46baac55c334abccea87f8c6c59f1c3aaa753bcbc2c08e9bad17d342410ca882a75e37edcf9bdfd26ac7ec1ba
+AUX freebsd-mk-defs-10.3-gentoo.patch 11845 SHA256 2298f4bead99ffed440d92c7b0d5ff81542bce0cbf07a3fe99f920201297d010 SHA512 05d0366b58e02ff11e6fa34cd3f731a06e5d4464eee92f05128e2b68bf6b2539e792489a44ff9e224bb994fcdc6807c19be7aaa459163bb900c8ee130b6a4c11 WHIRLPOOL 3bfdda2ebfa3ba81ad7464845c9ca9c81c438a0becf848e960d2a30171d506ae868aa5b5151cfce6f5390a5d487e423112c56eb8a4be24885e1df28a256c2da7
+AUX freebsd-mk-defs-11.0-drop-unsupport-cflags.patch 461 SHA256 4f592c92b88173156bb4688ccc2f26d79a37fa2c9905fc93286291fe80fb9533 SHA512 82275fe36338a31f1da5ed7d60d72e3f7f5eb3c8e029700afbcb9bc6219dc3051f35a49d33694d553fb8bce0dcf2fbdfbead5bc6e074fa7d9aebda19da603168 WHIRLPOOL de041217c36baee221543ebfd6fd202bd8a7f753d27cb9118f8c38b4f94bdde6b6726db6967a007f6ed6aba4b65e39aa139ae374858b32e5a895cb7bd3335d33
+AUX freebsd-mk-defs-11.0-gentoo.patch 12840 SHA256 30b491c6037f302f62c6d7d9cec93d32b03333ded0dc4bf54dbd37b0394801c6 SHA512 1b070418a5cb5739c55dc8f3e146ccd1390031ec6c13283573900922cd547310e0ccc18093c81df8836c3f78d6ce4279c3b56d6ad059ecb1d09f2b55b781ff79 WHIRLPOOL 1e3d87efa5303586218e9719e9d7aa86b9168413638c7b98cb64ff670f30c84d024627c66e8f53f8227c62b945333a8d625160caaaa9b7ce943718a8556c9736
+AUX freebsd-mk-defs-11.0-gnu.patch 1946 SHA256 37005860ec5ecb6fb916668af794f43bdc6fa64a79b01ab01e93cb1156ae1435 SHA512 bda6a5396c653b964426a3de80ed9c37205d30f3a863f7df231e0cc708ce3bca65ef46f2ca8bf63ea9a37309e2d3ac74ccbf0000e147688be686c998d940ded0 WHIRLPOOL f6d4a3cc293e87789827a81e8ddd1c81226dc1bb7f894c8a397b494ae418fdc5a75ac1055ff11ff70a3deec9dbc4fb971d580d9ed588f6de9f18a11f584b2109
+AUX freebsd-mk-defs-11.0-libproc-libcxx.patch 369 SHA256 dbefba73ba46a51a252fe17dbd0530df9fcf613ea990bdfa75689151e24d9ef8 SHA512 87de2c90588bccdc2e74ee206f2ca4135fbf5a4674d8400479d5eb08575a30a5b421bb81008ae1cf577e7acbebdc951fd1bd204b7b99f2818343c3f74ed59545 WHIRLPOOL 1a6df92d61ac0d72ce04c0989377e63a08f995990abb0d7c6fbe876594bf005c6fc277d2fc63b54e5f1dafbf7c1d1740da263a6441fede72d13eb617fae4713b
+AUX freebsd-mk-defs-11.0-rename-libs.patch 478 SHA256 a776bf656af7c328d2cd02c13e95e2c869240476459d8129e0227254e79a0847 SHA512 e07091f6b91d4d02cc6db5f76e0fbddc682f594dc5b9176cf282758253eddfb03093f4ef0b0bb5c514724d6065a6a4784e518526b32a86c7b344f43cb1e56ec2 WHIRLPOOL 5e175ca3eba51680ae1fdd54dfe92eff92f83de4d9b589d7067e0cdd4480991b264da01a28f2a3e237cfe781332ca26e5bbc12f61c5fc9f8e90646a438df0a87
+AUX freebsd-mk-defs-11.1-gentoo.patch 12921 SHA256 c590ae467d76689bac1e78b3da13183dd50dba2fd60cfcc3e5fdfd8e5450168e SHA512 5253780ce30522f90d7c6ba7292333e3e8edf7a295042f954dd70d3b0806a0cea16f8f6eb0fc9bd9e60d6d191569b4e4248d96b114c5133832c5a1c5e3a50339 WHIRLPOOL 68757bc8d78ad81ebdd5ac2115a6ac2ff937bff44b83bc23efbc556573c32c8c333db4f4876d7267a3795426719adde3e5110cda8a242a726c83c5a092bc62d4
+AUX freebsd-mk-defs-8.0-gentoo.patch 11076 SHA256 5510a8e9530c3585374bba26942c46c9bc799da3ae0de9b6fa8bd364088260c5 SHA512 3b3e828ac0f5cafdd3f3ef84ae2e0ea5eb36d9c3d465800d1234d8b405b727628b82ca691513bb47c609dbb7767cfb8f16be05f7eefa361a96cb8f282569e480 WHIRLPOOL ae4a0110d88e584ee650fdb04847a29c285e40f4a5a931fbbc21fefeccd4a3a7b948a15f0a9b09b9672e662de55dd4e293d3745c12eacb0dac3ec7d7f433b973
+AUX freebsd-mk-defs-8.0-gnu.patch 4074 SHA256 00034d4d94ec011f595864113d469ec83d11786802b997b2350e955c6d2d64a0 SHA512 8196f6f01059dd7890af9e0e0be654ad264938f4e8c9a209543b995baf6be43d841417ba8b8340c3c092c8d5f14ad76d578ddcd9267c372999b857ca9a566f03 WHIRLPOOL 28a4600e93855aba192d326beb479743890814c68999290d65a94e7cfa636db897c2c2a2c4ac177a87f8af12ff0a51c1b8ba5a8bb22802e0ef695e7418469d70
+AUX freebsd-mk-defs-9.1-gentoo.patch 11769 SHA256 d9f0585ecdbaec0483d9443543974f6a2157af2fcbe4554e8b61b6255ce6c818 SHA512 2ac2f700b168905df79b8a4c43fb7893ba752fa95b9d55bf0924602903ea5fdd6e4510b89a212dac70dd208ce24928eb202891f932a69507695d49ba59c4c6fe WHIRLPOOL 65946289e0e62ca575e3ce1acd22955e41143eefe0412f5dc6f6d358d95d08c2325d4870475d664a9565cc5492a0debe73d4f24a8ca34dce03ea20b46306f924
+AUX freebsd-mk-defs-9.1-gnu.patch 2273 SHA256 6b8ebbfd2ff724099d593a00dc226ca7f2e12020a9afcf0602b3098b95a2bb18 SHA512 b1537d3c9dcac78de5ddc026b1281887f755990a4a164e9f05cee53acfc1d7f2674ab1dfb4345b3862bdf971d9403e677e0900fb64a4e7b200c38b8d06c64fbd WHIRLPOOL 91b7e4a43f5f83fdd3c9bbaa9a2a82ab28373cca6050e7f558baa67fcc39983be84d43e64b17949c4ed3066c0b2e27d409b4cf18c930e4de793a4f41a54a10e6
+AUX freebsd-mk-defs-add-nossp-cflags.patch 1017 SHA256 fa9f47aa7bee35feee0462b6c91995f648143384c547326bcec3b58f69d3db5b SHA512 012897f4f4b4c3f71d1288ab57adeed56d7f399e508cfa4f593a1f787443e3e4752f7002c86f5da65952ac57eb908d0cce751d7b029048b1c70a9b3c79bea913 WHIRLPOOL 98c8fd10f85e9b2e780ef639de932caaa68ae4da50d7417601ae3366d119445364d15307016561b11fa91e4849a0ba45599a85b988702688e15ebd44457883c1
+DIST freebsd-share-8.2.tar.bz2 3797560 SHA256 dd082c6ddbf8e08ec91d9810d51af4111339bed912b0f74d05be283780292ba0 SHA512 b3f964253f80e58cde12f26e48a23aa75c17b9ab2810f91a4bd2d7efbe902af7c73c219f8373a4fc97ee0a35d25627b8815c79c136ef18620acc8bd0ee5bd6c4 WHIRLPOOL 42326ad6139feadf80509f5e810f6a86009ad3a69aad9550c6355389773c28d5b2f7930eaa852f8442808485d13e5b758ed3420e39048bb3966785e6953119ea
+DIST freebsd-share-9.1.tar.bz2 6733003 SHA256 2bbd8aa05d52b18a1780772a8518d79d375c1eeae98f52fb6aded233ac2491d7 SHA512 9665e3d5253f49a55921012bd21a8688210a1993ba6be4ad17b5ba5619104a50f3199d49a0eb83cf29db5a06c407beb15616bfe71338c680fe34ec47564c4b43 WHIRLPOOL 7d15596888ac42af1a0c125591283524ff794dccbf9f6592963602f046a45ca073b10bda43c2d0d662fd3414753de64c05293788e03c4eea67de55d9bc083c11
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+EBUILD freebsd-mk-defs-10.3.ebuild 788 SHA256 7f6621e97e306b63a2994a12f2e7f150943017e4d0fdbe340ea4b0c1a6d03b42 SHA512 6ac51811daa22723de886e74ebdea439f7c470b8b694e4f23290c5ea0e0adb2318d6fd437b37a1c93efc19b0c10b9dfc49715f7b9d91a7ba1b26c8b36d2d5def WHIRLPOOL 85f3a191db8dff3a9d1d0d1d4f9a59507983fd39753069ff500c39b37fad28002699f97d3b7251de1fe4d22caecfd0178912a597b3aec698546603cd689dc8bf
+EBUILD freebsd-mk-defs-11.0.ebuild 1149 SHA256 44dd3fc8836bb6f789180d0f6347508fda089969caf80b094fec7d9a44b7c07e SHA512 fd01633abb5978ef5655cbe94a014937a18489bb6d04285e7df2e80f5c10cd7a6e33fd0733449bcc791a0cab05fc80ddb4230667806bcfacaf9d4dd4e9fff1d3 WHIRLPOOL dd8db3918113ada116f69ea5f8a620186ab6568dbf0bccc74bc4f84c097163824c5f48b474c5876bdfecb97cc89674cb5ac4f13da9812be408cb5e6510c3de4f
+EBUILD freebsd-mk-defs-11.1.ebuild 1149 SHA256 925e218ab2a8a31a3b9b5e4ddf329b1ddfd930f1f3928238c98e7f9f648196e4 SHA512 b7fb837f9b5012e3871a49411b3847d5bc9b0051ea714bcf530f777a28f4332eb6300eb0cd0d8c61b6b69cc80ba42f072f42bc2038aeedddcac7cb82c2ff88e2 WHIRLPOOL e904f403838fc0be527438aa97205c920bdbf1fa3d0abab753554566bb58812fd4ebf8beb87fba5f3dc39127bf69aac4638848a708e26e40420d2f681cc6cdf1
+EBUILD freebsd-mk-defs-8.2.ebuild 748 SHA256 e04638eeee587d0815fbbada8055cecc844d04805b8c595774329b8c1863e23a SHA512 9a22a431da4e76eb6c65666a90d1b43c06cc7670dc218684a38ab64e1dff49315c10e6c39dc9bfcd8ab0d0891b224dfb4fb80f86472e5281695a876a413a2d18 WHIRLPOOL ad2e423cc1d7b7f3f2368b77f19c4c774f01b02a5ca9d07d472e0c00a4fdc3de0f9f272558b4483babc6ee690c15b27ba311ffa3dd01d48005924ccb27832c6c
+EBUILD freebsd-mk-defs-9.1.ebuild 772 SHA256 12472e4661c75506934e2e31ef03c7c46f7e77d7800e2a96f4eb5019b5eb1038 SHA512 cb737ae76e02f4a8105bde9c14737370a10b1c5c0962ded3275c1faef30fb84f2328409a89b243f5cfd91cec67d73c6da0b0c63a17453311a67ab56e91033dc5 WHIRLPOOL 59d0038b8d384b4cade307959eb1b9cb204e4e8ece39e3bb9a77918439de2356fcef5db5bba1bbd3cc48c9f00f5c97cddd2cbfc371a70b5e37e3e38372197ac3
+MISC ChangeLog 4153 SHA256 634e3fef5c9ae0f4d88ce400eb770c785a9ab0497e7e5f88d08e64fb1d18650b SHA512 a6d99161376d1decd938b611323d5393908d5ef12ad8f61c31d641ccd85dbae2792bd4d89f00c4c1f19e6a162c362b4fa2c03570ee5979527349813e30180a8c WHIRLPOOL 26a3eb87d86c83c7f8aa6d2d929a972712b37fb08b744790a55b3e7b8436164a4f191fd9ea2f67613dd4f637ce0eabb60f472499519e25ad3ac2141e4b33d198
+MISC ChangeLog-2015 13372 SHA256 e6e8cbcb39e9106eb67a3b84d6eafedac45a1289893a3a0c83cd2e9ef6025d82 SHA512 b02e2c36de5881725945c0b3f4711c7087ae13950887ed246c11d6021ca13448edb40282e644d8941fed957f5a9d6496e5fa6c5481dd9d7852b9e69166efa618 WHIRLPOOL 8280172b04096f2af53512fd7a8303d617bd6b8ed371716249f125389323e529313ce626e4ed704c44521292525c82fb3939dbc5c5111413737dc8aaf7499e83
+MISC metadata.xml 238 SHA256 501d93b0c41ed422505100f002758cd173cd9783ae7fbb53e2ec5f238c868340 SHA512 173efaa53a514acf1e2f0c6681c82a48ec16d505844f551d2cc823ee8685b27837c7461f7956c12182059ee7e83023e2f0bcd5d1afab74beeaf998487193656d WHIRLPOOL 4ca51d994f011a5e7e4939f02a54b5c2f9f3e526665893c9ac2876c9871b7dc80361393d41c5247b3a5520e82d31d0dd10da520e7715c94b806a94ce0fed2a5a
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.2-gnu.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.2-gnu.patch
new file mode 100644
index 000000000000..b88fde255007
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.2-gnu.patch
@@ -0,0 +1,63 @@
+diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
+index 80549d8..fd2aac5 100644
+--- a/share/mk/bsd.lib.mk
++++ b/share/mk/bsd.lib.mk
+@@ -173,7 +173,7 @@ _LIBS= lib${LIB}.a
+ lib${LIB}.a: ${OBJS} ${STATICOBJS}
+ @${ECHO} building static ${LIB} library
+ @rm -f ${.TARGET}
+- @${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
++ @${AR} ${ARFLAGS} ${.TARGET} ${OBJS} ${STATICOBJS} ${ARADD}
+ ${RANLIB} ${RANLIBFLAGS} ${.TARGET}
+ .endif
+
+@@ -186,7 +186,7 @@ POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po}
+ lib${LIB}_p.a: ${POBJS}
+ @${ECHO} building profiled ${LIB} library
+ @rm -f ${.TARGET}
+- @${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD}
++ @${AR} ${ARFLAGS} ${.TARGET} {POBJS} ${ARADD}
+ ${RANLIB} ${RANLIBFLAGS} ${.TARGET}
+ .endif
+
+@@ -215,7 +215,7 @@ ${SHLIB_NAME_FULL}: ${SOBJS}
+ .endif
+ ${_LD} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
+ -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD}
++ `echo ${SOBJS} | xargs -n 1 echo | sort -u` ${LDADD}
+ .if ${MK_CTF} != "no"
+ ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
+ .endif
+@@ -273,13 +273,6 @@ _EXTRADEPEND:
+
+ .if !target(install)
+
+-.if defined(PRECIOUSLIB)
+-.if !defined(NO_FSCHG)
+-SHLINSTALLFLAGS+= -fschg
+-.endif
+-SHLINSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
+diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
+index 19ad99f..46c4b09 100644
+--- a/share/mk/bsd.prog.mk
++++ b/share/mk/bsd.prog.mk
+@@ -179,13 +179,6 @@ _EXTRADEPEND:
+
+ .if !target(install)
+
+-.if defined(PRECIOUSPROG)
+-.if !defined(NO_FSCHG)
+-INSTALLFLAGS+= -fschg
+-.endif
+-INSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.3-gentoo.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.3-gentoo.patch
new file mode 100644
index 000000000000..cdc244d6e059
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-10.3-gentoo.patch
@@ -0,0 +1,337 @@
+diff --git a/share/mk/bsd.doc.mk b/share/mk/bsd.doc.mk
+index a8aa595..476b33b 100644
+--- a/share/mk/bsd.doc.mk
++++ b/share/mk/bsd.doc.mk
+@@ -135,10 +135,12 @@ CLEANFILES+= ${DOC}.ascii ${DOC}.ascii${DCOMPRESS_EXT} \
+ realinstall:
+ .if ${PRINTERDEVICE:Mhtml}
+ cd ${SRCDIR}; \
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}
+ .endif
+ .for _dev in ${PRINTERDEVICE:Nhtml}
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME}
+ .endfor
+diff --git a/share/mk/bsd.files.mk b/share/mk/bsd.files.mk
+index 183cb1c..5b57594 100644
+--- a/share/mk/bsd.files.mk
++++ b/share/mk/bsd.files.mk
+@@ -40,6 +40,7 @@ ${group}NAME_${file:T}?= ${file:T}
+ .endif
+ installfiles-${group}: _${group}INS_${file:T}
+ _${group}INS_${file:T}: ${file}
++ ${INSTALL} -d ${DESTDIR}${${group}DIR_${.ALLSRC:T}}
+ ${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -52,10 +53,12 @@ _${group}FILES+= ${file}
+ installfiles-${group}: _${group}INS
+ _${group}INS: ${_${group}FILES}
+ .if defined(${group}NAME)
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}/${${group}NAME}
+ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} \
+ ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+diff --git a/share/mk/bsd.incs.mk b/share/mk/bsd.incs.mk
+index b938221..6b98e72 100644
+--- a/share/mk/bsd.incs.mk
++++ b/share/mk/bsd.incs.mk
+@@ -41,6 +41,9 @@ ${group}NAME_${header:T}?= ${header:T}
+ .endif
+ installincludes: _${group}INS_${header:T}
+ _${group}INS_${header:T}: ${header}
++ ${INSTALL} -d -o ${${group}OWN_${.ALLSRC:T}} \
++ -g ${${group}GRP_${.ALLSRC:T}} \
++ ${DESTDIR}${${group}DIR_${.ALLSRC:T}}
+ ${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -53,9 +56,13 @@ _${group}INCS+= ${header}
+ installincludes: _${group}INS
+ _${group}INS: ${_${group}INCS}
+ .if defined(${group}NAME)
++ ${INSTALL} -d -o ${${group}OWN} -g ${${group}GRP} \
++ ${DESTDIR}${${group}DIR}
+ ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d -o ${${group}OWN} -g ${${group}GRP} \
++ ${DESTDIR}${${group}DIR}
+ ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+diff --git a/share/mk/bsd.info.mk b/share/mk/bsd.info.mk
+index 6275ce3..8d32289 100644
+--- a/share/mk/bsd.info.mk
++++ b/share/mk/bsd.info.mk
+@@ -83,6 +83,7 @@ INFO2HTML?= info2html
+ TEX?= tex
+ DVIPS?= dvips
+ DVIPS2ASCII?= dvips2ascii
++INSTALL?= install
+
+ .SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
+
+@@ -144,15 +145,17 @@ ${x:S/$/${ICOMPRESS_EXT}/}: ${x}
+ INSTALLINFODIRS+= ${x:S/$/-install/}
+ ${x:S/$/-install/}:
+ .if !empty(.MAKEFLAGS:M-j)
++ ${INSTALL} -d ${DESTDIR}${INFODIR}
+ lockf -k ${DESTDIR}${INFODIR}/${INFODIRFILE} \
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+- --defsection=${INFOSECTION} \
+- --defentry=${INFOENTRY_${x}} \
++ --section=${INFOSECTION} \
++ --entry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .else
++ ${INSTALL} -d ${DESTDIR}${INFODIR}
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+- --defsection=${INFOSECTION} \
+- --defentry=${INFOENTRY_${x}} \
++ --section=${INFOSECTION} \
++ --entry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .endif
+ .endfor
+diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
+index c753afe..14f74aa 100644
+--- a/share/mk/bsd.lib.mk
++++ b/share/mk/bsd.lib.mk
+@@ -46,8 +46,6 @@ CFLAGS+= ${DEBUG_FLAGS}
+ .if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != ""
+ CTFFLAGS+= -g
+ .endif
+-.else
+-STRIP?= -s
+ .endif
+
+ .if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \
+@@ -296,14 +294,17 @@ realinstall: _libinstall
+ .ORDER: beforeinstall _libinstall
+ _libinstall:
+ .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
++ ${INSTALL} -d ${DESTDIR}${_LIBDIR}
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${_LIBDIR}
+ .endif
+ .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${_LIBDIR}
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${_LIBDIR}
+ .endif
+ .if defined(SHLIB_NAME)
++ ${INSTALL} -d ${DESTDIR}${_SHLIBDIR}
+ ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
+ ${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR}
+@@ -357,10 +358,12 @@ _libinstall:
+ .endif # SHLIB_LINK
+ .endif # SHIB_NAME
+ .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
++ ${INSTALL} -d ${DESTDIR}${_LIBDIR}
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR}
+ .endif
+ .if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${LINTLIBDIR}
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${LINTLIB} ${DESTDIR}${LINTLIBDIR}
+ .endif
+diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk
+index c097c77..c2994d8 100644
+--- a/share/mk/bsd.libnames.mk
++++ b/share/mk/bsd.libnames.mk
+@@ -51,7 +51,7 @@ LIBELF?= ${DESTDIR}${LIBDIR}/libelf.a
+ LIBEXECINFO?= ${DESTDIR}${LIBDIR}/libexecinfo.a
+ LIBFETCH?= ${DESTDIR}${LIBDIR}/libfetch.a
+ LIBFIGPAR?= ${DESTDIR}${LIBDIR}/libfigpar.a
+-LIBFL?= "don't use LIBFL, use LIBL"
++LIBFL?= ${DESTDIR}${LIBDIR}/libfl.a
+ LIBFORM?= ${DESTDIR}${LIBDIR}/libform.a
+ LIBG2C?= ${DESTDIR}${LIBDIR}/libg2c.a
+ LIBGCC?= ${DESTDIR}${LIBDIR}/libgcc.a
+@@ -81,7 +81,7 @@ LIBKEYCAP?= ${DESTDIR}${LIBDIR}/libkeycap.a
+ LIBKICONV?= ${DESTDIR}${LIBDIR}/libkiconv.a
+ LIBKRB5?= ${DESTDIR}${LIBDIR}/libkrb5.a
+ LIBKVM?= ${DESTDIR}${LIBDIR}/libkvm.a
+-LIBL?= ${DESTDIR}${LIBDIR}/libl.a
++LIBL?= ${DESTDIR}${LIBDIR}/libfl.a
+ .if ${MK_LDNS} != "no"
+ LIBLDNS?= ${DESTDIR}${LIBPRIVATEDIR}/libldns.a
+ .endif
+diff --git a/share/mk/bsd.links.mk b/share/mk/bsd.links.mk
+index 574f0f5..b63b117 100644
+--- a/share/mk/bsd.links.mk
++++ b/share/mk/bsd.links.mk
+@@ -15,6 +15,8 @@ _installlinks:
+ t=${DESTDIR}$$1; \
+ shift; \
+ ${ECHO} $$t -\> $$l; \
++ d=`dirname $$t`; \
++ test -d $$d || mkdir $$d; \
+ ${INSTALL_LINK} $$l $$t; \
+ done; true
+ .endif
+@@ -26,6 +28,8 @@ _installlinks:
+ t=${DESTDIR}$$1; \
+ shift; \
+ ${ECHO} $$t -\> $$l; \
++ d=`dirname $$t`; \
++ test -d $$d || mkdir $$d; \
+ ${INSTALL_SYMLINK} $$l $$t; \
+ done; true
+ .endif
+diff --git a/share/mk/bsd.man.mk b/share/mk/bsd.man.mk
+index 0212d3a..6435936 100644
+--- a/share/mk/bsd.man.mk
++++ b/share/mk/bsd.man.mk
+@@ -165,9 +165,11 @@ _maninstall: ${MAN}
+ .if defined(NO_MANCOMPRESS)
+ .if defined(MANFILTER)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}/${page}
+ ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page}
+ .endif
+@@ -181,11 +183,14 @@ _maninstall: ${MAN}
+ esac; \
+ page=$$1; shift; sect=$$1; shift; \
+ d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \
++ ${ECHO} ${INSTALL} -d $${d}; \
++ ${INSTALL} -d $${d}; \
+ ${ECHO} ${MINSTALL} $${page} $${d}; \
+ ${MINSTALL} $${page} $${d}; \
+ done
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T}
+ .endfor
+@@ -193,9 +198,11 @@ _maninstall: ${MAN}
+ .endif
+ .else
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}
+ ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T:S/$/${MCOMPRESS_EXT}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/}
+ .endif
+diff --git a/share/mk/bsd.nls.mk b/share/mk/bsd.nls.mk
+index 28255ea..2bc6546 100644
+--- a/share/mk/bsd.nls.mk
++++ b/share/mk/bsd.nls.mk
+@@ -62,7 +62,8 @@ NLSDIR?= ${SHAREDIR}/nls
+ # installation rules
+ #
+ .for file in ${NLS}
+-NLSNAME_${file:T}= ${file:T:R}/${NLSNAME}.cat
++NLSDIR_${file:T}= ${SHAREDIR}/nls/${file:T:R}/
++NLSNAME_${file:T}= ${NLSNAME}.cat
+ .if defined(NLSLINKS_${file:R}) && !empty(NLSLINKS_${file:R})
+ NLSLINKS+= ${file:R}
+ .endif
+diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk
+index 73de02d..c6c30ca 100644
+--- a/share/mk/bsd.own.mk
++++ b/share/mk/bsd.own.mk
+@@ -206,9 +206,6 @@ INSTALL_LINK?= ${INSTALL} ${HRDLINK}
+ INSTALL_SYMLINK?= ${INSTALL} ${SYMLINK}
+
+ # Common variables
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+
+ COMPRESS_CMD?= gzip -cn
+ COMPRESS_EXT?= .gz
+diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
+index d6d0fa5..93a9046 100644
+--- a/share/mk/bsd.prog.mk
++++ b/share/mk/bsd.prog.mk
+@@ -42,10 +42,6 @@ CTFFLAGS+= -g
+ .endif
+ .endif
+
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ .if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO")
+ LDFLAGS+= -static
+ .endif
+@@ -200,6 +196,7 @@ realinstall: _proginstall
+ .ORDER: beforeinstall _proginstall
+ _proginstall:
+ .if defined(PROG)
++ ${INSTALL} -d ${DESTDIR}${BINDIR}
+ ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
+ .if ${MK_DEBUG_FILES} != "no"
+@@ -233,6 +230,7 @@ SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP}
+ SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
+ _scriptsinstall: _SCRIPTSINS_${script:T}
+ _SCRIPTSINS_${script:T}: ${script}
++ ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}
+ ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
+ -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
+index fee6ccc..c2fe39a 100644
+--- a/share/mk/bsd.sys.mk
++++ b/share/mk/bsd.sys.mk
+@@ -30,10 +30,6 @@ CFLAGS+= -std=${CSTD}
+ .if defined(WARNS)
+ .if ${WARNS} >= 1
+ CWARNFLAGS+= -Wsystem-headers
+-.if !defined(NO_WERROR) && (${COMPILER_TYPE} != "clang" \
+- || !defined(NO_WERROR.clang))
+-CWARNFLAGS+= -Werror
+-.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang)
+ .endif # WARNS >= 1
+ .if ${WARNS} >= 2
+ CWARNFLAGS+= -Wall -Wno-format-y2k
+@@ -102,10 +98,6 @@ CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args
+ CWARNFLAGS+= -Wno-format-nonliteral
+ .endif # WARNS <= 3
+ .endif # CLANG
+-.if !defined(NO_WERROR) && (${COMPILER_TYPE} != "clang" \
+- || !defined(NO_WERROR.clang))
+-CWARNFLAGS+= -Werror
+-.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang)
+ .endif # WFORMAT > 0
+ .endif # WFORMAT
+ .if defined(NO_WFORMAT) || (${COMPILER_TYPE} == "clang" && defined(NO_WFORMAT.clang))
+diff --git a/share/mk/sys.mk b/share/mk/sys.mk
+index c270260..68491ce 100644
+--- a/share/mk/sys.mk
++++ b/share/mk/sys.mk
+@@ -327,12 +327,6 @@ YFLAGS ?= -d
+ rm -f ${.PREFIX}.tmp.c
+ ${CTFCONVERT_CMD}
+
+-# FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef.
+-__MAKE_CONF?=/etc/make.conf
+-.if exists(${__MAKE_CONF})
+-.include "${__MAKE_CONF}"
+-.endif
+-
+ .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
+ SHELL= ${__MAKE_SHELL}
+ .SHELL: path=${__MAKE_SHELL}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-drop-unsupport-cflags.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-drop-unsupport-cflags.patch
new file mode 100644
index 000000000000..d12bbbe552fd
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-drop-unsupport-cflags.patch
@@ -0,0 +1,13 @@
+diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
+index 37c4d01..e840a25 100644
+--- a/share/mk/bsd.sys.mk
++++ b/share/mk/bsd.sys.mk
+@@ -112,7 +112,7 @@ CWARNFLAGS+= -Wno-error=unused-function -Wno-error=enum-compare -Wno-error=logic
+ .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
+ FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__
+ .else
+-FORMAT_EXTENSIONS= -fformat-extensions
++FORMAT_EXTENSIONS=
+ .endif
+
+ .if defined(IGNORE_PRAGMA)
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-gentoo.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-gentoo.patch
new file mode 100644
index 000000000000..e87bdbacd58b
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-gentoo.patch
@@ -0,0 +1,343 @@
+diff --git a/share/mk/bsd.doc.mk b/share/mk/bsd.doc.mk
+index 9f4ea2c..0f666bf 100644
+--- a/share/mk/bsd.doc.mk
++++ b/share/mk/bsd.doc.mk
+@@ -144,10 +144,12 @@ CLEANFILES+= ${DOC}.ascii ${DOC}.ascii${DCOMPRESS_EXT} \
+ realinstall:
+ .if ${PRINTERDEVICE:Mhtml}
+ cd ${SRCDIR}; \
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},docs} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}/
+ .endif
+ .for _dev in ${PRINTERDEVICE:Nhtml}
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},docs} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME}/
+ .endfor
+diff --git a/share/mk/bsd.files.mk b/share/mk/bsd.files.mk
+index bc123e1..4707b84 100644
+--- a/share/mk/bsd.files.mk
++++ b/share/mk/bsd.files.mk
+@@ -63,6 +63,7 @@ stage_as.${file:T}: ${file}
+
+ installfiles-${group}: _${group}INS_${file:T}
+ _${group}INS_${file:T}: ${file}
++ ${INSTALL} -d ${DESTDIR}${${group}DIR_${.ALLSRC:T}}
+ ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -77,10 +78,12 @@ stage_files.${group}: ${_${group}FILES}
+ installfiles-${group}: _${group}INS
+ _${group}INS: ${_${group}FILES}
+ .if defined(${group}NAME)
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}/${${group}NAME}
+ ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} \
+ ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+ ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}/
+ .endif
+diff --git a/share/mk/bsd.incs.mk b/share/mk/bsd.incs.mk
+index 9636e8c..fc2751a 100644
+--- a/share/mk/bsd.incs.mk
++++ b/share/mk/bsd.incs.mk
+@@ -62,6 +62,9 @@ stage_includes: stage_as.${header:T}
+
+ installincludes: _${group}INS_${header:T}
+ _${group}INS_${header:T}: ${header}
++ ${INSTALL} -d -o ${${group}OWN_${.ALLSRC:T}} \
++ -g ${${group}GRP_${.ALLSRC:T}} \
++ ${DESTDIR}${${group}DIR_${.ALLSRC:T}}
+ ${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -77,9 +80,13 @@ stage_includes: stage_files.${group}
+ installincludes: _${group}INS
+ _${group}INS: ${_${group}INCS}
+ .if defined(${group}NAME)
++ ${INSTALL} -d -o ${${group}OWN} -g ${${group}GRP} \
++ ${DESTDIR}${${group}DIR}
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d -o ${${group}OWN} -g ${${group}GRP} \
++ ${DESTDIR}${${group}DIR}
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}/
+ .endif
+diff --git a/share/mk/bsd.info.mk b/share/mk/bsd.info.mk
+index 0544662..1a7aad7 100644
+--- a/share/mk/bsd.info.mk
++++ b/share/mk/bsd.info.mk
+@@ -83,6 +83,7 @@ INFO2HTML?= info2html
+ TEX?= tex
+ DVIPS?= dvips
+ DVIPS2ASCII?= dvips2ascii
++INSTALL?= install
+
+ .SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
+
+@@ -141,15 +142,17 @@ ${x:S/$/${ICOMPRESS_EXT}/}: ${x}
+ INSTALLINFODIRS+= ${x:S/$/-install/}
+ ${x:S/$/-install/}:
+ .if !empty(.MAKEFLAGS:M-j)
++ ${INSTALL} -d ${DESTDIR}${INFODIR}
+ lockf -k ${DESTDIR}${INFODIR}/${INFODIRFILE} \
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+- --defsection=${INFOSECTION} \
+- --defentry=${INFOENTRY_${x}} \
++ --section=${INFOSECTION} \
++ --entry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .else
++ ${INSTALL} -d ${DESTDIR}${INFODIR}
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+- --defsection=${INFOSECTION} \
+- --defentry=${INFOENTRY_${x}} \
++ --section=${INFOSECTION} \
++ --entry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .endif
+ .endfor
+diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
+index bd93e57..92df111 100644
+--- a/share/mk/bsd.lib.mk
++++ b/share/mk/bsd.lib.mk
+@@ -52,8 +52,6 @@ CFLAGS+= ${DEBUG_FLAGS}
+ .if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != ""
+ CTFFLAGS+= -g
+ .endif
+-.else
+-STRIP?= -s
+ .endif
+
+ .if ${SHLIBDIR:M*lib32*}
+@@ -335,14 +333,17 @@ realinstall: _libinstall
+ .ORDER: beforeinstall _libinstall
+ _libinstall:
+ .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
++ ${INSTALL} -d ${DESTDIR}${_LIBDIR}
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}.a ${DESTDIR}${_LIBDIR}/
+ .endif
+ .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${_LIBDIR}
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},profile} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}_p.a ${DESTDIR}${_LIBDIR}/
+ .endif
+ .if defined(SHLIB_NAME)
++ ${INSTALL} -d ${DESTDIR}${_SHLIBDIR}
+ ${INSTALL} ${TAG_ARGS} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
+ ${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR}/
+@@ -387,10 +388,12 @@ _libinstall:
+ .endif # SHLIB_LINK
+ .endif # SHIB_NAME
+ .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
++ ${INSTALL} -d ${DESTDIR}${_LIBDIR}
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR}/
+ .endif
+ .if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${LINTLIBDIR}
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${LINTLIB} ${DESTDIR}${LINTLIBDIR}/
+ .endif
+diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk
+index 0844ae2..caec715 100644
+--- a/share/mk/bsd.libnames.mk
++++ b/share/mk/bsd.libnames.mk
+@@ -63,7 +63,7 @@ LIBELF?= ${DESTDIR}${LIBDIR}/libelf.a
+ LIBEXECINFO?= ${DESTDIR}${LIBDIR}/libexecinfo.a
+ LIBFETCH?= ${DESTDIR}${LIBDIR}/libfetch.a
+ LIBFIGPAR?= ${DESTDIR}${LIBDIR}/libfigpar.a
+-LIBFL?= "don't use LIBFL, use LIBL"
++LIBFL?= ${DESTDIR}${LIBDIR}/libfl.a
+ LIBFORM?= ${DESTDIR}${LIBDIR}/libform.a
+ LIBG2C?= ${DESTDIR}${LIBDIR}/libg2c.a
+ LIBGEOM?= ${DESTDIR}${LIBDIR}/libgeom.a
+@@ -92,7 +92,7 @@ LIBKEYCAP?= ${DESTDIR}${LIBDIR}/libkeycap.a
+ LIBKICONV?= ${DESTDIR}${LIBDIR}/libkiconv.a
+ LIBKRB5?= ${DESTDIR}${LIBDIR}/libkrb5.a
+ LIBKVM?= ${DESTDIR}${LIBDIR}/libkvm.a
+-LIBL?= ${DESTDIR}${LIBDIR}/libl.a
++LIBL?= ${DESTDIR}${LIBDIR}/libfl.a
+ LIBLN?= "don't use LIBLN, use LIBL"
+ LIBLZMA?= ${DESTDIR}${LIBDIR}/liblzma.a
+ LIBM?= ${DESTDIR}${LIBDIR}/libm.a
+diff --git a/share/mk/bsd.links.mk b/share/mk/bsd.links.mk
+index 0c7d063..f5d1779 100644
+--- a/share/mk/bsd.links.mk
++++ b/share/mk/bsd.links.mk
+@@ -16,9 +16,11 @@ afterinstall: _installlinks
+ _installlinks:
+ .for s t in ${LINKS}
+ @${ECHO} "${t} -> ${s}" ;\
++ test -d ${DESTDIR}/`dirname ${t}` || mkdir ${DESTDIR}/`dirname ${t}`;\
+ ${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}${s} ${DESTDIR}${t}
+ .endfor
+ .for s t in ${SYMLINKS}
+ @${ECHO} "${t} -> ${s}" ;\
++ test -d ${DESTDIR}/`dirname ${t}` || mkdir ${DESTDIR}/`dirname ${t}`;\
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ${s} ${DESTDIR}/${t}
+ .endfor
+diff --git a/share/mk/bsd.man.mk b/share/mk/bsd.man.mk
+index 6f78501..bc9a1a6 100644
+--- a/share/mk/bsd.man.mk
++++ b/share/mk/bsd.man.mk
+@@ -188,9 +188,11 @@ maninstall: ${MAN}
+ .if ${MK_MANCOMPRESS} == "no"
+ .if defined(MANFILTER)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page}
+ ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page}
+ .endif
+@@ -204,11 +206,14 @@ maninstall: ${MAN}
+ esac; \
+ page=$$1; shift; sect=$$1; shift; \
+ d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \
++ ${ECHO} ${INSTALL} -d $${d}; \
++ ${INSTALL} -d $${d}; \
+ ${ECHO} ${MINSTALL} $${page} $${d}; \
+ ${MINSTALL} $${page} $${d}; \
+ done
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T}
+ .endfor
+@@ -216,9 +221,11 @@ maninstall: ${MAN}
+ .endif # defined(MANFILTER)
+ .else # ${MK_MANCOMPRESS} == "yes"
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}
+ ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/}
+ .endif
+diff --git a/share/mk/bsd.nls.mk b/share/mk/bsd.nls.mk
+index 87a7347..c860c97 100644
+--- a/share/mk/bsd.nls.mk
++++ b/share/mk/bsd.nls.mk
+@@ -71,7 +71,8 @@ STAGE_SYMLINKS_DIR.NLS= ${STAGE_OBJTOP}
+ SYMLINKS+= ${NLSSYMLINKS}
+ .endif
+ .for file in ${NLS}
+-NLSNAME_${file:T}= ${file:T:R}/${NLSNAME}.cat
++NLSDIR_${file:T}= ${SHAREDIR}/nls/${file:T:R}/
++NLSNAME_${file:T}= ${NLSNAME}.cat
+ .if defined(NLSLINKS_${file:R}) && !empty(NLSLINKS_${file:R})
+ .if !empty(NLSLINKS_${file:R}:M${file:R})
+ .error NLSLINKS_${file:R} contains itself: ${file:R}
+diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk
+index c10e492..5984215 100644
+--- a/share/mk/bsd.own.mk
++++ b/share/mk/bsd.own.mk
+@@ -233,9 +233,6 @@ INSTALL_SYMLINK?= ${INSTALL} ${SYMLINK}
+ INSTALL_RSYMLINK?= ${INSTALL} ${RSYMLINK}
+
+ # Common variables
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+
+ COMPRESS_CMD?= gzip -cn
+ COMPRESS_EXT?= .gz
+diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
+index f1a5c65..3b1ecf8 100644
+--- a/share/mk/bsd.prog.mk
++++ b/share/mk/bsd.prog.mk
+@@ -44,10 +44,6 @@ CTFFLAGS+= -g
+ .endif
+ .endif
+
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ .if defined(NO_ROOT)
+ .if !defined(TAGS) || ! ${TAGS:Mpackage=*}
+ TAGS+= package=${PACKAGE:Uruntime}
+@@ -217,6 +213,7 @@ realinstall: _proginstall
+ .ORDER: beforeinstall _proginstall
+ _proginstall:
+ .if defined(PROG)
++ ${INSTALL} -d ${DESTDIR}${BINDIR}
+ ${INSTALL} ${TAG_ARGS} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
+ .if ${MK_DEBUG_FILES} != "no"
+@@ -255,6 +252,7 @@ SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
+ STAGE_AS_${script:T}= ${SCRIPTSDIR_${script:T}}/${SCRIPTSNAME_${script:T}}
+ _scriptsinstall: _SCRIPTSINS_${script:T}
+ _SCRIPTSINS_${script:T}: ${script}
++ ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}
+ ${INSTALL} ${TAG_ARGS} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
+ -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
+index 0ae45c5..37c4d01 100644
+--- a/share/mk/bsd.sys.mk
++++ b/share/mk/bsd.sys.mk
+@@ -29,9 +29,6 @@ CFLAGS+= -std=${CSTD}
+ .if defined(WARNS)
+ .if ${WARNS} >= 1
+ CWARNFLAGS+= -Wsystem-headers
+-.if !defined(NO_WERROR) && !defined(NO_WERROR.${COMPILER_TYPE})
+-CWARNFLAGS+= -Werror
+-.endif # !NO_WERROR && !NO_WERROR.${COMPILER_TYPE}
+ .endif # WARNS >= 1
+ .if ${WARNS} >= 2
+ CWARNFLAGS+= -Wall -Wno-format-y2k
+@@ -100,9 +97,6 @@ CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args
+ .if ${WARNS} <= 3
+ CWARNFLAGS.clang+= -Wno-format-nonliteral
+ .endif # WARNS <= 3
+-.if !defined(NO_WERROR) && !defined(NO_WERROR.${COMPILER_TYPE})
+-CWARNFLAGS+= -Werror
+-.endif # !NO_WERROR && !NO_WERROR.${COMPILER_TYPE}
+ .endif # WFORMAT > 0
+ .endif # WFORMAT
+ .if defined(NO_WFORMAT) || defined(NO_WFORMAT.${COMPILER_TYPE})
+@@ -151,6 +145,13 @@ CFLAGS.clang+= -fno-dwarf2-cfi-asm
+ # but not yet.
+ CXXFLAGS.clang+= -Wno-c++11-extensions
+
++.if ${MK_SSP} == "no"
++# gcc-4.9, -fstack-protector-strong is enabled by default.
++# Add -fno-stack-protector to disable it. Gentoo Bug #511698.
++SSP_CFLAGS?= -fno-stack-protector
++CFLAGS+= ${SSP_CFLAGS}
++.endif
++
+ .if ${MK_SSP} != "no" && \
+ ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
+ .if (${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30500) || \
+diff --git a/share/mk/sys.mk b/share/mk/sys.mk
+index 5cfd0bb..25abf8e 100644
+--- a/share/mk/sys.mk
++++ b/share/mk/sys.mk
+@@ -418,12 +418,6 @@ YFLAGS ?= -d
+ rm -f ${.PREFIX}.tmp.c
+ ${CTFCONVERT_CMD}
+
+-# Pull in global settings.
+-__MAKE_CONF?=/etc/make.conf
+-.if exists(${__MAKE_CONF})
+-.include "${__MAKE_CONF}"
+-.endif
+-
+ # late include for customization
+ .sinclude <local.sys.mk>
+
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-gnu.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-gnu.patch
new file mode 100644
index 000000000000..97e882d51aac
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-gnu.patch
@@ -0,0 +1,63 @@
+diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
+index 92df111..88c75d9 100644
+--- a/share/mk/bsd.lib.mk
++++ b/share/mk/bsd.lib.mk
+@@ -184,7 +184,7 @@ _LIBS= lib${LIB_PRIVATE}${LIB}.a
+ lib${LIB_PRIVATE}${LIB}.a: ${OBJS} ${STATICOBJS}
+ @${ECHO} building static ${LIB} library
+ @rm -f ${.TARGET}
+- ${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
++ ${AR} ${ARFLAGS} ${.TARGET} ${OBJS} ${STATICOBJS} ${ARADD}
+ ${RANLIB} ${RANLIBFLAGS} ${.TARGET}
+ .endif
+
+@@ -199,7 +199,7 @@ CLEANFILES+= ${POBJS}
+ lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS}
+ @${ECHO} building profiled ${LIB} library
+ @rm -f ${.TARGET}
+- ${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' lorder ${POBJS} | tsort -q` ${ARADD}
++ ${AR} ${ARFLAGS} ${.TARGET} {POBJS} ${ARADD}
+ ${RANLIB} ${RANLIBFLAGS} ${.TARGET}
+ .endif
+
+@@ -247,7 +247,7 @@ ${SHLIB_NAME_FULL}: ${SOBJS}
+ .endif
+ ${_LD:N${CCACHE_BIN}} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
+ -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `NM='${NM}' NMFLAGS='${NMFLAGS}' lorder ${SOBJS} | tsort -q` ${LDADD}
++ `echo ${SOBJS} | xargs -n 1 echo | sort -u` ${LDADD}
+ .if ${MK_CTF} != "no"
+ ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
+ .endif
+@@ -312,13 +312,6 @@ _EXTRADEPEND:
+
+ .if !target(install)
+
+-.if defined(PRECIOUSLIB)
+-.if !defined(NO_FSCHG)
+-SHLINSTALLFLAGS+= -fschg
+-.endif
+-SHLINSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
+diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
+index 3b1ecf8..26ac9c5 100644
+--- a/share/mk/bsd.prog.mk
++++ b/share/mk/bsd.prog.mk
+@@ -196,13 +196,6 @@ _EXTRADEPEND:
+
+ .if !target(install)
+
+-.if defined(PRECIOUSPROG)
+-.if !defined(NO_FSCHG)
+-INSTALLFLAGS+= -fschg
+-.endif
+-INSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-libproc-libcxx.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-libproc-libcxx.patch
new file mode 100644
index 000000000000..5da025d03f37
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-libproc-libcxx.patch
@@ -0,0 +1,13 @@
+diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk
+index 14489a8..c993f7c 100644
+--- a/share/mk/src.libnames.mk
++++ b/share/mk/src.libnames.mk
+@@ -245,7 +245,7 @@ _DP_radius= crypto
+ .endif
+ _DP_procstat= kvm util elf
+ .if ${MK_CXX} == "yes"
+-.if ${MK_LIBCPLUSPLUS} != "no"
++.if ${COMPILER_TYPE} == "clang"
+ _DP_proc= cxxrt
+ .else
+ _DP_proc= supcplusplus
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-rename-libs.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-rename-libs.patch
new file mode 100644
index 000000000000..fd72f1fe846e
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.0-rename-libs.patch
@@ -0,0 +1,16 @@
+diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk
+index 249ac52..14489a8 100644
+--- a/share/mk/src.libnames.mk
++++ b/share/mk/src.libnames.mk
+@@ -343,6 +343,11 @@ LIBATF_CXX= ${DESTDIR}${LIBDIR}/libprivateatf-c++.a
+ LDADD_atf_c= -lprivateatf-c
+ LDADD_atf_cxx= -lprivateatf-c++
+
++LDADD_bsdxml= -lexpat
++LDADD_l= -lfl
++LDADD_termcap= -lncurses
++LDADD_termcapw= -lncursesw
++
+ .for _l in ${_PRIVATELIBS}
+ LIB${_l:tu}?= ${DESTDIR}${LIBDIR}/libprivate${_l}.a
+ .endfor
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.1-gentoo.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.1-gentoo.patch
new file mode 100644
index 000000000000..051fd899b748
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-11.1-gentoo.patch
@@ -0,0 +1,343 @@
+diff --git a/share/mk/bsd.doc.mk b/share/mk/bsd.doc.mk
+index 9baa335..8cb61e2 100644
+--- a/share/mk/bsd.doc.mk
++++ b/share/mk/bsd.doc.mk
+@@ -144,10 +144,12 @@ CLEANFILES+= ${DOC}.ascii ${DOC}.ascii${DCOMPRESS_EXT} \
+ realinstall:
+ .if ${PRINTERDEVICE:Mhtml}
+ cd ${SRCDIR}; \
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},docs} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}/
+ .endif
+ .for _dev in ${PRINTERDEVICE:Nhtml}
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},docs} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME}/
+ .endfor
+diff --git a/share/mk/bsd.files.mk b/share/mk/bsd.files.mk
+index 111a7f1..cde2568 100644
+--- a/share/mk/bsd.files.mk
++++ b/share/mk/bsd.files.mk
+@@ -61,6 +61,7 @@ stage_as.${file:T}: ${file}
+
+ installfiles-${group}: _${group}INS_${file:T}
+ _${group}INS_${file:T}: ${file}
++ ${INSTALL} -d ${DESTDIR}${${group}DIR_${.ALLSRC:T}}
+ ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -75,10 +76,12 @@ stage_files.${group}: ${_${group}FILES}
+ installfiles-${group}: _${group}INS
+ _${group}INS: ${_${group}FILES}
+ .if defined(${group}NAME)
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}/${${group}NAME}
+ ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} \
+ ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+ ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}/
+ .endif
+diff --git a/share/mk/bsd.incs.mk b/share/mk/bsd.incs.mk
+index 04c1407..06ddde3 100644
+--- a/share/mk/bsd.incs.mk
++++ b/share/mk/bsd.incs.mk
+@@ -60,6 +60,9 @@ stage_includes: stage_as.${header:T}
+
+ installincludes: _${group}INS_${header:T}
+ _${group}INS_${header:T}: ${header}
++ ${INSTALL} -d -o ${${group}OWN_${.ALLSRC:T}} \
++ -g ${${group}GRP_${.ALLSRC:T}} \
++ ${DESTDIR}${${group}DIR_${.ALLSRC:T}}
+ ${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -75,9 +78,13 @@ stage_includes: stage_files.${group}
+ installincludes: _${group}INS
+ _${group}INS: ${_${group}INCS}
+ .if defined(${group}NAME)
++ ${INSTALL} -d -o ${${group}OWN} -g ${${group}GRP} \
++ ${DESTDIR}${${group}DIR}
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d -o ${${group}OWN} -g ${${group}GRP} \
++ ${DESTDIR}${${group}DIR}
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}/
+ .endif
+diff --git a/share/mk/bsd.info.mk b/share/mk/bsd.info.mk
+index 46498fa..7b673f8 100644
+--- a/share/mk/bsd.info.mk
++++ b/share/mk/bsd.info.mk
+@@ -83,6 +83,7 @@ INFO2HTML?= info2html
+ TEX?= tex
+ DVIPS?= dvips
+ DVIPS2ASCII?= dvips2ascii
++INSTALL?= install
+
+ .SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
+
+@@ -141,15 +142,17 @@ ${x:S/$/${ICOMPRESS_EXT}/}: ${x}
+ INSTALLINFODIRS+= ${x:S/$/-install/}
+ ${x:S/$/-install/}:
+ .if !empty(.MAKEFLAGS:M-j)
++ ${INSTALL} -d ${DESTDIR}${INFODIR}
+ lockf -k ${DESTDIR}${INFODIR}/${INFODIRFILE} \
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+- --defsection=${INFOSECTION} \
+- --defentry=${INFOENTRY_${x}} \
++ --section=${INFOSECTION} \
++ --entry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .else
++ ${INSTALL} -d ${DESTDIR}${INFODIR}
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+- --defsection=${INFOSECTION} \
+- --defentry=${INFOENTRY_${x}} \
++ --section=${INFOSECTION} \
++ --entry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .endif
+ .endfor
+diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
+index c59027c..f996c35 100644
+--- a/share/mk/bsd.lib.mk
++++ b/share/mk/bsd.lib.mk
+@@ -52,8 +52,6 @@ CFLAGS+= ${DEBUG_FLAGS}
+ .if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != ""
+ CTFFLAGS+= -g
+ .endif
+-.else
+-STRIP?= -s
+ .endif
+
+ .if ${SHLIBDIR:M*lib32*}
+@@ -336,14 +334,17 @@ realinstall: _libinstall
+ .ORDER: beforeinstall _libinstall
+ _libinstall:
+ .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
++ ${INSTALL} -d ${DESTDIR}${_LIBDIR}
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}.a ${DESTDIR}${_LIBDIR}/
+ .endif
+ .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${_LIBDIR}
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},profile} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}_p.a ${DESTDIR}${_LIBDIR}/
+ .endif
+ .if defined(SHLIB_NAME)
++ ${INSTALL} -d ${DESTDIR}${_SHLIBDIR}
+ ${INSTALL} ${TAG_ARGS} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
+ ${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR}/
+@@ -388,10 +389,12 @@ _libinstall:
+ .endif # SHLIB_LINK
+ .endif # SHIB_NAME
+ .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
++ ${INSTALL} -d ${DESTDIR}${_LIBDIR}
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR}/
+ .endif
+ .if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${LINTLIBDIR}
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${LINTLIB} ${DESTDIR}${LINTLIBDIR}/
+ .endif
+diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk
+index 98746fa..5c541ab 100644
+--- a/share/mk/bsd.libnames.mk
++++ b/share/mk/bsd.libnames.mk
+@@ -64,7 +64,7 @@ LIBELF?= ${DESTDIR}${LIBDIR_BASE}/libelf.a
+ LIBEXECINFO?= ${DESTDIR}${LIBDIR_BASE}/libexecinfo.a
+ LIBFETCH?= ${DESTDIR}${LIBDIR_BASE}/libfetch.a
+ LIBFIGPAR?= ${DESTDIR}${LIBDIR_BASE}/libfigpar.a
+-LIBFL?= "don't use LIBFL, use LIBL"
++LIBFL?= ${DESTDIR}${LIBDIR_BASE}/libfl.a
+ LIBFORM?= ${DESTDIR}${LIBDIR_BASE}/libform.a
+ LIBG2C?= ${DESTDIR}${LIBDIR_BASE}/libg2c.a
+ LIBGEOM?= ${DESTDIR}${LIBDIR_BASE}/libgeom.a
+@@ -93,7 +93,7 @@ LIBKEYCAP?= ${DESTDIR}${LIBDIR_BASE}/libkeycap.a
+ LIBKICONV?= ${DESTDIR}${LIBDIR_BASE}/libkiconv.a
+ LIBKRB5?= ${DESTDIR}${LIBDIR_BASE}/libkrb5.a
+ LIBKVM?= ${DESTDIR}${LIBDIR_BASE}/libkvm.a
+-LIBL?= ${DESTDIR}${LIBDIR_BASE}/libl.a
++LIBL?= ${DESTDIR}${LIBDIR_BASE}/libfl.a
+ LIBLN?= "don't use LIBLN, use LIBL"
+ LIBLZMA?= ${DESTDIR}${LIBDIR_BASE}/liblzma.a
+ LIBM?= ${DESTDIR}${LIBDIR_BASE}/libm.a
+diff --git a/share/mk/bsd.links.mk b/share/mk/bsd.links.mk
+index 75acbe1..b662439 100644
+--- a/share/mk/bsd.links.mk
++++ b/share/mk/bsd.links.mk
+@@ -16,9 +16,11 @@ afterinstall: _installlinks
+ _installlinks:
+ .for s t in ${LINKS}
+ @${ECHO} "${t} -> ${s}" ;\
++ test -d ${DESTDIR}/`dirname ${t}` || mkdir ${DESTDIR}/`dirname ${t}`;\
+ ${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}${s} ${DESTDIR}${t}
+ .endfor
+ .for s t in ${SYMLINKS}
+ @${ECHO} "${t} -> ${s}" ;\
++ test -d ${DESTDIR}/`dirname ${t}` || mkdir ${DESTDIR}/`dirname ${t}`;\
+ ${INSTALL_SYMLINK} ${TAG_ARGS} ${s} ${DESTDIR}/${t}
+ .endfor
+diff --git a/share/mk/bsd.man.mk b/share/mk/bsd.man.mk
+index 7306453..5fcd4f7 100644
+--- a/share/mk/bsd.man.mk
++++ b/share/mk/bsd.man.mk
+@@ -188,9 +188,11 @@ maninstall: ${MAN}
+ .if ${MK_MANCOMPRESS} == "no"
+ .if defined(MANFILTER)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page}
+ ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page}
+ .endif
+@@ -204,11 +206,14 @@ maninstall: ${MAN}
+ esac; \
+ page=$$1; shift; sect=$$1; shift; \
+ d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \
++ ${ECHO} ${INSTALL} -d $${d}; \
++ ${INSTALL} -d $${d}; \
+ ${ECHO} ${MINSTALL} $${page} $${d}; \
+ ${MINSTALL} $${page} $${d}; \
+ done
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T}
+ .endfor
+@@ -216,9 +221,11 @@ maninstall: ${MAN}
+ .endif # defined(MANFILTER)
+ .else # ${MK_MANCOMPRESS} == "yes"
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}
+ ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/}
+ .endif
+diff --git a/share/mk/bsd.nls.mk b/share/mk/bsd.nls.mk
+index 6f769d3..1679973 100644
+--- a/share/mk/bsd.nls.mk
++++ b/share/mk/bsd.nls.mk
+@@ -71,7 +71,8 @@ STAGE_SYMLINKS_DIR.NLS= ${STAGE_OBJTOP}
+ SYMLINKS+= ${NLSSYMLINKS}
+ .endif
+ .for file in ${NLS}
+-NLSNAME_${file:T}= ${file:T:R}/${NLSNAME}.cat
++NLSDIR_${file:T}= ${SHAREDIR}/nls/${file:T:R}/
++NLSNAME_${file:T}= ${NLSNAME}.cat
+ .if defined(NLSLINKS_${file:R}) && !empty(NLSLINKS_${file:R})
+ .if !empty(NLSLINKS_${file:R}:M${file:R})
+ .error NLSLINKS_${file:R} contains itself: ${file:R}
+diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk
+index 3450a01..8ad3e69 100644
+--- a/share/mk/bsd.own.mk
++++ b/share/mk/bsd.own.mk
+@@ -217,9 +217,6 @@ INSTALL_SYMLINK?= ${INSTALL} ${SYMLINK}
+ INSTALL_RSYMLINK?= ${INSTALL} ${RSYMLINK}
+
+ # Common variables
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+
+ COMPRESS_CMD?= gzip -cn
+ COMPRESS_EXT?= .gz
+diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
+index e4727ac..775fd8a 100644
+--- a/share/mk/bsd.prog.mk
++++ b/share/mk/bsd.prog.mk
+@@ -44,10 +44,6 @@ CTFFLAGS+= -g
+ .endif
+ .endif
+
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ .if defined(NO_ROOT)
+ .if !defined(TAGS) || ! ${TAGS:Mpackage=*}
+ TAGS+= package=${PACKAGE:Uruntime}
+@@ -217,6 +213,7 @@ realinstall: _proginstall
+ .ORDER: beforeinstall _proginstall
+ _proginstall:
+ .if defined(PROG)
++ ${INSTALL} -d ${DESTDIR}${BINDIR}
+ ${INSTALL} ${TAG_ARGS} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
+ .if ${MK_DEBUG_FILES} != "no"
+@@ -255,6 +252,7 @@ SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
+ STAGE_AS_${script:T}= ${SCRIPTSDIR_${script:T}}/${SCRIPTSNAME_${script:T}}
+ _scriptsinstall: _SCRIPTSINS_${script:T}
+ _SCRIPTSINS_${script:T}: ${script}
++ ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}
+ ${INSTALL} ${TAG_ARGS} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
+ -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
+index cb79bf1..3cad05f 100644
+--- a/share/mk/bsd.sys.mk
++++ b/share/mk/bsd.sys.mk
+@@ -29,9 +29,6 @@ CFLAGS+= -std=${CSTD}
+ .if defined(WARNS)
+ .if ${WARNS} >= 1
+ CWARNFLAGS+= -Wsystem-headers
+-.if !defined(NO_WERROR) && !defined(NO_WERROR.${COMPILER_TYPE})
+-CWARNFLAGS+= -Werror
+-.endif # !NO_WERROR && !NO_WERROR.${COMPILER_TYPE}
+ .endif # WARNS >= 1
+ .if ${WARNS} >= 2
+ CWARNFLAGS+= -Wall -Wno-format-y2k
+@@ -103,9 +100,6 @@ CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args
+ .if ${WARNS} <= 3
+ CWARNFLAGS.clang+= -Wno-format-nonliteral
+ .endif # WARNS <= 3
+-.if !defined(NO_WERROR) && !defined(NO_WERROR.${COMPILER_TYPE})
+-CWARNFLAGS+= -Werror
+-.endif # !NO_WERROR && !NO_WERROR.${COMPILER_TYPE}
+ .endif # WFORMAT > 0
+ .endif # WFORMAT
+ .if defined(NO_WFORMAT) || defined(NO_WFORMAT.${COMPILER_TYPE})
+@@ -154,6 +148,13 @@ CFLAGS.clang+= -fno-dwarf2-cfi-asm
+ # but not yet.
+ CXXFLAGS.clang+= -Wno-c++11-extensions
+
++.if ${MK_SSP} == "no"
++# gcc-4.9, -fstack-protector-strong is enabled by default.
++# Add -fno-stack-protector to disable it. Gentoo Bug #511698.
++SSP_CFLAGS?= -fno-stack-protector
++CFLAGS+= ${SSP_CFLAGS}
++.endif
++
+ .if ${MK_SSP} != "no" && \
+ ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
+ .if (${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30500) || \
+diff --git a/share/mk/sys.mk b/share/mk/sys.mk
+index 91d5a9a..7786edb 100644
+--- a/share/mk/sys.mk
++++ b/share/mk/sys.mk
+@@ -422,12 +422,6 @@ YFLAGS ?= -d
+ rm -f ${.PREFIX}.tmp.c
+ ${CTFCONVERT_CMD}
+
+-# Pull in global settings.
+-__MAKE_CONF?=/etc/make.conf
+-.if exists(${__MAKE_CONF})
+-.include "${__MAKE_CONF}"
+-.endif
+-
+ # late include for customization
+ .sinclude <local.sys.mk>
+
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gentoo.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gentoo.patch
new file mode 100644
index 000000000000..f17f6c4aad3a
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gentoo.patch
@@ -0,0 +1,332 @@
+Index: share/mk/bsd.doc.mk
+===================================================================
+--- share/mk/bsd.doc.mk.orig
++++ share/mk/bsd.doc.mk
+@@ -137,10 +137,12 @@ CLEANFILES+= ${DOC}.ascii ${DOC}.ascii${
+ realinstall:
+ .for _dev in ${PRINTERDEVICE:Mhtml}
+ cd ${SRCDIR}; \
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}
+ .endfor
+ .for _dev in ${PRINTERDEVICE:Nhtml}
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME}
+ .endfor
+Index: share/mk/bsd.files.mk
+===================================================================
+--- share/mk/bsd.files.mk.orig
++++ share/mk/bsd.files.mk
+@@ -39,6 +39,7 @@ ${group}NAME_${file:T}?= ${file:T}
+ .endif
+ installfiles: _${group}INS_${file:T}
+ _${group}INS_${file:T}: ${file}
++ ${INSTALL} -d ${DESTDIR}${${group}DIR_${.ALLSRC}}/${${group}NAME_${.ALLSRC:T}:H}
+ ${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -51,10 +52,12 @@ _${group}FILES+= ${file}
+ installfiles: _${group}INS
+ _${group}INS: ${_${group}FILES}
+ .if defined(${group}NAME)
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}/${${group}NAME}
+ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} \
+ ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+Index: share/mk/bsd.incs.mk
+===================================================================
+--- share/mk/bsd.incs.mk.orig
++++ share/mk/bsd.incs.mk
+@@ -41,6 +41,10 @@ ${group}NAME_${header:T}?= ${header:T}
+ .endif
+ installincludes: _${group}INS_${header:T}
+ _${group}INS_${header:T}: ${header}
++
++ ${INSTALL} -d -o ${${group}OWN_${.ALLSRC:T}} \
++ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
++ ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
+ ${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -53,9 +57,11 @@ _${group}INCS+= ${header}
+ installincludes: _${group}INS
+ _${group}INS: ${_${group}INCS}
+ .if defined(${group}NAME)
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+ ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+ ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+Index: share/mk/bsd.info.mk
+===================================================================
+--- share/mk/bsd.info.mk.orig
++++ share/mk/bsd.info.mk
+@@ -83,6 +83,7 @@ INFO2HTML?= info2html
+ TEX?= tex
+ DVIPS?= dvips
+ DVIPS2ASCII?= dvips2ascii
++INSTALL?= install
+
+ .SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
+
+@@ -144,12 +145,14 @@ ${x:S/$/${ICOMPRESS_EXT}/}: ${x}
+ INSTALLINFODIRS+= ${x:S/$/-install/}
+ ${x:S/$/-install/}:
+ .if !empty(.MAKEFLAGS:M-j)
++ ${INSTALL} -d ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ lockf -k ${DESTDIR}${INFODIR}/${INFODIRFILE} \
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+ --defsection=${INFOSECTION} \
+ --defentry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .else
++ ${INSTALL} -d ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+ --defsection=${INFOSECTION} \
+ --defentry=${INFOENTRY_${x}} \
+Index: share/mk/bsd.lib.mk
+===================================================================
+--- share/mk/bsd.lib.mk.orig
++++ share/mk/bsd.lib.mk
+@@ -41,10 +41,6 @@ CTFFLAGS+= -g
+ .endif
+ .endif
+
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ .include <bsd.libnames.mk>
+
+ # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
+@@ -276,14 +272,17 @@ realinstall: _libinstall
+ .ORDER: beforeinstall _libinstall
+ _libinstall:
+ .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if defined(SHLIB_NAME)
++ ${INSTALL} -d ${DESTDIR}${SHLIBDIR}
+ ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
+ ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
+Index: share/mk/bsd.libnames.mk
+===================================================================
+--- share/mk/bsd.libnames.mk.orig
++++ share/mk/bsd.libnames.mk
+@@ -46,7 +46,7 @@ LIBDWARF?= ${DESTDIR}${LIBDIR}/libdwarf.
+ LIBEDIT?= ${DESTDIR}${LIBDIR}/libedit.a
+ LIBELF?= ${DESTDIR}${LIBDIR}/libelf.a
+ LIBFETCH?= ${DESTDIR}${LIBDIR}/libfetch.a
+-LIBFL?= "don't use LIBFL, use LIBL"
++LIBFL?= ${DESTDIR}${LIBDOR}/libfl.a
+ LIBFORM?= ${DESTDIR}${LIBDIR}/libform.a
+ LIBFTPIO?= ${DESTDIR}${LIBDIR}/libftpio.a
+ LIBG2C?= ${DESTDIR}${LIBDIR}/libg2c.a
+@@ -77,7 +77,7 @@ LIBKEYCAP?= ${DESTDIR}${LIBDIR}/libkeyca
+ LIBKICONV?= ${DESTDIR}${LIBDIR}/libkiconv.a
+ LIBKRB5?= ${DESTDIR}${LIBDIR}/libkrb5.a
+ LIBKVM?= ${DESTDIR}${LIBDIR}/libkvm.a
+-LIBL?= ${DESTDIR}${LIBDIR}/libl.a
++LIBL?= ${DESTDIR}${LIBDOR}/libfl.a
+ LIBLN?= "don't use LIBLN, use LIBL"
+ .if ${MK_BIND} != "no"
+ LIBLWRES?= ${DESTDIR}${LIBDIR}/liblwres.a
+Index: share/mk/bsd.man.mk
+===================================================================
+--- share/mk/bsd.man.mk.orig
++++ share/mk/bsd.man.mk
+@@ -165,9 +165,11 @@ _maninstall: ${MAN}
+ .if defined(NO_MANCOMPRESS)
+ .if defined(MANFILTER)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}/${page}
+ ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}/${page}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page}
+ .endif
+@@ -181,11 +183,14 @@ _maninstall: ${MAN}
+ esac; \
+ page=$$1; shift; sect=$$1; shift; \
+ d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \
++ ${ECHO} ${INSTALL} -d $${d}; \
++ ${INSTALL} -d $${d}; \
+ ${ECHO} ${MINSTALL} $${page} $${d}; \
+ ${MINSTALL} $${page} $${d}; \
+ done
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T}
+ .endfor
+@@ -193,9 +198,11 @@ _maninstall: ${MAN}
+ .endif
+ .else
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}
+ ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T:S/$/${MCOMPRESS_EXT}/}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/}
+ .endif
+Index: share/mk/bsd.prog.mk
+===================================================================
+--- share/mk/bsd.prog.mk.orig
++++ share/mk/bsd.prog.mk
+@@ -27,10 +27,6 @@ CTFFLAGS+= -g
+ CFLAGS+=${CRUNCH_CFLAGS}
+ .endif
+
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ .if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO")
+ LDFLAGS+= -static
+ .endif
+@@ -152,9 +148,11 @@ realinstall: _proginstall
+ _proginstall:
+ .if defined(PROG)
+ .if defined(PROGNAME)
++ ${INSTALL} -d ${DESTDIR}${BINDIR}
+ ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
+ .else
++ ${INSTALL} -d ${DESTDIR}${BINDIR}
+ ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
+ .endif
+@@ -182,6 +180,7 @@ SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP}
+ SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
+ _scriptsinstall: _SCRIPTSINS_${script:T}
+ _SCRIPTSINS_${script:T}: ${script}
++ ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}
+ ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
+ -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+Index: share/mk/bsd.sys.mk
+===================================================================
+--- share/mk/bsd.sys.mk.orig
++++ share/mk/bsd.sys.mk
+@@ -28,9 +28,6 @@ CFLAGS += -std=${CSTD}
+ . if defined(WARNS)
+ . if ${WARNS} >= 1
+ CWARNFLAGS += -Wsystem-headers
+-. if !defined(NO_WERROR)
+-CWARNFLAGS += -Werror
+-. endif
+ . endif
+ . if ${WARNS} >= 2
+ CWARNFLAGS += -Wall -Wno-format-y2k
+@@ -64,9 +61,6 @@ WFORMAT = 1
+ . if ${WFORMAT} > 0
+ #CWARNFLAGS += -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
+ CWARNFLAGS += -Wformat=2 -Wno-format-extra-args
+-. if !defined(NO_WERROR)
+-CWARNFLAGS += -Werror
+-. endif
+ . endif
+ . endif
+ .endif
+Index: share/mk/bsd.links.mk
+===================================================================
+--- share/mk/bsd.links.mk.orig
++++ share/mk/bsd.links.mk
+@@ -15,6 +15,8 @@ _installlinks:
+ t=${DESTDIR}$$1; \
+ shift; \
+ ${ECHO} $$t -\> $$l; \
++ d=`dirname $$t`; \
++ test -d $$d || mkdir $$d; \
+ ln -f $$l $$t; \
+ done; true
+ .endif
+@@ -26,6 +28,8 @@ _installlinks:
+ t=${DESTDIR}$$1; \
+ shift; \
+ ${ECHO} $$t -\> $$l; \
++ d=`dirname $$t`; \
++ test -d $$d || mkdir $$d; \
+ ln -fs $$l $$t; \
+ done; true
+ .endif
+Index: share/mk/bsd.own.mk
+===================================================================
+--- share/mk/bsd.own.mk.orig
++++ share/mk/bsd.own.mk
+@@ -164,11 +164,6 @@ NLSMODE?= ${NOBINMODE}
+
+ INCLUDEDIR?= /usr/include
+
+-# Common variables
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ COMPRESS_CMD?= gzip -cn
+ COMPRESS_EXT?= .gz
+
+Index: share/mk/sys.mk
+===================================================================
+--- share/mk/sys.mk.orig
++++ share/mk/sys.mk
+@@ -34,11 +34,11 @@ AFLAGS ?=
+ CC ?= c89
+ CFLAGS ?= -O
+ .else
+-CC ?= cc
++CC ?= gcc
+ .if ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "mips"
+-CFLAGS ?= -O -pipe
++CFLAGS ?= -pipe
+ .else
+-CFLAGS ?= -O2 -pipe
++CFLAGS ?= -pipe
+ .endif
+ .if defined(NO_STRICT_ALIASING)
+ CFLAGS += -fno-strict-aliasing
+@@ -64,7 +64,7 @@ CFLAGS += -g
+ .endif
+ .endif
+
+-CXX ?= c++
++CXX ?= g++
+ CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign}
+
+ CPP ?= cpp
+@@ -333,12 +333,6 @@ YFLAGS ?= -d
+ ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
+ .endif
+
+-# FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef.
+-__MAKE_CONF?=/etc/make.conf
+-.if exists(${__MAKE_CONF})
+-.include "${__MAKE_CONF}"
+-.endif
+-
+ .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
+ SHELL= ${__MAKE_SHELL}
+ .SHELL: path=${__MAKE_SHELL}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gnu.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gnu.patch
new file mode 100644
index 000000000000..41c4de4f945d
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-8.0-gnu.patch
@@ -0,0 +1,121 @@
+Index: mk/bsd.incs.mk
+===================================================================
+--- mk/bsd.incs.mk.orig
++++ mk/bsd.incs.mk
+@@ -45,7 +45,7 @@ _${group}INS_${header:T}: ${header}
+ ${INSTALL} -d -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
+- ${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
++ ${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+ ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
+@@ -58,11 +58,11 @@ installincludes: _${group}INS
+ _${group}INS: ${_${group}INCS}
+ .if defined(${group}NAME)
+ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+- ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
++ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
+ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+- ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
++ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+ .endif
+Index: mk/bsd.lib.mk
+===================================================================
+--- mk/bsd.lib.mk.orig
++++ mk/bsd.lib.mk
+@@ -156,11 +156,7 @@ _LIBS= lib${LIB}.a
+ lib${LIB}.a: ${OBJS} ${STATICOBJS}
+ @${ECHO} building static ${LIB} library
+ @rm -f ${.TARGET}
+-.if !defined(NM)
+- @${AR} cq ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
+-.else
+- @${AR} cq ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
+-.endif
++ @${AR} cq ${.TARGET} ${OBJS} ${STATICOBJS} ${ARADD}
+ ${RANLIB} ${.TARGET}
+ .endif
+
+@@ -173,11 +169,7 @@ POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=
+ lib${LIB}_p.a: ${POBJS}
+ @${ECHO} building profiled ${LIB} library
+ @rm -f ${.TARGET}
+-.if !defined(NM)
+- @${AR} cq ${.TARGET} `lorder ${POBJS} | tsort -q` ${ARADD}
+-.else
+- @${AR} cq ${.TARGET} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD}
+-.endif
++ @${AR} cq ${.TARGET} ${POBJS} ${ARADD}
+ ${RANLIB} ${.TARGET}
+ .endif
+
+@@ -195,15 +187,9 @@ ${SHLIB_NAME}: ${SOBJS}
+ .if defined(SHLIB_LINK)
+ @ln -fs ${.TARGET} ${SHLIB_LINK}
+ .endif
+-.if !defined(NM)
+- @${CC} ${LDFLAGS} ${SSP_CFLAGS} -shared -Wl,-x \
+- -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `lorder ${SOBJS} | tsort -q` ${LDADD}
+-.else
+ @${CC} ${LDFLAGS} ${SSP_CFLAGS} -shared -Wl,-x \
+ -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD}
+-.endif
++ `echo ${SOBJS} | xargs -n 1 echo | sort -u` ${LDADD}
+ .if defined(CTFMERGE)
+ ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
+ .endif
+@@ -251,13 +237,6 @@ _EXTRADEPEND:
+
+ .if !target(install)
+
+-.if defined(PRECIOUSLIB)
+-.if !defined(NO_FSCHG)
+-SHLINSTALLFLAGS+= -fschg
+-.endif
+-SHLINSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
+@@ -273,12 +252,12 @@ realinstall: _libinstall
+ _libinstall:
+ .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
+ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+- ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
++ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
+ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+- ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
++ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if defined(SHLIB_NAME)
+Index: mk/bsd.prog.mk
+===================================================================
+--- mk/bsd.prog.mk.orig
++++ mk/bsd.prog.mk
+@@ -130,13 +130,6 @@ _EXTRADEPEND:
+
+ .if !target(install)
+
+-.if defined(PRECIOUSPROG)
+-.if !defined(NO_FSCHG)
+-INSTALLFLAGS+= -fschg
+-.endif
+-INSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gentoo.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gentoo.patch
new file mode 100644
index 000000000000..598d0b9145b4
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gentoo.patch
@@ -0,0 +1,326 @@
+diff -Nur share.orig/mk/bsd.doc.mk share/mk/bsd.doc.mk
+--- share.orig/mk/bsd.doc.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.doc.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -135,10 +135,12 @@
+ realinstall:
+ .for _dev in ${PRINTERDEVICE:Mhtml}
+ cd ${SRCDIR}; \
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}
+ .endfor
+ .for _dev in ${PRINTERDEVICE:Nhtml}
++ ${INSTALL} -d ${DESTDIR}${BINDIR}/${VOLUME}; \
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME}
+ .endfor
+diff -Nur share.orig/mk/bsd.files.mk share/mk/bsd.files.mk
+--- share.orig/mk/bsd.files.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.files.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -39,6 +39,7 @@
+ .endif
+ installfiles: _${group}INS_${file:T}
+ _${group}INS_${file:T}: ${file}
++ ${INSTALL} -d ${DESTDIR}${${group}DIR_${.ALLSRC:T}}
+ ${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -51,10 +52,12 @@
+ installfiles: _${group}INS
+ _${group}INS: ${_${group}FILES}
+ .if defined(${group}NAME)
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}/${${group}NAME}
+ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} \
+ ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d ${DESTDIR}${${group}DIR}
+ ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
+ -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+diff -Nur share.orig/mk/bsd.incs.mk share/mk/bsd.incs.mk
+--- share.orig/mk/bsd.incs.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.incs.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -41,6 +41,9 @@
+ .endif
+ installincludes: _${group}INS_${header:T}
+ _${group}INS_${header:T}: ${header}
++ ${INSTALL} -d -o ${${group}OWN_${.ALLSRC:T}} \
++ -g ${${group}GRP_${.ALLSRC:T}} \
++ ${DESTDIR}${${group}DIR_${.ALLSRC:T}}
+ ${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
+ -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+@@ -53,9 +56,13 @@
+ installincludes: _${group}INS
+ _${group}INS: ${_${group}INCS}
+ .if defined(${group}NAME)
++ ${INSTALL} -d -o ${${group}OWN} -g ${${group}GRP} \
++ ${DESTDIR}${${group}DIR}
+ ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
+ .else
++ ${INSTALL} -d -o ${${group}OWN} -g ${${group}GRP} \
++ ${DESTDIR}${${group}DIR}
+ ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
+ ${.ALLSRC} ${DESTDIR}${${group}DIR}
+ .endif
+diff -Nur share.orig/mk/bsd.info.mk share/mk/bsd.info.mk
+--- share.orig/mk/bsd.info.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.info.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -83,6 +83,7 @@
+ TEX?= tex
+ DVIPS?= dvips
+ DVIPS2ASCII?= dvips2ascii
++INSTALL?= install
+
+ .SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
+
+@@ -144,15 +145,17 @@
+ INSTALLINFODIRS+= ${x:S/$/-install/}
+ ${x:S/$/-install/}:
+ .if !empty(.MAKEFLAGS:M-j)
++ ${INSTALL} -d ${DESTDIR}${INFODIR}
+ lockf -k ${DESTDIR}${INFODIR}/${INFODIRFILE} \
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+- --defsection=${INFOSECTION} \
+- --defentry=${INFOENTRY_${x}} \
++ --section=${INFOSECTION} \
++ --entry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .else
++ ${INSTALL} -d ${DESTDIR}${INFODIR}
+ ${INSTALLINFO} ${INSTALLINFOFLAGS} \
+- --defsection=${INFOSECTION} \
+- --defentry=${INFOENTRY_${x}} \
++ --section=${INFOSECTION} \
++ --entry=${INFOENTRY_${x}} \
+ ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
+ .endif
+ .endfor
+diff -Nur share.orig/mk/bsd.lib.mk share/mk/bsd.lib.mk
+--- share.orig/mk/bsd.lib.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.lib.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -46,10 +46,6 @@
+ .endif
+ .endif
+
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ .include <bsd.libnames.mk>
+
+ # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
+@@ -284,14 +280,17 @@
+ .ORDER: beforeinstall _libinstall
+ _libinstall:
+ .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if defined(SHLIB_NAME)
++ ${INSTALL} -d ${DESTDIR}${SHLIBDIR}
+ ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
+ ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
+@@ -329,10 +328,12 @@
+ .endif # SHLIB_LINK
+ .endif # SHIB_NAME
+ .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
++ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
+ .endif
+ .if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB)
++ ${INSTALL} -d ${DESTDIR}${LINTLIBDIR}
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${LINTLIB} ${DESTDIR}${LINTLIBDIR}
+ .endif
+diff -Nur share.orig/mk/bsd.libnames.mk share/mk/bsd.libnames.mk
+--- share.orig/mk/bsd.libnames.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.libnames.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -48,7 +48,7 @@
+ LIBEDIT?= ${DESTDIR}${LIBDIR}/libedit.a
+ LIBELF?= ${DESTDIR}${LIBDIR}/libelf.a
+ LIBFETCH?= ${DESTDIR}${LIBDIR}/libfetch.a
+-LIBFL?= "don't use LIBFL, use LIBL"
++LIBFL?= ${DESTDIR}${LIBDIR}/libfl.a
+ LIBFORM?= ${DESTDIR}${LIBDIR}/libform.a
+ LIBFTPIO?= ${DESTDIR}${LIBDIR}/libftpio.a
+ LIBG2C?= ${DESTDIR}${LIBDIR}/libg2c.a
+@@ -79,7 +79,7 @@
+ LIBKICONV?= ${DESTDIR}${LIBDIR}/libkiconv.a
+ LIBKRB5?= ${DESTDIR}${LIBDIR}/libkrb5.a
+ LIBKVM?= ${DESTDIR}${LIBDIR}/libkvm.a
+-LIBL?= ${DESTDIR}${LIBDIR}/libl.a
++LIBL?= ${DESTDIR}${LIBDIR}/libfl.a
+ LIBLN?= "don't use LIBLN, use LIBL"
+ .if ${MK_BIND} != "no"
+ LIBLWRES?= ${DESTDIR}${LIBDIR}/liblwres.a
+diff -Nur share.orig/mk/bsd.links.mk share/mk/bsd.links.mk
+--- share.orig/mk/bsd.links.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.links.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -15,6 +15,8 @@
+ t=${DESTDIR}$$1; \
+ shift; \
+ ${ECHO} $$t -\> $$l; \
++ d=`dirname $$t`; \
++ test -d $$d || mkdir $$d; \
+ ln -f $$l $$t; \
+ done; true
+ .endif
+@@ -26,6 +28,8 @@
+ t=${DESTDIR}$$1; \
+ shift; \
+ ${ECHO} $$t -\> $$l; \
++ d=`dirname $$t`; \
++ test -d $$d || mkdir $$d; \
+ ln -fs $$l $$t; \
+ done; true
+ .endif
+diff -Nur share.orig/mk/bsd.man.mk share/mk/bsd.man.mk
+--- share.orig/mk/bsd.man.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.man.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -165,9 +165,11 @@
+ .if defined(NO_MANCOMPRESS)
+ .if defined(MANFILTER)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}/${page}
+ ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page}
+ .endif
+@@ -181,11 +183,14 @@
+ esac; \
+ page=$$1; shift; sect=$$1; shift; \
+ d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \
++ ${ECHO} ${INSTALL} -d $${d}; \
++ ${INSTALL} -d $${d}; \
+ ${ECHO} ${MINSTALL} $${page} $${d}; \
+ ${MINSTALL} $${page} $${d}; \
+ done
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T}
+ .endfor
+@@ -193,9 +198,11 @@
+ .endif
+ .else
+ .for __page in ${MAN}
++ ${INSTALL} -d ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}
+ ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}
+ .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
++ ${INSTALL} -d ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T:S/$/${MCOMPRESS_EXT}
+ ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \
+ ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/}
+ .endif
+diff -Nur share.orig/mk/bsd.nls.mk share/mk/bsd.nls.mk
+--- share.orig/mk/bsd.nls.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.nls.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -62,7 +62,8 @@
+ # installation rules
+ #
+ .for file in ${NLS}
+-NLSNAME_${file:T}= ${file:T:R}/${NLSNAME}.cat
++NLSDIR_${file:T}= ${SHAREDIR}/nls/${file:T:R}/
++NLSNAME_${file:T}= ${NLSNAME}.cat
+ .if defined(NLSLINKS_${file:R}) && !empty(NLSLINKS_${file:R})
+ NLSLINKS+= ${file:R}
+ .endif
+diff -Nur share.orig/mk/bsd.own.mk share/mk/bsd.own.mk
+--- share.orig/mk/bsd.own.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.own.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -182,9 +182,6 @@
+ INCLUDEDIR?= /usr/include
+
+ # Common variables
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+
+ COMPRESS_CMD?= gzip -cn
+ COMPRESS_EXT?= .gz
+diff -Nur share.orig/mk/bsd.prog.mk share/mk/bsd.prog.mk
+--- share.orig/mk/bsd.prog.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.prog.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -33,10 +33,6 @@
+ CFLAGS+=${CRUNCH_CFLAGS}
+ .endif
+
+-.if !defined(DEBUG_FLAGS)
+-STRIP?= -s
+-.endif
+-
+ .if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO")
+ LDFLAGS+= -static
+ .endif
+@@ -155,6 +151,7 @@
+ .ORDER: beforeinstall _proginstall
+ _proginstall:
+ .if defined(PROG)
++ ${INSTALL} -d ${DESTDIR}${BINDIR}
+ .if defined(PROGNAME)
+ ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME}
+@@ -186,6 +183,7 @@
+ SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE}
+ _scriptsinstall: _SCRIPTSINS_${script:T}
+ _SCRIPTSINS_${script:T}: ${script}
++ ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}
+ ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \
+ -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \
+ ${.ALLSRC} \
+diff -Nur share.orig/mk/bsd.sys.mk share/mk/bsd.sys.mk
+--- share.orig/mk/bsd.sys.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/bsd.sys.mk 2012-07-16 00:04:14.000000000 +0900
+@@ -28,10 +28,6 @@
+ .if defined(WARNS)
+ .if ${WARNS} >= 1
+ CWARNFLAGS+= -Wsystem-headers
+-.if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && \
+- ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang))
+-CWARNFLAGS+= -Werror
+-.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang)
+ .endif # WARNS >= 1
+ .if ${WARNS} >= 2
+ CWARNFLAGS+= -Wall -Wno-format-y2k
+@@ -95,10 +91,6 @@
+ CWARNFLAGS+= -Wno-format-nonliteral
+ .endif # WARNS <= 3
+ .endif # CLANG
+-.if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && \
+- ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang))
+-CWARNFLAGS+= -Werror
+-.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang)
+ .endif # WFORMAT > 0
+ .endif # WFORMAT
+ .if defined(NO_WFORMAT) || ((${MK_CLANG_IS_CC} != "no" || \
+diff -Nur share.orig/mk/sys.mk share/mk/sys.mk
+--- share.orig/mk/sys.mk 2012-07-12 13:25:44.000000000 +0900
++++ share/mk/sys.mk 2012-07-16 00:01:55.000000000 +0900
+@@ -349,12 +349,6 @@
+ (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \
+ ${CTFCONVERT} ${CTFFLAGS} ${.TARGET})
+
+-# FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef.
+-__MAKE_CONF?=/etc/make.conf
+-.if exists(${__MAKE_CONF})
+-.include "${__MAKE_CONF}"
+-.endif
+-
+ .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
+ SHELL= ${__MAKE_SHELL}
+ .SHELL: path=${__MAKE_SHELL}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gnu.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gnu.patch
new file mode 100644
index 000000000000..f986ed9c3e11
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-9.1-gnu.patch
@@ -0,0 +1,77 @@
+diff -Nur share.orig/mk/bsd.lib.mk share/mk/bsd.lib.mk
+--- share.orig/mk/bsd.lib.mk 2012-07-16 02:40:07.000000000 +0900
++++ share/mk/bsd.lib.mk 2012-07-16 02:41:40.000000000 +0900
+@@ -155,11 +155,7 @@
+ lib${LIB}.a: ${OBJS} ${STATICOBJS}
+ @${ECHO} building static ${LIB} library
+ @rm -f ${.TARGET}
+-.if !defined(NM)
+- @${AR} cq ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
+-.else
+- @${AR} cq ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
+-.endif
++ @${AR} cq ${.TARGET} ${OBJS} ${STATICOBJS} ${ARADD}
+ ${RANLIB} ${.TARGET}
+ .endif
+
+@@ -172,11 +168,7 @@
+ lib${LIB}_p.a: ${POBJS}
+ @${ECHO} building profiled ${LIB} library
+ @rm -f ${.TARGET}
+-.if !defined(NM)
+- @${AR} cq ${.TARGET} `lorder ${POBJS} | tsort -q` ${ARADD}
+-.else
+- @${AR} cq ${.TARGET} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD}
+-.endif
++ @${AR} cq ${.TARGET} ${POBJS} ${ARADD}
+ ${RANLIB} ${.TARGET}
+ .endif
+
+@@ -203,15 +195,9 @@
+ .if defined(SHLIB_LINK)
+ @ln -fs ${.TARGET} ${SHLIB_LINK}
+ .endif
+-.if !defined(NM)
+ @${CC} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
+ -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `lorder ${SOBJS} | tsort -q` ${LDADD}
+-.else
+- @${CC} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
+- -o ${.TARGET} -Wl,-soname,${SONAME} \
+- `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD}
+-.endif
++ `echo ${SOBJS} | xargs -n 1 echo | sort -u` ${LDADD}
+ @[ -z "${CTFMERGE}" -o -n "${NO_CTF}" ] || \
+ (${ECHO} ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS} && \
+ ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS})
+@@ -259,13 +245,6 @@
+
+ .if !target(install)
+
+-.if defined(PRECIOUSLIB)
+-.if !defined(NO_FSCHG)
+-SHLINSTALLFLAGS+= -fschg
+-.endif
+-SHLINSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
+diff -Nur share.orig/mk/bsd.prog.mk share/mk/bsd.prog.mk
+--- share.orig/mk/bsd.prog.mk 2012-07-16 02:40:07.000000000 +0900
++++ share/mk/bsd.prog.mk 2012-07-16 02:40:24.000000000 +0900
+@@ -134,13 +134,6 @@
+
+ .if !target(install)
+
+-.if defined(PRECIOUSPROG)
+-.if !defined(NO_FSCHG)
+-INSTALLFLAGS+= -fschg
+-.endif
+-INSTALLFLAGS+= -S
+-.endif
+-
+ _INSTALLFLAGS:= ${INSTALLFLAGS}
+ .for ie in ${INSTALLFLAGS_EDIT}
+ _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
diff --git a/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-add-nossp-cflags.patch b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-add-nossp-cflags.patch
new file mode 100644
index 000000000000..8eb80c38cc7a
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/files/freebsd-mk-defs-add-nossp-cflags.patch
@@ -0,0 +1,28 @@
+https://bugs.gentoo.org/show_bug.cgi?id=511698
+
+diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
+index e438633..de4a05b 100644
+--- a/share/mk/bsd.sys.mk
++++ b/share/mk/bsd.sys.mk
+@@ -111,12 +111,18 @@ CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\
+ CFLAGS+= -Qunused-arguments
+ .endif # CLANG
+
+-.if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
+- ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
++.if ${MACHINE_CPUARCH} != "ia64" && ${MACHINE_CPUARCH} != "arm" \
++ && ${MACHINE_CPUARCH} != "mips"
++.if ${MK_SSP} != "no"
+ # Don't use -Wstack-protector as it breaks world with -Werror.
+ SSP_CFLAGS?= -fstack-protector
++.else
++# gcc-4.9, -fstack-protector-strong is enabled by default.
++# Add -fno-stack-protector to disable it. Gentoo Bug #511698.
++SSP_CFLAGS= -fno-stack-protector
++.endif #SSP
+ CFLAGS+= ${SSP_CFLAGS}
+-.endif # SSP && !IA64 && !ARM && !MIPS
++.endif # !IA64 && !ARM && !MIPS
+
+ # Allow user-specified additional warning flags
+ CFLAGS+= ${CWARNFLAGS}
diff --git a/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-10.3.ebuild b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-10.3.ebuild
new file mode 100644
index 000000000000..d6de89d0ca7b
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-10.3.ebuild
@@ -0,0 +1,41 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd
+
+DESCRIPTION="Makefiles definitions used for building and installing libraries and system files"
+SLOT="0"
+
+IUSE="userland_GNU"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64 ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="share/"
+
+RDEPEND=""
+DEPEND=""
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share/mk"
+
+src_prepare() {
+ epatch "${FILESDIR}/${PN}-10.3-gentoo.patch"
+ epatch "${FILESDIR}/${PN}-add-nossp-cflags.patch"
+ use userland_GNU && epatch "${FILESDIR}/${PN}-10.2-gnu.patch"
+}
+
+src_compile() { :; }
+
+src_install() {
+ if [[ ${CHOST} != *-freebsd* ]]; then
+ insinto /usr/share/mk/freebsd
+ else
+ insinto /usr/share/mk
+ fi
+ doins *.mk *.awk
+}
diff --git a/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-11.0.ebuild b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-11.0.ebuild
new file mode 100644
index 000000000000..626f7863925f
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-11.0.ebuild
@@ -0,0 +1,54 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd
+
+DESCRIPTION="Makefiles definitions used for building and installing libraries and system files"
+SLOT="0"
+
+IUSE="userland_GNU"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64 ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="share/"
+
+RDEPEND=""
+DEPEND=""
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share/mk"
+
+src_prepare() {
+ local installdir
+
+ epatch "${FILESDIR}/${PN}-11.0-gentoo.patch"
+ epatch "${FILESDIR}/${PN}-11.0-rename-libs.patch"
+ epatch "${FILESDIR}/${PN}-11.0-libproc-libcxx.patch"
+ epatch "${FILESDIR}/${PN}-11.0-drop-unsupport-cflags.patch"
+ use userland_GNU && epatch "${FILESDIR}/${PN}-11.0-gnu.patch"
+
+ if [[ ${CHOST} != *-freebsd* ]]; then
+ installdir="/usr/share/mk/freebsd"
+ else
+ installdir="/usr/share/mk"
+ fi
+
+ sed -i -e "s:FILESDIR=.*:FILESDIR= ${installdir}:" "${S}"/Makefile || die
+}
+
+src_compile() { :; }
+
+src_install() {
+ freebsd_src_install
+ if [[ ${CHOST} != *-freebsd* ]]; then
+ insinto /usr/share/mk/freebsd/system
+ else
+ insinto /usr/share/mk/system
+ fi
+ doins *.mk *.awk
+}
diff --git a/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-11.1.ebuild b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-11.1.ebuild
new file mode 100644
index 000000000000..1d2928c159a3
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-11.1.ebuild
@@ -0,0 +1,54 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd
+
+DESCRIPTION="Makefiles definitions used for building and installing libraries and system files"
+SLOT="0"
+
+IUSE="userland_GNU"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64 ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="share/"
+
+RDEPEND=""
+DEPEND=""
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share/mk"
+
+src_prepare() {
+ local installdir
+
+ epatch "${FILESDIR}/${PN}-11.1-gentoo.patch"
+ epatch "${FILESDIR}/${PN}-11.0-rename-libs.patch"
+ epatch "${FILESDIR}/${PN}-11.0-libproc-libcxx.patch"
+ epatch "${FILESDIR}/${PN}-11.0-drop-unsupport-cflags.patch"
+ use userland_GNU && epatch "${FILESDIR}/${PN}-11.0-gnu.patch"
+
+ if [[ ${CHOST} != *-freebsd* ]]; then
+ installdir="/usr/share/mk/freebsd"
+ else
+ installdir="/usr/share/mk"
+ fi
+
+ sed -i -e "s:FILESDIR=.*:FILESDIR= ${installdir}:" "${S}"/Makefile || die
+}
+
+src_compile() { :; }
+
+src_install() {
+ freebsd_src_install
+ if [[ ${CHOST} != *-freebsd* ]]; then
+ insinto /usr/share/mk/freebsd/system
+ else
+ insinto /usr/share/mk/system
+ fi
+ doins *.mk *.awk
+}
diff --git a/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-8.2.ebuild b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-8.2.ebuild
new file mode 100644
index 000000000000..e08e22094a41
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-8.2.ebuild
@@ -0,0 +1,40 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd
+
+DESCRIPTION="Makefiles definitions used for building and installing libraries and system files"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~sparc-fbsd ~x86-fbsd"
+
+IUSE=""
+
+SRC_URI="mirror://gentoo/${SHARE}.tar.bz2"
+
+RDEPEND=""
+DEPEND=""
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share/mk"
+
+src_unpack() {
+ unpack ${A}
+
+ cd "${S}"
+ epatch "${FILESDIR}/${PN}-8.0-gentoo.patch"
+
+ [[ ${CHOST} != *-*bsd* || ${CHOST} == *-gnu ]] && \
+ epatch "${FILESDIR}/${PN}-8.0-gnu.patch"
+}
+
+src_compile() { :; }
+
+src_install() {
+ if [[ ${CHOST} != *-freebsd* ]]; then
+ insinto /usr/share/mk/freebsd
+ else
+ insinto /usr/share/mk
+ fi
+ doins *.mk *.awk
+}
diff --git a/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-9.1.ebuild b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-9.1.ebuild
new file mode 100644
index 000000000000..d5f8b0df4b0e
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/freebsd-mk-defs-9.1.ebuild
@@ -0,0 +1,38 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=3
+
+inherit bsdmk freebsd
+
+DESCRIPTION="Makefiles definitions used for building and installing libraries and system files"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+
+IUSE="userland_GNU"
+
+SRC_URI="mirror://gentoo/${SHARE}.tar.bz2"
+
+RDEPEND=""
+DEPEND=""
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share/mk"
+
+src_prepare() {
+ epatch "${FILESDIR}/${PN}-9.1-gentoo.patch"
+ epatch "${FILESDIR}/${PN}-add-nossp-cflags.patch"
+ use userland_GNU && epatch "${FILESDIR}/${PN}-9.1-gnu.patch"
+}
+
+src_compile() { :; }
+
+src_install() {
+ if [[ ${CHOST} != *-freebsd* ]]; then
+ insinto /usr/share/mk/freebsd
+ else
+ insinto /usr/share/mk
+ fi
+ doins *.mk *.awk
+}
diff --git a/sys-freebsd/freebsd-mk-defs/metadata.xml b/sys-freebsd/freebsd-mk-defs/metadata.xml
new file mode 100644
index 000000000000..a00f3aeb1f81
--- /dev/null
+++ b/sys-freebsd/freebsd-mk-defs/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-pam-modules/Manifest b/sys-freebsd/freebsd-pam-modules/Manifest
new file mode 100644
index 000000000000..42024cca861f
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/Manifest
@@ -0,0 +1,16 @@
+AUX README.pamd 2840 SHA256 8f017c64cc5a54afbfa72152ed45d9a3f291cf636786c61409637b3e439b9e20 SHA512 7188bbb741bacbd2c826976f7f3b3150036f0855514ead679f56f0a4ab70fd6657fd38a33215cd883264ca2e801b7b2f3d7b73c40e04adc685e5fa6385c49357 WHIRLPOOL 8c7a2cdd6a5586d14bb4cf3c4158b0eaac0657137d72eb790083bab8363925d77eaa8d4200c1860e03a0b18cff9a96610ac51a2104e75feaf91a23a1a4c079aa
+AUX freebsd-pam-modules-6.0-gentoo.patch 701 SHA256 8346d95aa5b4f283fedf4387ebb85a61f5f10fac38dc45bdea8c2c345fdc633d SHA512 7adba1261547c11bb1a0b0d3c8cc800bba9aca4a878c9fa63f8b68e270a3a0d54388eb1e156aadcba54d9dd23a2817232b3f287522d820da15abb7dd9c8cd995 WHIRLPOOL 2b02611fce484145fe62468826bbdb8f1dedfb1c4a7a14b01234c99f13daefe9597d08a23e0836f5804f92c26cc1b950180f7fcbd1698af360b23e06c143621c
+AUX freebsd-pam-modules-9.0-gentoo.patch 622 SHA256 b397d5d646712c4a63606d94c45d25551344872d77d7b6b5f646403a2b09f7fb SHA512 752b593a8bea623110683a181deefd7126eaded7bf94973bcd994b2415db5739cd69a125ee9bd0c960fd5a3e30e3a2eaf8c711893f94966a9cc5a9b0c3191af0 WHIRLPOOL 168b0ba47e9a326ff1db9cfe46724c83a45d744df0fa737599894ef1574b0e199c46e7626b16f5cc83cd4886fd79320c5f92e4c2b37801ef3604ffd4ec1b2de7
+DIST freebsd-lib-8.2.tar.bz2 3323878 SHA256 e3590c12794fcb5ba8eb7a1f58b497587cf19f9200b3254c194a793da3b5bfb0 SHA512 c059cfdd1099bb519b2a5c43fb7e7104c500ef8906229ed7eb9e420cb3a217cdaf8655e9e7a9f45cfadc5491f8115e0e738fd49251d9f0c3a83780845b09f007 WHIRLPOOL 95f98a372f44a89bc8ac3029ec065dbbfec338e6f889d057d75644bfcdfb9d27fdc0421d7e392cad5a823712b97f0857297ec3d321580254c63032c22b95792e
+DIST freebsd-lib-9.1.tar.bz2 3206685 SHA256 f31fa8107b4de711c548f6d0c1bb1f81d09f51bcc3b14a1e9e90bb0e7cc4a35d SHA512 40d0c36b6b889c404fa0e0afa38ba4e84a55bc88ffa2f98a70afbd7a32c4f32c158617ba770567d082a986d62c09b3ec8db3dc5ab853ee1c9bbe0b90bb82396e WHIRLPOOL 581878bf9c43184b043b4293409b85901c9ed1f9bd279e965414aca41ba50950848ebda3ee10a503a028135dfd2765e95a11acd4e62a11c528e104392bbbd8d0
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+EBUILD freebsd-pam-modules-10.3.ebuild 1099 SHA256 774ce105193dd2d0abdb4b3618e7e9f2956730f12174bea3cc26752303c1d3cd SHA512 d5214489e78d9c73d8f9700c34707f1e1509d45b89604f02ff12dbddc522e0feb1425cb96e7aca5dbc17bfb3dc3b2e5c8dabc000d2771bb719f6f0d3e0fd5a4b WHIRLPOOL 9bf7b6e5f7a7c20b63de3b7b6bb633e1c980fc16be850e8c0543a6da779e95c1bff8d1d60a7748122acdbc66d57787e3a2080f4483ce8348367e35382a767b7a
+EBUILD freebsd-pam-modules-11.0.ebuild 1035 SHA256 e01905d67b9f6dab6b79cbbcbbaaf67ff2c2409d39c728c24913527d8083d031 SHA512 ff5551e2bf795c77b143e389ea750e8641d314b147a070fa5ffe386bb3205da7c295963a3823c53be9afc66b0b0eeb663d17f401bf0a303ff9534ad2bf166b66 WHIRLPOOL e6d88812430732b747ed499793b103d2c11688f72ffdc3a3193c0dc931b44b40df57a904218757d8e2d3c811b24ad89f928d2cb04a7612efc89b4da4898648de
+EBUILD freebsd-pam-modules-11.1.ebuild 1035 SHA256 09065a890abb2f619204fe04fca4f3d19e237ca24b87f1771c265c7b6797f265 SHA512 150ba570785b63e2fea121de424a7a8a5c0e6a74c4d498f743d4b7377d55f3eef7db10cfb5b0ded06f39913d32eb68565f17043863d16097ec9ce9f4cc5a04e2 WHIRLPOOL 36927d3345f7c592a09bed185626b3ba7926fa02138afd7d80bc70a76871e7f662d0316899aa0d5ac353b57f661826d547ad41d725196bffe482bfd82841537f
+EBUILD freebsd-pam-modules-8.2.ebuild 1123 SHA256 44374b45def40da679a7b7c9b3617f730fbc8e183cf199e2e1250dfa55328f40 SHA512 134d96116953ec37a82d8ca96673c9a83191c8cb6d5564800292f311fdd3d2f7c5b827bb7727855e6cad764850573345d88764a0b985704c2987cb58caa680f1 WHIRLPOOL b3d6b57984576295ef2616780405f54f5f88fb9f0dae382584737d940266ac2cbc9de7408ac7a15f15ef92f1f3c28326e1ad1c9ecd5c0f70e0014d5a523b1a94
+EBUILD freebsd-pam-modules-9.1-r1.ebuild 1072 SHA256 b8348015a5306b80d7eed2e602575e39c4f0a4bd13739016768bed8e8c369668 SHA512 d5a4f80a980481f368e99c319b81a548fbfa20ea72b3044755a1065b09dbf63519f412328e4eaac8752de593a9e01b07eca0f0187e98e588cf5f38c04d528273 WHIRLPOOL 2ed440852bdf1f9b3fc042e30b5954bb8ccae911588f8ffd60eb562fbfc9b1d570fbeb882c09a91296fbfe7399c27bade865911acc4650459c220ca920d50134
+MISC ChangeLog 3542 SHA256 a32b7ad541a4539a999f1e2413140853a916b13c6ea8b7b2beeb4e6168bb87d0 SHA512 d59e812cfbe1e7ac7ac6c403be2dabef497ff55f801baf52c4bdf56fb4276fdc47898d786edcedb7b1d3e9ada8a4662eefd32ca5784ad54f565f9f9f5370bca9 WHIRLPOOL f63a4154f3d524ebb326d16f47fba71162e2c0e776c85cc31b0225887fd8cd3b6f621011f0586f0aceea5e0e9d73737d78092b17e3e998cbedc06f61643c47e4
+MISC ChangeLog-2015 9856 SHA256 10c43b28a821f301baf48c0ae326028831677fcfe315962efc72e304878b08ba SHA512 6f3d46f102b01a0d1ea46f8bdf1362e92948852dd78eaf59ed908daf0589d7dd5f5238ea8621cd3cac4a91ed6b5dab6064d333bd8d51aad674214298bb922b97 WHIRLPOOL 6604c921081140080910d1837cde8dbd6155fbc3ad94ec4ac9961a65c85f8faaa199721da2e9667bbe93783ec42a42d7a682c3ef6745c0b65cbffe82f2f1dad4
+MISC metadata.xml 238 SHA256 501d93b0c41ed422505100f002758cd173cd9783ae7fbb53e2ec5f238c868340 SHA512 173efaa53a514acf1e2f0c6681c82a48ec16d505844f551d2cc823ee8685b27837c7461f7956c12182059ee7e83023e2f0bcd5d1afab74beeaf998487193656d WHIRLPOOL 4ca51d994f011a5e7e4939f02a54b5c2f9f3e526665893c9ac2876c9871b7dc80361393d41c5247b3a5520e82d31d0dd10da520e7715c94b806a94ce0fed2a5a
diff --git a/sys-freebsd/freebsd-pam-modules/files/README.pamd b/sys-freebsd/freebsd-pam-modules/files/README.pamd
new file mode 100644
index 000000000000..51d703973be9
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/files/README.pamd
@@ -0,0 +1,61 @@
+/etc/pam.d
+
+This directory contains configuration files for the Pluggable
+Authentication Modules (PAM) library.
+
+Each file details the module chain for a single service, and must be
+named after that service. If no configuration file is found for a
+particular service, the /etc/pam.d/other is used instead. If that
+file does not exist, /etc/pam.conf is searched for entries matching
+the specified service or, failing that, the "other" service.
+
+See the pam(8) manual page for an explanation of the workings of the
+PAM library and descriptions of the various files and modules. Below
+is a summary of the format for the pam.conf and /etc/pam.d/* files.
+
+Configuration lines take the following form:
+
+module-type control-flag module-path arguments
+
+Comments are introduced with a hash mark ('#'). Blank lines and lines
+consisting entirely of comments are ignored.
+
+The meanings of the different fields are as follows:
+
+ module-type:
+ auth: prompt for a password to authenticate that the user is
+ who they say they are, and set any credentials.
+ account: non-authentication based authorization, based on time,
+ resources, etc.
+ session: housekeeping before and/or after login.
+ password: update authentication tokens.
+
+ control-flag: How libpam handles success or failure of the module.
+ required: success is required; on failure all remaining
+ modules are run, but the request will be denied.
+ requisite: success is required, and on failure no remaining
+ modules are run.
+ sufficient: success is sufficient, and if no previous required
+ module failed, no remaining modules are run.
+ binding: success is sufficient; on failure all remaining
+ modules are run, but the request will be denied.
+ optional: ignored unless the other modules return PAM_IGNORE.
+
+ arguments: Module-specific options, plus some generic ones:
+ debug: syslog debug info.
+ no_warn: return no warning messages to the application.
+ Remove this to feed back to the user the
+ reason(s) they are being rejected.
+ use_first_pass: try authentication using password from the
+ preceding auth module.
+ try_first_pass: first try authentication using password from
+ the preceding auth module, and if that fails
+ prompt for a new password.
+ use_mapped_pass: convert cleartext password to a crypto key.
+ expose_account: allow printing more info about the user when
+ prompting.
+
+Note that having a "sufficient" module as the last entry for a
+particular service and module type may result in surprising behaviour.
+To get the intended semantics, add a "required" entry listing the
+pam_deny module at the end of the chain.
diff --git a/sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-6.0-gentoo.patch b/sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-6.0-gentoo.patch
new file mode 100644
index 000000000000..ce1a7fbff8c6
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-6.0-gentoo.patch
@@ -0,0 +1,24 @@
+Index: fbsd-6.0/lib/libpam/modules/Makefile.inc
+===================================================================
+--- fbsd-6.0.orig/lib/libpam/modules/Makefile.inc
++++ fbsd-6.0/lib/libpam/modules/Makefile.inc
+@@ -5,18 +5,10 @@ PAMDIR= ${.CURDIR}/../../../../contrib/
+ NO_INSTALLLIB=
+ NO_PROFILE=
+
+-CFLAGS+= -I${PAMDIR}/include -I${.CURDIR}/../../libpam
++CFLAGS+= -I${.CURDIR}/../../libpam
+ WARNS?= 4
+
+-# This is nasty.
+-# For the static case, libpam.a depends on the modules.
+-# For the dynamic case, the modules depend on libpam.so.N
+-.if defined(_NO_LIBPAM_SO_YET)
+-NO_PIC=
+-.else
+ SHLIB_NAME?= ${LIB}.so.${SHLIB_MAJOR}
+-DPADD+= ${LIBPAM}
+ LDADD+= -lpam
+-.endif
+
+ .include "../Makefile.inc"
diff --git a/sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-9.0-gentoo.patch b/sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-9.0-gentoo.patch
new file mode 100644
index 000000000000..aa08d40693cd
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/files/freebsd-pam-modules-9.0-gentoo.patch
@@ -0,0 +1,22 @@
+--- lib/libpam/modules/Makefile.inc.old 2011-11-02 20:46:56.000000000 +0000
++++ lib/libpam/modules/Makefile.inc 2011-11-02 20:47:16.000000000 +0000
+@@ -5,18 +5,10 @@
+ NO_INSTALLLIB=
+ NO_PROFILE=
+
+-CFLAGS+= -I${PAMDIR}/include -I${.CURDIR}/../../libpam
++CFLAGS+= -I${.CURDIR}/../../libpam
+
+-# This is nasty.
+-# For the static case, libpam.a depends on the modules.
+-# For the dynamic case, the modules depend on libpam.so.N
+-.if defined(_NO_LIBPAM_SO_YET)
+-NO_PIC=
+-.else
+ SHLIB_NAME?= ${LIB}.so.${SHLIB_MAJOR}
+-DPADD+= ${LIBPAM}
+ LDADD+= -lpam
+-.endif
+
+ .c.o:
+ ${CC} ${CFLAGS} -DOPENPAM_STATIC_MODULES -c ${.IMPSRC}
diff --git a/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-10.3.ebuild b/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-10.3.ebuild
new file mode 100644
index 000000000000..3289409bc5c6
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-10.3.ebuild
@@ -0,0 +1,47 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd multilib pam
+
+DESCRIPTION="FreeBSD's PAM authentication modules"
+SLOT="0"
+
+IUSE="kerberos nis"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="lib/"
+
+RDEPEND=">=sys-auth/openpam-20050201-r1
+ kerberos? ( dev-libs/openssl:0=
+ virtual/krb5 )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+
+S=${WORKDIR}/lib/libpam/modules
+
+PATCHES=( "${FILESDIR}"/${PN}-9.0-gentoo.patch )
+
+pkg_setup() {
+ # Avoid installing pam_ssh as that has its own ebuild.
+ mymakeopts="${mymakeopts} WITHOUT_OPENSSH= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+}
+
+src_prepare() {
+ for module in pam_deny pam_passwdqc pam_permit pam_krb5; do
+ sed -i -e "s:${module}::" "${S}"/modules.inc || die
+ done
+}
+
+src_install() {
+ mkinstall "LIBDIR=/$(get_libdir)/security" || die "install failed"
+
+ dodoc "${FILESDIR}/README.pamd"
+}
diff --git a/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-11.0.ebuild b/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-11.0.ebuild
new file mode 100644
index 000000000000..3d4ceae6b8db
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-11.0.ebuild
@@ -0,0 +1,45 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd multilib pam
+
+DESCRIPTION="FreeBSD's PAM authentication modules"
+SLOT="0"
+
+IUSE="kerberos nis"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="lib/"
+
+RDEPEND=">=sys-auth/openpam-20050201-r1
+ kerberos? ( dev-libs/openssl:0=
+ virtual/krb5 )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+
+S=${WORKDIR}/lib/libpam/modules
+
+pkg_setup() {
+ # Avoid installing pam_ssh as that has its own ebuild.
+ mymakeopts="${mymakeopts} WITHOUT_OPENSSH= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+}
+
+src_prepare() {
+ for module in pam_deny pam_passwdqc pam_permit pam_krb5; do
+ sed -i -e "s:${module}::" "${S}"/modules.inc || die
+ done
+}
+
+src_install() {
+ freebsd_src_install "LIBDIR=/$(get_libdir)/security"
+
+ dodoc "${FILESDIR}/README.pamd"
+}
diff --git a/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-11.1.ebuild b/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-11.1.ebuild
new file mode 100644
index 000000000000..4c29c927a781
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-11.1.ebuild
@@ -0,0 +1,45 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd multilib pam
+
+DESCRIPTION="FreeBSD's PAM authentication modules"
+SLOT="0"
+
+IUSE="kerberos nis"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="lib/"
+
+RDEPEND=">=sys-auth/openpam-20050201-r1
+ kerberos? ( dev-libs/openssl:0=
+ virtual/krb5 )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+
+S=${WORKDIR}/lib/libpam/modules
+
+pkg_setup() {
+ # Avoid installing pam_ssh as that has its own ebuild.
+ mymakeopts="${mymakeopts} WITHOUT_OPENSSH= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+}
+
+src_prepare() {
+ for module in pam_deny pam_passwdqc pam_permit pam_krb5; do
+ sed -i -e "s:${module}::" "${S}"/modules.inc || die
+ done
+}
+
+src_install() {
+ freebsd_src_install "LIBDIR=/$(get_libdir)/security"
+
+ dodoc "${FILESDIR}/README.pamd"
+}
diff --git a/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-8.2.ebuild b/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-8.2.ebuild
new file mode 100644
index 000000000000..a04f7b0eb72d
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-8.2.ebuild
@@ -0,0 +1,47 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd multilib pam
+
+DESCRIPTION="FreeBSD's PAM authentication modules"
+SLOT="0"
+KEYWORDS="~x86-fbsd ~sparc-fbsd"
+
+IUSE="kerberos nis"
+
+SRC_URI="mirror://gentoo/${LIB}.tar.bz2"
+
+RDEPEND=">=sys-auth/openpam-20050201-r1
+ kerberos? ( dev-libs/openssl
+ virtual/krb5 )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+
+S=${WORKDIR}/lib/libpam/modules
+
+pkg_setup() {
+ # Avoid installing pam_ssh as that has its own ebuild.
+ mymakeopts="${mymakeopts} NO_OPENSSH= "
+ use kerberos || mymakeopts="${mymakeopts} NO_KERBEROS= "
+ use nis || mymakeopts="${mymakeopts} NO_NIS= "
+}
+
+src_unpack() {
+ unpack ${A}
+
+ cd "${WORKDIR}"/lib
+
+ for module in pam_deny pam_passwdqc pam_permit; do
+ sed -i -e "s:${module}::" "${S}"/modules.inc
+ done
+
+ # Avoid using static versions; use gentoo /lib/security dir
+ epatch "${FILESDIR}"/${PN}-6.0-gentoo.patch
+}
+
+src_install() {
+ mkinstall "LIBDIR=/$(get_libdir)/security" || die "install failed"
+
+ dodoc "${FILESDIR}/README.pamd"
+}
diff --git a/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-9.1-r1.ebuild b/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-9.1-r1.ebuild
new file mode 100644
index 000000000000..0d4662e54e14
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/freebsd-pam-modules-9.1-r1.ebuild
@@ -0,0 +1,44 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd multilib pam
+
+DESCRIPTION="FreeBSD's PAM authentication modules"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+
+IUSE="kerberos nis"
+
+SRC_URI="mirror://gentoo/${LIB}.tar.bz2"
+
+RDEPEND=">=sys-auth/openpam-20050201-r1
+ kerberos? ( dev-libs/openssl
+ virtual/krb5 )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+
+S=${WORKDIR}/lib/libpam/modules
+
+PATCHES=( "${FILESDIR}"/${PN}-9.0-gentoo.patch )
+
+pkg_setup() {
+ # Avoid installing pam_ssh as that has its own ebuild.
+ mymakeopts="${mymakeopts} NO_OPENSSH= "
+ use kerberos || mymakeopts="${mymakeopts} NO_KERBEROS= "
+ use nis || mymakeopts="${mymakeopts} NO_NIS= "
+}
+
+src_unpack() {
+ freebsd_src_unpack
+
+ for module in pam_deny pam_passwdqc pam_permit pam_krb5; do
+ sed -i -e "s:${module}::" "${S}"/modules.inc
+ done
+}
+
+src_install() {
+ mkinstall "LIBDIR=/$(get_libdir)/security" || die "install failed"
+
+ dodoc "${FILESDIR}/README.pamd"
+}
diff --git a/sys-freebsd/freebsd-pam-modules/metadata.xml b/sys-freebsd/freebsd-pam-modules/metadata.xml
new file mode 100644
index 000000000000..a00f3aeb1f81
--- /dev/null
+++ b/sys-freebsd/freebsd-pam-modules/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-pf/Manifest b/sys-freebsd/freebsd-pf/Manifest
new file mode 100644
index 000000000000..f55d4dd02ed2
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/Manifest
@@ -0,0 +1,34 @@
+AUX freebsd-pf-10.0-libevent.patch 403 SHA256 b3de99dbc75a116ae46fec1aeaab0bfcc7448a87b963e9defbb94238bb79bee0 SHA512 1ec0d97afd9392c852071d6df704b05a0ca3146a20a3daa4ac541291a2a30c7c8752330381e1f3ae3d874640dd2f04d4b94c5b4adf985a3fbf8890da6a7f9b0b WHIRLPOOL 9cfa4b4b751737b224c43eb75a6eb27ba2e02f2c99829ce8327956d5b0aa381afce7cb86455bc97792ffbe66d8919959865f0c4a5ba44302391c8ea91c7bc065
+AUX freebsd-pf-10.0-pflogd.patch 349 SHA256 630346adc5d39d32112ebb299391b728a0e22b517376fa5f1d872593186f3800 SHA512 d4a605bb1a31837bfb0fa5d20fbac5ed449e4d579c5ab6025da2988ff101c31df7c67e23f9863f2f0b98a76788123e06402d8790d1c9baafd5b732dff0678644 WHIRLPOOL 388b3e724a6971e17867fc4749ea8769d56327a07fbba318f6e4d052ac049f78cc673911cca28dc37dbc3ca93f47eee061c07c0854101cefe6919b373746ebe1
+AUX freebsd-pf-11.0-libevent.patch 312 SHA256 9a70eb1587538294c9d046d06fc0a14d86514061b157277805c439bf3bb89ff2 SHA512 0c9eef97f7bfa5bcf4019a2449a096a6a6b66d3f0b5275181af86694cd0efd832788433d0203d3b9a54fc11c3eb728b6e67b143a622ce6f8b36f52299a9db85f WHIRLPOOL ef2ae2aec4a52b857574325133a788e1a97099b998bc44237affc0dd48aedd5322da618e0313552f4f9d54a1dd86164804d7502b8c445aca8774f73f5e09c5cc
+AUX freebsd-pf-11.0-pflogd.patch 326 SHA256 0a2bff431b2fb3f29200b6337d7e77f1e16c8dbacefd52995d60a851a3fad5e4 SHA512 25327461327f01f1858e6d2108db973090c62c1dbccb09390d834cdfaff97d5258123b1162538e2d8faf7f452a8a7eb743ef72ebfddeac3c989aa43b96f05a90 WHIRLPOOL fab1348ddaf1f13e79c218a26de9b0b7978548be137c5e39b9bb8874789d97c7e23ae322ea3d2e899bbbd9b88e69884b8bb9bcfa4cb6d8df84e47c8df456c62d
+AUX freebsd-pf-11.1-libevent.patch 305 SHA256 2efe63f644db87da0e70b86208ece03f47fdc94234a095c8bf1b0dbfe0d18728 SHA512 a75ff98e8d87ec5182bb1a7226b34d6223500c0a5659727392d97d69d1a66af6d439d4c23a6817740c25306654468e82e52ddfa591d4509001e407e099c83b44 WHIRLPOOL 572b2945c1247a34c0849bfbd249306d870e4205cf8576c6408c50dee91cb1a4b340f59eb429f8d6fc41cd781bde64fda8cf1fc52a9e473fec406ef887cf2275
+AUX freebsd-pf-11.1-pflogd.patch 363 SHA256 9354c8c389a2c76844f2e85d40ab5861be549a35fa93f1353bf35e4b3f2bbf85 SHA512 bceaf0f234948acf30aab4391d73c7545bd860dc5b2bba8eb8da1a9791de905654450592674c75419a8dc0646215ba5bcdd885d61cac336d34c017a7c57039fd WHIRLPOOL 0023c87ad5fb566a1c06c0512a1e95e7260115735f947ad68969c673a409eedf33b0122a506861d18e9037781fa2546b40dedf44cc86a08177585607632117ae
+AUX freebsd-pf-7.0-libevent.patch 331 SHA256 ea5db9308712447cee285d2ac479d95399f1c0948afbbaf6598ad362e262c716 SHA512 fe2db637c8b1f6f8853fd4f6a88dbc0de8d58cc8f3875f0a94dbda74ef4bab4f1402409ff4732f8deae5d9da6bf5eb32d2a8e985f210b84926f94942dffe9c61 WHIRLPOOL 2f84a4ae54fa3dd53610db31af88c064b6df82460516f2024176d4acd5dd6c702c5adee98473a6a05ed701b07b0404c90dae490acd11483a48206ce542b21a96
+AUX freebsd-pf-7.0-pcap_pollution.patch 437 SHA256 65eb1dd0c9084981faa80dfc74140deb431223ae14cf47b1ee0b83fc0fa2bfef SHA512 e08df63ac57747cbd42e32b6e61e08e92b0f7af333508e32717194e9c0d0a1b0f23bf4ed9f0b745f804c164b2c950bf92d2abc22ece58113b7ccaee5e86ea3d9 WHIRLPOOL 735d498ba1765df65acb2db018c0f058da06dd5bef27eca3137ed1409e959bd637c6040f32fe40d022d6fba98272c496765e84319e1f1f5857618ac66744c872
+AUX freebsd-pf-9.0-bpf.patch 309 SHA256 9adf0af94c2cf2f61c1e9f2ab071c8628b3845778f7f61abfe52feb347a615a7 SHA512 e3364e372b5c2d2c4a1960ee1f6d5fa411810ba3597356ec17b275afd8bb6813cce62d781fc683663037b008d81804d28a2617f308c942a741657cf8dcf0e039 WHIRLPOOL 141a2ad5dbc1e199dc669aef995fcd9b4c71a6a0da55c11645adbef073755a8d661ae4e653d377c42ab000913599ba7f90aa611059496996a2f57282eaf07f8a
+AUX freebsd-pf-9.0-getline.patch 1159 SHA256 c56fa01870e2ea7ea187b14ef0d13801782c3f479f3e7fe31ac8fba2917969aa SHA512 2b7ab780e8a66a63e17302f9de19a9a72c7246b349f16745fbe7a2a69d8c83c9d8c5c7e18311bf0273620ce18cd9add6dcf051364013f941d477dbbf165b3ddb WHIRLPOOL 4ab2c2598b79a4066d013bc056f6e3977501cdce959568b7f14360b8b34f3622654a784291c9ba979390fb71f6b76672c26c0242ee9c1df09aadbe96e3e4156e
+AUX freebsd-pf-9.0-libevent.patch 384 SHA256 e1331cdc64d5d135f3cf33bea70031cba7813abc39778f860f06a161c395f799 SHA512 763c352e5a1e789e5d634066cfa7de84199db14a1f0d61b699f84f04ef1a2acb82dd63d59cffa339ff673bf92a3a9aab25f4b60fb5928e040e47b8c43b6a93f8 WHIRLPOOL ac352886754590178c550aa755a2380e493cccb66815f2875e03427d5d644394de5f711b6d01625a49fafabb4df1e63bff89ea19f47f99b1f6252ff7ca248ab2
+AUX freebsd-pf-9.0-pcap_pollution.patch 450 SHA256 d6ec6b1952e22f621b33d85956837bae26fd06a79cd3daf5e073b889d4650276 SHA512 262d23f74449f75d628dcda09a7c7e0d501b61899c0a2a1ca71179989803f5c5f70fd4f8908f06ce998aca994d54b43efe03578892ff121c0a27e7fa36e4f1dd WHIRLPOOL 9dd4be7cf9741a8cbb0395346a79656233532b10762551d04c85a36637bd95e5d1aed0024ba1ee4259d41d1b5d26777524353787d3c13ad12e4dfb21f12955cf
+AUX freebsd-pf-9.0-pflogd.patch 332 SHA256 fc832fdfa406603a2cb185b8f0f746b13f7673742578913ba635849e1fd778f6 SHA512 7bc7ea7695504a236b7f0aef2598ce577314843e0937258a68b21a7a246db733b9952e6822c938aac9f31409ddaef6753abe7f5143a514d4875abab4aec3f073 WHIRLPOOL b90b5e454e96cc6f243e99358b78d45b6a13a46810a3683d837f03721052e7b4fc3f8733ac2c96cabed204435a9be93a0652da5311f6552ece294031b0b663df
+AUX pf.confd 274 SHA256 dba0e34d34ef583b3a06499eae5f5dd9a73cacdb238915060735e24bd6c2c8eb SHA512 bf476bf7dc796307f2bf916e73780a6c70a2defd75f4dcbce664a99fdbb5aa69ce7004483073036a0c52fadcf9e7e7c8bcc902e9eacb7ac1963714740bdfc5e5 WHIRLPOOL fa87094a2339af4fc117840741e6460331c8de1d7ff656394701d58d0f362243788b1d6e650ee2cea34e9e4ad9c19f97996de8d01927808875384af2925a8adc
+AUX pf.initd 803 SHA256 0f3e53dbd63ad6ff2128b658aac05d2ca350107e9729ee52bf6861efdfa5e243 SHA512 b447683fb3abd11a6c5158b452ac9a72858c0a57bb424a1ec3a4cc8dce09336228d6e43ce0c58a63d63ee3917211227a6c5f1d4ac4bde42ce7fc5aa6d188f28d WHIRLPOOL 4a88e57a138ad9e3f485e2397bb99444e46064ac937b4a46444907245819fbf510d449ba2bfac5bb0f5ff49a71e63003bba239467ca83951948e4b3c05d4d17c
+DIST freebsd-contrib-8.2.tar.bz2 40931651 SHA256 8b9cb688e81c2980b3fc66411d00ab277a24dadd50d5bdd5e0e6c63ac687b9b6 SHA512 4f7bf825b579fbb88f2aac531d07e531474179c63fa0b66c4e80821290a8c94bf611bb4dcaef51b762aacd25b11dfae798a4ec3bad3b9e3f6b3490ebfaa72476 WHIRLPOOL edd3d9e26e8d22d9028082e107ec1a44402e206dab8722f34b445676959305996c3f699152af42ace249b7f58498492787823b172fb6bcb273119c6bb50a35f0
+DIST freebsd-contrib-9.1.tar.bz2 54751432 SHA256 e7ffa056d4050ce03ee8e23e276e2a9a494326a98d60c43bee2afcc59576deb8 SHA512 71be13049258c6e6b5e4f63cc16da5d349a89d68f04d87446e4ad33ae8bf2a93ea67d9c256b7bec60b61e65db0487268070cfb77a484c3ac0f8ba368b48c2438 WHIRLPOOL a2a84423175499208d34809e802284d6ba649f317c3a9ad8b7312fa19efe142ebadab0048bac0db8e988e59f9a7468ac7c5d0d25e78b82bdb269a20d18153cee
+DIST freebsd-etc-8.2.tar.bz2 188629 SHA256 6bc745fa259f9fa2b65df865d45443a7b23c24445195e33a4ac50bf1040ae238 SHA512 3e5c106754a6a1ac806bd46b711fba7ee9cb31a4eab5262c995a5d59dbeb02f756dd8b495640dda94189d204a5d2c5218de2bd23467172d6a4ebe1048986e89c WHIRLPOOL 23b658a214f1a64c43420351020e32b1182e9aac3ed5253f49ee86f9cee9166ce32bd556cd2a2b3c0e60a165462a8700f37dea19e57ad5716415e17f61da912e
+DIST freebsd-etc-9.1.tar.bz2 207776 SHA256 a317bf85532d6192f5506e8d7bd5d5c201fe24017700e3a974a7712c2c69cdb8 SHA512 4fbe56fde519cf2f44e39a8869efa26c34f703cf540f4a83389da8d170873d7c6fb18e4010e643b8d793cfc5c55d15eeb198057a5b2a8da9d9e8f791801bf314 WHIRLPOOL 0c27019fe140fe96f870697acbaa89ac2f281f55b892c5791b08abf1cfa4da94d9d42a1df1c2091317573ed7234253857aecb797065f911a0a5d57bbf64349a5
+DIST freebsd-sbin-8.2.tar.bz2 1211665 SHA256 8b7e21a66b4696e8763d29b8b02b2d35f29fc51820a194d1e469e7cace84c527 SHA512 c6643c29ab62344c98d8991708798730ee1c17e6478071718beeaa79788300a1f4ed2e6aeb8e39e3c216877d4ed2ac85b2a9531d534f1ac5125a508927898959 WHIRLPOOL 2a21cd0f15f95d66718031680ac87f1fe73f1e1b03cb012e1db1dd1bd2fe2bb7897457a8ba2f5a28c8806775611dca542cbadec16566c47ab9efa673e2cb53f3
+DIST freebsd-sbin-9.1.tar.bz2 1273913 SHA256 45008b0733b232ef03707ef5fa3e5c889e3b3728393d736bd9a869ea83be6447 SHA512 9f186602b7de96f268c352ca386986652fddf5570e7eca1afa8c0d2bdc83b57df1198efe47f36dd5c7a6abf4f9c935f1c8207a4a12a6b2153bd6c3c6292719dc WHIRLPOOL 20920dfa9607a0ce854319cef29bbd77fb1b31f6f6cfd5ac60cbd678169e43929e215743fe636d0c224443f3e6149a8f07c292d647f7f901592795ac292699f9
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+DIST freebsd-usbin-8.2.tar.bz2 2443024 SHA256 aa7cabf10f5c3a9daabea32e4de24d04ec312247842981476da666eff5054603 SHA512 bcb8ff3df54848b9107bbb52e5ced7a91e24bb181f06769b6997221729b8064ec17652eaf7500de3268cbcb63ff5760beb54d15fc78c27b02687b5b1067c74a6 WHIRLPOOL 20f5278e2a1dd387a75b44f10507958d6c0e84a2faa1bddbf808c14ab86d8dd14a956192911bbc1880f5f5f7bd05972dcbb4aec85d241f0dcf91bf4246883f0a
+DIST freebsd-usbin-9.1.tar.bz2 2670916 SHA256 b938c20b8c09aa9a610e13b69b9afeea72f561ab3636a59fba2bdac290f4db75 SHA512 21c234312f70eb35cd2926519efc1f61592892f5d0940786dbeb959c3c5ec7819a51ae95c6e8a1a06aa01f669350fe0fd3dd7c4ec8a84dd6b90f24cb192356ca WHIRLPOOL 7f6ad2eb5410cc5e685881654a788807848af026b1277a974682755ab7c9db28f576bfd1576441ea10c5f1e9edb7d30a4a23fb8eccd6d69d86ecc9ce4c9adc7e
+EBUILD freebsd-pf-10.3.ebuild 1586 SHA256 15481c8f4630e7b25a3ff919c8ac61da36f1d99d378a04155fdc8fdca1ca023f SHA512 232f37e4733f79b963ababf3152c17ec41358c0f0ef45e6e76136cb903d1d46826f4747f0563661ef3f26a07ff4517086da74723bef4a33c26bda1441a357434 WHIRLPOOL 590c19b64dde7ed5bd9be5e00de0675e73fbb4a5c289c99634b30d705bf1abb7f0f7fb874aa4d64c5576ca2111fbe3ce288a11852ff5f10deb200812b53588c3
+EBUILD freebsd-pf-11.0.ebuild 1491 SHA256 c8a2c1cac762fa8742fe4211a1d69b1e2825fc0a443f9faf114b75d2f0122c71 SHA512 ae66d1c3a7cfe5dd6f43fd4933e4d8a36bd7d320cee6b2094312e00ca90c6de1f155725e942b23b5accac89f571ba356a7c0ee13a71b2f7d2458ec93d2d6ac44 WHIRLPOOL fde1c675ad901a668b2f10fc8fde23d8e7cbc90ed3d96247f64bfac28cac2117ea67474c3d9ccb1eef1ea87b6175273313aeff2a4373c3ef1d2c3e8fcb36b8b3
+EBUILD freebsd-pf-11.1.ebuild 1491 SHA256 f4053919e3eeb06cece8c4329baf2f3c6fbe052157228e9eac6f12bcc140c579 SHA512 2ace1ad0f89365b9b707a2b9b29f04dff926ad3a3340abd156862aa0c50396ce078d4f997d1298b498df1c52745b5216f2c112424254ae12abbb554783c276a8 WHIRLPOOL 1c9f8e61e77c13e744080b8270e9dc7f60707dd566b7e1e09a022809df2bce33d7ce87277a63042f7b07bd06169be90c18afda4c9addf6960a6d7a4db6c9085a
+EBUILD freebsd-pf-8.2.ebuild 1493 SHA256 63c95090d32b32064e44067c16395033f3f2db0b04c1efe50b27f656f2f25110 SHA512 cc1d221ffa6a763641c64802ae6d8a1f1a5598c48ce07e3bc7f1b1a70454c1ba7730a30c6881de7dc493bccf49dcfb7a64998162dda4d47165b088dc0a63bdff WHIRLPOOL 9208196e225c337fa694d4f72276b3ac484a5d9a9d5bf7358c831782884760d149a274b1de4ff8f8d488c7df46706d26a02d62f948acc70ef975d911b83fae5a
+EBUILD freebsd-pf-9.1.ebuild 1614 SHA256 77a31882109f107819e7a4e3fb982f220aec8f28fc10eaabfd3bf0e74b547f79 SHA512 db5c7a663f784b6fb73515312a91e7971da959b1b67fd40fd479b6f2b272f5fbf2eebee1a29c4dfd63bbdfddaedb51ffca9b2297004ffc03851e1127fa3e890c WHIRLPOOL df3191fc469f0ed46550521653129aa85fc367a7878d16f20bf86cd51cb4ba77c0ac967aa0990e9384543a541b31523673e9af88f9ec20e5ea31abd27b162e21
+MISC ChangeLog 3991 SHA256 8a8716416393537448eb46e7355f51477694088beab8e29f7db7f9ba5ed09da6 SHA512 d89fe8401ca5023586e7111caeda5bd399006957e0d2bbbf2f60866718c16ee767316b1d33bee230f13e4f0e32f38cb781351a33ef1c00343cc78f91f51ea688 WHIRLPOOL 818bbf735d8ce090979e24dc2781c355acebae06c05471f2e66c3925718e4b5521eb0c6b93d67cb11becb1430ba46271eb7043bf58464e308d127a41ee011daa
+MISC ChangeLog-2015 8929 SHA256 d84dd1f0a6af6a41a292a86d458da32bdd79eca0a5cb94cbd30d690e4ecb3b9a SHA512 e5fd90753940531d48f8ae677dcd77ba43735666b20e0547083bc437476bea6b14c167f59978dbd23061f9a3e4eeaa4ddcef5735d6a88ad174c87be2dcdd0289 WHIRLPOOL 21832e5c6864a47582a1a3d7aed04de771ac7268aa4c295d3b1fd4876ff8ba8b715f5b5230ebdc4a196cbf1639901f6307c062a597c1d720e248bf38ef1955b5
+MISC metadata.xml 238 SHA256 501d93b0c41ed422505100f002758cd173cd9783ae7fbb53e2ec5f238c868340 SHA512 173efaa53a514acf1e2f0c6681c82a48ec16d505844f551d2cc823ee8685b27837c7461f7956c12182059ee7e83023e2f0bcd5d1afab74beeaf998487193656d WHIRLPOOL 4ca51d994f011a5e7e4939f02a54b5c2f9f3e526665893c9ac2876c9871b7dc80361393d41c5247b3a5520e82d31d0dd10da520e7715c94b806a94ce0fed2a5a
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-libevent.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-libevent.patch
new file mode 100644
index 000000000000..57474ea31dfb
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-libevent.patch
@@ -0,0 +1,16 @@
+diff --git a/usr.sbin/ftp-proxy/ftp-proxy/Makefile b/usr.sbin/ftp-proxy/ftp-proxy/Makefile
+index de49888..2ab32fb 100644
+--- a/usr.sbin/ftp-proxy/ftp-proxy/Makefile
++++ b/usr.sbin/ftp-proxy/ftp-proxy/Makefile
+@@ -7,10 +7,7 @@ MAN= ftp-proxy.8
+
+ SRCS= ftp-proxy.c filter.c
+
+-CFLAGS+= -I${.CURDIR}/../../../contrib/pf/libevent
+-
+-LDADD+= ${LIBEVENT}
+-DPADD+= ${LIBEVENT}
++LDADD+= -levent
+
+ WARNS?= 3
+
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-pflogd.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-pflogd.patch
new file mode 100644
index 000000000000..1316d3be832a
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-10.0-pflogd.patch
@@ -0,0 +1,15 @@
+diff --git a/sbin/pflogd/Makefile b/sbin/pflogd/Makefile
+index fcff8eb..0da383d 100644
+--- a/sbin/pflogd/Makefile
++++ b/sbin/pflogd/Makefile
+@@ -6,10 +6,7 @@ PROG= pflogd
+ SRCS= pflogd.c pidfile.c privsep.c privsep_fdpass.c
+ MAN= pflogd.8
+
+-CFLAGS+=-include ${.CURDIR}/../../lib/libpcap/config.h
+-
+ LDADD= -lpcap
+-DPADD= ${LIBPCAP}
+
+ WARNS?= 2
+
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-11.0-libevent.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-11.0-libevent.patch
new file mode 100644
index 000000000000..0f3ecb1fc615
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-11.0-libevent.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.sbin/ftp-proxy/Makefile b/usr.sbin/ftp-proxy/Makefile
+index 941505f..df5ccb2 100644
+--- a/usr.sbin/ftp-proxy/Makefile
++++ b/usr.sbin/ftp-proxy/Makefile
+@@ -7,8 +7,6 @@ MAN= ftp-proxy.8
+
+ SRCS= ftp-proxy.c filter.c
+
+-CFLAGS+=-I${.CURDIR}/../../contrib/pf/libevent
+-
+ LIBADD= event
+
+ WARNS?= 3
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-11.0-pflogd.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-11.0-pflogd.patch
new file mode 100644
index 000000000000..6435280b7e96
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-11.0-pflogd.patch
@@ -0,0 +1,13 @@
+diff --git a/sbin/pflogd/Makefile b/sbin/pflogd/Makefile
+index b3822dd..5912ad2 100644
+--- a/sbin/pflogd/Makefile
++++ b/sbin/pflogd/Makefile
+@@ -7,8 +7,6 @@ PROG= pflogd
+ SRCS= pflogd.c pidfile.c privsep.c privsep_fdpass.c
+ MAN= pflogd.8
+
+-CFLAGS+=-include ${.CURDIR}/../../lib/libpcap/config.h
+-
+ LIBADD= pcap
+
+ WARNS?= 2
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-11.1-libevent.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-11.1-libevent.patch
new file mode 100644
index 000000000000..057088f3298c
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-11.1-libevent.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.sbin/ftp-proxy/Makefile b/usr.sbin/ftp-proxy/Makefile
+index 3708edc..efdfcc6 100644
+--- a/usr.sbin/ftp-proxy/Makefile
++++ b/usr.sbin/ftp-proxy/Makefile
+@@ -7,8 +7,6 @@ MAN= ftp-proxy.8
+
+ SRCS= ftp-proxy.c filter.c
+
+-CFLAGS+=-I${SRCTOP}/contrib/pf/libevent
+-
+ LIBADD= event
+
+ WARNS?= 3
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-11.1-pflogd.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-11.1-pflogd.patch
new file mode 100644
index 000000000000..a10e21dd19c0
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-11.1-pflogd.patch
@@ -0,0 +1,14 @@
+diff --git a/sbin/pflogd/Makefile b/sbin/pflogd/Makefile
+index f9d47da..bb00d39 100644
+--- a/sbin/pflogd/Makefile
++++ b/sbin/pflogd/Makefile
+@@ -7,9 +7,6 @@ PROG= pflogd
+ SRCS= pflogd.c pidfile.c privsep.c privsep_fdpass.c
+ MAN= pflogd.8
+
+-CFLAGS+=-include ${SRCTOP}/lib/libpcap/config.h
+-CFLAGS+=-I${.CURDIR}/../../contrib/libpcap
+-
+ LIBADD= pcap
+
+ WARNS?= 2
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-libevent.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-libevent.patch
new file mode 100644
index 000000000000..1425db24d975
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-libevent.patch
@@ -0,0 +1,12 @@
+--- usr.sbin/ftp-proxy/ftp-proxy/Makefile.orig 2008-06-14 00:01:52 -0300
++++ usr.sbin/ftp-proxy/ftp-proxy/Makefile 2008-06-14 00:03:19 -0300
+@@ -10,8 +10,7 @@
+ CFLAGS+= -I${.CURDIR}/../../../contrib/pf/libevent
+ CFLAGS+= -I${.CURDIR}/../../../sys/contrib/pf
+
+-DPADD= ${LIBEVENT}
+-LDADD= ${LIBEVENT}
++LDADD= -levent
+
+ WARNS?= 2
+
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-pcap_pollution.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-pcap_pollution.patch
new file mode 100644
index 000000000000..4a7c2e9a0e46
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-7.0-pcap_pollution.patch
@@ -0,0 +1,18 @@
+--- contrib/pf/pflogd/privsep.c.orig 2007-07-03 09:30:02 -0300
++++ contrib/pf/pflogd/privsep.c 2008-06-13 23:55:39 -0300
+@@ -31,13 +31,14 @@
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <limits.h>
++#include <stdio.h>
++#define HAVE_SNPRINTF
+ #ifndef __FreeBSD__
+ #include <pcap.h>
+ #include <pcap-int.h>
+ #endif
+ #include <pwd.h>
+ #include <signal.h>
+-#include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #ifdef __FreeBSD__
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-bpf.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-bpf.patch
new file mode 100644
index 000000000000..fb3c7012eccf
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-bpf.patch
@@ -0,0 +1,10 @@
+--- contrib/pf/pflogd/pflogd.c.old 2011-11-02 21:12:57.000000000 +0000
++++ contrib/pf/pflogd/pflogd.c 2011-11-02 21:13:11.000000000 +0000
+@@ -39,6 +39,7 @@
+ #include <sys/stat.h>
+ #include <sys/socket.h>
+ #include <net/if.h>
++#include <net/bpf.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-getline.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-getline.patch
new file mode 100644
index 000000000000..6679d32e8060
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-getline.patch
@@ -0,0 +1,38 @@
+--- contrib/pf/ftp-proxy/ftp-proxy.c.old 2011-11-02 21:18:19.000000000 +0000
++++ contrib/pf/ftp-proxy/ftp-proxy.c 2011-11-02 21:18:36.000000000 +0000
+@@ -103,7 +103,7 @@
+ int drop_privs(void);
+ void end_session(struct session *);
+ void exit_daemon(void);
+-int getline(char *, size_t *);
++int ftpgetline(char *, size_t *);
+ void handle_connection(const int, short, void *);
+ void handle_signal(int, short, void *);
+ struct session * init_session(void);
+@@ -249,7 +249,7 @@
+ buf_avail);
+ s->cbuf_valid += clientread;
+
+- while ((n = getline(s->cbuf, &s->cbuf_valid)) > 0) {
++ while ((n = ftpgetline(s->cbuf, &s->cbuf_valid)) > 0) {
+ logmsg(LOG_DEBUG, "#%d client: %s", s->id, linebuf);
+ if (!client_parse(s)) {
+ end_session(s);
+@@ -343,7 +343,7 @@
+ }
+
+ int
+-getline(char *buf, size_t *valid)
++ftpgetline(char *buf, size_t *valid)
+ {
+ size_t i;
+
+@@ -1087,7 +1087,7 @@
+ buf_avail);
+ s->sbuf_valid += srvread;
+
+- while ((n = getline(s->sbuf, &s->sbuf_valid)) > 0) {
++ while ((n = ftpgetline(s->sbuf, &s->sbuf_valid)) > 0) {
+ logmsg(LOG_DEBUG, "#%d server: %s", s->id, linebuf);
+ if (!server_parse(s)) {
+ end_session(s);
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-libevent.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-libevent.patch
new file mode 100644
index 000000000000..e488423fc09a
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-libevent.patch
@@ -0,0 +1,15 @@
+--- usr.sbin/ftp-proxy/ftp-proxy/Makefile.old 2011-11-02 20:57:03.000000000 +0000
++++ usr.sbin/ftp-proxy/ftp-proxy/Makefile 2011-11-02 20:57:21.000000000 +0000
+@@ -7,11 +7,9 @@
+
+ SRCS= ftp-proxy.c filter.c
+
+-CFLAGS+= -I${.CURDIR}/../../../contrib/pf/libevent
+ CFLAGS+= -I${.CURDIR}/../../../sys/contrib/pf
+
+-LDADD+= ${LIBEVENT}
+-DPADD+= ${LIBEVENT}
++LDADD+= -levent
+
+ WARNS?= 3
+
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pcap_pollution.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pcap_pollution.patch
new file mode 100644
index 000000000000..184ab6f31bc4
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pcap_pollution.patch
@@ -0,0 +1,17 @@
+--- contrib/pf/pflogd/privsep.c.old 2011-11-02 21:04:01.000000000 +0000
++++ contrib/pf/pflogd/privsep.c 2011-11-02 21:04:27.000000000 +0000
+@@ -32,11 +32,13 @@
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <limits.h>
++#include <stdio.h>
++#define HAVE_SNPRINTF
++#define HAVE_STRLCPY
+ #include <pcap.h>
+ #include <pcap-int.h>
+ #include <pwd.h>
+ #include <signal.h>
+-#include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <syslog.h>
diff --git a/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pflogd.patch b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pflogd.patch
new file mode 100644
index 000000000000..d5a65eab928c
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/freebsd-pf-9.0-pflogd.patch
@@ -0,0 +1,13 @@
+--- sbin/pflogd/Makefile.old 2011-11-02 21:08:46.000000000 +0000
++++ sbin/pflogd/Makefile 2011-11-02 21:08:53.000000000 +0000
+@@ -6,10 +6,7 @@
+ SRCS= pflogd.c pidfile.c privsep.c privsep_fdpass.c
+ MAN= pflogd.8
+
+-CFLAGS+=-include ${.CURDIR}/../../lib/libpcap/config.h
+-
+ LDADD= -lpcap
+-DPADD= ${LIBPCAP} ${LIBUTIL}
+
+ WARNS?= 2
+
diff --git a/sys-freebsd/freebsd-pf/files/pf.confd b/sys-freebsd/freebsd-pf/files/pf.confd
new file mode 100644
index 000000000000..87c21b281e2b
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/pf.confd
@@ -0,0 +1,9 @@
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# Defines where the rules file is found, by default /etc/pf.conf
+# pf_conf=/etc/pf.conf
+
+# Extra options to pass to pfctl when loading the rules
+# See pfctl(8)
+# pf_args=
diff --git a/sys-freebsd/freebsd-pf/files/pf.initd b/sys-freebsd/freebsd-pf/files/pf.initd
new file mode 100644
index 000000000000..c1b3e9eb5747
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/files/pf.initd
@@ -0,0 +1,49 @@
+#!/sbin/openrc-run
+# Copyright 2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net
+}
+
+checkconfig() {
+ if ! [ -c /dev/pf ]; then
+ ewarn "Pseudo-device /dev/pf not found."
+
+ ebegin "Loading pf module"
+ if ! kldload pf; then
+ eerror "Unable to load pf module."
+ eend 1
+ return 1
+ fi
+ eend $?
+
+ if ! [ -c /dev/pf ]; then
+ eerror "Pseudo-device /dev/pf still not found."
+ return 1
+ fi
+ fi
+
+ return 0
+}
+
+start() {
+ checkconfig || return 1
+
+ einfo "Starting firewall"
+
+ if [ -r "${PF_RULES_FILE}" ]; then
+ einfo "Loading firewall rules"
+ /sbin/pfctl -qe -f ${PF_RULES_FILE:-/etc/pf.conf} ${PF_OPTS}
+ else
+ /sbin/pfctl -qe ${PF_OPTS}
+ fi
+
+ eend $?
+}
+
+stop() {
+ einfo "Stopping firewall"
+ /sbin/pfctl -qd || retval=1
+ eend $?
+}
diff --git a/sys-freebsd/freebsd-pf/freebsd-pf-10.3.ebuild b/sys-freebsd/freebsd-pf/freebsd-pf-10.3.ebuild
new file mode 100644
index 000000000000..e0a26d65e2f1
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/freebsd-pf-10.3.ebuild
@@ -0,0 +1,72 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd user
+
+DESCRIPTION="FreeBSD's base system libraries"
+SLOT="0"
+
+IUSE=""
+
+# Crypto is needed to have an internal OpenSSL header
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ usr.sbin/
+ sbin/
+ contrib/pf/
+ etc/
+"
+
+RDEPEND="net-libs/libpcap"
+DEPEND="${RDEPEND}
+ dev-libs/libevent
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+
+S="${WORKDIR}"
+
+SUBDIRS="usr.sbin/authpf sbin/pfctl sbin/pflogd usr.sbin/ftp-proxy/ftp-proxy"
+
+pkg_setup() {
+ enewgroup authpf 63
+ mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= "
+}
+
+src_prepare() {
+ # pcap-int.h redefines snprintf as pcap_snprintf
+ epatch "${FILESDIR}/${PN}-9.0-pcap_pollution.patch"
+ # Use system's libevent
+ epatch "${FILESDIR}/${PN}-10.0-libevent.patch"
+ epatch "${FILESDIR}/${PN}-10.0-pflogd.patch"
+ epatch "${FILESDIR}/${PN}-9.0-bpf.patch"
+ epatch "${FILESDIR}/${PN}-9.0-getline.patch"
+ # Link in kernel sources
+ [[ ! -e "${WORKDIR}/sys" ]] && ln -s "/usr/src/sys" "${WORKDIR}/sys"
+}
+
+src_compile() {
+ for dir in ${SUBDIRS}; do
+ einfo "Starting make in ${dir}"
+ cd "${S}/${dir}" || die
+ mkmake || die "Make ${dir} failed"
+ done
+}
+
+src_install() {
+ for dir in ${SUBDIRS}; do
+ einfo "Starting install in ${dir}"
+ cd "${S}/${dir}" || die
+ mkinstall || die "Install ${dir} failed"
+ done
+
+ cd "${WORKDIR}"/etc
+ insinto /etc
+ doins pf.os
+ # pf.initd provided by openrc, but no pf.confd
+ newconfd "${FILESDIR}/pf.confd" pf
+}
diff --git a/sys-freebsd/freebsd-pf/freebsd-pf-11.0.ebuild b/sys-freebsd/freebsd-pf/freebsd-pf-11.0.ebuild
new file mode 100644
index 000000000000..49e2f293e51f
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/freebsd-pf-11.0.ebuild
@@ -0,0 +1,70 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd user
+
+DESCRIPTION="FreeBSD's base system libraries"
+SLOT="0"
+
+IUSE=""
+
+# Crypto is needed to have an internal OpenSSL header
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ usr.sbin/
+ sbin/
+ contrib/pf/
+ etc/
+"
+
+RDEPEND="net-libs/libpcap"
+DEPEND="${RDEPEND}
+ dev-libs/libevent
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+
+S="${WORKDIR}"
+
+SUBDIRS="usr.sbin/authpf sbin/pfctl sbin/pflogd usr.sbin/ftp-proxy"
+
+pkg_setup() {
+ enewgroup authpf 63
+}
+
+src_prepare() {
+ # pcap-int.h redefines snprintf as pcap_snprintf
+ epatch "${FILESDIR}/${PN}-9.0-pcap_pollution.patch"
+ # Use system's libevent
+ epatch "${FILESDIR}/${PN}-11.0-libevent.patch"
+ epatch "${FILESDIR}/${PN}-11.0-pflogd.patch"
+ epatch "${FILESDIR}/${PN}-9.0-bpf.patch"
+ # Link in kernel sources
+ [[ ! -e "${WORKDIR}/sys" ]] && ln -s "/usr/src/sys" "${WORKDIR}/sys"
+}
+
+src_compile() {
+ for dir in ${SUBDIRS}; do
+ einfo "Starting make in ${dir}"
+ cd "${S}/${dir}" || die
+ freebsd_src_compile || die "Make ${dir} failed"
+ done
+}
+
+src_install() {
+ for dir in ${SUBDIRS}; do
+ einfo "Starting install in ${dir}"
+ cd "${S}/${dir}" || die
+ freebsd_src_install || die "Install ${dir} failed"
+ done
+
+ cd "${WORKDIR}"/etc
+ insinto /etc
+ doins pf.os
+ # pf.initd provided by openrc, but no pf.confd
+ newconfd "${FILESDIR}/pf.confd" pf
+}
diff --git a/sys-freebsd/freebsd-pf/freebsd-pf-11.1.ebuild b/sys-freebsd/freebsd-pf/freebsd-pf-11.1.ebuild
new file mode 100644
index 000000000000..a210e789bf43
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/freebsd-pf-11.1.ebuild
@@ -0,0 +1,70 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd user
+
+DESCRIPTION="FreeBSD's base system libraries"
+SLOT="0"
+
+IUSE=""
+
+# Crypto is needed to have an internal OpenSSL header
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ usr.sbin/
+ sbin/
+ contrib/pf/
+ etc/
+"
+
+RDEPEND="net-libs/libpcap"
+DEPEND="${RDEPEND}
+ dev-libs/libevent
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+
+S="${WORKDIR}"
+
+SUBDIRS="usr.sbin/authpf sbin/pfctl sbin/pflogd usr.sbin/ftp-proxy"
+
+pkg_setup() {
+ enewgroup authpf 63
+}
+
+src_prepare() {
+ # pcap-int.h redefines snprintf as pcap_snprintf
+ epatch "${FILESDIR}/${PN}-9.0-pcap_pollution.patch"
+ # Use system's libevent
+ epatch "${FILESDIR}/${PN}-11.1-libevent.patch"
+ epatch "${FILESDIR}/${PN}-11.1-pflogd.patch"
+ epatch "${FILESDIR}/${PN}-9.0-bpf.patch"
+ # Link in kernel sources
+ [[ ! -e "${WORKDIR}/sys" ]] && ln -s "/usr/src/sys" "${WORKDIR}/sys"
+}
+
+src_compile() {
+ for dir in ${SUBDIRS}; do
+ einfo "Starting make in ${dir}"
+ cd "${S}/${dir}" || die
+ freebsd_src_compile || die "Make ${dir} failed"
+ done
+}
+
+src_install() {
+ for dir in ${SUBDIRS}; do
+ einfo "Starting install in ${dir}"
+ cd "${S}/${dir}" || die
+ freebsd_src_install || die "Install ${dir} failed"
+ done
+
+ cd "${WORKDIR}"/etc
+ insinto /etc
+ doins pf.os
+ # pf.initd provided by openrc, but no pf.confd
+ newconfd "${FILESDIR}/pf.confd" pf
+}
diff --git a/sys-freebsd/freebsd-pf/freebsd-pf-8.2.ebuild b/sys-freebsd/freebsd-pf/freebsd-pf-8.2.ebuild
new file mode 100644
index 000000000000..b21039807877
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/freebsd-pf-8.2.ebuild
@@ -0,0 +1,64 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd user
+
+DESCRIPTION="FreeBSD's base system libraries"
+SLOT="0"
+KEYWORDS="~x86-fbsd"
+
+IUSE=""
+
+# Crypto is needed to have an internal OpenSSL header
+SRC_URI="mirror://gentoo/${USBIN}.tar.bz2
+ mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2"
+
+RDEPEND="net-libs/libpcap"
+DEPEND="${RDEPEND}
+ dev-libs/libevent
+ sys-freebsd/freebsd-mk-defs
+ =sys-freebsd/freebsd-sources-${RV}*"
+
+S="${WORKDIR}"
+
+SUBDIRS="usr.sbin/authpf sbin/pfctl sbin/pflogd usr.sbin/ftp-proxy/ftp-proxy"
+
+pkg_setup() {
+ enewgroup authpf 63
+ mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= "
+}
+
+src_unpack() {
+ freebsd_src_unpack
+ # pcap-int.h redefines snprintf as pcap_snprintf
+ epatch "${FILESDIR}/${PN}-7.0-pcap_pollution.patch"
+ # Use system's libevent
+ epatch "${FILESDIR}/${PN}-7.0-libevent.patch"
+ # Link in kernel sources
+ ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys"
+}
+
+src_compile() {
+ for dir in ${SUBDIRS}; do
+ einfo "Starting make in ${dir}"
+ cd "${S}/${dir}"
+ mkmake || die "Make ${dir} failed"
+ done
+}
+
+src_install() {
+ for dir in ${SUBDIRS}; do
+ einfo "Starting install in ${dir}"
+ cd "${S}/${dir}"
+ mkinstall || die "Install ${dir} failed"
+ done
+
+ cd "${WORKDIR}"/etc
+ insinto /etc
+ doins pf.os
+ newdoc pf.conf pf.conf.example
+ # pf.initd provided by openrc, but no pf.confd
+ newconfd "${FILESDIR}/pf.confd" pf
+}
diff --git a/sys-freebsd/freebsd-pf/freebsd-pf-9.1.ebuild b/sys-freebsd/freebsd-pf/freebsd-pf-9.1.ebuild
new file mode 100644
index 000000000000..a47d24a6ee8b
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/freebsd-pf-9.1.ebuild
@@ -0,0 +1,66 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd user
+
+DESCRIPTION="FreeBSD's base system libraries"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~x86-fbsd"
+
+IUSE=""
+
+# Crypto is needed to have an internal OpenSSL header
+SRC_URI="mirror://gentoo/${USBIN}.tar.bz2
+ mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2"
+
+RDEPEND="net-libs/libpcap"
+DEPEND="${RDEPEND}
+ dev-libs/libevent
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+
+S="${WORKDIR}"
+
+SUBDIRS="usr.sbin/authpf sbin/pfctl sbin/pflogd usr.sbin/ftp-proxy/ftp-proxy"
+
+pkg_setup() {
+ enewgroup authpf 63
+ mymakeopts="${mymakeopts} NO_MANCOMPRESS= NO_INFOCOMPRESS= "
+}
+
+src_unpack() {
+ freebsd_src_unpack
+ # pcap-int.h redefines snprintf as pcap_snprintf
+ epatch "${FILESDIR}/${PN}-9.0-pcap_pollution.patch"
+ # Use system's libevent
+ epatch "${FILESDIR}/${PN}-9.0-libevent.patch"
+ epatch "${FILESDIR}/${PN}-9.0-pflogd.patch"
+ epatch "${FILESDIR}/${PN}-9.0-bpf.patch"
+ epatch "${FILESDIR}/${PN}-9.0-getline.patch"
+ # Link in kernel sources
+ ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys"
+}
+
+src_compile() {
+ for dir in ${SUBDIRS}; do
+ einfo "Starting make in ${dir}"
+ cd "${S}/${dir}"
+ mkmake || die "Make ${dir} failed"
+ done
+}
+
+src_install() {
+ for dir in ${SUBDIRS}; do
+ einfo "Starting install in ${dir}"
+ cd "${S}/${dir}"
+ mkinstall || die "Install ${dir} failed"
+ done
+
+ cd "${WORKDIR}"/etc
+ insinto /etc
+ doins pf.os
+ # pf.initd provided by openrc, but no pf.confd
+ newconfd "${FILESDIR}/pf.confd" pf
+}
diff --git a/sys-freebsd/freebsd-pf/metadata.xml b/sys-freebsd/freebsd-pf/metadata.xml
new file mode 100644
index 000000000000..a00f3aeb1f81
--- /dev/null
+++ b/sys-freebsd/freebsd-pf/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+</maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-rescue/Manifest b/sys-freebsd/freebsd-rescue/Manifest
new file mode 100644
index 000000000000..b1ababf94fc4
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/Manifest
@@ -0,0 +1,42 @@
+AUX freebsd-rescue-10.0-zlib.patch 861 SHA256 e6ed90b353f180dc805d8ebf8774ef221f99dcd2ee2df485d48e795020ae8f4c SHA512 b055878934144bb2403bcf7d93b6239d161654d822ff5839676430eec282b1a7d210e9d4d4b744995b6e6d400ac15a98af9268f0ef62e455c6e776fa79d7b037 WHIRLPOOL 13e41e3aa5d9e0ca581927a8550acddd31ca0619b8e59f34a4f1c0a4a43b1d5fe2927fe8860db9c3bbd8cce8f7267c6f88ceca139569a0ac3ab575561929b4b8
+AUX freebsd-rescue-11.0-rename-libs.patch 874 SHA256 05dbc376b4e0b84d2d41a1d627d2a8b704584047acd0331fdbd927d44945066c SHA512 8ac692342e0ce3cd39286c08523bc89d56f15964242c08ec2065e70fbf3cec24c00608d50ab5b94ab4a7781a4175acc40c2bcc0e4a2cfaf3afcd89fa06dd77c9 WHIRLPOOL 2d3670648d3aea78b77ac0cf201e77fb9028eb00d105113543362df801a3f48610356f4adc6635a18852fc6ac750fa39c6fe223d50ab70474ab117d6199ad99b
+AUX freebsd-rescue-7.1-zlib.patch 800 SHA256 18c028bf1b51cf7c57d5517d8fe6f3221c8a4d00d1ae436e40af0d1cd095bc4f SHA512 54db6c1ad6030002fb1b5848e75470136a2b0b3d0c5398e1e0b3439c0bb736eb1ffa4799da7a3775a29761196a2c09a9cf70f75244de7d4e99bfe07357ed759c WHIRLPOOL cc5572b6ed34cb0462da77edf714e92ba10b672a315b216f342d200f0081ffdc417936b69cdf9e7e5ba8e1451f509fe222d366c84d98a005999c2987ae08d3ef
+AUX freebsd-rescue-8.0-pkgconfig_static_libarchive.patch 330 SHA256 3690730ee66082fcc4f04ab79c49c6759772c0aefc68abdebbe4497b1155a7bc SHA512 529294fbff01e573f714e7f0474ccb85755453da057d224ffc1eab91ea6945af2efc8cafcc48db4d75f5204fa5ab514da35af66d75f90df4bde3f0b8e8aa7dc5 WHIRLPOOL 95b65d6501a8d77fe4ecbc13aea1010e85fa5591fb5fc12d4a3ccaee51b908245ac79961bccd3d0e4b8430eacd7eb0fe271907c8a94812fad8df0ab888e3bd7d
+AUX freebsd-rescue-8.2-libzcleverlink.patch 789 SHA256 80d86cb1b632d0c09fdcfd7b998fb1189e957619a41fc65682e2c439392c38fd SHA512 5c24aed5b05b1de4aad67961edbc168c31f80a2d0d034839af8b2fb73497b34d525e1af2c0979b1e23bbcbb53d6079030aa68a1b218cef470c8daa2f439d3a7f WHIRLPOOL 55b39e959f0d0821189070ca03167becdd6d446a97dff7c171c40b12629cb2365aed6633635e6d8f6e3f3fa6bea68c46f31b79e537c3d56752e4aee76d76ce84
+AUX freebsd-rescue-9.1-bsdtar.patch 404 SHA256 0e71e3e370b33318bbb167e82d6507589fb95cc2c2d1fc6e8b74d0faf3d17ef1 SHA512 320d2a69c2f0de5e6cb733238fcc46133e571d8536f2ac573597f008d4261fae4d27619c244a90a70392688004df438b80e89f6be810841f6a40a22c2c361bb4 WHIRLPOOL 412da27f4535e1300d150edc74f72cf5e4e2b8bb6d4c7e9f31a498396ac12514e97e4b3a83040484b4713a7edb6b2d6ed5e8b2fe714d13f297c35d657f90fc08
+AUX freebsd-rescue-9.1-libcleverlink.patch 801 SHA256 53794263aabaf55cd570adbbfdb68e86a9e9b17557e8ca223d424a5c2f4f6831 SHA512 556bb68f3307dc7fb10096080db2d336ba4096ba6bebc6a1fe9449ab5298ce2c66fb53f11f0702ee75c2208b45a6e2cb366a3d774bedb65bcdb2a49f51c08fa3 WHIRLPOOL 88125b9143113b1f7049bf63a20a0c6d82fbe2c722198405830092b0a183f4bf7744420e6a82b601c8fb25911556c8f3a9088949798c7f66caf7843a5f9b2347
+AUX freebsd-sbin-bsdxml2expat.patch 424 SHA256 f40f55bec52d0e3e0205c363ad624a1139a74d5de36f99ca2ff9e53583bc2287 SHA512 f455db40e528c9bf19a68a639d2c0b304371d66741ee852c279246647f43620fd33911787aa9721547e086cbaa7dafa85b1ee6571094593c74de15e2ccc2f522 WHIRLPOOL 9409fa6d31a1a9b7dad59a6bdd820319c8a895b27c130af7d29e0db969be6760c4ab7df952420fb4fca9445fe0433b3aca5377f509852261d0f6b4e5a2fbd72b
+AUX freebsd-ubin-10.2-bsdxml.patch 367 SHA256 3bedd2e3efc7817c446395866e3ec2ca65430624dd4958bc91296d77cfc4fb90 SHA512 234fe495fcefaa9c36d97460da05365ff081661411451ae3d8dca83b3f8b1746450e111ac43baccd15a6c86c03c7cdd37d54d70fed551d694800dc6bca7c5e8d WHIRLPOOL 4946a71b63b05691ede60f15573356d98ef62b44cab40ba40a24d2be11e9655c95c660b62e898ff15ff9cdd8c006402c0dbe43a82d913b7707c1f30a55720863
+DIST freebsd-bin-8.2.tar.bz2 415900 SHA256 fb31b7fab259bda8396e615246f85dc99c3c9f7e98f4e4a613e20b6a394c4921 SHA512 c39b26f75f7d812f46e907acabd8dfaf45c97adf4488bcafa35fd46c805d821e177609d403cf5e677f3674020290199ac97059a0609f7705bce58a7aab3ee8e3 WHIRLPOOL 49e70b1c09c4b72b3f23850e8c9873556571ec02d70ade8f18f683eff6fa92dc8f6d02d58473fe7b4d8d1f3de96c63df41150b2091caafbc9a0e92e6055b43fd
+DIST freebsd-bin-9.1.tar.bz2 385664 SHA256 0a9524d75a8cb4c9c2654f2f9843087b09e8599bba97b9b59f00bc2e92b87e00 SHA512 fa0571a705befe1cb9c07285d3df55c9b5f4f295760511d668d80fec8cd4d59b70c676f07164f2aa44911decef0fb54fa6d78405ac2ceec822b6b8920abc5ca8 WHIRLPOOL 6f2bfe17604339e8260c49582bc941d255932b5c0a7b604e58187626a3a38766cd1e4aed9fc93a737ec9b4fa661f88aac23769b3542f35eb20da8b260216e985
+DIST freebsd-cddl-8.2.tar.bz2 823706 SHA256 6d2b2362ce60538bcba4afa47bd6baa98b05292babae4b20d6ba08592ce98698 SHA512 9f9728d9bf0f9fb320a0378186b29133e5e9276494f57ac3cffa9917ec94d3b886708406990107f2fbf742c255f9ac716f35ea14f6a6a835712eb55581421721 WHIRLPOOL 0150d972fc5200efcf22b5baded0bc7d826f03420a8328bc9ce1f53f39d1f3cd07dc367fcb3b0c8bdcc3b33bc9045f262928d76532c91820fd3c6bc8c9ee57c9
+DIST freebsd-cddl-9.1.tar.bz2 899348 SHA256 bcc79fb002052128e9e91b16beb3083ee152be0936494715c6c159bfc8d2ca3a SHA512 ae0a969e710785bbcf36a2ec22cc5b1dcdb25398be951e047a1237d0c977e38fc9e05504db51f8bf9ed83bc1f68b04fc88ce18fc48a93f785b8a3f8ef481bacd WHIRLPOOL 2c4a5baf162dbb698af45b9262f104e27c05e6a2630c3e7b1765e76c8987a330c315f741df69c8771d2509708d2934db2a07f2e0218aa59d0100dfc3f952bf72
+DIST freebsd-contrib-8.2.tar.bz2 40931651 SHA256 8b9cb688e81c2980b3fc66411d00ab277a24dadd50d5bdd5e0e6c63ac687b9b6 SHA512 4f7bf825b579fbb88f2aac531d07e531474179c63fa0b66c4e80821290a8c94bf611bb4dcaef51b762aacd25b11dfae798a4ec3bad3b9e3f6b3490ebfaa72476 WHIRLPOOL edd3d9e26e8d22d9028082e107ec1a44402e206dab8722f34b445676959305996c3f699152af42ace249b7f58498492787823b172fb6bcb273119c6bb50a35f0
+DIST freebsd-contrib-9.1.tar.bz2 54751432 SHA256 e7ffa056d4050ce03ee8e23e276e2a9a494326a98d60c43bee2afcc59576deb8 SHA512 71be13049258c6e6b5e4f63cc16da5d349a89d68f04d87446e4ad33ae8bf2a93ea67d9c256b7bec60b61e65db0487268070cfb77a484c3ac0f8ba368b48c2438 WHIRLPOOL a2a84423175499208d34809e802284d6ba649f317c3a9ad8b7312fa19efe142ebadab0048bac0db8e988e59f9a7468ac7c5d0d25e78b82bdb269a20d18153cee
+DIST freebsd-gnu-8.2.tar.bz2 815379 SHA256 34be1326b8e188427ea4a59de5dd24049f99adb5e172d61a645db1b7124f7876 SHA512 8b278e386b22b22658eef18341073c1c757b86ecdef5c5b543fb781cfee295d71cef599544eda5f8cf273fc22d28a1ab14d912086ff8398c36ee2b71281617d4 WHIRLPOOL aaf91562f147095e09a9f6aa2d4c33494f430cbe7340377edff1b8a44cc60edfe4af7ef90350018f0c80e82f5518110689cb582bb227d2360488dfbdd7bcb7c8
+DIST freebsd-gnu-9.1.tar.bz2 795778 SHA256 3b99c1fa1087bf69549e0990a0d7997954533ac9d7938c4760ec2b01aa509a5f SHA512 b05f2a5a10bdaeef19dfd0e962bc09f1571288a831e9345f404b920037f47db5c0ca3d620d1cbdd138b18bca1c3feab5b211b57e3041727341e5238cb9feb4fd WHIRLPOOL 4f776b99296c4fcc0d6f4d30a12b0773f6704292e1361826b260ce34dcc8e537ef7eb7c6332c4988e0e03bc84ca07fb18e6b2785fe4c6f175c08865b72d6bb0b
+DIST freebsd-lib-8.2.tar.bz2 3323878 SHA256 e3590c12794fcb5ba8eb7a1f58b497587cf19f9200b3254c194a793da3b5bfb0 SHA512 c059cfdd1099bb519b2a5c43fb7e7104c500ef8906229ed7eb9e420cb3a217cdaf8655e9e7a9f45cfadc5491f8115e0e738fd49251d9f0c3a83780845b09f007 WHIRLPOOL 95f98a372f44a89bc8ac3029ec065dbbfec338e6f889d057d75644bfcdfb9d27fdc0421d7e392cad5a823712b97f0857297ec3d321580254c63032c22b95792e
+DIST freebsd-lib-9.1.tar.bz2 3206685 SHA256 f31fa8107b4de711c548f6d0c1bb1f81d09f51bcc3b14a1e9e90bb0e7cc4a35d SHA512 40d0c36b6b889c404fa0e0afa38ba4e84a55bc88ffa2f98a70afbd7a32c4f32c158617ba770567d082a986d62c09b3ec8db3dc5ab853ee1c9bbe0b90bb82396e WHIRLPOOL 581878bf9c43184b043b4293409b85901c9ed1f9bd279e965414aca41ba50950848ebda3ee10a503a028135dfd2765e95a11acd4e62a11c528e104392bbbd8d0
+DIST freebsd-libexec-8.2.tar.bz2 289147 SHA256 10b996d1d8cd044ee2e7a877e5e6ad2bf050cce9b3bd402a5e0dea7d290b595d SHA512 abe6cf5a268675d7dcb1c214c46fef47a3fb09b31947f5d8a0b938d352295efe0249beb5007649c52187bf4c221b6ebf074d18dfe9bafd168cae09ee02ab608d WHIRLPOOL 27e854fe465eb933dd8e27c5a09b063e4d3798b54e0914c79a9120dcdc34cc5d525a0c92da7b645ff7ab2ab4f34c7f7b2783012dfa5004407acd11150062b7ad
+DIST freebsd-libexec-9.1.tar.bz2 304592 SHA256 71e6e9e41328c2148c54b81ad9b59f912a1d5f0d52e17ac07f223aa7a94b82be SHA512 7baa4160dda2610250dd52f445e24478e0f1ea10bce21fcd0e5d1b856f399b896adc334114de0c7f61a5637e4349bb1688fdbe5c72798d8568ae791114710b92 WHIRLPOOL d800f477ac5c9ad6dae3e0091c83e107609b5a1e3aa79e9533fcd10a8dd34ff7733ab9523eae7c292310fe94f6a529209cae6b9e8bac6b47244e59834593e74b
+DIST freebsd-rescue-8.2.tar.bz2 5041 SHA256 82f05e98c977771c87f416be80e3634df231c0a2cd26059fd7276ca3a4284031 SHA512 3311e1ee1d2fc1de0ecc9c5351bfbe007a4651e89a3f3f86ce6cf0fea83a65692fc7a709ccf3a4e9a3179ce51a87b36256481d91819a7621db4045394aa51c29 WHIRLPOOL ffb36c14c7bf5263a1fc8c3f2fe01ee912a476c3053db4b7a0f237bb3c0494a4d9500906eea22ef81052c5f2955fbfb6489f9494ce6897d44f0aeebf95daa631
+DIST freebsd-rescue-9.1.tar.bz2 3939 SHA256 15794c65e2977a2623f0a09090f835c67e6ec49e13996b2d69a018ff4185be4e SHA512 93015a725cea428fd6f4813370eab460979bbae3aac2e6688319a06012b4e0fe1f7b847f9e0d4da423835e59ba5a3842057b61d110d24f79109a50133e5e23bb WHIRLPOOL c303a26b2594e87ea9f9c5a05b1f46cdf9712aa521d21a210e5b452c883fd7e2d36b1ece7d6c9988860a909d00e77825367b0a6f33e5938a8fa23e02e58aeec2
+DIST freebsd-sbin-8.2.tar.bz2 1211665 SHA256 8b7e21a66b4696e8763d29b8b02b2d35f29fc51820a194d1e469e7cace84c527 SHA512 c6643c29ab62344c98d8991708798730ee1c17e6478071718beeaa79788300a1f4ed2e6aeb8e39e3c216877d4ed2ac85b2a9531d534f1ac5125a508927898959 WHIRLPOOL 2a21cd0f15f95d66718031680ac87f1fe73f1e1b03cb012e1db1dd1bd2fe2bb7897457a8ba2f5a28c8806775611dca542cbadec16566c47ab9efa673e2cb53f3
+DIST freebsd-sbin-9.1.tar.bz2 1273913 SHA256 45008b0733b232ef03707ef5fa3e5c889e3b3728393d736bd9a869ea83be6447 SHA512 9f186602b7de96f268c352ca386986652fddf5570e7eca1afa8c0d2bdc83b57df1198efe47f36dd5c7a6abf4f9c935f1c8207a4a12a6b2153bd6c3c6292719dc WHIRLPOOL 20920dfa9607a0ce854319cef29bbd77fb1b31f6f6cfd5ac60cbd678169e43929e215743fe636d0c224443f3e6149a8f07c292d647f7f901592795ac292699f9
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+DIST freebsd-sys-8.2.tar.bz2 25835329 SHA256 0c6c7b61aae94db2931f985d5899f3bca78fc8ffab6b598fbaa158142d676f16 SHA512 6ea4516a5c52e25c4f993f7acb875463a5caea93dbdf250c5d48eee95fff226956e9f030cab7e341b5e6a132325bc3dbf93dcb4b1185acb011918e50b1a22be3 WHIRLPOOL 870deeff877c6b9fc812a4260e4fdbb6715a5dc2065cab3bfbf2a42d876f6654703ccb124275a4e2c410cef48f3db02b63cc76059eccf9cf90244826f35b7a15
+DIST freebsd-sys-9.1.tar.bz2 32588103 SHA256 b93a7ac8334ac16cc9f60665048e5ef812c0a6c62f10d0b0a674aec3f56516a8 SHA512 7dc9d9e00dde8f592bb171f4386d02b655b73cb4f153fe5ec063d010a148ef0639eae0dcdb3eeb09ecd1e3653c69e49a2d261329fa6d0381d2ddabe258ddde6d WHIRLPOOL c8348344dfb14bad64bd3a78ee615ddd29203175b292233254f8ba175e7a3fb7218af6f95f7b4dbf394c0354bafe9d8bb0c21cdf0ceaeb697214964b280469b3
+DIST freebsd-ubin-8.2.tar.bz2 1808012 SHA256 6b99554f3ad6ee052069b347eb6e6219b71598d7b222acb90a24cbfc805c7b68 SHA512 48d0103323e820c431aa4f62d3be40cb3b200fb62e3de01f36c88760395bf2ba3367c51f3fa72da4dbccc2812176a051a12ca5cb7e84125c3e0fc78d4cab2c29 WHIRLPOOL ea8f3a29a37b42c2b5bcc0f2c343fa1538522157ef075363c94606a4620a590e9a03f856ce2494e3e727935b62431991d0aa9fde71de699e78b4fe225bdf1c2c
+DIST freebsd-ubin-9.1.tar.bz2 1910472 SHA256 ff6e586f213534b6ec2e65002c0dee64063d76ddad515c12221b1a80a1815e48 SHA512 74ae0aceec8597aa66c3f1ab313f0685a3c63d7273c36ae7baf8794275ad9bca241c60c3f6281cccf6d531d250d7611099977d3b1a27279cef3586401b6af05e WHIRLPOOL c85a3c9cf2bceff2c60ff03556bcc81d3aca22b0bce3c9538990071ac0a907236eee5ae7743ad22c5fd309b047ebf392aaaf2fe177ef5790ea869aff3da7e2fe
+DIST freebsd-usbin-8.2.tar.bz2 2443024 SHA256 aa7cabf10f5c3a9daabea32e4de24d04ec312247842981476da666eff5054603 SHA512 bcb8ff3df54848b9107bbb52e5ced7a91e24bb181f06769b6997221729b8064ec17652eaf7500de3268cbcb63ff5760beb54d15fc78c27b02687b5b1067c74a6 WHIRLPOOL 20f5278e2a1dd387a75b44f10507958d6c0e84a2faa1bddbf808c14ab86d8dd14a956192911bbc1880f5f5f7bd05972dcbb4aec85d241f0dcf91bf4246883f0a
+DIST freebsd-usbin-9.1.tar.bz2 2670916 SHA256 b938c20b8c09aa9a610e13b69b9afeea72f561ab3636a59fba2bdac290f4db75 SHA512 21c234312f70eb35cd2926519efc1f61592892f5d0940786dbeb959c3c5ec7819a51ae95c6e8a1a06aa01f669350fe0fd3dd7c4ec8a84dd6b90f24cb192356ca WHIRLPOOL 7f6ad2eb5410cc5e685881654a788807848af026b1277a974682755ab7c9db28f576bfd1576441ea10c5f1e9edb7d30a4a23fb8eccd6d69d86ecc9ce4c9adc7e
+EBUILD freebsd-rescue-10.3.ebuild 1832 SHA256 c4d927d777c0d376cfc312ae6823441f0390ca2dcbcae3f275b494d5845481e4 SHA512 051aec60e165431c1b2c19489f43c36137c6de8d6a992a371e66369587dab321cea45a6667732b23e03c123a921dd888c25a8f1ffd94c349705295fb217da886 WHIRLPOOL d861998d13e9d3030a9f1cd044ac4d8c070d16176926ca6d50c78fc93212a720a9c00ca55808fc3a66d00cb3a29fe885b66091c91a7bb239f9a53fd588c18250
+EBUILD freebsd-rescue-11.0.ebuild 1869 SHA256 29e229937161626f0491be08fc9721f829eae021b2d955a6d40f8f6186d79ea6 SHA512 8291dc4063691b846ee21a77ef5fdca9ee42c1918e7b67e766b3cbc2117fb6b7b60f6c23473a34fd1240ed728faa2c040d79fd17d3e075db153ef6441d07eb16 WHIRLPOOL cab8ed5e0fea9de63f0a8a0e13010ec9c4d3fe99013dc6034b801043a952c840a667b8e5b129696beb721c08b17c2bdbeebcaba70b4ba722ce1a73c1fe1d9af8
+EBUILD freebsd-rescue-11.1.ebuild 1863 SHA256 017db63d5745cf1bbc3f54ce063accf5db996845ad6d2b377edf702770e6f5da SHA512 38821a85f4e5f2efb6746b096b64c02b6534ce98ad743c44e45f65d8a6cafc3fba6cc452d3d465df1021fa2bf02063d3a5fa5be89ce7c667a9912626a7317591 WHIRLPOOL 30dfb303111e3d27635bf8c3d07d449739f16e43d0042ccd93e4c23af42d826ede14b8f70f293953cd1edf89001f6fedeb6293a3674ac3ebbd34e825178cd6be
+EBUILD freebsd-rescue-8.2.ebuild 1488 SHA256 6e4f3fb61b6bb117b2f8b5438c1379dfa9d0604445e971489d04fee742e8cfef SHA512 6cf49d8ef4f62affa527d0339c56087d49576da2c27bce2ed25d72755ce8852ff43448e51382553d5605f8d8cdd5e124cd2ca00228b542ee9b85790152f6dba2 WHIRLPOOL 5d18c3e18184f7639290c9f070f7955a5f28c22d4e67dc13531fee5c926b9664010f92eacd97930b5375405915d431c0c6aab63f0d6e8f8872fddabdc6d79a59
+EBUILD freebsd-rescue-9.1.ebuild 1780 SHA256 46a3fe8f77534ba7e63ad754a63a86734214f34aaff854c4054aac22d598fc3b SHA512 0d463b226f9520d5d752a5de402e2d01bc6a7f778fb0747725f976053746685549c70ee59c78f2a53768ff1e0850f0c4fc479f8ecb611008af2b1e881e8c84a3 WHIRLPOOL 5afc2dccdaae98b15c09e4f847dac4036d27e606b0499d147393268731f1d18b629e8074b1ba17e6107876802158d5c7eda0a857d73f2aee996e92178fa765c3
+MISC ChangeLog 4344 SHA256 4a4b5a0d1b1af9f6ca4cea0f36835e0774cd0de563d61f60806860e2d78404a2 SHA512 b6da7df8fab55542e5a709297a80d861b92bd3dccadc21250e968f6c83a065999ee788c0e6f5fb7f596efae2345128372f190c513423fe6155fea583a56bf606 WHIRLPOOL d1e48723df7f0b49ff8822cabac09c163a5fbbc187a9d90bc93c2655396a5d7fc4ce8fa896caef0f7cb5ccc3cc1bd1a8645666604168f1bc179af97a8f129f12
+MISC ChangeLog-2015 8241 SHA256 05ef252174f276aa328aeb6eb547b92dd1ec839685990f851e97e54df305d4d6 SHA512 9b48f6861425acd6c7ce6cf660ef1f7347773c230cef9d854c061d6313ec76820fcc1b08aa78df48192794e3bf4cb51101b1ecf3fe731edd5b28f7a19c5dd61a WHIRLPOOL bc2aa37dcf6e0b613ad2476d859fc9efcdaf7f24c279d906dbecad8a5551778be08e8973d45000ab5caf18d7640067cef3579db7f7ae3f37a9b06c29c0e4122a
+MISC metadata.xml 402 SHA256 75ec89a9158454c340bf52b7b8c9206f5cb65fe01afd5dfd36aaf13fd68eca7b SHA512 247e4e4c80cd64a81f698fc7fbeab529a02f8b2c6b0040628936ab7d83a09c7242df0b10d7cb4e4e8d7d78806c303cd82903adc4a38b649e911337a832c35834 WHIRLPOOL 4cd689a5c3a69a0ae7614bbed3c7a51eade7c77e03eba094fbeb75390ec9faee52c2bb085655ad3069148ec03838c03c713921a62eb6c1380e2a90781d294d72
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-10.0-zlib.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-10.0-zlib.patch
new file mode 100644
index 000000000000..42165c4249ed
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-10.0-zlib.patch
@@ -0,0 +1,22 @@
+diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
+index 13c0d43..1f258f3 100644
+--- a/sbin/savecore/savecore.c
++++ b/sbin/savecore/savecore.c
+@@ -92,7 +92,7 @@ static int checkfor, compress, clear, force, keep, verbose; /* flags */
+ static int nfound, nsaved, nerr; /* statistics */
+ static int maxdumps;
+
+-extern FILE *zopen(const char *, const char *);
++extern FILE *gzopen(const char *, const char *);
+
+ static sig_atomic_t got_siginfo;
+ static void infohandler(int);
+@@ -626,7 +626,7 @@ DoFile(const char *savedir, const char *device)
+ if (compress) {
+ snprintf(corename, sizeof(corename), "%s.%d.gz",
+ istextdump ? "textdump.tar" : "vmcore", bounds);
+- fp = zopen(corename, "w");
++ fp = gzopen(corename, "w");
+ } else {
+ snprintf(corename, sizeof(corename), "%s.%d",
+ istextdump ? "textdump.tar" : "vmcore", bounds);
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-11.0-rename-libs.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-11.0-rename-libs.patch
new file mode 100644
index 000000000000..31035747a43d
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-11.0-rename-libs.patch
@@ -0,0 +1,22 @@
+diff --git a/rescue/rescue/Makefile b/rescue/rescue/Makefile
+index e747c02..a061436 100644
+--- a/rescue/rescue/Makefile
++++ b/rescue/rescue/Makefile
+@@ -54,7 +54,7 @@ CRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo \
+ ed expr getfacl hostname kenv kill ln ls mkdir mv \
+ pkill ps pwd realpath rm rmdir setfacl sh sleep stty \
+ sync test
+-CRUNCH_LIBS+= -lcrypt -ledit -ljail -lkvm -lelf -ll -ltermcapw -lutil -lxo
++CRUNCH_LIBS+= -lcrypt -ledit -ljail -lkvm -lelf -lfl -lncursesw -lutil -lxo
+ CRUNCH_BUILDTOOLS+= bin/sh
+
+ # Additional options for specific programs
+@@ -128,7 +128,7 @@ CRUNCH_LIBS+= -lavl -lzpool -lzfs_core -lzfs -lnvpair -lpthread -luutil -lumem
+ # liblzma needs pthread
+ CRUNCH_LIBS+= -lpthread
+ .endif
+-CRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv
++CRUNCH_LIBS+= -lgeom -lexpat -lkiconv
+ .if ${MK_OPENSSL} == "no"
+ CRUNCH_LIBS+= -lmd
+ .endif
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-7.1-zlib.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-7.1-zlib.patch
new file mode 100644
index 000000000000..22fb2ec62d4f
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-7.1-zlib.patch
@@ -0,0 +1,21 @@
+diff -ur sbin/savecore/savecore.c sbin-zlib/savecore/savecore.c
+--- sbin/savecore/savecore.c 2005-02-26 01:21:50 +0000
++++ sbin-zlib/savecore/savecore.c 2005-05-06 12:00:06 +0000
+@@ -95,7 +95,7 @@
+ static int checkfor, compress, clear, force, keep, verbose; /* flags */
+ static int nfound, nsaved, nerr; /* statistics */
+
+-extern FILE *zopen(const char *, const char *);
++extern FILE *gzopen(const char *, const char *);
+
+ static void
+ printheader(FILE *f, const struct kerneldumpheader *h, const char *device,
+@@ -553,7 +553,7 @@
+ if (compress) {
+ sprintf(filename, "%s.%d.gz", istextdump ? "textdump.tar" :
+ "vmcore", bounds);
+- fp = zopen(filename, "w");
++ fp = gzopen(filename, "w");
+ } else {
+ sprintf(filename, "%s.%d", istextdump ? "textdump.tar" :
+ "vmcore", bounds);
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.0-pkgconfig_static_libarchive.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.0-pkgconfig_static_libarchive.patch
new file mode 100644
index 000000000000..7d12621cec80
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.0-pkgconfig_static_libarchive.patch
@@ -0,0 +1,11 @@
+--- rescue/rescue/Makefile.old 2010-03-12 12:14:17 +0100
++++ rescue/rescue/Makefile 2010-03-12 12:14:47 +0100
+@@ -209,7 +209,7 @@
+ CRUNCH_LIBS+= -lbz2
+
+ CRUNCH_PROGS_usr.bin+= tar
+-CRUNCH_LIBS+= -larchive -lmd
++CRUNCH_LIBS+= `pkg-config --static --libs libarchive` -lmd
+ .if ${MK_OPENSSL} != "no"
+ CRUNCH_LIBS+= -lcrypto
+ .endif
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.2-libzcleverlink.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.2-libzcleverlink.patch
new file mode 100644
index 000000000000..3d444575515f
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-8.2-libzcleverlink.patch
@@ -0,0 +1,20 @@
+--- rescue/rescue/Makefile.old 2011-07-06 01:35:13.000000000 +0000
++++ rescue/rescue/Makefile 2011-07-06 01:35:54.000000000 +0000
+@@ -143,7 +143,7 @@
+ .if ${MK_ZFS} != "no"
+ CRUNCH_LIBS+= -lzfs -lnvpair -luutil -lavl
+ .endif
+-CRUNCH_LIBS+= -lgeom -lbsdxml -ljail -lkiconv -lmd -lreadline -lsbuf -lufs -lz
++CRUNCH_LIBS+= -lgeom -lbsdxml -ljail -lkiconv -lmd -lreadline -lsbuf -lufs
+
+ .if ${MACHINE_ARCH} == "i386"
+ CRUNCH_PROGS_sbin+= bsdlabel sconfig fdisk
+@@ -234,7 +234,7 @@
+ CRUNCH_PROGS_usr.sbin+= chown
+ CRUNCH_ALIAS_chown= chgrp
+ ##################################################################
+-CRUNCH_LIBS+= -lm
++CRUNCH_LIBS+= -lz -lm
+
+ ##################################################################
+ # The following is pretty nearly a generic crunchgen-handling makefile
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-bsdtar.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-bsdtar.patch
new file mode 100644
index 000000000000..d4d23d73f11c
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-bsdtar.patch
@@ -0,0 +1,12 @@
+diff -Nur work.orig/contrib/libarchive/tar/bsdtar.c work/contrib/libarchive/tar/bsdtar.c
+--- work.orig/contrib/libarchive/tar/bsdtar.c 2012-07-12 13:44:29.000000000 +0900
++++ work/contrib/libarchive/tar/bsdtar.c 2012-07-29 00:57:25.000000000 +0900
+@@ -691,7 +691,7 @@
+ {
+ printf("bsdtar %s - %s\n",
+ BSDTAR_VERSION_STRING,
+- archive_version());
++ archive_version_string());
+ exit(0);
+ }
+
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-libcleverlink.patch b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-libcleverlink.patch
new file mode 100644
index 000000000000..a194397b1311
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-rescue-9.1-libcleverlink.patch
@@ -0,0 +1,21 @@
+diff -Nur work.orig/rescue/rescue/Makefile work/rescue/rescue/Makefile
+--- work.orig/rescue/rescue/Makefile 2012-07-29 00:50:20.000000000 +0900
++++ work/rescue/rescue/Makefile 2012-07-29 00:56:01.000000000 +0900
+@@ -125,7 +125,7 @@
+ .if ${MK_ZFS} != "no"
+ CRUNCH_LIBS+= -lavl -lnvpair -lpthread -lzfs -luutil -lumem
+ .endif
+-CRUNCH_LIBS+= -lgeom -lexpat -ljail -lkiconv -lmd -lreadline -lsbuf -lufs -lz
++CRUNCH_LIBS+= -lgeom -lexpat -ljail -lkiconv -lreadline -lsbuf -lufs
+
+ .if ${MACHINE_CPUARCH} == "i386"
+ CRUNCH_PROGS_sbin+= bsdlabel sconfig fdisk
+@@ -216,7 +216,7 @@
+ CRUNCH_PROGS_usr.sbin+= chown
+ CRUNCH_ALIAS_chown= chgrp
+ ##################################################################
+-CRUNCH_LIBS+= -lm
++CRUNCH_LIBS+= -lmd -lz -lm
+
+ .include <bsd.crunchgen.mk>
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-sbin-bsdxml2expat.patch b/sys-freebsd/freebsd-rescue/files/freebsd-sbin-bsdxml2expat.patch
new file mode 100644
index 000000000000..bdda99b8c0da
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-sbin-bsdxml2expat.patch
@@ -0,0 +1,13 @@
+diff -uNr sbin/ifconfig.old/regdomain.c sbin/ifconfig/regdomain.c
+--- sbin/ifconfig.old/regdomain.c 2010-12-21 17:09:25.000000000 +0000
++++ sbin/ifconfig/regdomain.c 2011-07-10 15:56:27.000000000 +0000
+@@ -39,7 +39,7 @@
+ #include <err.h>
+ #include <unistd.h>
+
+-#include <bsdxml.h>
++#include <expat.h>
+
+ #include "regdomain.h"
+
+Los ficheros binarios sbin/ifconfig.old/regdomain.o y sbin/ifconfig/regdomain.o son distintos
diff --git a/sys-freebsd/freebsd-rescue/files/freebsd-ubin-10.2-bsdxml.patch b/sys-freebsd/freebsd-rescue/files/freebsd-ubin-10.2-bsdxml.patch
new file mode 100644
index 000000000000..606471713fba
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/files/freebsd-ubin-10.2-bsdxml.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.bin/mt/mt.c b/usr.bin/mt/mt.c
+index af6562b..3121c81 100644
+--- a/usr.bin/mt/mt.c
++++ b/usr.bin/mt/mt.c
+@@ -92,7 +92,7 @@ __FBSDID("$FreeBSD: stable/10/usr.bin/mt/mt.c 280438 2015-03-24 14:36:10Z ken $"
+ #include <unistd.h>
+ #include <stdint.h>
+ #include <errno.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <mtlib.h>
+
+ #include <cam/cam.h>
diff --git a/sys-freebsd/freebsd-rescue/freebsd-rescue-10.3.ebuild b/sys-freebsd/freebsd-rescue/freebsd-rescue-10.3.ebuild
new file mode 100644
index 000000000000..a7e52e525efc
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/freebsd-rescue-10.3.ebuild
@@ -0,0 +1,81 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd toolchain-funcs
+
+DESCRIPTION="FreeBSD's rescue binaries"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+IUSE="atm netware nis zfs"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ usr.bin/
+ contrib/
+ lib/
+ bin/
+ sbin/
+ usr.sbin/
+ gnu/
+ sys/
+ libexec/
+ rescue/
+"
+
+RDEPEND=""
+DEPEND="sys-devel/flex
+ app-arch/xz-utils[static-libs]
+ sys-libs/ncurses[static-libs]
+ dev-libs/expat[static-libs]
+ app-arch/bzip2[static-libs]
+ dev-libs/libedit[static-libs]
+ dev-libs/libxml2:2[static-libs]
+ dev-libs/openssl:0=[static-libs]
+ sys-libs/zlib[static-libs]
+ sys-libs/readline[static-libs]
+ =sys-freebsd/freebsd-lib-${RV}*[atm?,netware?]
+ =sys-freebsd/freebsd-sources-${RV}*
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )"
+
+S="${WORKDIR}/rescue"
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ mymakeopts="${mymakeopts} NO_PIC= "
+}
+
+src_prepare() {
+ # As they are patches from ${WORKDIR} apply them by hand
+ cd "${WORKDIR}" || die
+ epatch "${FILESDIR}/${PN}"-10.0-zlib.patch
+ epatch "${FILESDIR}/freebsd-sbin-bsdxml2expat.patch"
+ epatch "${FILESDIR}/freebsd-ubin-10.2-bsdxml.patch"
+}
+
+src_compile() {
+ tc-export CC
+ # crunchgen is now checks env MAKE.
+ # Use to force BSD's make
+ export MAKE=/usr/bin/make
+
+ cd "${WORKDIR}/lib/libarchive" || die
+ echo "#include <expat.h>" > bsdxml.h
+ freebsd_src_compile
+ export CC="${CC} -L${WORKDIR}/lib/libarchive"
+
+ cd "${S}" || die
+ freebsd_src_compile
+}
diff --git a/sys-freebsd/freebsd-rescue/freebsd-rescue-11.0.ebuild b/sys-freebsd/freebsd-rescue/freebsd-rescue-11.0.ebuild
new file mode 100644
index 000000000000..4f35e4425b18
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/freebsd-rescue-11.0.ebuild
@@ -0,0 +1,84 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd toolchain-funcs
+
+DESCRIPTION="FreeBSD's rescue binaries"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+IUSE="atm netware nis zfs"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ usr.bin/
+ contrib/
+ lib/
+ bin/
+ sbin/
+ usr.sbin/
+ gnu/
+ sys/
+ libexec/
+ rescue/
+"
+
+RDEPEND=""
+DEPEND="sys-devel/flex
+ app-arch/xz-utils[static-libs]
+ sys-libs/ncurses[static-libs]
+ dev-libs/expat[static-libs]
+ app-arch/bzip2[static-libs]
+ dev-libs/libedit[static-libs]
+ dev-libs/libxml2:2[static-libs]
+ dev-libs/openssl:0=[static-libs]
+ sys-libs/zlib[static-libs]
+ sys-libs/readline[static-libs]
+ =sys-freebsd/freebsd-lib-${RV}*[atm?,netware?]
+ =sys-freebsd/freebsd-sources-${RV}*
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )"
+
+S="${WORKDIR}/rescue"
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ mymakeopts="${mymakeopts} NO_PIC= "
+}
+
+src_prepare() {
+ # As they are patches from ${WORKDIR} apply them by hand
+ cd "${WORKDIR}" || die
+ epatch "${FILESDIR}/${PN}-10.0-zlib.patch"
+ epatch "${FILESDIR}/${PN}-11.0-rename-libs.patch"
+ epatch "${FILESDIR}/freebsd-ubin-10.2-bsdxml.patch"
+}
+
+src_compile() {
+ export ESED=/usr/bin/sed
+ unalias sed
+
+ tc-export CC
+ # crunchgen is now checks env MAKE.
+ # Use to force BSD's make
+ export MAKE=/usr/bin/make
+
+ cd "${WORKDIR}/lib/libarchive" || die
+ echo "#include <expat.h>" > bsdxml.h
+ freebsd_src_compile
+ export CC="${CC} -L${WORKDIR}/lib/libarchive"
+
+ cd "${S}" || die
+ freebsd_src_compile
+}
diff --git a/sys-freebsd/freebsd-rescue/freebsd-rescue-11.1.ebuild b/sys-freebsd/freebsd-rescue/freebsd-rescue-11.1.ebuild
new file mode 100644
index 000000000000..9cecae29df98
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/freebsd-rescue-11.1.ebuild
@@ -0,0 +1,83 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd toolchain-funcs
+
+DESCRIPTION="FreeBSD's rescue binaries"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+IUSE="atm netware nis zfs"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ usr.bin/
+ contrib/
+ lib/
+ bin/
+ sbin/
+ usr.sbin/
+ gnu/
+ sys/
+ libexec/
+ rescue/
+"
+
+RDEPEND=""
+DEPEND="sys-devel/flex
+ app-arch/xz-utils[static-libs]
+ sys-libs/ncurses[static-libs]
+ dev-libs/expat[static-libs]
+ app-arch/bzip2[static-libs]
+ dev-libs/libedit[static-libs]
+ dev-libs/libxml2:2[static-libs]
+ dev-libs/openssl:0=[static-libs]
+ sys-libs/zlib[static-libs]
+ sys-libs/readline[static-libs]
+ =sys-freebsd/freebsd-lib-${RV}*[atm?,netware?]
+ =sys-freebsd/freebsd-sources-${RV}*
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )"
+
+S="${WORKDIR}/rescue"
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ mymakeopts="${mymakeopts} NO_PIC= "
+}
+
+src_prepare() {
+ # As they are patches from ${WORKDIR} apply them by hand
+ cd "${WORKDIR}" || die
+ epatch "${FILESDIR}/${PN}-10.0-zlib.patch"
+ epatch "${FILESDIR}/${PN}-11.0-rename-libs.patch"
+ epatch "${FILESDIR}/freebsd-ubin-10.2-bsdxml.patch"
+}
+
+src_compile() {
+ export ESED=/usr/bin/sed
+ unalias sed
+
+ tc-export CC
+ # crunchgen requires BSD's make to compile successfully.
+ export MAKE=/usr/bin/make
+
+ cd "${WORKDIR}/lib/libarchive" || die
+ echo "#include <expat.h>" > bsdxml.h
+ freebsd_src_compile
+ export CC="${CC} -L${WORKDIR}/lib/libarchive"
+
+ cd "${S}" || die
+ freebsd_src_compile
+}
diff --git a/sys-freebsd/freebsd-rescue/freebsd-rescue-8.2.ebuild b/sys-freebsd/freebsd-rescue/freebsd-rescue-8.2.ebuild
new file mode 100644
index 000000000000..a63b59c79f4b
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/freebsd-rescue-8.2.ebuild
@@ -0,0 +1,53 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=2
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD's rescue binaries"
+SLOT="0"
+KEYWORDS="~x86-fbsd"
+LICENSE="BSD zfs? ( CDDL )"
+
+IUSE="atm netware nis zfs"
+
+SRC_URI="mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${BIN}.tar.bz2
+ mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${USBIN}.tar.bz2
+ mirror://gentoo/${GNU}.tar.bz2
+ mirror://gentoo/${SYS}.tar.bz2
+ mirror://gentoo/${LIBEXEC}.tar.bz2
+ mirror://gentoo/${RESCUE}.tar.bz2
+ zfs? ( mirror://gentoo/${CDDL}.tar.bz2 )"
+
+RDEPEND=""
+DEPEND="sys-devel/flex
+ >=app-arch/libarchive-2.7.1[static-libs]
+ dev-libs/libedit[static-libs]
+ app-arch/xz-utils[static-libs]
+ sys-libs/ncurses[static-libs]
+ virtual/pkgconfig
+ =sys-freebsd/freebsd-lib-${RV}*[atm?,netware?]
+ =sys-freebsd/freebsd-sources-${RV}*
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/rescue"
+
+pkg_setup() {
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+}
+
+src_prepare() {
+ # As they are patches from ${WORKDIR} apply them by hand
+ cd "${WORKDIR}"
+ epatch "${FILESDIR}/${PN}"-8.0-pkgconfig_static_libarchive.patch
+ epatch "${FILESDIR}/${PN}"-7.1-zlib.patch
+ epatch "${FILESDIR}/${PN}"-8.2-libzcleverlink.patch
+}
diff --git a/sys-freebsd/freebsd-rescue/freebsd-rescue-9.1.ebuild b/sys-freebsd/freebsd-rescue/freebsd-rescue-9.1.ebuild
new file mode 100644
index 000000000000..6220bcfdfa0d
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/freebsd-rescue-9.1.ebuild
@@ -0,0 +1,61 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=2
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD's rescue binaries"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~x86-fbsd"
+LICENSE="BSD zfs? ( CDDL )"
+
+IUSE="atm netware nis zfs"
+
+SRC_URI="mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${BIN}.tar.bz2
+ mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${USBIN}.tar.bz2
+ mirror://gentoo/${GNU}.tar.bz2
+ mirror://gentoo/${SYS}.tar.bz2
+ mirror://gentoo/${LIBEXEC}.tar.bz2
+ mirror://gentoo/${RESCUE}.tar.bz2
+ zfs? ( mirror://gentoo/${CDDL}.tar.bz2 )"
+
+RDEPEND=""
+DEPEND="sys-devel/flex
+ >=app-arch/libarchive-3.0.3[static-libs]
+ app-arch/xz-utils[static-libs]
+ sys-libs/ncurses[static-libs]
+ dev-libs/expat[static-libs]
+ app-arch/bzip2[static-libs]
+ dev-libs/libedit[static-libs]
+ dev-libs/libxml2:2[static-libs]
+ dev-libs/openssl[static-libs]
+ sys-libs/zlib[static-libs]
+ sys-libs/readline[static-libs]
+ virtual/pkgconfig
+ =sys-freebsd/freebsd-lib-${RV}*[atm?,netware?]
+ =sys-freebsd/freebsd-sources-${RV}*
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/rescue"
+
+pkg_setup() {
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+}
+
+src_prepare() {
+ # As they are patches from ${WORKDIR} apply them by hand
+ cd "${WORKDIR}"
+ epatch "${FILESDIR}/${PN}"-8.0-pkgconfig_static_libarchive.patch
+ epatch "${FILESDIR}/${PN}"-7.1-zlib.patch
+ epatch "${FILESDIR}/${PN}"-9.1-libcleverlink.patch
+ epatch "${FILESDIR}/${PN}"-9.1-bsdtar.patch
+ epatch "${FILESDIR}/freebsd-sbin-bsdxml2expat.patch"
+}
diff --git a/sys-freebsd/freebsd-rescue/metadata.xml b/sys-freebsd/freebsd-rescue/metadata.xml
new file mode 100644
index 000000000000..8703f7b26e6d
--- /dev/null
+++ b/sys-freebsd/freebsd-rescue/metadata.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="zfs">Enable ZFS support.</flag>
+ <flag name="netware"> Build tools to work with NetWare protocols (IPX and NCP).</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-sbin/Manifest b/sys-freebsd/freebsd-sbin/Manifest
new file mode 100644
index 000000000000..9e1fe3f58d05
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/Manifest
@@ -0,0 +1,33 @@
+AUX adjkerntz-crontab 184 SHA256 f3b08140ea38bfe502b34dd8c69aa4a6b65b786d792828cce082be8f844345dc SHA512 28ecfd94257eca2d91323e4bac1920969e589a13f877f1d67c4be0dd5d0bf4585eba8f749ae04f2e0761d5860b76e0c04993350bbdeb52736584ea9df97c6093 WHIRLPOOL 883509014af5a6f3803993eb4fc9f53608b08eaffdfcb409be3945d8234ab66b6a99c620b781a8d650aaeaff1f05db2e5249fb280f9a2bb079421062be3e5332
+AUX freebsd-sbin-10.0-zlib.patch 861 SHA256 9e2b89c1def6424b4a628d286ced8554f5f59bdf890e647f5b07e431e4bc9351 SHA512 8a6e14d15e44e9de22863c65cd359cc408207a4329ecdfe053317fd120d01025f5d42b958447ed0bb2e584cc050391306438934ac8cae0edc4a6a785da8138b7 WHIRLPOOL ebad6febc4ebdd4355fe6a60f99af13d2b15e52f538a6c677705401982e1e55556234df7099c570fa7e6fa5ee9c9264e5a394382c626919d43c214d21023d6ba
+AUX freebsd-sbin-6.1-pr102701.patch 548 SHA256 dccf32386359a2cfd80272c86085467d612c8f4d7924a6a223cd1259a8b7a176 SHA512 2b882565670ffe559410b17e2fa6a94624eee89d25a791ef3e27d657dedcf95b2be282217a2350203af7727b839d5d6ff50368f72c4bef3d7e60fef8a6325cbe WHIRLPOOL 14db7a26e6189314cc9a0e8ff5ccd01bedba178d9ddff856df262b18ce35fbd85999f5f4a612c2388af8718c6a1c0b544db4287bca08356fa5fb191f1cccf978
+AUX freebsd-sbin-6.2-ldconfig.patch 389 SHA256 b3fd47a733d39dea3400bee180d156ed09ff4c19dd47fbf5df52af33bdc5dc2b SHA512 ed8f6073991ba0c8823aea1570e720273d7dc68ec6daf38d7e1d41f2285d307d7905cf674a1148d4783c69f2dafd7fc8a51e729aa4727eb46d857218ab2d71ed WHIRLPOOL 3ecccd7b56c9bee820ca92b8a6a446a1bf69e61e889324407f2e76336eb0328b1162c7dc5d5f24505ec1f36d235bfe33fbecc5c5d60bf0f04741eeca9eb5b1cb
+AUX freebsd-sbin-7.1-zlib.patch 800 SHA256 18c028bf1b51cf7c57d5517d8fe6f3221c8a4d00d1ae436e40af0d1cd095bc4f SHA512 54db6c1ad6030002fb1b5848e75470136a2b0b3d0c5398e1e0b3439c0bb736eb1ffa4799da7a3775a29761196a2c09a9cf70f75244de7d4e99bfe07357ed759c WHIRLPOOL cc5572b6ed34cb0462da77edf714e92ba10b672a315b216f342d200f0081ffdc417936b69cdf9e7e5ba8e1451f509fe222d366c84d98a005999c2987ae08d3ef
+AUX freebsd-sbin-bsdxml2expat.patch 424 SHA256 f40f55bec52d0e3e0205c363ad624a1139a74d5de36f99ca2ff9e53583bc2287 SHA512 f455db40e528c9bf19a68a639d2c0b304371d66741ee852c279246647f43620fd33911787aa9721547e086cbaa7dafa85b1ee6571094593c74de15e2ccc2f522 WHIRLPOOL 9409fa6d31a1a9b7dad59a6bdd820319c8a895b27c130af7d29e0db969be6760c4ab7df952420fb4fca9445fe0433b3aca5377f509852261d0f6b4e5a2fbd72b
+AUX freebsd-sbin-setXid.patch 541 SHA256 2d8158df7af52f9ce15f1513d16ed08ea6244f310aea3f271b12184a6a4c4267 SHA512 e6f1aefab22eca6941a5b62f6f9d9c82e0efc2b308ec636ecab40d9a678e87f2f6ccfefac99f5367ad8a16d18ddadf9a877a2f93697248b3f38a09edac75ec6e WHIRLPOOL a2d578ff3b54ad25875f65d6724d0762c0fc3a400aa8e14c93ab94dc789910fbc6ab70528cbd0074fd0d7a4957a2d2d51bf10f615cbfd751aa4e95edc88d4e7d
+AUX idmapd.initd 441 SHA256 876ef332062f6e0335bd09152e6289ac1df8827cbf5d24d43b704e01ca875bce SHA512 69e548dd863c12dd9d525d9dd77ed06fd0418b6744c97899766d73aca26b60d12f27c791720b195c46b244fd2f3effd47d43b4fa277f795f402494f991837714 WHIRLPOOL 33e800223fac44ca8e476449044d75b274e1b1db7e8c6f1c615f4479b51f5f0255c15d46d9ea39888a8a2d0b419a6ce9786a9d9869ed81cde90b52e11fefa55d
+DIST freebsd-contrib-8.2.tar.bz2 40931651 SHA256 8b9cb688e81c2980b3fc66411d00ab277a24dadd50d5bdd5e0e6c63ac687b9b6 SHA512 4f7bf825b579fbb88f2aac531d07e531474179c63fa0b66c4e80821290a8c94bf611bb4dcaef51b762aacd25b11dfae798a4ec3bad3b9e3f6b3490ebfaa72476 WHIRLPOOL edd3d9e26e8d22d9028082e107ec1a44402e206dab8722f34b445676959305996c3f699152af42ace249b7f58498492787823b172fb6bcb273119c6bb50a35f0
+DIST freebsd-contrib-9.1.tar.bz2 54751432 SHA256 e7ffa056d4050ce03ee8e23e276e2a9a494326a98d60c43bee2afcc59576deb8 SHA512 71be13049258c6e6b5e4f63cc16da5d349a89d68f04d87446e4ad33ae8bf2a93ea67d9c256b7bec60b61e65db0487268070cfb77a484c3ac0f8ba368b48c2438 WHIRLPOOL a2a84423175499208d34809e802284d6ba649f317c3a9ad8b7312fa19efe142ebadab0048bac0db8e988e59f9a7468ac7c5d0d25e78b82bdb269a20d18153cee
+DIST freebsd-etc-8.2.tar.bz2 188629 SHA256 6bc745fa259f9fa2b65df865d45443a7b23c24445195e33a4ac50bf1040ae238 SHA512 3e5c106754a6a1ac806bd46b711fba7ee9cb31a4eab5262c995a5d59dbeb02f756dd8b495640dda94189d204a5d2c5218de2bd23467172d6a4ebe1048986e89c WHIRLPOOL 23b658a214f1a64c43420351020e32b1182e9aac3ed5253f49ee86f9cee9166ce32bd556cd2a2b3c0e60a165462a8700f37dea19e57ad5716415e17f61da912e
+DIST freebsd-etc-9.1.tar.bz2 207776 SHA256 a317bf85532d6192f5506e8d7bd5d5c201fe24017700e3a974a7712c2c69cdb8 SHA512 4fbe56fde519cf2f44e39a8869efa26c34f703cf540f4a83389da8d170873d7c6fb18e4010e643b8d793cfc5c55d15eeb198057a5b2a8da9d9e8f791801bf314 WHIRLPOOL 0c27019fe140fe96f870697acbaa89ac2f281f55b892c5791b08abf1cfa4da94d9d42a1df1c2091317573ed7234253857aecb797065f911a0a5d57bbf64349a5
+DIST freebsd-lib-8.2.tar.bz2 3323878 SHA256 e3590c12794fcb5ba8eb7a1f58b497587cf19f9200b3254c194a793da3b5bfb0 SHA512 c059cfdd1099bb519b2a5c43fb7e7104c500ef8906229ed7eb9e420cb3a217cdaf8655e9e7a9f45cfadc5491f8115e0e738fd49251d9f0c3a83780845b09f007 WHIRLPOOL 95f98a372f44a89bc8ac3029ec065dbbfec338e6f889d057d75644bfcdfb9d27fdc0421d7e392cad5a823712b97f0857297ec3d321580254c63032c22b95792e
+DIST freebsd-lib-9.1.tar.bz2 3206685 SHA256 f31fa8107b4de711c548f6d0c1bb1f81d09f51bcc3b14a1e9e90bb0e7cc4a35d SHA512 40d0c36b6b889c404fa0e0afa38ba4e84a55bc88ffa2f98a70afbd7a32c4f32c158617ba770567d082a986d62c09b3ec8db3dc5ab853ee1c9bbe0b90bb82396e WHIRLPOOL 581878bf9c43184b043b4293409b85901c9ed1f9bd279e965414aca41ba50950848ebda3ee10a503a028135dfd2765e95a11acd4e62a11c528e104392bbbd8d0
+DIST freebsd-libexec-8.2.tar.bz2 289147 SHA256 10b996d1d8cd044ee2e7a877e5e6ad2bf050cce9b3bd402a5e0dea7d290b595d SHA512 abe6cf5a268675d7dcb1c214c46fef47a3fb09b31947f5d8a0b938d352295efe0249beb5007649c52187bf4c221b6ebf074d18dfe9bafd168cae09ee02ab608d WHIRLPOOL 27e854fe465eb933dd8e27c5a09b063e4d3798b54e0914c79a9120dcdc34cc5d525a0c92da7b645ff7ab2ab4f34c7f7b2783012dfa5004407acd11150062b7ad
+DIST freebsd-libexec-9.1.tar.bz2 304592 SHA256 71e6e9e41328c2148c54b81ad9b59f912a1d5f0d52e17ac07f223aa7a94b82be SHA512 7baa4160dda2610250dd52f445e24478e0f1ea10bce21fcd0e5d1b856f399b896adc334114de0c7f61a5637e4349bb1688fdbe5c72798d8568ae791114710b92 WHIRLPOOL d800f477ac5c9ad6dae3e0091c83e107609b5a1e3aa79e9533fcd10a8dd34ff7733ab9523eae7c292310fe94f6a529209cae6b9e8bac6b47244e59834593e74b
+DIST freebsd-sbin-8.2.tar.bz2 1211665 SHA256 8b7e21a66b4696e8763d29b8b02b2d35f29fc51820a194d1e469e7cace84c527 SHA512 c6643c29ab62344c98d8991708798730ee1c17e6478071718beeaa79788300a1f4ed2e6aeb8e39e3c216877d4ed2ac85b2a9531d534f1ac5125a508927898959 WHIRLPOOL 2a21cd0f15f95d66718031680ac87f1fe73f1e1b03cb012e1db1dd1bd2fe2bb7897457a8ba2f5a28c8806775611dca542cbadec16566c47ab9efa673e2cb53f3
+DIST freebsd-sbin-9.1.tar.bz2 1273913 SHA256 45008b0733b232ef03707ef5fa3e5c889e3b3728393d736bd9a869ea83be6447 SHA512 9f186602b7de96f268c352ca386986652fddf5570e7eca1afa8c0d2bdc83b57df1198efe47f36dd5c7a6abf4f9c935f1c8207a4a12a6b2153bd6c3c6292719dc WHIRLPOOL 20920dfa9607a0ce854319cef29bbd77fb1b31f6f6cfd5ac60cbd678169e43929e215743fe636d0c224443f3e6149a8f07c292d647f7f901592795ac292699f9
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+DIST freebsd-sys-8.2.tar.bz2 25835329 SHA256 0c6c7b61aae94db2931f985d5899f3bca78fc8ffab6b598fbaa158142d676f16 SHA512 6ea4516a5c52e25c4f993f7acb875463a5caea93dbdf250c5d48eee95fff226956e9f030cab7e341b5e6a132325bc3dbf93dcb4b1185acb011918e50b1a22be3 WHIRLPOOL 870deeff877c6b9fc812a4260e4fdbb6715a5dc2065cab3bfbf2a42d876f6654703ccb124275a4e2c410cef48f3db02b63cc76059eccf9cf90244826f35b7a15
+DIST freebsd-sys-9.1.tar.bz2 32588103 SHA256 b93a7ac8334ac16cc9f60665048e5ef812c0a6c62f10d0b0a674aec3f56516a8 SHA512 7dc9d9e00dde8f592bb171f4386d02b655b73cb4f153fe5ec063d010a148ef0639eae0dcdb3eeb09ecd1e3653c69e49a2d261329fa6d0381d2ddabe258ddde6d WHIRLPOOL c8348344dfb14bad64bd3a78ee615ddd29203175b292233254f8ba175e7a3fb7218af6f95f7b4dbf394c0354bafe9d8bb0c21cdf0ceaeb697214964b280469b3
+DIST freebsd-usbin-8.2.tar.bz2 2443024 SHA256 aa7cabf10f5c3a9daabea32e4de24d04ec312247842981476da666eff5054603 SHA512 bcb8ff3df54848b9107bbb52e5ced7a91e24bb181f06769b6997221729b8064ec17652eaf7500de3268cbcb63ff5760beb54d15fc78c27b02687b5b1067c74a6 WHIRLPOOL 20f5278e2a1dd387a75b44f10507958d6c0e84a2faa1bddbf808c14ab86d8dd14a956192911bbc1880f5f5f7bd05972dcbb4aec85d241f0dcf91bf4246883f0a
+DIST freebsd-usbin-9.1.tar.bz2 2670916 SHA256 b938c20b8c09aa9a610e13b69b9afeea72f561ab3636a59fba2bdac290f4db75 SHA512 21c234312f70eb35cd2926519efc1f61592892f5d0940786dbeb959c3c5ec7819a51ae95c6e8a1a06aa01f669350fe0fd3dd7c4ec8a84dd6b90f24cb192356ca WHIRLPOOL 7f6ad2eb5410cc5e685881654a788807848af026b1277a974682755ab7c9db28f576bfd1576441ea10c5f1e9edb7d30a4a23fb8eccd6d69d86ecc9ce4c9adc7e
+EBUILD freebsd-sbin-10.3.ebuild 2571 SHA256 afcad42d73209acf407f93d4798b1d6e01693ca0ff3e91f94fb7a8a97fa51377 SHA512 5c35a35123fe063088db3c9f27f56e412fbd7dd155800ae8901d375a92ee6b11dcd2665aa134cb0eba534e3c3324988c7ab29b2a857b936c5b5d54b36c8ff483 WHIRLPOOL b2528e87451dc5a1b57c26de889ab1746fd38e0ea3eff8768e68dabe9d5298dfe17cdb1dbda0ed927ebb125c9ef53f5148e36e292e1c35cacc433504d74e9583
+EBUILD freebsd-sbin-11.0.ebuild 2531 SHA256 96ecc60a6fab9646567d8448ae293f391182128ed5cf3bad79f0e2c2fc14b7a7 SHA512 4c1264e0596782f51b0bfade8184ca18d0cbc69a4539ddeb12cdc1b3e6c096d8f38f2aa850574fe55fb92ea13eb53bc884015856dc59bfa8510c137c549560df WHIRLPOOL ea260f7fca1d233f02e93f9435cc42b93af47697fb9f926a7a7f43c5883ddc204a1626e6f40c59a3cfbdd005c1e059689509a7fcb7310e926d1e5d0f256c13f2
+EBUILD freebsd-sbin-11.1.ebuild 2658 SHA256 5a4c42b1b472c733df32cc6425e42a392aa40c6368b2457f5f9a41425a388598 SHA512 9f04e9c38c4040fc95075368e6a6133f8c98e48647249634fce0962372f032c48e82f76d7fe164efc4ff96ff73038875ee8d75445d33564b63df4229f7dfe0a4 WHIRLPOOL ea85a85aca5a91d5fb3ac5461ad4712d79670a2da19fd4b4fb1a015fcae68fe5a11e6160a7ff024271a5f3af5fe8be2201c0dfeb75332efea155d720e14b33d4
+EBUILD freebsd-sbin-8.2-r1.ebuild 2554 SHA256 cac32495f7ecbea4a36b75cae07b1ad12e0085fe32881103a82f6c9981aa4b8c SHA512 f8e7eb0416726aa824ab309b298f8d16a43694deecd8740fe9abe071f6bac40d5b2827bf74e0e89701684718a686a05a8586b093fe10d2a1b3b3138b9c3341d5 WHIRLPOOL 8e2160b7ba2e01790fbd0b15f269e51ecdfa29406d57b00556555caeedf974ec77b20a1717e81552370eea33852a19913cb170eb99b94091790a40c2c26abb87
+EBUILD freebsd-sbin-9.1.ebuild 2668 SHA256 fd53175a6db272119f41103524f5f0f95dbc392bb6474cc322b011ed25aaf0e1 SHA512 e6d9ac18f8ee6118228cdad1fc2b2a8ebe7237fa491873cdf37f894420d26b0244c25c7d9d24bfa25b417ed81523890ffc2bfd1b77260a622e5192379ef72b4e WHIRLPOOL 4abecb1f8a4a09ae0fcdbcb435e76386dc6cd2c60cdea7f3f63ce97ce7e01537af83a23bf151b0e3d21819e879664588a1efa3eac66e8dad436486b9795f707b
+MISC ChangeLog 4622 SHA256 8286b2f25527d0dbae7764c64b0cdcfe1336ac98fd181694f97dd83a0a0c39f0 SHA512 5ba131a0af6eccd4c98265440c87f9ff96d3da20781a3ebb5d2c36e5ed90783ac2341e1e23ac8a390ef4131d734a4120e33a82f8e7531c6b27cff786f046ad17 WHIRLPOOL afe9a3165261405a3b2224e028db1f8d996fcc2bc4d3ecc7b6a4f79f1d2b140814bbae6f300a723fffcd12a5b5d2b14af979e1be33ee9884d91bbd305dee598e
+MISC ChangeLog-2015 16463 SHA256 5222a4fc2db748e9a3407a67c960ed6f3fc43bbaef543481e75d792e1b6a22e5 SHA512 681d0d4702acf96951f21baadf713e11f2222c9f79693346811afae880351575c4a8b71c034d8abd153cd2108b94a80735c630f2da4201464a33ed15191077d3 WHIRLPOOL d94e0cf0d03450daa97abeb244d07265d58b67fb2665dbb9f6530586005d7a138058373d625b713f51c5f32b83c97b8eb720f4b746a1daaaf8a30987087558d3
+MISC metadata.xml 611 SHA256 814de8ee234fea786a1e52e9447a8e3d4141f9d5a4eb30877b0934bca17d5149 SHA512 f5564d34b62dfd20fda9ce5e17de3fc45b9d281de062e8858aa090049218ee5a05670967111032bce63363ae64a98ba39753964c013e12aaf5e15e90719a720e WHIRLPOOL 389bfa663faceea1aec6bdca66173c339a5608f6f06bab8574df42985faf9bf5fa9cc442e55ab668f6ca73cab2eed8524e4673e0a85f93e0b2771e4a02a2671a
diff --git a/sys-freebsd/freebsd-sbin/files/adjkerntz-crontab b/sys-freebsd/freebsd-sbin/files/adjkerntz-crontab
new file mode 100644
index 000000000000..5fc46f5bf48e
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/adjkerntz-crontab
@@ -0,0 +1,4 @@
+# Adjust the time zone if the CMOS clock keeps local time, as opposed to
+# UTC time. See adjkerntz(8) for details.
+1,31 0-5 * * * root /sbin/adjkerntz -a
+
diff --git a/sys-freebsd/freebsd-sbin/files/freebsd-sbin-10.0-zlib.patch b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-10.0-zlib.patch
new file mode 100644
index 000000000000..c0a2bf923c23
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-10.0-zlib.patch
@@ -0,0 +1,22 @@
+diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
+index bdbf7e3..a4c67ec 100644
+--- a/sbin/savecore/savecore.c
++++ b/sbin/savecore/savecore.c
+@@ -92,7 +92,7 @@ static int checkfor, compress, clear, force, keep, verbose; /* flags */
+ static int nfound, nsaved, nerr; /* statistics */
+ static int maxdumps;
+
+-extern FILE *zopen(const char *, const char *);
++extern FILE *gzopen(const char *, const char *);
+
+ static sig_atomic_t got_siginfo;
+ static void infohandler(int);
+@@ -626,7 +626,7 @@ DoFile(const char *savedir, const char *device)
+ if (compress) {
+ snprintf(corename, sizeof(corename), "%s.%d.gz",
+ istextdump ? "textdump.tar" : "vmcore", bounds);
+- fp = zopen(corename, "w");
++ fp = gzopen(corename, "w");
+ } else {
+ snprintf(corename, sizeof(corename), "%s.%d",
+ istextdump ? "textdump.tar" : "vmcore", bounds);
diff --git a/sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.1-pr102701.patch b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.1-pr102701.patch
new file mode 100644
index 000000000000..7b9578c40c87
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.1-pr102701.patch
@@ -0,0 +1,17 @@
+Solves the issue reported in Problem Report bin/102701.
+
+Can't delete an inet6 alias address from an interface.
+
+Index: fbsd-6.1/sbin/ifconfig/af_inet6.c
+===================================================================
+--- fbsd-6.1.orig/sbin/ifconfig/af_inet6.c
++++ fbsd-6.1/sbin/ifconfig/af_inet6.c
+@@ -515,7 +515,7 @@ static struct afswtch af_inet6 = {
+ .af_settunnel = in6_set_tunnel,
+ .af_difaddr = SIOCDIFADDR_IN6,
+ .af_aifaddr = SIOCAIFADDR_IN6,
+- .af_ridreq = &in6_addreq,
++ .af_ridreq = &in6_ridreq,
+ .af_addreq = &in6_addreq,
+ };
+
diff --git a/sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.2-ldconfig.patch b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.2-ldconfig.patch
new file mode 100644
index 000000000000..81ad02461681
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-6.2-ldconfig.patch
@@ -0,0 +1,13 @@
+diff -ur sbin.orig/ldconfig/elfhints.c sbin/ldconfig/elfhints.c
+--- sbin.orig/ldconfig/elfhints.c 2001-05-03 00:56:18 +0100
++++ sbin/ldconfig/elfhints.c 2007-08-06 10:16:24 +0100
+@@ -245,6 +245,9 @@
+ else
+ add_dir(hintsfile, argv[i], 0);
+ }
++ /* Always add our system dirs */
++ add_dir (hintsfile, "/lib", 1);
++ add_dir (hintsfile, "/usr/lib", 1);
+ write_elf_hints(hintsfile);
+ }
+
diff --git a/sys-freebsd/freebsd-sbin/files/freebsd-sbin-7.1-zlib.patch b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-7.1-zlib.patch
new file mode 100644
index 000000000000..22fb2ec62d4f
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-7.1-zlib.patch
@@ -0,0 +1,21 @@
+diff -ur sbin/savecore/savecore.c sbin-zlib/savecore/savecore.c
+--- sbin/savecore/savecore.c 2005-02-26 01:21:50 +0000
++++ sbin-zlib/savecore/savecore.c 2005-05-06 12:00:06 +0000
+@@ -95,7 +95,7 @@
+ static int checkfor, compress, clear, force, keep, verbose; /* flags */
+ static int nfound, nsaved, nerr; /* statistics */
+
+-extern FILE *zopen(const char *, const char *);
++extern FILE *gzopen(const char *, const char *);
+
+ static void
+ printheader(FILE *f, const struct kerneldumpheader *h, const char *device,
+@@ -553,7 +553,7 @@
+ if (compress) {
+ sprintf(filename, "%s.%d.gz", istextdump ? "textdump.tar" :
+ "vmcore", bounds);
+- fp = zopen(filename, "w");
++ fp = gzopen(filename, "w");
+ } else {
+ sprintf(filename, "%s.%d", istextdump ? "textdump.tar" :
+ "vmcore", bounds);
diff --git a/sys-freebsd/freebsd-sbin/files/freebsd-sbin-bsdxml2expat.patch b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-bsdxml2expat.patch
new file mode 100644
index 000000000000..bdda99b8c0da
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-bsdxml2expat.patch
@@ -0,0 +1,13 @@
+diff -uNr sbin/ifconfig.old/regdomain.c sbin/ifconfig/regdomain.c
+--- sbin/ifconfig.old/regdomain.c 2010-12-21 17:09:25.000000000 +0000
++++ sbin/ifconfig/regdomain.c 2011-07-10 15:56:27.000000000 +0000
+@@ -39,7 +39,7 @@
+ #include <err.h>
+ #include <unistd.h>
+
+-#include <bsdxml.h>
++#include <expat.h>
+
+ #include "regdomain.h"
+
+Los ficheros binarios sbin/ifconfig.old/regdomain.o y sbin/ifconfig/regdomain.o son distintos
diff --git a/sys-freebsd/freebsd-sbin/files/freebsd-sbin-setXid.patch b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-setXid.patch
new file mode 100644
index 000000000000..c8cbebc68c2b
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/freebsd-sbin-setXid.patch
@@ -0,0 +1,20 @@
+diff -ur sbin.orig/ping/Makefile sbin.setXid/ping/Makefile
+--- sbin.orig/ping/Makefile Thu Apr 7 20:27:57 2005
++++ sbin.setXid/ping/Makefile Thu Apr 7 20:42:02 2005
+@@ -18,4 +18,6 @@
+ LDADD+= -lipsec
+ .endif
+
++LDFLAGS+= -Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur sbin.orig/shutdown/Makefile sbin.setXid/shutdown/Makefile
+--- sbin.orig/shutdown/Makefile Thu Apr 7 20:27:57 2005
++++ sbin.setXid/shutdown/Makefile Thu Apr 7 20:42:17 2005
+@@ -7,4 +7,6 @@
+ BINGRP= operator
+ BINMODE=4550
+
++LDFLAGS+= -Wl,-z,now
++
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-sbin/files/idmapd.initd b/sys-freebsd/freebsd-sbin/files/idmapd.initd
new file mode 100644
index 000000000000..60a0bb8ad30e
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/files/idmapd.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need rpcbind
+}
+
+start() {
+ ebegin "Starting NFS idmapd"
+ start-stop-daemon --start --quiet --exec \
+ /sbin/idmapd -- $idmapdopts
+ eend $? "Error starting NFS idmapd"
+}
+
+stop() {
+ ebegin "Stopping NFS idmapd"
+ start-stop-daemon --stop --quiet --exec /sbin/idmapd
+ eend $? "Error stopping NFS idmapd"
+}
diff --git a/sys-freebsd/freebsd-sbin/freebsd-sbin-10.3.ebuild b/sys-freebsd/freebsd-sbin/freebsd-sbin-10.3.ebuild
new file mode 100644
index 000000000000..99c4a3b6aed2
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/freebsd-sbin-10.3.ebuild
@@ -0,0 +1,100 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd multilib
+
+DESCRIPTION="FreeBSD sbin utils"
+SLOT="0"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ sbin/
+ contrib/
+ lib/
+ libexec/
+ usr.sbin/
+ etc/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[ipv6?,atm?,netware?]
+ =sys-freebsd/freebsd-libexec-${RV}*
+ >=dev-libs/expat-2.0.1
+ ssl? ( dev-libs/openssl:0= )
+ >=dev-libs/libedit-20120311.3.0-r1
+ sys-libs/readline:0=
+ || (
+ sys-process/cronie
+ sys-process/vixie-cron
+ )
+ atm? ( net-analyzer/bsnmp )"
+DEPEND="${RDEPEND}
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/sbin"
+
+IUSE="atm ipfilter +pf ipv6 build ssl +cxx netware"
+
+pkg_setup() {
+ # Add the required source files.
+ use build && EXTRACTONLY+="sys/ "
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use cxx || mymakeopts="${mymakeopts} WITHOUT_CXX="
+ use ipfilter || mymakeopts="${mymakeopts} WITHOUT_IPFILTER= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT="
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use pf || mymakeopts="${mymakeopts} WITHOUT_PF= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL="
+}
+
+REMOVE_SUBDIRS="dhclient pfctl pflogd rcorder resolvconf"
+
+PATCHES=( "${FILESDIR}/${PN}-setXid.patch"
+ "${FILESDIR}/${PN}-10.0-zlib.patch"
+ "${FILESDIR}/${PN}-6.2-ldconfig.patch"
+ "${FILESDIR}/${PN}-6.1-pr102701.patch"
+ "${FILESDIR}/${PN}-bsdxml2expat.patch" )
+
+src_prepare() {
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ use build || ln -s "/usr/src/sys" "${WORKDIR}/sys"
+ fi
+}
+
+src_install() {
+ mymakeopts="${mymakeopts} GEOM_CLASS_DIR=/$(get_libdir)/geom "
+ freebsd_src_install
+ keepdir /var/log
+ # Needed by ldconfig:
+ keepdir /var/run
+
+ # Maybe ship our own sysctl.conf so things like radvd work out of the box.
+ # New wireless config method requires regdomain.xml in /etc
+ cd "${WORKDIR}/etc/" || die
+ insinto /etc
+ doins minfree sysctl.conf regdomain.xml || die
+
+ # Install a crontab for adjkerntz
+ insinto /etc/cron.d
+ newins "${FILESDIR}/adjkerntz-crontab" adjkerntz
+
+ # Install the periodic stuff (needs probably to be ported in a more
+ # gentooish way)
+ cd "${WORKDIR}/etc/periodic" || die
+
+ doperiodic security \
+ security/*.ipfwlimit \
+ security/*.ipfwdenied || die
+
+ use ipfilter && { doperiodic security \
+ security/*.ipfdenied || die ; }
+
+ use pf && { doperiodic security \
+ security/*.pfdenied || die ; }
+}
diff --git a/sys-freebsd/freebsd-sbin/freebsd-sbin-11.0.ebuild b/sys-freebsd/freebsd-sbin/freebsd-sbin-11.0.ebuild
new file mode 100644
index 000000000000..5188b97c05b5
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/freebsd-sbin-11.0.ebuild
@@ -0,0 +1,99 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd multilib
+
+DESCRIPTION="FreeBSD sbin utils"
+SLOT="0"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ sbin/
+ contrib/
+ lib/
+ libexec/
+ usr.sbin/
+ etc/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[ipv6?,atm?,netware?]
+ =sys-freebsd/freebsd-libexec-${RV}*
+ >=dev-libs/expat-2.0.1
+ ssl? ( dev-libs/openssl:0= )
+ >=dev-libs/libedit-20120311.3.0-r1
+ sys-libs/readline:0=
+ || (
+ sys-process/cronie
+ sys-process/vixie-cron
+ )
+ atm? ( net-analyzer/bsnmp )"
+DEPEND="${RDEPEND}
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/sbin"
+
+IUSE="atm ipfilter +pf ipv6 build ssl +cxx netware"
+
+pkg_setup() {
+ # Add the required source files.
+ use build && EXTRACTONLY+="sys/ "
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use cxx || mymakeopts="${mymakeopts} WITHOUT_CXX="
+ use ipfilter || mymakeopts="${mymakeopts} WITHOUT_IPFILTER= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT="
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use pf || mymakeopts="${mymakeopts} WITHOUT_PF= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL="
+}
+
+REMOVE_SUBDIRS="dhclient pfctl pflogd rcorder resolvconf"
+
+PATCHES=( "${FILESDIR}/${PN}-setXid.patch"
+ "${FILESDIR}/${PN}-10.0-zlib.patch"
+ "${FILESDIR}/${PN}-6.2-ldconfig.patch"
+ "${FILESDIR}/${PN}-6.1-pr102701.patch" )
+
+src_prepare() {
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ use build || ln -s "/usr/src/sys" "${WORKDIR}/sys"
+ fi
+}
+
+src_install() {
+ mymakeopts="${mymakeopts} GEOM_CLASS_DIR=/$(get_libdir)/geom "
+ freebsd_src_install
+ keepdir /var/log
+ # Needed by ldconfig:
+ keepdir /var/run
+
+ # Maybe ship our own sysctl.conf so things like radvd work out of the box.
+ # New wireless config method requires regdomain.xml in /etc
+ cd "${WORKDIR}/etc/" || die
+ insinto /etc
+ doins minfree sysctl.conf regdomain.xml || die
+
+ # Install a crontab for adjkerntz
+ insinto /etc/cron.d
+ newins "${FILESDIR}/adjkerntz-crontab" adjkerntz
+
+ # Install the periodic stuff (needs probably to be ported in a more
+ # gentooish way)
+ cd "${WORKDIR}/etc/periodic" || die
+
+ doperiodic security \
+ security/*.ipfwlimit \
+ security/*.ipfwdenied || die
+
+ use ipfilter && { doperiodic security \
+ security/*.ipfdenied || die ; }
+
+ use pf && { doperiodic security \
+ security/*.pfdenied || die ; }
+}
diff --git a/sys-freebsd/freebsd-sbin/freebsd-sbin-11.1.ebuild b/sys-freebsd/freebsd-sbin/freebsd-sbin-11.1.ebuild
new file mode 100644
index 000000000000..09b3cbb45f8e
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/freebsd-sbin-11.1.ebuild
@@ -0,0 +1,102 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd multilib
+
+DESCRIPTION="FreeBSD sbin utils"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ sbin/
+ contrib/
+ lib/
+ libexec/
+ usr.sbin/
+ etc/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[ipv6?,atm?,netware?]
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )
+ >=dev-libs/expat-2.0.1
+ ssl? ( dev-libs/openssl:0= )
+ >=dev-libs/libedit-20120311.3.0-r1
+ sys-libs/readline:0=
+ || (
+ sys-process/cronie
+ sys-process/vixie-cron
+ )
+ atm? ( net-analyzer/bsnmp )"
+DEPEND="${RDEPEND}
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/sbin"
+
+IUSE="atm ipfilter +pf ipv6 build ssl +cxx netware zfs"
+
+pkg_setup() {
+ # Add the required source files.
+ use build && EXTRACTONLY+="sys/ "
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use cxx || mymakeopts="${mymakeopts} WITHOUT_CXX="
+ use ipfilter || mymakeopts="${mymakeopts} WITHOUT_IPFILTER= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT="
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use pf || mymakeopts="${mymakeopts} WITHOUT_PF= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+}
+
+REMOVE_SUBDIRS="dhclient pfctl pflogd rcorder resolvconf"
+
+PATCHES=( "${FILESDIR}/${PN}-setXid.patch"
+ "${FILESDIR}/${PN}-10.0-zlib.patch"
+ "${FILESDIR}/${PN}-6.2-ldconfig.patch"
+ "${FILESDIR}/${PN}-6.1-pr102701.patch" )
+
+src_prepare() {
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ use build || ln -s "/usr/src/sys" "${WORKDIR}/sys"
+ fi
+}
+
+src_install() {
+ mymakeopts="${mymakeopts} GEOM_CLASS_DIR=/$(get_libdir)/geom "
+ freebsd_src_install
+ keepdir /var/log
+ # Needed by ldconfig:
+ keepdir /var/run
+
+ # Maybe ship our own sysctl.conf so things like radvd work out of the box.
+ # New wireless config method requires regdomain.xml in /etc
+ cd "${WORKDIR}/etc/" || die
+ insinto /etc
+ doins minfree sysctl.conf regdomain.xml || die
+
+ # Install a crontab for adjkerntz
+ insinto /etc/cron.d
+ newins "${FILESDIR}/adjkerntz-crontab" adjkerntz
+
+ # Install the periodic stuff (needs probably to be ported in a more
+ # gentooish way)
+ cd "${WORKDIR}/etc/periodic" || die
+
+ doperiodic security \
+ security/*.ipfwlimit \
+ security/*.ipfwdenied || die
+
+ use ipfilter && { doperiodic security \
+ security/*.ipfdenied || die ; }
+
+ use pf && { doperiodic security \
+ security/*.pfdenied || die ; }
+}
diff --git a/sys-freebsd/freebsd-sbin/freebsd-sbin-8.2-r1.ebuild b/sys-freebsd/freebsd-sbin/freebsd-sbin-8.2-r1.ebuild
new file mode 100644
index 000000000000..430a320ac379
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/freebsd-sbin-8.2-r1.ebuild
@@ -0,0 +1,93 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=2
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD sbin utils"
+KEYWORDS="~sparc-fbsd ~x86-fbsd"
+SLOT="0"
+
+SRC_URI="mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${LIBEXEC}.tar.bz2
+ mirror://gentoo/${USBIN}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2
+ build? ( mirror://gentoo/${SYS}.tar.bz2 )"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[ipv6?,atm?,netware?]
+ =sys-freebsd/freebsd-libexec-${RV}*
+ >=dev-libs/expat-2.0.1
+ ssl? ( dev-libs/openssl )
+ dev-libs/libedit
+ sys-libs/readline
+ || (
+ sys-process/cronie
+ sys-process/vixie-cron
+ )
+ atm? ( net-analyzer/bsnmp )"
+DEPEND="${RDEPEND}
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/sbin"
+
+IUSE="atm ipfilter +pf ipv6 build ssl +cxx netware"
+
+pkg_setup() {
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use cxx || mymakeopts="${mymakeopts} WITHOUT_CXX="
+ use ipfilter || mymakeopts="${mymakeopts} WITHOUT_IPFILTER= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT="
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use pf || mymakeopts="${mymakeopts} WITHOUT_PF= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL="
+}
+
+REMOVE_SUBDIRS="dhclient pfctl pflogd rcorder"
+
+PATCHES=( "${FILESDIR}/${PN}-setXid.patch"
+ "${FILESDIR}/${PN}-7.1-zlib.patch"
+ "${FILESDIR}/${PN}-6.2-ldconfig.patch"
+ "${FILESDIR}/${PN}-6.1-pr102701.patch"
+ "${FILESDIR}/${PN}-bsdxml2expat.patch" )
+
+src_prepare() {
+ use build || ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys"
+}
+
+src_install() {
+ freebsd_src_install
+ keepdir /var/log
+ # Needed by ldconfig:
+ keepdir /var/run
+
+ # Maybe ship our own sysctl.conf so things like radvd work out of the box.
+ # New wireless config method requires regdomain.xml in /etc
+ cd "${WORKDIR}/etc/"
+ insinto /etc
+ doins minfree sysctl.conf regdomain.xml || die
+
+ # initd script for idmapd
+ newinitd "${FILESDIR}/idmapd.initd" idmapd
+
+ # Install a crontab for adjkerntz
+ insinto /etc/cron.d
+ newins "${FILESDIR}/adjkerntz-crontab" adjkerntz
+
+ # Install the periodic stuff (needs probably to be ported in a more
+ # gentooish way)
+ cd "${WORKDIR}/etc/periodic"
+
+ doperiodic security \
+ security/*.ipfwlimit \
+ security/*.ipfwdenied || die
+
+ use ipfilter && { doperiodic security \
+ security/*.ipfdenied || die ; }
+
+ use pf && { doperiodic security \
+ security/*.pfdenied || die ; }
+}
diff --git a/sys-freebsd/freebsd-sbin/freebsd-sbin-9.1.ebuild b/sys-freebsd/freebsd-sbin/freebsd-sbin-9.1.ebuild
new file mode 100644
index 000000000000..31c9d7794de8
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/freebsd-sbin-9.1.ebuild
@@ -0,0 +1,94 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=2
+
+inherit bsdmk freebsd multilib
+
+DESCRIPTION="FreeBSD sbin utils"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+SLOT="0"
+
+SRC_URI="mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${LIBEXEC}.tar.bz2
+ mirror://gentoo/${USBIN}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2
+ build? ( mirror://gentoo/${SYS}.tar.bz2 )"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[ipv6?,atm?,netware?]
+ =sys-freebsd/freebsd-libexec-${RV}*
+ >=dev-libs/expat-2.0.1
+ ssl? ( dev-libs/openssl )
+ >=dev-libs/libedit-20120311.3.0-r1
+ sys-libs/readline
+ || (
+ sys-process/cronie
+ sys-process/vixie-cron
+ )
+ atm? ( net-analyzer/bsnmp )"
+DEPEND="${RDEPEND}
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+S="${WORKDIR}/sbin"
+
+IUSE="atm ipfilter +pf ipv6 build ssl +cxx netware"
+
+pkg_setup() {
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use cxx || mymakeopts="${mymakeopts} WITHOUT_CXX="
+ use ipfilter || mymakeopts="${mymakeopts} WITHOUT_IPFILTER= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT="
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use pf || mymakeopts="${mymakeopts} WITHOUT_PF= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL="
+}
+
+REMOVE_SUBDIRS="dhclient pfctl pflogd rcorder resolvconf"
+
+PATCHES=( "${FILESDIR}/${PN}-setXid.patch"
+ "${FILESDIR}/${PN}-7.1-zlib.patch"
+ "${FILESDIR}/${PN}-6.2-ldconfig.patch"
+ "${FILESDIR}/${PN}-6.1-pr102701.patch"
+ "${FILESDIR}/${PN}-bsdxml2expat.patch" )
+
+src_prepare() {
+ use build || ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys"
+}
+
+src_install() {
+ mymakeopts="${mymakeopts} GEOM_CLASS_DIR=/$(get_libdir)/geom "
+ freebsd_src_install
+ keepdir /var/log
+ # Needed by ldconfig:
+ keepdir /var/run
+
+ # Maybe ship our own sysctl.conf so things like radvd work out of the box.
+ # New wireless config method requires regdomain.xml in /etc
+ cd "${WORKDIR}/etc/"
+ insinto /etc
+ doins minfree sysctl.conf regdomain.xml || die
+
+ # initd script for idmapd
+ newinitd "${FILESDIR}/idmapd.initd" idmapd
+
+ # Install a crontab for adjkerntz
+ insinto /etc/cron.d
+ newins "${FILESDIR}/adjkerntz-crontab" adjkerntz
+
+ # Install the periodic stuff (needs probably to be ported in a more
+ # gentooish way)
+ cd "${WORKDIR}/etc/periodic"
+
+ doperiodic security \
+ security/*.ipfwlimit \
+ security/*.ipfwdenied || die
+
+ use ipfilter && { doperiodic security \
+ security/*.ipfdenied || die ; }
+
+ use pf && { doperiodic security \
+ security/*.pfdenied || die ; }
+}
diff --git a/sys-freebsd/freebsd-sbin/metadata.xml b/sys-freebsd/freebsd-sbin/metadata.xml
new file mode 100644
index 000000000000..d5e743263983
--- /dev/null
+++ b/sys-freebsd/freebsd-sbin/metadata.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="ipfilter">
+ Build tools to administer the ipfilter firewall.
+ </flag>
+ <flag name="pf">
+ Build tools to administer the PF firewall.
+ </flag>
+ <flag name="netware">
+ Build libraries and tools to work with NetWare protocols (IPX
+ and NCP).
+ </flag>
+ <flag name="zfs">Enable ZFS support.</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-share/Manifest b/sys-freebsd/freebsd-share/Manifest
new file mode 100644
index 000000000000..dc24cee8fa35
--- /dev/null
+++ b/sys-freebsd/freebsd-share/Manifest
@@ -0,0 +1,35 @@
+AUX freebsd-share-10.0-gentoo-eapi3.patch 475 SHA256 504841c762c1fa82ac14c22e16b84543e88927608f3fb972d995caa89449e487 SHA512 b7fe870aafe1cf9029c1d1d9de16413b5be8354b1c2ba0d0eab6f0fe3076ab03da08ff764c923c087e246b90355a48d55acef9b9b5a29238ddf8c92bdb3ca0f8 WHIRLPOOL 58dd84d64cea1c149b0126d7e9567caf7dbe6f238b1434eb4ffde08496e45e268691ba8604ea80da863d06d3f6ac6aeff4e9f7a01d558a28a31f347ed6c0c4c9
+AUX freebsd-share-10.2-gnu-miscfiles.patch 913 SHA256 e2a7e8221753dabf78380b9820991ee067670b9593e3dc9d8ecc8bf487b1ebc8 SHA512 fa792f15e325117e4448b344ab3dbf64d3880719698d88d8dda60c8cc4afea8c11cb845f44fa3b78ddc98fc6b021ef9edac639f649e8d166d79bf2c0e4f654f5 WHIRLPOOL 3c9e15340a71a85f44df3cbc41a6bc46eba7f790410d1aa70266a342038c39dff2b3ec887c210afdde559fecc7c51fb5c0e1484db86d3fff1d5851c21d3f6f8d
+AUX freebsd-share-10.3-gentoo-skel.patch 600 SHA256 6860f0376babafbc0367bfde0d348fac1e4f95f42cdfd2931c3d7a027cd62536 SHA512 338eb369c50b11835f00474be5363bf6af43d8391a28a6e78e1517afc686b168fd0bfc32d45a78e79515c3d89a35b097548117cb2838b751d3d41330939c7dc2 WHIRLPOOL 1a833bc8e2376b25275d5be27dcc403cb8f7b498be08ab1532da1b27e77af32779a38b9a8d54b03d80f36b0ec398425269b58a04d9eea74fd2af5d91fec4d8b9
+AUX freebsd-share-5.3-doc-locations.patch 608 SHA256 d949e9081a181ab9443a18e56949905a77eff2cbd16d09d37b8abb5771cee3b6 SHA512 2156f679683b8a02fd01fa71268f13f342d282b1885095e48611d9a94bdf99f03bad71f5c22253425c09ad5ae1ea544d1db3d0d40361f3b814f7e10f0061f2a6 WHIRLPOOL bac15f5c439ffa81b83dfac5dce981e346e2815b6a035e9b9791db16df77d7f2e9fb6706f7b5315c65d18f209176866b23a34b311c56847f543f1257fa5e9634
+AUX freebsd-share-5.4-gentoo-skel.patch 621 SHA256 5480127971c2a5df5faf44355d5ed6a8586923577d37e6cff10805626726c767 SHA512 608e108bcfdc1eaa1f45f4115f460e26fa89211aaefea9602d1943dfa51e34f721526ef5e71d7e44f019d31b43efbd8f9f937e71d71074b0c3b48a33329281af WHIRLPOOL 8fabb340e4fcb1a174e3870a2ebe737f89b892586fed61a239e96bb34fb508daaef1e8e80811634e2075dbf6a161a236bca10a589340fbc609382f685b0697a9
+AUX freebsd-share-8.0-gnu-miscfiles.patch 858 SHA256 20b3761bd18d4ff8e7257ab006f9c23b99473809c138c44145e25832e0c79855 SHA512 0b10a29d7840b7839c819afba1beb0ba4c22af02a63400d90735ea4330413ab672bf247e375194e75746a858c5a2727d07cdf958a8618f9cf059b71105ea9853 WHIRLPOOL f8d6675121ac43d2672f77d7ea4215073ff213c311fc1c09fe367f2d86f7dc1791a95f31b6def6f5bb757a5cd682de4c373c91465aa05acd38acfb537e781a6a
+DIST freebsd-bin-8.2.tar.bz2 415900 SHA256 fb31b7fab259bda8396e615246f85dc99c3c9f7e98f4e4a613e20b6a394c4921 SHA512 c39b26f75f7d812f46e907acabd8dfaf45c97adf4488bcafa35fd46c805d821e177609d403cf5e677f3674020290199ac97059a0609f7705bce58a7aab3ee8e3 WHIRLPOOL 49e70b1c09c4b72b3f23850e8c9873556571ec02d70ade8f18f683eff6fa92dc8f6d02d58473fe7b4d8d1f3de96c63df41150b2091caafbc9a0e92e6055b43fd
+DIST freebsd-bin-9.1.tar.bz2 385664 SHA256 0a9524d75a8cb4c9c2654f2f9843087b09e8599bba97b9b59f00bc2e92b87e00 SHA512 fa0571a705befe1cb9c07285d3df55c9b5f4f295760511d668d80fec8cd4d59b70c676f07164f2aa44911decef0fb54fa6d78405ac2ceec822b6b8920abc5ca8 WHIRLPOOL 6f2bfe17604339e8260c49582bc941d255932b5c0a7b604e58187626a3a38766cd1e4aed9fc93a737ec9b4fa661f88aac23769b3542f35eb20da8b260216e985
+DIST freebsd-contrib-8.2.tar.bz2 40931651 SHA256 8b9cb688e81c2980b3fc66411d00ab277a24dadd50d5bdd5e0e6c63ac687b9b6 SHA512 4f7bf825b579fbb88f2aac531d07e531474179c63fa0b66c4e80821290a8c94bf611bb4dcaef51b762aacd25b11dfae798a4ec3bad3b9e3f6b3490ebfaa72476 WHIRLPOOL edd3d9e26e8d22d9028082e107ec1a44402e206dab8722f34b445676959305996c3f699152af42ace249b7f58498492787823b172fb6bcb273119c6bb50a35f0
+DIST freebsd-contrib-9.1.tar.bz2 54751432 SHA256 e7ffa056d4050ce03ee8e23e276e2a9a494326a98d60c43bee2afcc59576deb8 SHA512 71be13049258c6e6b5e4f63cc16da5d349a89d68f04d87446e4ad33ae8bf2a93ea67d9c256b7bec60b61e65db0487268070cfb77a484c3ac0f8ba368b48c2438 WHIRLPOOL a2a84423175499208d34809e802284d6ba649f317c3a9ad8b7312fa19efe142ebadab0048bac0db8e988e59f9a7468ac7c5d0d25e78b82bdb269a20d18153cee
+DIST freebsd-etc-8.2.tar.bz2 188629 SHA256 6bc745fa259f9fa2b65df865d45443a7b23c24445195e33a4ac50bf1040ae238 SHA512 3e5c106754a6a1ac806bd46b711fba7ee9cb31a4eab5262c995a5d59dbeb02f756dd8b495640dda94189d204a5d2c5218de2bd23467172d6a4ebe1048986e89c WHIRLPOOL 23b658a214f1a64c43420351020e32b1182e9aac3ed5253f49ee86f9cee9166ce32bd556cd2a2b3c0e60a165462a8700f37dea19e57ad5716415e17f61da912e
+DIST freebsd-etc-9.1.tar.bz2 207776 SHA256 a317bf85532d6192f5506e8d7bd5d5c201fe24017700e3a974a7712c2c69cdb8 SHA512 4fbe56fde519cf2f44e39a8869efa26c34f703cf540f4a83389da8d170873d7c6fb18e4010e643b8d793cfc5c55d15eeb198057a5b2a8da9d9e8f791801bf314 WHIRLPOOL 0c27019fe140fe96f870697acbaa89ac2f281f55b892c5791b08abf1cfa4da94d9d42a1df1c2091317573ed7234253857aecb797065f911a0a5d57bbf64349a5
+DIST freebsd-gnu-8.2.tar.bz2 815379 SHA256 34be1326b8e188427ea4a59de5dd24049f99adb5e172d61a645db1b7124f7876 SHA512 8b278e386b22b22658eef18341073c1c757b86ecdef5c5b543fb781cfee295d71cef599544eda5f8cf273fc22d28a1ab14d912086ff8398c36ee2b71281617d4 WHIRLPOOL aaf91562f147095e09a9f6aa2d4c33494f430cbe7340377edff1b8a44cc60edfe4af7ef90350018f0c80e82f5518110689cb582bb227d2360488dfbdd7bcb7c8
+DIST freebsd-gnu-9.1.tar.bz2 795778 SHA256 3b99c1fa1087bf69549e0990a0d7997954533ac9d7938c4760ec2b01aa509a5f SHA512 b05f2a5a10bdaeef19dfd0e962bc09f1571288a831e9345f404b920037f47db5c0ca3d620d1cbdd138b18bca1c3feab5b211b57e3041727341e5238cb9feb4fd WHIRLPOOL 4f776b99296c4fcc0d6f4d30a12b0773f6704292e1361826b260ce34dcc8e537ef7eb7c6332c4988e0e03bc84ca07fb18e6b2785fe4c6f175c08865b72d6bb0b
+DIST freebsd-lib-8.2.tar.bz2 3323878 SHA256 e3590c12794fcb5ba8eb7a1f58b497587cf19f9200b3254c194a793da3b5bfb0 SHA512 c059cfdd1099bb519b2a5c43fb7e7104c500ef8906229ed7eb9e420cb3a217cdaf8655e9e7a9f45cfadc5491f8115e0e738fd49251d9f0c3a83780845b09f007 WHIRLPOOL 95f98a372f44a89bc8ac3029ec065dbbfec338e6f889d057d75644bfcdfb9d27fdc0421d7e392cad5a823712b97f0857297ec3d321580254c63032c22b95792e
+DIST freebsd-lib-9.1.tar.bz2 3206685 SHA256 f31fa8107b4de711c548f6d0c1bb1f81d09f51bcc3b14a1e9e90bb0e7cc4a35d SHA512 40d0c36b6b889c404fa0e0afa38ba4e84a55bc88ffa2f98a70afbd7a32c4f32c158617ba770567d082a986d62c09b3ec8db3dc5ab853ee1c9bbe0b90bb82396e WHIRLPOOL 581878bf9c43184b043b4293409b85901c9ed1f9bd279e965414aca41ba50950848ebda3ee10a503a028135dfd2765e95a11acd4e62a11c528e104392bbbd8d0
+DIST freebsd-sbin-8.2.tar.bz2 1211665 SHA256 8b7e21a66b4696e8763d29b8b02b2d35f29fc51820a194d1e469e7cace84c527 SHA512 c6643c29ab62344c98d8991708798730ee1c17e6478071718beeaa79788300a1f4ed2e6aeb8e39e3c216877d4ed2ac85b2a9531d534f1ac5125a508927898959 WHIRLPOOL 2a21cd0f15f95d66718031680ac87f1fe73f1e1b03cb012e1db1dd1bd2fe2bb7897457a8ba2f5a28c8806775611dca542cbadec16566c47ab9efa673e2cb53f3
+DIST freebsd-sbin-9.1.tar.bz2 1273913 SHA256 45008b0733b232ef03707ef5fa3e5c889e3b3728393d736bd9a869ea83be6447 SHA512 9f186602b7de96f268c352ca386986652fddf5570e7eca1afa8c0d2bdc83b57df1198efe47f36dd5c7a6abf4f9c935f1c8207a4a12a6b2153bd6c3c6292719dc WHIRLPOOL 20920dfa9607a0ce854319cef29bbd77fb1b31f6f6cfd5ac60cbd678169e43929e215743fe636d0c224443f3e6149a8f07c292d647f7f901592795ac292699f9
+DIST freebsd-share-8.2.tar.bz2 3797560 SHA256 dd082c6ddbf8e08ec91d9810d51af4111339bed912b0f74d05be283780292ba0 SHA512 b3f964253f80e58cde12f26e48a23aa75c17b9ab2810f91a4bd2d7efbe902af7c73c219f8373a4fc97ee0a35d25627b8815c79c136ef18620acc8bd0ee5bd6c4 WHIRLPOOL 42326ad6139feadf80509f5e810f6a86009ad3a69aad9550c6355389773c28d5b2f7930eaa852f8442808485d13e5b758ed3420e39048bb3966785e6953119ea
+DIST freebsd-share-9.1.tar.bz2 6733003 SHA256 2bbd8aa05d52b18a1780772a8518d79d375c1eeae98f52fb6aded233ac2491d7 SHA512 9665e3d5253f49a55921012bd21a8688210a1993ba6be4ad17b5ba5619104a50f3199d49a0eb83cf29db5a06c407beb15616bfe71338c680fe34ec47564c4b43 WHIRLPOOL 7d15596888ac42af1a0c125591283524ff794dccbf9f6592963602f046a45ca073b10bda43c2d0d662fd3414753de64c05293788e03c4eea67de55d9bc083c11
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+DIST freebsd-ubin-8.2.tar.bz2 1808012 SHA256 6b99554f3ad6ee052069b347eb6e6219b71598d7b222acb90a24cbfc805c7b68 SHA512 48d0103323e820c431aa4f62d3be40cb3b200fb62e3de01f36c88760395bf2ba3367c51f3fa72da4dbccc2812176a051a12ca5cb7e84125c3e0fc78d4cab2c29 WHIRLPOOL ea8f3a29a37b42c2b5bcc0f2c343fa1538522157ef075363c94606a4620a590e9a03f856ce2494e3e727935b62431991d0aa9fde71de699e78b4fe225bdf1c2c
+DIST freebsd-ubin-9.1.tar.bz2 1910472 SHA256 ff6e586f213534b6ec2e65002c0dee64063d76ddad515c12221b1a80a1815e48 SHA512 74ae0aceec8597aa66c3f1ab313f0685a3c63d7273c36ae7baf8794275ad9bca241c60c3f6281cccf6d531d250d7611099977d3b1a27279cef3586401b6af05e WHIRLPOOL c85a3c9cf2bceff2c60ff03556bcc81d3aca22b0bce3c9538990071ac0a907236eee5ae7743ad22c5fd309b047ebf392aaaf2fe177ef5790ea869aff3da7e2fe
+DIST freebsd-usbin-8.2.tar.bz2 2443024 SHA256 aa7cabf10f5c3a9daabea32e4de24d04ec312247842981476da666eff5054603 SHA512 bcb8ff3df54848b9107bbb52e5ced7a91e24bb181f06769b6997221729b8064ec17652eaf7500de3268cbcb63ff5760beb54d15fc78c27b02687b5b1067c74a6 WHIRLPOOL 20f5278e2a1dd387a75b44f10507958d6c0e84a2faa1bddbf808c14ab86d8dd14a956192911bbc1880f5f5f7bd05972dcbb4aec85d241f0dcf91bf4246883f0a
+DIST freebsd-usbin-9.1.tar.bz2 2670916 SHA256 b938c20b8c09aa9a610e13b69b9afeea72f561ab3636a59fba2bdac290f4db75 SHA512 21c234312f70eb35cd2926519efc1f61592892f5d0940786dbeb959c3c5ec7819a51ae95c6e8a1a06aa01f669350fe0fd3dd7c4ec8a84dd6b90f24cb192356ca WHIRLPOOL 7f6ad2eb5410cc5e685881654a788807848af026b1277a974682755ab7c9db28f576bfd1576441ea10c5f1e9edb7d30a4a23fb8eccd6d69d86ecc9ce4c9adc7e
+EBUILD freebsd-share-10.3.ebuild 3106 SHA256 dcbd60fc0599b1967970aa81f356e4b688501e0563219934891a471337c94591 SHA512 8be33a1a2aa0e25225c4a310bbcf954a93b9adee72f3e58bca9e6516f61f6d6da9717c6ce249bea997314ec7c717f2bdb94bcb49b9015795b40d462f0fd55f55 WHIRLPOOL b223bb2057496d7ffe253b51979787d6a330758cdababfd1cac7bb165bfa1bb71d8c51887253039e7374cb27cb198e8a82e6e1d0f3b100dc4df387b61198192a
+EBUILD freebsd-share-11.0.ebuild 3139 SHA256 543cac437638a89e6ff48dbd2e54b7dbe29665f97673444f428c169eb0b9fb2b SHA512 51adbb008184d71b2f8589af70eaf78dd76a1700fcdedca5027bce9b8526960d9e8ffe254b6928c79458bee1855171c5b243db7acc9b9e94fd28dd3982fa30eb WHIRLPOOL 05b620511d0b938f83de6239910849133812cd4ce998087d2cf52fecf9fa3265ce541921d34b2a07f18d964065d736b5dba25cfed09eee2b6afc86c24c5a3dfc
+EBUILD freebsd-share-11.1.ebuild 3335 SHA256 225c68add7ac9eb5f55155e8ca3267adac3e37eecb584d0c66b6da428fbecc3d SHA512 b8c7622003e91ef718b25552a71d5219e8d609580e4a46798da08312b90353449a8293415b6bf1244ead161216b6956f9e93a3a5e98710ebcf589bb9e04a8107 WHIRLPOOL d12ff816ef1e116e9a3a9e51cc02c90e27c44f9e14494131a534522ccc181d0cc75d9c84a36e2c69c30b3460177a423f887ae0dfc63bb11180b1518a89f3eedd
+EBUILD freebsd-share-8.2.ebuild 2445 SHA256 dceecff007dd673c41a90216c5382ec1c915c5b59d304040bf32ec170869793a SHA512 9c5141a258faad0bd1bb3903f359ef0dad2ea88f73d5ae4e24ec7d2b86d2f0642bf7cd960f18785cca7b729b7082040641366b3207c21b69cc3da5a812b23b41 WHIRLPOOL a362b604464076d09b1011ccd9bdfd907988b2c057727bec49baef67d714103417071ffb5a8e8b60d7eacb177a8b5394c082aed8020c35de7ecd20ba2b031ab6
+EBUILD freebsd-share-9.1.ebuild 2574 SHA256 2fa4dc9532c7a744f173281b70ba685a261cfebb6e04bdd55cfe25a9d5d30d17 SHA512 e0061942e6004beaf43e1f5fdcabfd9033b69e10ed29508c51a4fd8f917e68130d7a24ca6a4a0d92429245576847292989cf6f38290f840c06de8b7a7b87004d WHIRLPOOL bf478eee4264b10493ab72fb44c35504d7e9ca9c6f3372c3ab0a0a076a51acc6ad3325aa18ef349efc9d0f3509593f89dea96bc998c827e808bd879db3145e0e
+MISC ChangeLog 4250 SHA256 e7161ec770b84a3a45d823de9e142d7f9244f95fb2a0fb55a02d3f416bac4224 SHA512 00a7f46bde7da2d76cdb4c4d09a73e8ae7169e4d4633b450d75af32879be76a59b7d520ef04fee0f79c8e669ecf9fc03873a84276b8b39394db7ecfb0a9f104c WHIRLPOOL f715072a2ea0de049dd3b725c01dbc1be4a9abc5aa37591fddf6f01b433410c002cd158aba4b850728d34958ad3b2c5741cd9036bbf4a5799732affdda6f3a9c
+MISC ChangeLog-2015 11268 SHA256 9a1205e526905657dec5a78f100931bdcb97eae1f63b00668938bd4270ef469f SHA512 544dfdcb940457ae437688a545f557099b4aefb43cfffee5084fd8d5b4bd063cef5c867f793c804a770cce643ce05ae20a1cbc4c7df7881920a03ea2f1b88af8 WHIRLPOOL 91e02d1fcbb65a7f75e16c4c613973baeb0af755522eeef0c15c62c08cbda13ef42e17ff7060e9e4ee8746349c384e0198084d65f215bb6045cf0b9e6edf27cf
+MISC metadata.xml 359 SHA256 e204eb4e849ada468d2815276528d5bd274b727484eb9edf73f601e7b3b9d302 SHA512 998035745a4f78369a7c88d69e52a5377f09e7804ee93f37758fb26a97731b1dbde42d69cae4656b47e57c5dd6c0f2fa1c1ede360aaee38e3170acb7f73643ac WHIRLPOOL 429a60edcf9afc20c72f296f08e72f36d9e1c86bb7054a32983ca21f057c8720b457352daf15afab2c2e92b2835629ccf3b47b67d8b0833805821924eedd167f
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-10.0-gentoo-eapi3.patch b/sys-freebsd/freebsd-share/files/freebsd-share-10.0-gentoo-eapi3.patch
new file mode 100644
index 000000000000..1d0a53ef10cb
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-10.0-gentoo-eapi3.patch
@@ -0,0 +1,17 @@
+diff --git a/share/i18n/esdb/Makefile.part b/share/i18n/esdb/Makefile.part
+index 9ca8577..329e9fb 100644
+--- a/share/i18n/esdb/Makefile.part
++++ b/share/i18n/esdb/Makefile.part
+@@ -13,10 +13,10 @@ PART!= sed '/^\#/d;/^ *$$/d' ${PARTFILE}
+ .endif
+ .if !defined(NO_EPREFIX)
+ CODESETS?= ${PART:C/^/${CODE}${SEP}/}
+-EPREFIX?= ${CODE}${SEP}
++EPREFIX= ${CODE}${SEP}
+ .else
+ CODESETS?= ${PART}
+-EPREFIX?=
++EPREFIX=
+ .endif
+ ESUBDIR?= ${CODE}
+ ESDB?= ${CODESETS:C/$/.esdb/:S/:/@/}
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-10.2-gnu-miscfiles.patch b/sys-freebsd/freebsd-share/files/freebsd-share-10.2-gnu-miscfiles.patch
new file mode 100644
index 000000000000..1dc848873a67
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-10.2-gnu-miscfiles.patch
@@ -0,0 +1,30 @@
+diff --git a/share/dict/Makefile b/share/dict/Makefile
+index 3e2a0df..5395077 100644
+--- a/share/dict/Makefile
++++ b/share/dict/Makefile
+@@ -4,8 +4,7 @@
+ NO_OBJ=
+
+ # XXX MISSING: connectives words
+-FILES= README propernames web2 web2a freebsd
++FILES= README freebsd
+ FILESDIR= ${BINDIR}/dict
+-SYMLINKS= web2 ${FILESDIR}/words
+
+ .include <bsd.prog.mk>
+diff --git a/share/misc/Makefile b/share/misc/Makefile
+index ffd42d8..7eb90bb 100644
+--- a/share/misc/Makefile
++++ b/share/misc/Makefile
+@@ -5,9 +5,9 @@
+
+ .PATH: ${.CURDIR}/../../sys/dev/usb
+
+-FILES= ascii birthtoken bsd-family-tree committers-doc.dot committers-ports.dot \
++FILES= bsd-family-tree committers-doc.dot committers-ports.dot \
+ committers-src.dot eqnchar flowers init.ee \
+- iso3166 iso639 latin1 man.template mdoc.template operator pci_vendors \
++ iso3166 iso639 man.template mdoc.template pci_vendors \
+ scsi_modes \
+ organization.dot
+
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-10.3-gentoo-skel.patch b/sys-freebsd/freebsd-share/files/freebsd-share-10.3-gentoo-skel.patch
new file mode 100644
index 000000000000..79e29e989e2a
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-10.3-gentoo-skel.patch
@@ -0,0 +1,20 @@
+diff --git a/share/skel/Makefile b/share/skel/Makefile
+index 024985c..6f6e563 100644
+--- a/share/skel/Makefile
++++ b/share/skel/Makefile
+@@ -2,11 +2,11 @@
+ # $FreeBSD: stable/10/share/skel/Makefile 291794 2015-12-04 18:21:05Z bdrewery $
+
+ FILESGROUPS= FILES1 FILES2
+-FILES1= dot.cshrc dot.login dot.login_conf dot.mailrc dot.profile \
++FILES1= dot.login_conf dot.mailrc \
+ dot.shrc
+-FILES2= dot.mail_aliases dot.rhosts
+-FILES1DIR= ${SHAREDIR}/skel
+-FILES2DIR= ${SHAREDIR}/skel
++FILES2= dot.mail_aliases
++FILES1DIR= /etc/skel
++FILES2DIR= /etc/skel
+ FILES1MODE= 0644
+ FILES2MODE= 0600
+ NO_OBJ=
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-5.3-doc-locations.patch b/sys-freebsd/freebsd-share/files/freebsd-share-5.3-doc-locations.patch
new file mode 100644
index 000000000000..c0798d3db147
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-5.3-doc-locations.patch
@@ -0,0 +1,20 @@
+--- examples/smbfs/Makefile.orig Tue Mar 22 15:20:20 2005
++++ examples/smbfs/Makefile Tue Mar 22 15:20:46 2005
+@@ -2,6 +2,7 @@
+
+ NOOBJ=
+ BINDIR= /usr/share/examples/smbfs
++FILESDIR= ${DOCDIR}/smbfs
+ FILES= dot.nsmbrc
+
+ .PATH: ${.CURDIR}/../../../contrib/smbfs/examples
+--- examples/smbfs/print/Makefile.orig Tue Mar 22 15:22:17 2005
++++ examples/smbfs/print/Makefile Tue Mar 22 15:22:35 2005
+@@ -2,6 +2,7 @@
+
+ NOOBJ=
+ BINDIR= /usr/share/examples/smbfs/print
++FILESDIR= ${DOCDIR}/smbfs/print
+ FILES= lj6l ljspool printcap.sample tolj
+
+ .PATH: ${.CURDIR}/../../../../contrib/smbfs/examples/print
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-5.4-gentoo-skel.patch b/sys-freebsd/freebsd-share/files/freebsd-share-5.4-gentoo-skel.patch
new file mode 100644
index 000000000000..f668d04c4f9c
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-5.4-gentoo-skel.patch
@@ -0,0 +1,20 @@
+Index: fbsd/share/skel/Makefile
+===================================================================
+--- fbsd.orig/share/skel/Makefile
++++ fbsd/share/skel/Makefile
+@@ -2,11 +2,11 @@
+ # $FreeBSD: src/share/skel/Makefile,v 1.9.2.1 2005/02/13 07:23:30 obrien Exp $
+
+ FILESGROUPS= FILES1 FILES2
+-FILES1= dot.cshrc dot.login dot.login_conf dot.mailrc dot.profile \
++FILES1= dot.login_conf dot.mailrc \
+ dot.shrc
+-FILES2= dot.mail_aliases dot.rhosts
+-FILES1DIR= /usr/share/skel
+-FILES2DIR= /usr/share/skel
++FILES2= dot.mail_aliases
++FILES1DIR= /etc/skel
++FILES2DIR= /etc/skel
+ FILES1MODE= 0644
+ FILES2MODE= 0600
+ NOOBJ=
diff --git a/sys-freebsd/freebsd-share/files/freebsd-share-8.0-gnu-miscfiles.patch b/sys-freebsd/freebsd-share/files/freebsd-share-8.0-gnu-miscfiles.patch
new file mode 100644
index 000000000000..19167a6e04c7
--- /dev/null
+++ b/sys-freebsd/freebsd-share/files/freebsd-share-8.0-gnu-miscfiles.patch
@@ -0,0 +1,26 @@
+--- share/misc/Makefile.old 2010-03-12 01:32:39 +0100
++++ share/misc/Makefile 2010-03-12 01:33:25 +0100
+@@ -3,9 +3,9 @@
+
+ .PATH: ${.CURDIR}/../../sys/dev/usb
+
+-FILES= ascii birthtoken bsd-family-tree committers-doc.dot committers-ports.dot \
++FILES= bsd-family-tree committers-doc.dot committers-ports.dot \
+ committers-src.dot eqnchar flowers init.ee \
+- iso3166 iso639 latin1 man.template mdoc.template operator pci_vendors \
++ iso3166 iso639 man.template mdoc.template pci_vendors \
+ scsi_modes usb_hid_usages usbdevs
+
+ NO_OBJ=
+--- share/dict/Makefile.old 2010-03-12 01:33:53 +0100
++++ share/dict/Makefile 2010-03-12 01:34:18 +0100
+@@ -4,8 +4,7 @@
+ NO_OBJ=
+
+ # XXX MISSING: connectives words
+-FILES= README propernames web2 web2a freebsd
++FILES= README freebsd
+ FILESDIR= ${BINDIR}/dict
+-SYMLINKS= web2 ${FILESDIR}/words
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-share/freebsd-share-10.3.ebuild b/sys-freebsd/freebsd-share/freebsd-share-10.3.ebuild
new file mode 100644
index 000000000000..071efda03a82
--- /dev/null
+++ b/sys-freebsd/freebsd-share/freebsd-share-10.3.ebuild
@@ -0,0 +1,112 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD shared tools/files"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+IUSE="doc usb zfs"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ share/
+ contrib/
+ gnu/
+ usr.bin/
+ usr.sbin/
+ sbin/
+ bin/
+ lib/
+ etc/
+"
+
+DEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+RDEPEND="sys-apps/miscfiles"
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share"
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ use doc || mymakeopts="${mymakeopts} NO_SHAREDOCS= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ [[ ! -e /usr/bin/vtfontcvt ]] && mymakeopts="${mymakeopts} WITHOUT_VT= "
+
+ mymakeopts="${mymakeopts} NO_SENDMAIL= NO_MANCOMPRESS= NO_INFOCOMPRESS= WITHOUT_CLANG= "
+}
+
+REMOVE_SUBDIRS="mk termcap zoneinfo tabset"
+
+PATCHES=( "${FILESDIR}/${PN}-10.3-gentoo-skel.patch"
+ "${FILESDIR}/${PN}-10.0-gentoo-eapi3.patch"
+ "${FILESDIR}/${PN}-10.2-gnu-miscfiles.patch" )
+
+src_prepare() {
+ # Remove make.conf manpage as it describes bsdmk's make.conf.
+ sed -i -e 's:make.conf.5::' "${S}/man/man5/Makefile"
+ # Remove rc.conf manpage as it describes bsd's rc.conf.
+ sed -i -e 's:\brc.conf.5::' "${S}/man/man5/Makefile"
+ sed -i -e 's:\brc.conf.local.5::' "${S}/man/man5/Makefile"
+ # Remove mailer.conf manpage
+ sed -i -e 's:mailer.conf.5::' "${S}/man/man5/Makefile"
+ # Remove pbm and moduli(ssh) manpages
+ sed -i -e 's:pbm.5::' -e 's:moduli.5::' "${S}/man/man5/Makefile"
+ # Remove builtins manpage
+ sed -i -e '/builtins\.1/d' "${S}/man/man1/Makefile"
+ # Remove rc manpages
+ sed -i -e '/rc.8/d' "${S}/man/man8/Makefile"
+ # Remove hv_kvp_daemon.8 manpage. It's provided by freebsd-usbin.
+ sed -i -e '/hv_kvp_daemon.8/d' "${S}/man/man8/Makefile"
+
+ # Don't install the arch-specific directories in subdirectories
+ sed -i -e '/MANSUBDIR/d' "${S}"/man/man4/man4.{i386,sparc64}/Makefile
+
+ # Remove them so that they can't be included by error
+ rm -rf "${S}"/mk/*.mk
+
+ # Make proper symlinks by defining the full target.
+ local sdir
+ for sdir in colldef mklocale monetdef msgdef numericdef timedef
+ do
+ sed -e 's:\${enc2}$:\${enc2}/\${FILESNAME}:g' -i \
+ "${S}/${sdir}/Makefile" || \
+ die "Error fixing ${sdir}/Makefile"
+ done
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ ln -s "/usr/src/sys" "${WORKDIR}/sys" || die "failed to set sys symlink"
+ fi
+}
+
+src_compile() {
+ export ESED="/usr/bin/sed"
+
+ # libiconv support.
+ # i18n/csmapper/APPLE requires mkcsmapper_static
+ # i18n/esdb/APPLE requires mkesdb_static
+ for pkg in mkcsmapper_static mkesdb_static
+ do
+ cd "${WORKDIR}"/usr.bin/${pkg} || die
+ freebsd_src_compile
+ done
+
+ # This is a groff problem and not a -shared problem.
+ cd "${S}" || die
+ export GROFF_TMAC_PATH="/usr/share/tmac/:/usr/share/groff/1.22.2/tmac/"
+ freebsd_src_compile -j1 || die "emake failed"
+}
+
+src_install() {
+ mkmake -j1 DESTDIR="${D}" DOCDIR=/usr/share/doc/${PF} install || die "Install failed"
+}
diff --git a/sys-freebsd/freebsd-share/freebsd-share-11.0.ebuild b/sys-freebsd/freebsd-share/freebsd-share-11.0.ebuild
new file mode 100644
index 000000000000..3e5bae2b14c2
--- /dev/null
+++ b/sys-freebsd/freebsd-share/freebsd-share-11.0.ebuild
@@ -0,0 +1,113 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD shared tools/files"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+IUSE="doc usb zfs"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ share/
+ contrib/
+ gnu/
+ usr.bin/
+ usr.sbin/
+ sbin/
+ bin/
+ lib/
+ etc/
+ tools/tools/locale/
+"
+
+DEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+RDEPEND="sys-apps/miscfiles"
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share"
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ use doc || mymakeopts="${mymakeopts} WITHOUT_SHAREDOCS= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ [[ ! -e /usr/bin/vtfontcvt ]] && mymakeopts="${mymakeopts} WITHOUT_VT= "
+ [[ ! -e /usr/bin/localedef ]] && mymakeopts="${mymakeopts} WITHOUT_LOCALES= "
+ mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_CLANG= "
+}
+
+REMOVE_SUBDIRS="mk termcap zoneinfo tabset"
+
+PATCHES=( "${FILESDIR}/${PN}-10.3-gentoo-skel.patch"
+ "${FILESDIR}/${PN}-10.0-gentoo-eapi3.patch"
+ "${FILESDIR}/${PN}-10.2-gnu-miscfiles.patch" )
+
+src_prepare() {
+ # Remove make.conf manpage as it describes bsdmk's make.conf.
+ sed -i -e 's:make.conf.5::' "${S}/man/man5/Makefile"
+ # Remove rc.conf manpage as it describes bsd's rc.conf.
+ sed -i -e 's:\brc.conf.5::' "${S}/man/man5/Makefile"
+ sed -i -e 's:\brc.conf.local.5::' "${S}/man/man5/Makefile"
+ # Remove mailer.conf manpage
+ sed -i -e 's:mailer.conf.5::' "${S}/man/man5/Makefile"
+ # Remove pbm and moduli(ssh) manpages
+ sed -i -e 's:pbm.5::' -e 's:moduli.5::' "${S}/man/man5/Makefile"
+ # Remove builtins manpage
+ sed -i -e '/builtins\.1/d' "${S}/man/man1/Makefile"
+ # Remove rc manpages
+ sed -i -e '/rc.8/d' "${S}/man/man8/Makefile"
+ # Remove hv_kvp_daemon.8 manpage. It's provided by freebsd-usbin.
+ sed -i -e '/hv_kvp_daemon.8/d' "${S}/man/man8/Makefile"
+
+ # Don't install the arch-specific directories in subdirectories
+ sed -i -e '/MANSUBDIR/d' "${S}"/man/man4/man4.{i386,sparc64}/Makefile
+
+ # Remove them so that they can't be included by error
+ rm -rf "${S}"/mk/*.mk
+
+ # Make proper symlinks by defining the full target.
+ local sdir
+ for sdir in colldef monetdef msgdef numericdef timedef
+ do
+ sed -e 's:\${enc2}$:\${enc2}/\${FILESNAME}:g' -i \
+ "${S}/${sdir}/Makefile" || \
+ die "Error fixing ${sdir}/Makefile"
+ done
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ ln -s "/usr/src/sys" "${WORKDIR}/sys" || die "failed to set sys symlink"
+ fi
+}
+
+src_compile() {
+ export ESED="/usr/bin/sed"
+
+ # libiconv support.
+ # i18n/csmapper/APPLE requires mkcsmapper_static
+ # i18n/esdb/APPLE requires mkesdb_static
+ for pkg in mkcsmapper_static mkesdb_static
+ do
+ cd "${WORKDIR}"/usr.bin/${pkg} || die
+ freebsd_src_compile
+ done
+
+ # This is a groff problem and not a -shared problem.
+ cd "${S}" || die
+ export GROFF_TMAC_PATH="/usr/share/tmac/:/usr/share/groff/1.22.2/tmac/"
+ freebsd_src_compile -j1 || die "emake failed"
+}
+
+src_install() {
+ freebsd_src_install -j1 DOCDIR=/usr/share/doc/${PF}
+}
diff --git a/sys-freebsd/freebsd-share/freebsd-share-11.1.ebuild b/sys-freebsd/freebsd-share/freebsd-share-11.1.ebuild
new file mode 100644
index 000000000000..13169051c085
--- /dev/null
+++ b/sys-freebsd/freebsd-share/freebsd-share-11.1.ebuild
@@ -0,0 +1,118 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD shared tools/files"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+IUSE="doc usb zfs"
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+fi
+
+EXTRACTONLY="
+ share/
+ contrib/
+ gnu/
+ usr.bin/
+ usr.sbin/
+ sbin/
+ bin/
+ lib/
+ etc/
+ tools/tools/locale/
+"
+
+DEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+RDEPEND="sys-apps/miscfiles"
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share"
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ use doc || mymakeopts="${mymakeopts} WITHOUT_SHAREDOCS= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+
+ has_version "<sys-freebsd/freebsd-ubin-10.1" && mymakeopts="${mymakeopts} WITHOUT_VT= "
+ has_version "<sys-freebsd/freebsd-ubin-11.0" && mymakeopts="${mymakeopts} WITHOUT_LOCALES= "
+ has_version "<sys-freebsd/freebsd-lib-9.1-r11" && mymakeopts="${mymakeopts} WITHOUT_ICONV= "
+
+ mymakeopts="${mymakeopts} WITHOUT_SENDMAIL= WITHOUT_CLANG= "
+}
+
+REMOVE_SUBDIRS="mk termcap zoneinfo tabset"
+
+PATCHES=( "${FILESDIR}/${PN}-10.3-gentoo-skel.patch"
+ "${FILESDIR}/${PN}-10.0-gentoo-eapi3.patch"
+ "${FILESDIR}/${PN}-10.2-gnu-miscfiles.patch" )
+
+src_prepare() {
+ # Remove make.conf manpage as it describes bsdmk's make.conf.
+ sed -i -e 's:make.conf.5::' "${S}/man/man5/Makefile"
+ # Remove rc.conf manpage as it describes bsd's rc.conf.
+ sed -i -e 's:\brc.conf.5::' "${S}/man/man5/Makefile"
+ sed -i -e 's:\brc.conf.local.5::' "${S}/man/man5/Makefile"
+ # Remove mailer.conf manpage
+ sed -i -e 's:mailer.conf.5::' "${S}/man/man5/Makefile"
+ # Remove pbm and moduli(ssh) manpages
+ sed -i -e 's:pbm.5::' -e 's:moduli.5::' "${S}/man/man5/Makefile"
+ # Remove builtins manpage
+ sed -i -e '/builtins\.1/d' "${S}/man/man1/Makefile"
+ # Remove rc manpages
+ sed -i -e '/rc.8/d' "${S}/man/man8/Makefile"
+ # Remove hv_kvp_daemon.8 manpage. It's provided by freebsd-usbin.
+ sed -i -e '/hv_kvp_daemon.8/d' "${S}/man/man8/Makefile"
+
+ # Don't install the arch-specific directories in subdirectories
+ sed -i -e '/MANSUBDIR/d' "${S}"/man/man4/man4.{i386,sparc64}/Makefile
+
+ # Remove them so that they can't be included by error
+ rm -rf "${S}"/mk/*.mk
+
+ # Make proper symlinks by defining the full target.
+ local sdir
+ for sdir in colldef monetdef msgdef numericdef timedef
+ do
+ sed -e 's:\${enc2}$:\${enc2}/\${FILESNAME}:g' -i \
+ "${S}/${sdir}/Makefile" || \
+ die "Error fixing ${sdir}/Makefile"
+ done
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ ln -s "/usr/src/sys" "${WORKDIR}/sys" || die "failed to set sys symlink"
+ fi
+}
+
+src_compile() {
+ export ESED="/usr/bin/sed"
+
+ # libiconv support.
+ if has_version ">=sys-freebsd/freebsd-lib-9.1-r11" ; then
+ # i18n/csmapper/APPLE requires mkcsmapper_static
+ # i18n/esdb/APPLE requires mkesdb_static
+ for pkg in mkcsmapper_static mkesdb_static
+ do
+ cd "${WORKDIR}"/usr.bin/${pkg} || die
+ freebsd_src_compile
+ done
+ fi
+
+ # This is a groff problem and not a -shared problem.
+ cd "${S}" || die
+ export GROFF_TMAC_PATH="/usr/share/tmac/:/usr/share/groff/1.22.2/tmac/"
+ freebsd_src_compile -j1 || die "emake failed"
+}
+
+src_install() {
+ freebsd_src_install -j1 DOCDIR=/usr/share/doc/${PF}
+}
diff --git a/sys-freebsd/freebsd-share/freebsd-share-8.2.ebuild b/sys-freebsd/freebsd-share/freebsd-share-8.2.ebuild
new file mode 100644
index 000000000000..df7170c8f1b4
--- /dev/null
+++ b/sys-freebsd/freebsd-share/freebsd-share-8.2.ebuild
@@ -0,0 +1,84 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD shared tools/files"
+SLOT="0"
+KEYWORDS="~sparc-fbsd ~x86-fbsd"
+
+IUSE="doc isdn"
+
+SRC_URI="mirror://gentoo/${SHARE}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${GNU}.tar.bz2
+ mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${USBIN}.tar.bz2
+ mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${BIN}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2"
+
+DEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+RDEPEND="sys-apps/miscfiles"
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share"
+
+pkg_setup() {
+ use isdn || mymakeopts="${mymakeopts} NO_I4B= "
+ use doc || mymakeopts="${mymakeopts} NO_SHAREDOCS= "
+
+ mymakeopts="${mymakeopts} NO_SENDMAIL= NO_MANCOMPRESS= NO_INFOCOMPRESS= "
+}
+
+REMOVE_SUBDIRS="mk termcap zoneinfo tabset"
+
+PATCHES=( "${FILESDIR}/${PN}-5.3-doc-locations.patch"
+ "${FILESDIR}/${PN}-5.4-gentoo-skel.patch"
+ "${FILESDIR}/${PN}-8.0-gnu-miscfiles.patch" )
+
+src_unpack() {
+ freebsd_src_unpack
+
+ # Remove make.conf manpage as it describes bsdmk's make.conf.
+ sed -i -e 's:make.conf.5::' "${S}/man/man5/Makefile"
+ # Remove mailer.conf manpage
+ sed -i -e 's:mailer.conf.5::' "${S}/man/man5/Makefile"
+ # Remove pbm and moduli(ssh) manpages
+ sed -i -e 's:pbm.5::' -e 's:moduli.5::' "${S}/man/man5/Makefile"
+ # Remove builtins manpage
+ sed -i -e '/builtins\.1/d' "${S}/man/man1/Makefile"
+ # Remove rc manpages
+ sed -i -e '/rc.8/d' "${S}/man/man8/Makefile"
+
+ # Don't install the arch-specific directories in subdirectories
+ sed -i -e '/MANSUBDIR/d' "${S}"/man/man4/man4.{i386,sparc64}/Makefile
+
+ # Remove them so that they can't be included by error
+ rm -rf "${S}"/mk/*.mk
+
+ # Make proper symlinks by defining the full target.
+ local sdir
+ for sdir in colldef mklocale monetdef msgdef numericdef timedef
+ do
+ sed -e 's:\${enc2}$:\${enc2}/\${FILESNAME}:g' -i \
+ "${S}/${sdir}/Makefile" || \
+ die "Error fixing ${sdir}/Makefile"
+ done
+ ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys" || die "failed to set sys symlink"
+}
+
+src_compile() {
+ export ESED="/usr/bin/sed"
+
+ # This is a groff problem and not a -shared problem.
+ export GROFF_TMAC_PATH="/usr/share/tmac/:/usr/share/groff/1.19.1/tmac/"
+ mkmake || die "emake failed"
+}
+
+src_install() {
+ mkmake -j1 DESTDIR="${D}" DOCDIR=/usr/share/doc/${PF} install || die "Install failed"
+}
diff --git a/sys-freebsd/freebsd-share/freebsd-share-9.1.ebuild b/sys-freebsd/freebsd-share/freebsd-share-9.1.ebuild
new file mode 100644
index 000000000000..f3a6f4c52e40
--- /dev/null
+++ b/sys-freebsd/freebsd-share/freebsd-share-9.1.ebuild
@@ -0,0 +1,86 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd
+
+DESCRIPTION="FreeBSD shared tools/files"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+
+IUSE="doc"
+
+SRC_URI="mirror://gentoo/${SHARE}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${GNU}.tar.bz2
+ mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${USBIN}.tar.bz2
+ mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${BIN}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2"
+
+DEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-sources-${RV}*"
+RDEPEND="sys-apps/miscfiles"
+
+RESTRICT="strip"
+
+S="${WORKDIR}/share"
+
+pkg_setup() {
+ use doc || mymakeopts="${mymakeopts} NO_SHAREDOCS= "
+
+ mymakeopts="${mymakeopts} NO_SENDMAIL= NO_MANCOMPRESS= NO_INFOCOMPRESS= "
+}
+
+REMOVE_SUBDIRS="mk termcap zoneinfo tabset"
+
+PATCHES=( "${FILESDIR}/${PN}-5.3-doc-locations.patch"
+ "${FILESDIR}/${PN}-5.4-gentoo-skel.patch"
+ "${FILESDIR}/${PN}-8.0-gnu-miscfiles.patch" )
+
+src_unpack() {
+ freebsd_src_unpack
+
+ # Remove make.conf manpage as it describes bsdmk's make.conf.
+ sed -i -e 's:make.conf.5::' "${S}/man/man5/Makefile"
+ # Remove rc.conf manpage as it describes bsd's rc.conf.
+ sed -i -e 's:\brc.conf.5::' "${S}/man/man5/Makefile"
+ sed -i -e 's:\brc.conf.local.5::' "${S}/man/man5/Makefile"
+ # Remove mailer.conf manpage
+ sed -i -e 's:mailer.conf.5::' "${S}/man/man5/Makefile"
+ # Remove pbm and moduli(ssh) manpages
+ sed -i -e 's:pbm.5::' -e 's:moduli.5::' "${S}/man/man5/Makefile"
+ # Remove builtins manpage
+ sed -i -e '/builtins\.1/d' "${S}/man/man1/Makefile"
+ # Remove rc manpages
+ sed -i -e '/rc.8/d' "${S}/man/man8/Makefile"
+
+ # Don't install the arch-specific directories in subdirectories
+ sed -i -e '/MANSUBDIR/d' "${S}"/man/man4/man4.{i386,sparc64}/Makefile
+
+ # Remove them so that they can't be included by error
+ rm -rf "${S}"/mk/*.mk
+
+ # Make proper symlinks by defining the full target.
+ local sdir
+ for sdir in colldef mklocale monetdef msgdef numericdef timedef
+ do
+ sed -e 's:\${enc2}$:\${enc2}/\${FILESNAME}:g' -i \
+ "${S}/${sdir}/Makefile" || \
+ die "Error fixing ${sdir}/Makefile"
+ done
+ ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys" || die "failed to set sys symlink"
+}
+
+src_compile() {
+ export ESED="/usr/bin/sed"
+
+ # This is a groff problem and not a -shared problem.
+ export GROFF_TMAC_PATH="/usr/share/tmac/:/usr/share/groff/1.19.1/tmac/"
+ mkmake || die "emake failed"
+}
+
+src_install() {
+ mkmake -j1 DESTDIR="${D}" DOCDIR=/usr/share/doc/${PF} install || die "Install failed"
+}
diff --git a/sys-freebsd/freebsd-share/metadata.xml b/sys-freebsd/freebsd-share/metadata.xml
new file mode 100644
index 000000000000..9a9053ff2d30
--- /dev/null
+++ b/sys-freebsd/freebsd-share/metadata.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="isdn">Enable ISDN support</flag>
+ <flag name="zfs">Enable ZFS support.</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-sources/Manifest b/sys-freebsd/freebsd-sources/Manifest
new file mode 100644
index 000000000000..2dd724457b2d
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/Manifest
@@ -0,0 +1,67 @@
+AUX config-GENTOO 73 SHA256 04a7695383baa247120cfd39f399b62c9d9b66682b79bc9bc1117f0aeb95b858 SHA512 436e1e1cb4077488cd1e054a96598c1c6dc2fda5c060d2d6c1bf2986b534016c86ea2afee0dcf883b4bde6946625596ea474a273013b18fdfa5538ebcfe6ea54 WHIRLPOOL 467ed565c0c6b508185f3c7d9a2031ce1861573614ba6fd5db7d6825fdaaabf23b9be1daef035d7fea9fa66f9d92ba17267085e894db66d8c9f49ed4ca9f16b9
+AUX freebsd-sources-10.0-gentoo.patch 713 SHA256 13588f0572ba95c86beb755ce3d681c963e220694e3c0b3aae29faf05f8479da SHA512 98b8d1bf033b9bd7147f10e5bb4a39ac4883ec02ef0cc3825541ff11cb9bfe5e7722e7b8dcefe4c356f9fb0f86ec5cad6fbf9b80dbfd04149142fea5f8712d4d WHIRLPOOL 6372ec9abb566d06db174dd20785ab1768487ac2d57799fabad2d45cb77418f0e39aa0bad745c873e1c50de86a70fa80890f7f2f377f6a53f4fd5b7a6fa49edf
+AUX freebsd-sources-10.1-gcc48.patch 452 SHA256 26ad0753e59bd7e45f957cc98c8a11c8c1bcaf89ed55898b4efc6d95e3943671 SHA512 55e5249ec8337d880d96fd9429a0ffe5663c6182996b6b2ab8d19fe9d5168a0042b81222b2bb89de6d90f98d042b593fb40a7f4178ac739f681f84c2d62b5c96 WHIRLPOOL b6ed5ad4d7e444c79afcc0a14ce9fc85fddd5d1ae6b1d7dc8aa3e4949bb598e0da7a0d95025ba7e3981fc0af741c52e3c84fc81cba00bc79f59ab510afa85441
+AUX freebsd-sources-11.0-gentoo-gcc.patch 430 SHA256 e8f031a81dc611c7368bbb4330f2e162a50b72af9b3cdce012c93d0130668b8f SHA512 9869ba13091cc0975a7fe1a1b18a279835d19f1f57204dd3463798d3695a250ba6c96f2c1f6a2352dfce0022d7365257b0f938032b55e7090f68e58c4455bffe WHIRLPOOL 01b61475aabca1647092a8d77c426ffd609ce66a508672eb85b87f2b25db37dbc6191a3f9bfaa24f5fe03a233c122a4f2b971c3a4f4fd9022acaad55c8ad3427
+AUX freebsd-sources-11.0-gentoo.patch 852 SHA256 ea3a49d8d4da8bb67ae715b0551415ae144457386c1c63a11090cc80d223e70b SHA512 11f65627bb5436052b227d884c384e888bb8f44696c36b80a8715c912e41c953b57c1420b37030155c2751c72289470c4f681d14ed149e4f6aa82d8b63766ade WHIRLPOOL 418d1adc24fe6770beb7273724f510a3f89321e1f3cca1ee0242a2c6ce3e3533655339c10da67f92118b82fabf87f680487ef2d8e1781bf965e889e19adbd4b7
+AUX freebsd-sources-6.0-flex-2.5.31.patch 826 SHA256 8aaf240a344106fc5434fd098eb6555a554d16513b71c95f93a93388021c3d99 SHA512 7183b1923019df12849e7d3984c4227d65275077cf95c3b0719b99dc852234eb3813db0e69e9c34bdfca45a59f7340209211d0b7a2a5074c2d1ad8ea0a3a3f64 WHIRLPOOL 620ae55a54333c55e44247aad76be467bdfa491dac646f65dc0e0b6b1a95fe8edf5087e9ed68abeac1ef6db1a91c0e673342bf44f8753b6b8a5dce889137cdcc
+AUX freebsd-sources-6.1-ntfs.patch 1043 SHA256 2eb0e22bea267d7ac41c3dec81682d3cc1f1744316ea39342e2aaae1f2dca469 SHA512 5401b50ed93bd9155b8adc3f0d6ec81b6e48431bb950cdf468be2e918553e19cd88a1988cdad49be2a34a1db44419cb9eb7067ff0fb1feb8b3f6373aa3c262ad WHIRLPOOL bf4821beae08e002f290286bc290b2bfeac86db46c1597232f06a23e505d720e34841393d9fb4d7276ff7b98c1c133aae5d58c3ec7b8f12712b51260b981bd14
+AUX freebsd-sources-7.0-tmpfs_whiteout_stub.patch 1015 SHA256 7857fc90c6d5ed28d848146d50ab5bcd01f79ad3480ad1335929f08e45afbc44 SHA512 9dc96b967869efd7480785977764e879bf50978b5e609867e678574f9ed1476695690832bdb725eaebc8d93e83b4a0b3fe9f23b94e2de072a6540a168b13c4a7 WHIRLPOOL 6841f24f2d3ff569ff0e7bd4d628955c9b61b41aa039bdd1e736fa82f737842101c212d8ae8961d1db335e53ba332cdbec1d021a4c57520e426926981bca4512
+AUX freebsd-sources-7.1-binutils_link.patch 1297 SHA256 957c03640f3aac6141efa3e775f33fcadd501f920612055d0e00b3f80fcd8f17 SHA512 0e3aa342646d18429ed76e484d7e15d353d858f00bda906dae74b01b4e73f1b4ccfb6404590d79cb206da3a732528a4437813540a26292d697ccc3b964dabfb0 WHIRLPOOL 5108bd5a1bd49f94a7902b5b478528b29f1e15fe1e06f96a80de6fbf047eaf4f925f00fcd5f83085d44e86828dee50cc2efd150ece362bbd3ab24b292d9e7249
+AUX freebsd-sources-7.1-includes.patch 318 SHA256 70c73d0939325185430a3a133380f0bc10674cb8fbe5c7ebfe3b07630d023369 SHA512 f73db3fd72bdd2972ae25c3f661e7677bd5877aa623981303a4b0c5e9522fd458e294799a0ebad17ac3c639d588394b10ad5fcab4d88743a6dfcc8a8d60eecd7 WHIRLPOOL 5dca685df773113dff0c8aac16f244882728ad586b62b7c20df948240b097e89d1bb62f16ed181f2535e13835471754d8fdd0f4ef02b73ce5077b9169c958557
+AUX freebsd-sources-7.1-types.h-fix.patch 371 SHA256 9e745fcfe046c405a365d8d0db8763867f0a618952f7d6bab4c76a8c82273473 SHA512 133ab13e98c3f2dc5f96cd5e45cd11c4da9757f4ea64831a6e17b309bc4692e4213b48c7ab6dd634f1feb069ca2dfc3a8afe1585d0d1425b5304fd7494cd342f WHIRLPOOL d284dd82244a108e4677be143cfc302c18f18e5b39c39fcaa8915c61053d94bf7171e48028f40d25f8058f8ec910c3e55a3753ccecb46bbabbb0e5ba86e808e3
+AUX freebsd-sources-7.2-debug-O2.patch 771 SHA256 ad1fdd8a6dd53186793d70b65e1b37e3d3e7a4e50c32069aa535ae9f8e9aded8 SHA512 a74dacbd24c6130ec4c762a9c2df58a37d5fee2ee6fa4a970245b53837afa5ee3f72318b6e723e0591ddce00a5aa0fd66746a06783174d4edb9814e3a3724201 WHIRLPOOL 598f1e3282f5b8ebacd43835e148e5249737d8d7b240eaa459e5374444e0aeb39a692b01d3da5a8bec6aa44b8fe97879ce3bea739796688d8d6b365baac438b6
+AUX freebsd-sources-8.0-gentoo.patch 1138 SHA256 0bb6e4cb59bb6f5fd86c88bfd36ce8c9d148d96e8722f1d6a485f98ba892650c SHA512 677adbbbba367bda65f01b604a0a6235ac12d7b307857fa35c7722eb05e0a74d3cd35c03a9dfa56023b7869a865959c9edcfa601d841add92ff21a941d395ddc WHIRLPOOL bcf25d6f650f6435e7fa7c6d5888a1dbded300f0e4c9f595abc1386663b65fd378805efe1b8355c91efc357e0684ce7722526f93beae55a1102e813aaecbd711
+AUX freebsd-sources-8.0-subnet-route-pr40133.patch 548 SHA256 091764c97f4148d2245c24dcfabebd53ef0b4f3175a140fd5b1132788e718ca1 SHA512 9ae65e2775302b664dd4e5f5cbc58fe1ca7db61b6182db10971660207c72ec74e542181f1c2aefcacd2fd4b54e10d371efc619c3c03a977c35d3cf67b99b7de5 WHIRLPOOL 01e27e011c94641498cf0c04a663e4f8f4844a57bd462aa38a1c23a8b3244e5eec226fb11b5e8e598de7227ac2d3dd33aaa98d16f6e7628329ac59e1e7ce62ae
+AUX freebsd-sources-8.2-unix2.patch 1642 SHA256 6dd35d13a13f5e9333557a84b56c89fc4988d55bc3267cca72e8ca8ca169ce61 SHA512 a7f8166abc9883cab92a4b1ce038cefc3c00a6567fd79ebab96ccebbed7e230459dd8efc0b96ba2029a89b4b5d41305be87d0c40ad85fcfe4c819a4604b4490b WHIRLPOOL 5152dca64e3799cc9b6ffd97019c542f93082631489b9c0e03128a09a3d0c667da4220cfc67039c24d13a2cb527dd325db501029478d528c688c0c35cf2373c7
+AUX freebsd-sources-9.0-disable-optimization.patch 927 SHA256 e8ad8d8ed1f729b7b22839a7af93b3dd667f257b05db95f408c48b270003a486 SHA512 0b74874d42eab95994309b922f37ebbf3706d01db6c447c9f062b03e64b77c7f793bc297150b539acdf39530a8afd91f4bf824a87c674dd625a59056656c614b WHIRLPOOL 86f9586a3f07118f95e5fbce1a65fdd3be8dd701ed1bee1379ed2133cef3d9473b437826a13ec2a53c73f7b3e1003256d912a45eb80c86195749a8cd08f9813c
+AUX freebsd-sources-9.0-ipv6refcount.patch 3259 SHA256 18186ef2f9fc020c0da053953b9e8c8629c2302082e0ee172dd7e84a7104bdd5 SHA512 04d89da7ab4c50d3405ff18eea49f94ffff34375c6333a6bb84bc81a63046ba12f384d256e010dc1b64a186650c7ad4702403ed933e6a678d2c5ee4238b56658 WHIRLPOOL c0511b2fec1f2ecc8a6e3aba23808a4c60a4c94f45693b6f21a30cb01386e24969fcc9b655584c78a501524579f7e266993fdd6d565525740f4f8e04f47b55a9
+AUX freebsd-sources-9.0-sysctluint.patch 403 SHA256 884fbc5d6d3766ea3d4609946f56072f36f95368dc13ee316c330a46d42f0c9e SHA512 f3a87cb187858bc6fd1bafda3c3bd7bbda52b07239a50a7c1aa201df2c52a58d4809e196b8799b1949c8ca1a556519d454ad1789358540e3a96cd480fc0a504c WHIRLPOOL 1fd9852d59378b3fa8682886085f4f63ccd2a57806161b9a3ccb0cbe0c465be2e5620ed57942a8687656859e1a9df17c7d298ea66ec037514bbe7707783aa9f8
+AUX freebsd-sources-9.1-ciss.patch 2067 SHA256 a450312394a9ed449144c1b320ec323f8fcd6cb744ad6c6862046b0fd5086e4e SHA512 5b8088644813d465443754f248e0068da1c53b4f947b7c1e584ae9dcd9b7b135a53edd70efc463b500aef74c4f8193e2d1d349b39ce183ed1f18284a2c2d7989 WHIRLPOOL 59f1324eaa98e11a094e4fe48e8ad8f468bc373691de101c5082630d1a69d10a3e6d904f3b6138a2107b0f35f37c16f07da575c1efb4bbfa22869a7cf328e5e2
+AUX freebsd-sources-9.1-cve-2013-3077.patch 1064 SHA256 2c0b8a4df43b3a2b15bbb33000f4c0e0e132901dfe5d5531a694a17b9e1fd7b8 SHA512 12244d1335ab626e4a391cdd1d435f9f002ec4142fa2a2a93832b554f03fff69de09e950c4e80c797fd0b568504a69e18341fd35bd952a56e01a05024de8206f WHIRLPOOL 01c9e9270eea92448de3754ab0d6dc2efdec4b8e06a00b0d86c550e318c07c8e4a5b2b32e645008713e399c20b96d5e91e740e5120f889050ab91416763be3fa
+AUX freebsd-sources-9.1-cve-2013-3266.patch 535 SHA256 3ddd63716570d7a08956228d3f2b165e80380d3062cecfa9ed781696542cf7e2 SHA512 04f421724d79a2e8c5a23120a44601bd611b938e4452d064034b7cf91ab36e2b019e3a12af62d5bd180a5da30ca59886f90aeb6f1255dcd2124285aec6b65fa7 WHIRLPOOL e12449b21f4a3200da65d815bdc33972e9aa7b2941560fba13a634be9baad4246b635ee87510a09dee123b65ea614ed57f17e482ba41a0ea2c986e579d75f3a9
+AUX freebsd-sources-9.1-cve-2013-5209.patch 645 SHA256 1b334cae7f7ac266785449bc34a8b4b652b961b7b77acc3488e418f4359b6041 SHA512 1ed132883d22aaf48be98dd9adaa48cea0023f3c986cedb45f986676f1c4a40d3d5463006f516d78fe77a408e5f4821cb7b26d8fbff7091bc2aad9faac2e728a WHIRLPOOL 8ea85c387106009ed4c5ac4652520d349cf403d6568d81aedcc05f81ebdb5ac0c287a188071bb7651b4e847d95abf9874bfc8710a025c9ea1c986993b6d4a0a9
+AUX freebsd-sources-9.1-cve-2013-5691.patch 2854 SHA256 418cb39d555c036013cd87a2205d2b1b9e4c729f409b3bd4c509648282a0a993 SHA512 6c3342e79fe3de90d37d82415b186f5012597dfbc5f522f9aadfa5420d601e4e6042b899ed348b581537491d4c49d6b4959ca3b438f9bda454b8d9b494120534 WHIRLPOOL 7436a1c9402c2de662b98e3615d1a62f290a8638c597d671474dab005a60a5c5b162ea31603902568c9443ebd39a2631297b6e19bd26f343c808e086b78da263
+AUX freebsd-sources-9.1-cve-2013-5710.patch 704 SHA256 c076858b5dd9ab31be241144bef4de2824fa27599f7f114bcab9a2934436a1dd SHA512 a87d571aa060f435e0ac53816307703e300e16365df13c88be0a982d5851d3c224e0cc23b32ef61445413abda86762e0e43b964d475f1d816ca83d2c6b3f7d58 WHIRLPOOL 71bceec1fad2cde48cd32475805f96a33d9fef85ac8f3b69c601874514b6eef89479cf9b372bc8639d48a317dc5216bd7e2f2902570a148da865983845f5fbc6
+AUX freebsd-sources-9.1-cve-2014-1453.patch 2239 SHA256 2605926b9a36cf2eecf65fc3bcc92ed772922562fdfebfd39c99137526f2a440 SHA512 27b48c96447cb961d2de3ad7f67a739ff78ee3904da508b2e6c1948d299090cb169bd3f289b0448e7d242c1c0d39fd5e5fc29700d92ba4877c3e6d013a6cd6a1 WHIRLPOOL 206c18f70756f77050c681ee4b14f7e0d0e38cac42d146ae0ccd9bd79a3977c4db57d1456c3bfe0294dad313eead5dfb748446e0fa401c98105ea53097505e45
+AUX freebsd-sources-9.1-exec.patch 2032 SHA256 8e75954777f69e87b9401f3ed79d65fd6e498bd82bdad4378a076fa088480e8f SHA512 db2ac3a96b9c2bfc3e785a6ea8060e7cf516e6cb25629749a7cae4ca8171b0f3b8f1128c5b646f8dfcd78c21fb3859b548907ba1781a698235dd5cf6a90f824b WHIRLPOOL f0a29fea6f7cd5096deb29a53830c7c7e51b9c5c2eb2b28b2baca42fa0003f54181245cd8c9dc63beafea1d8000f05ac615705cfb573af33d03d6d89ee2712e6
+AUX freebsd-sources-9.1-gentoo.patch 743 SHA256 f75e451259933aac8028ad0a2b6d9ee43d21bf40f7309e556d139c7a125392bd SHA512 9a7abc263c87134534d6f5a727e08c5f5c34b0272b8b03ddb89daf2ea27e4ec1e46d59202347e4b4154ac617e8c8fa8c29be95d498b54e392680b96fdd10cb6c WHIRLPOOL 237fbd8f3770442cc2692a2b62e83ecc732f54510d267a575a388de778f4b5c22a778d6fd8a69822ff8e782118c936e843e845c6461b0694ab357b261608a86e
+AUX freebsd-sources-9.1-ktrace.patch 463 SHA256 328d14c5fd775b1a99f065911ab8c95065823dbd488bc0b1b3bc8bf46fcb8515 SHA512 b0cf73180320e0d1295fcde2c19a281575150f28d71fecd31c5793b6f0e9784005745fbc56b8578d40615e9276cfadf25d6fd3ea5e21f315e3c6beedc0476ffa WHIRLPOOL 03e3e9a090bd14c9f8be2fbf62a0c305da6e6e20ca1f5e30dd66c22b3f031132046ebd959c6f66a9b3227756c339cc3f87f339829592625dace8116f3ed67814
+AUX freebsd-sources-9.1-mmap-2014.patch 758 SHA256 cfc0663e536972ced5a45b5ff491b8590e95739ea6cd34687b9ca56e5d7e63b8 SHA512 fb1f28268355ad0a25705fecb7555222b53b04fd92b1b80af2db4b6f2ac02bf5a948ba0521d1674e31da57a1baf037fe0fe581c03a437d86325e185a8050aaa3 WHIRLPOOL 8995fb9d0751aa3c12bab79206f22c924ffe583060895c2cfc62e53ce89ce1cdde0f511e12e017209221075aa536e839ab68c241b8feffc26910c613aa8753ed
+AUX freebsd-sources-9.1-mmap.patch 676 SHA256 4adee0a45d519d93d4bd3554c6b685becbaac2bc5e89511f61260e85a914235e SHA512 0daff1ef440be8e4f841eeff8917a36591bd3f4c31d79feb4666f9c3d65d49ee180397b81b07753c8892efd76436bf19d2218979cef3847d3cd46bdfcf166d6b WHIRLPOOL a31b32fb6fe8d7ca4464abae9c444e62d6ff00b4d53beed7c81c89bf0e85e61cf1eed7e70c7861a3559432086a923926737c4f6a727d2e389745de045e6f30cb
+AUX freebsd-sources-9.1-nfsserver.patch 650 SHA256 b288a29155fbce8ac58460a3f64ce77b644c32ee54814e35086700d2fae3610a SHA512 e1d505440371d35722b3520212ded13acf5ccb433c18988aea08d8035881f633c04dedb912931684334154303731ad21ca849c02831f6b9122b54486fb5ab8fe WHIRLPOOL b4469dfb52ca87e95539bd63dcc36ba34c9a29b812b887ad9656c2adea7acee5ae6a14850d2f4733aff7248fb9d6d6107ea38f06365efba18f8f025506675de9
+AUX freebsd-sources-9.1-random.patch 792 SHA256 46d4035d31e8a64531e1893c08b8235ee92af002848a781d9f1af1a886f17fdc SHA512 6e7137a5b68ec92a6eaa5d6bbc1609794f7a71210331959135663bf4021b6cffcbf87f23b5d757956a1ff6907929012490bd85ca0ec37efbdfc2b70de108bc99 WHIRLPOOL db318323bd0d757ab0a97ef5e552ee38b9fe5eaf12f87769912abf16dda40b11692ae3715cd5fc34aa11d5ae226366b8bb63feff3067c539b9fc23a9ad14c840
+AUX freebsd-sources-9.1-tcp.patch 1249 SHA256 a51412349a8724931cfc749150e3c07802126382a6ce5dbbc6617e4f81188e7a SHA512 46a2039ef4c000447ce22cd64515cffa34615e6980fba9f493c9cf527f45012f1d6128aadce401b3620667bfe9191d70c4c415f8e2d2c08617453822f73a029e WHIRLPOOL 6e81938c55e2a40f4d75a53f4bfeac1c4183feebf023bcc320c0179dbf802151cc5f04dde9302e233eff86c33fdca8a6e80dda70d47d0d762da61e22782b1b0d
+AUX freebsd-sources-9.2-gentoo-gcc.patch 506 SHA256 7457421478066b686dabc9a072ea1a30da8878014d0799220557820fd3a4bbe8 SHA512 cf553ad66b5a55dd2383a55c9a3c5c852985c4842244569aef91596a98481ca12c6189dfdd5fb2badcbe7901a87c81a3e0432cbf10add66dfb481ddcf38ebdcf WHIRLPOOL 42be74cafdad3e43815f638144b3ef8e89a7a95d791a312899a24387bf6a9cbc08acb0b30855d45fed607c6b73a3632afe1a44fb2bcd5738f76a7cf444b39218
+AUX freebsd-sources-cve-2012-0217.patch 856 SHA256 9b752e65a29b2b9a4a1412765d69d00310c05508af1cfa6d8d3c16d545bb3ffe SHA512 b1ac18cae23b81fd5ab2fcb44bb9f9808d6eb80f52b8572b81296fdd0b18edee62460520bc753848283d67e13367bf99775a2a5c6cf0272def9cdff6ec6fa4d9 WHIRLPOOL 27e4d0647c5275b77123bef6b866ac841af4b1b547fc663f776da82a7889995eba21b930adeabf2a71b3fbe053d2af5583cbdb6e8fd16a0379d10214d24b9121
+AUX freebsd-ubin-10.3-bmake-workaround.patch 301 SHA256 97e14b032622bcc652ede9c5154160e937b3ade0155fddfe19112354bfeb6138 SHA512 8efd4e8199886ec0c647a13a334de54813372d9d6eb09d6b93785000da9a84ec40fb4d28d645a4809b531bee0bb4c11522aaae089285c52e595b2f9749af7dfe WHIRLPOOL 910bb3807c15ee8ced94c508ab2bd1e3112cd890de28bbdf2b152efe5e5ce187e366376938996e2a41e07599d7c76abe741463bbf4475297d604531ac80ea6ae
+DIST freebsd-sources-9.1-en-13-03.patch 32571 SHA256 8bafbaba1b23f4651a9e578dbbb3b8d9b4a0a28dc1702f6dc17a40728b861595 SHA512 013a21da3618da9098020c85abe42d99e4eeb8d6b9b818cd5c6d27ee2ea2d31b60ad4521e73cb996f2f5c99fd0f34bd4a35458977264c51e79f4f53bfca6e7cc WHIRLPOOL c7b0a56efd9cebecde56590cacb1ee743845ce13577505255deca44c167d679ce94c759cfb363c26a5f2a9fc16dfc06d17eea18d638fd72c21ec0fdd81a71c5f
+DIST freebsd-sources-EN-1607-ipi.patch 2557 SHA256 da1a24b82a16de4007379e4f2c030054787e5b3c95f9ecf8afc1693f456943b2 SHA512 41bee92ac36685ea81437befc07e1d1f7ba9d93b3d733981fce512e68a77eb3e9563a88e23fd9ae27a331e63c42966a55041cd5ae05d61895b8e20b1edae86dd WHIRLPOOL 650d5fabf4e017d387baf96a0f8c9131e0f5d4fdf80a36f673746a92a9382fd4d6566a382590a1d66b6f0d384b38ac26d2b782a0a9449b954c15271cc4348fa5
+DIST freebsd-sources-EN-1608-zfs.patch 280 SHA256 1d6b954e2819bec83084224fba47f79781bf458f50a777dcd2ae3c1413fd95a2 SHA512 df2e133cfa565332da3c2b173c98e866bc1d9ddcfa06156da1f9a2f382186cafb130b7f0e19617482af71b730d95b9d8a7d81195a57760a93736bc2f49ed1c03 WHIRLPOOL fdb4e88206dbd732aec0541c8aa986a4540cbd52c36140d87db5a775fe8c3600a4c8369d67fad5207a85df2f06b6e4cc0a1c99df198c31f7e1f44bde16054278
+DIST freebsd-sources-EN-1611-vmbus.patch 6755 SHA256 86a5702d958dba47a988d74551bdc6bec17f9037001d5d231b85842f672417cf SHA512 8a2296612f688692691765dbbd695f7aa75bf45fab8a569b3d6671aa5cf2d022e498f6f0266d89c999a1799a862f9cdeda8179a0e8eef85f5613bdaa792dcd41 WHIRLPOOL 240f3b0a6731b5a24b5cecd7f4485815b86017e1629296280309917116329cbc25b8236d4f205cb46465ad3e5b726692845ac3d5de541b98acce39922c0a2b44
+DIST freebsd-sources-EN-1612-hv_storvsc.patch 6459 SHA256 91f419fc1206d4c5c66664e9f3034360fd7e08955081b0259120771db8b075f4 SHA512 90cc301222cb31d2c5cbb289666bea0291880a2c1236fe056c5c29b571fe656a39047e131eacf41af0b783e0c22f07681665e33046980f98f233a28baef18ade WHIRLPOOL 607cc513638e78554034443f130e1715c7433a32f809d3db9da580c135d32d6374720bf4e75938757e40e5259d71547fee814c098dfa860abec40ce90ff4c12f
+DIST freebsd-sources-EN-1613-vmbus.patch 3886 SHA256 9a9cadc9789184ad9caae387a78610eafdc104eaffc06be3123c98acfd4e2676 SHA512 14d7d6e1acf3e78b0b5653aa83dda8cb6fdbd8e2824624e093d73e217bad2600de157479e66f94248e38afa21ddc1292c30ba8381f76cac95b5d11caca1fee50 WHIRLPOOL dc730b2eaea44668f84340f1c3c2fa98c16b187ab7a04aad0ed1b29d9daf10dcc6034287d640d1ca4f200906b39e8e532f7379a51577ee78f065042e79d78b46
+DIST freebsd-sources-EN-1614-hv_storvsc.patch 1134 SHA256 e6aafccbf60789bce56e714f7a866cd8ca869babf4a881ffc3703bed7fb7c404 SHA512 bcb687290b2a9572345e5e4c8d2408dadf2fe2f206d457ba8147bbc62fd6dff064b132b66b4e2ac6fa98c73c37eda7bf22538d51a29cbb773fb90c4af44f5986 WHIRLPOOL aa1dd36407c9b1db25e36858a7bb1647128f1ddaab3f59e4fe01af33e8d92534b1c2187c70ddb61636110194086f4050370d2fc66c401a0a191bfbc20e4f0f32
+DIST freebsd-sources-EN-1615-vmbus.patch 2114 SHA256 166079ba7d6289a1f3f08a65aafc450e6119e86688a1cbbd808c6e39ca2a40f1 SHA512 81477e9f5e4980d3e0c0487fbc7b760e7500ef37be42444782cd1fb5202d33e622109519e4bf4ba419a4d13c250e27e01f34d77c57b504584a2fab77b4f122c6 WHIRLPOOL 1b19d57b6b66c408ef65157688967167ccef588b88d89ef42219bde49b592f2905045492e3fd2d3a6e3337b91ff60bb28c2f68daeb32b17cb575d465bff46e6e
+DIST freebsd-sources-EN-1616-hv_storvsc.patch 5358 SHA256 5516019b216edcd4b0f4268bac760ad24ecca85b9cf5da7e4c37b9d587975a24 SHA512 7364108737334ef7a12a8babf47b5139b973e68810b0cad335a6d8a7b7696fcfda047b1b7e85d28427f75001184a3c07418901ba0b9b152592d238bd392bf002 WHIRLPOOL 950aa89c4685d9ffc7306011a347dfbcc392b78a615a42cf7436820630a988407cb5c378b68e28d90b29df259f750ff91d0b623c35e1bdac37db7d7aeae88cf3
+DIST freebsd-sources-EN-1617-vm.patch 6332 SHA256 743a0ace4ea4a1afc9b5f5d2d26bf1eb842289f44f687348a0893b7566367be2 SHA512 8d8112d1df50ef45311736cb24dc8be38bc93e6246ef1cb0535928a6a4cd4cecd58e755e0ef7992197a3995f3a92893141e01f3dd7d095b4e645528dc9e060ff WHIRLPOOL e01cdbbd71bda85d547900a17bd0f21edd4418cb924aad41f078d990b01ca28377765879edc497aa3dad53ca6be43972eb8fb68e60c5521a52ac93e0809d6eac
+DIST freebsd-sources-EN-1707-vnet.patch 356 SHA256 4359de4eeb899953a6b60bcea372d5385e49d3999f72352c86452349a025f8dd SHA512 2fdb58388acb98811588beeabaf8a533926f96ac3f594f53dd80dcdb38ede4fe0dd66f0dd7bb32b40a27f756e2b03fed91c4416cbdcd4c16dd8143f5438885d7 WHIRLPOOL 1efc5b2fba85cd7af0d8b10788a19a9ea70628e7d1d3906632dba10057461812d0d88c7ff00247ba0675836377a76ebe54ebf665725ee4f975098fcc50e8bfb0
+DIST freebsd-sources-EN-1708-pf.patch 706 SHA256 34f177d1bb146a288ecfdc6107e750568b08d5d5129cd876ae1f0f4a1e1846e8 SHA512 e9dc61ff10aafb9b92721c599577ce995458b8a1a93b31fc6cc39b910db2b8f965ff0354a45bf82d2d57abba7aa0bf6d2f002044d242e19121d5ee4cd7a1dc15 WHIRLPOOL c16bacb48eeb39902ce2daec4dac8326ef21b23a76c73cc4c87dccb6642cac12c89c470bc63e41a2da9ca6eec86839d72fb5c2d35af803c7ea1208f33ecccad7
+DIST freebsd-sources-SA-1615-sysarch-01.patch 655 SHA256 471f70e82f81936a9426bdfd9052aa051013443537b25b750e3960a1ca3c02c1 SHA512 3ddc42f0e713a8f1753526b877141563b93d845e57cd111ef2219e969424efa88f3e726288bbd81fef7d4f06f2d68faa3f0c63c996a9579289236518e316739d WHIRLPOOL 9f8b40a78cb0f0d3bdb186541bba9fa92b45111fa156bad98bbbad82dfe25c930fb69801390061efcf544565e70e0ec9b5f11466d09ba996c732f0b3a3a2fa77
+DIST freebsd-sources-SA-1618-atkbd.patch 352 SHA256 63e159fc9000df20dfb626e0bdaab679577afd1a0d811363ad031e3a24e9f02b SHA512 aed4ee6b51905d04680181f571f0f89d60b66a2201c397f88931d9ce92b58148e2d638d93328a78ed53b4bf7a5040f1f646ba50566994252e73c13a09659ba3f WHIRLPOOL 1393954e2dd4a1617fe6242ba5458b9a8a1bf061a65854c84e2430ba76d0fb5eb030f6bcec253917063c6b96d6e718064f17e570a041497954e958059bd78c28
+DIST freebsd-sources-SA-1619-sendmsg.patch 247 SHA256 d847e42634e26e29b3ce1d68d28b7a687863070a4c1e3e51e7663785e2f6a7f0 SHA512 878e2b283358c050603cc32241077b25987696232bce3b9d41373c1186f5dbeb41881adc69e8754804054a57fffa71cad930b82ad8d5abd458779d5a3bd61978 WHIRLPOOL f077a1ba62110a5492d13413a1223b6b4b60553a0093a7344b5c7692b443cb5926c648ec151f6a566f1d099cc32df0c1ac0d29478843903e3cb8b221951d4e85
+DIST freebsd-sources-SA-1620-linux.patch 492 SHA256 a62f5402b2a3d2b73b684854eaed45864dade33f7b04d6469b556776866380a9 SHA512 1fb28b25ac5f89e2f7fa9a1f74ba83b4c949f2175217b669b5fcd2062c54307dcb50ad072acbe18162272b9bc29ba40ac4e19db1564a2959e885ac826a332ae5 WHIRLPOOL 7ba8da63513a495418a7e6433c4814eedb43e0305ada423057d2df27e90a51ce8b3caa7a06665fe114185c6335426ed12dbb346ef2a2c2c0d168a04707aa6395
+DIST freebsd-sources-SA-1621-stat.patch 223 SHA256 dd924b1f983ff653edb6676cb5f02621309c3493501c9741a35a2cbcc021cbbf SHA512 501244c0831d2aeb37c8a8aaa762cc6c8c39929355e6695df23dc83c78d6bb499dcb903f50c17e3f7774306d53836a0633d65e284167590c015aa1f8e10e5e4a WHIRLPOOL cd17cd613a2bb234224a21b491d4bfee6e9d9c43126689a8600f9d46eccf835661078fc926fd8a73599d30db770cb9fa0baa2817dcfb6ab3b06c1e39374bd946
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+DIST freebsd-sys-8.2.tar.bz2 25835329 SHA256 0c6c7b61aae94db2931f985d5899f3bca78fc8ffab6b598fbaa158142d676f16 SHA512 6ea4516a5c52e25c4f993f7acb875463a5caea93dbdf250c5d48eee95fff226956e9f030cab7e341b5e6a132325bc3dbf93dcb4b1185acb011918e50b1a22be3 WHIRLPOOL 870deeff877c6b9fc812a4260e4fdbb6715a5dc2065cab3bfbf2a42d876f6654703ccb124275a4e2c410cef48f3db02b63cc76059eccf9cf90244826f35b7a15
+DIST freebsd-sys-9.1.tar.bz2 32588103 SHA256 b93a7ac8334ac16cc9f60665048e5ef812c0a6c62f10d0b0a674aec3f56516a8 SHA512 7dc9d9e00dde8f592bb171f4386d02b655b73cb4f153fe5ec063d010a148ef0639eae0dcdb3eeb09ecd1e3653c69e49a2d261329fa6d0381d2ddabe258ddde6d WHIRLPOOL c8348344dfb14bad64bd3a78ee615ddd29203175b292233254f8ba175e7a3fb7218af6f95f7b4dbf394c0354bafe9d8bb0c21cdf0ceaeb697214964b280469b3
+EBUILD freebsd-sources-10.3-r6.ebuild 4898 SHA256 cfe1f99582b80e72e8cf152a3d873e238444bfcbfe38363afdf5a0b4e4ffe62c SHA512 9476b45b1c353df0fa9dc6b15665b666e8b1d24d5885647f63b94abde6cc5f4ca77175eccfacbf925e2d42895c5d683dfc7c40a3e450f03acae134bdceadbfd3 WHIRLPOOL 13f3afff7174dd33b7aa4a3729067521b217eda2e8f83ec150f347ff0c5f0bf9394681dbb2e3d1aec7047719e7ecd117d1c90568716ef4deaede30578a47147e
+EBUILD freebsd-sources-11.0-r1.ebuild 4846 SHA256 ed18ed971cebc84c608194c3b6b3b94e00266ee620fbc1f49e920f9bb869cbda SHA512 32302cf50a644d87df08f7e75b7e1fb6340ea925c31b9c701463f76975f5947b90899e101bba66d6b5610a797727f929806ae9c9637c1b35d19503c34121de76 WHIRLPOOL 4dee819a0983bf2f31872394b0ea840602eaaa7c526c3b92c419a56a7443afae3a305aa91817103616b0de45b24ada8cd621aaaa1c1522872170c1e598100cfc
+EBUILD freebsd-sources-11.1_p1.ebuild 4874 SHA256 556f4f1cbf46cf64a3a0129f07001d44924e43b54981a086d246efdee8d4c9c4 SHA512 3c88b5edbb79250465c302a8ec653ec6c023b645a52faf7beccb1e6cf6bc33d433b5b68729069e30ca29c9102e70a5621277351055d376b19650eaea32b04e20 WHIRLPOOL b20954eec390b3aa7c2525adb803d7a8868dba0edc1f2ad89a9da8efe97a9e389ba3c9b6c21f02fec37e00d4906bace5b37f8bdb3bc016b3c68bb222d936312b
+EBUILD freebsd-sources-8.2-r2.ebuild 3671 SHA256 ca78f43810a54f1c4112683c7c130410eb9b116d41b40569f872a815fad030ef SHA512 4e2c7ff852639c0cc5124beb0a3b5f998780553892eae1d1c6bbc2b253a82e56838897062f6e55e4fb47be2f99060f1e9b7392e794b25a49a38d925774a1423a WHIRLPOOL 8c91c7a7cabfa3febfb97b88e60a75a8224ce02d2ccbfb8ce7c17e4ad57be5dc402b476616266a53e83f395d2202d70c76cc79393cdf9be17b930e4abdd7e353
+EBUILD freebsd-sources-9.1-r3.ebuild 2514 SHA256 035ac213985f98d3ff19a9559cda9ba7321af713aea284122cdc94b439a99a48 SHA512 e21a899b3329ac8abfb1a167a56a71a6e37b0b3ec50af9f6274f2353c2a422805a62543105eeda21a1f7d7a4325de6bb749b08851ffe7f5e8b113d8e8571023d WHIRLPOOL f5112f9e31b5ea3b6f3adb767720d5533ae2075ecce3a239e6d793b50007ba0d60f11d03640eda5a2e13c6f67cf229eb99527f6793da77e1aa7220ff2f5e3133
+EBUILD freebsd-sources-9.1-r9.ebuild 3059 SHA256 21ff076faab90f4fe1486203123674f87740154a48248820e4356ba1d8e4634d SHA512 5e241adb02fe3b5fedbd4dac59c1f38d815c2b1041bf6efdd0ed406ff9b380ff7b8ba72210539fc94a11dbb3d7b7422a162e03ee0fb393f8fa7a77df3b327d55 WHIRLPOOL a7c3a84a5f1c4801699c083bea25d0b4f821f2d9e8a92a1f89bd41b2df345e5b578f9fa6941294f1ccf9087f9e6ba82c5edfa9d2d8d881dd84720817cf29f2af
+MISC ChangeLog 9759 SHA256 7b98dd78ff705ba9f5e7374eec73f9267b6228a89d3655d1a3a56e1628b341f3 SHA512 68e400beacc26e48b6700ef4759f5467d56830cd5b0696b61665afb9c800b10054c5a6dfbd4a2b6343af936caa52be3cf2d3b551f91b5fbd4c72dc05d36d977b WHIRLPOOL a5aa526a291a28159fa2b49bc8b900ed4ebd897f4bb2a9b73e90c98efd1c147b62249c3358b871db1ee770def2c3a1c920fa1fe8c5b40ee7d353a62f81883f58
+MISC ChangeLog-2015 29998 SHA256 2a7cf0c8d8ffc2a93861c3636353d697b10a8b3e2ddce1faace78074680f893a SHA512 e89cf7f1857cae0bf0ae1cb5e2480c959f46b3e8ee91a26be5452214a77f697d6f9e3584c9ced4906164986928b43e4699ab65c918ae9366cab719d8b0357583 WHIRLPOOL d4ae89862be8617a877e31724431b6d854209c6d8219ad309a4407e3a2e441863faa7798e22ccd49485b9ecd0ebc3322acc3d66cb4608974a2b23517cce7492e
+MISC metadata.xml 444 SHA256 c4696a22f747056498f14d7fbac5d3b317ee5ed5d0762351003ae7873475ff39 SHA512 9e2abef67d9a4092a62f92a0b32e5d8547a046d26551ef15c577dedf3b56231ba055702a7476104993a8ed15717b5610d1cdbd6c167b0571a84392f41f177cdc WHIRLPOOL af64f83a4459752b8b8656412abaf5feaedbaa4b06dbbd0a71f31fc440eb945d39617a540e6b9969586b190c984452f1eaded80062481c6b2b0121482cfa61c2
diff --git a/sys-freebsd/freebsd-sources/files/config-GENTOO b/sys-freebsd/freebsd-sources/files/config-GENTOO
new file mode 100644
index 000000000000..7c7eb26cccc2
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/config-GENTOO
@@ -0,0 +1,4 @@
+# Kernel configuration for Gentoo/FreeBSD.
+include GENERIC
+ident GENTOO
+
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-10.0-gentoo.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-10.0-gentoo.patch
new file mode 100644
index 000000000000..c7e12bdf8a4e
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-10.0-gentoo.patch
@@ -0,0 +1,22 @@
+diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
+index 2939a59..124ef6f 100644
+--- a/sys/conf/kern.mk
++++ b/sys/conf/kern.mk
+@@ -5,7 +5,7 @@
+ #
+ CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
+ -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
+- -Wundef -Wno-pointer-sign ${FORMAT_EXTENSIONS} \
++ -Wundef -Wno-pointer-sign \
+ -Wmissing-include-dirs -fdiagnostics-show-option \
+ ${CWARNEXTRA}
+ #
+@@ -61,7 +61,7 @@ FORMAT_EXTENSIONS= -fformat-extensions
+ #
+ .if ${MACHINE_CPUARCH} == "i386"
+ .if ${COMPILER_TYPE} != "clang"
+-CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2
++CFLAGS+= -mpreferred-stack-boundary=2
+ .else
+ CFLAGS+= -mno-aes -mno-avx
+ .endif
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-10.1-gcc48.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-10.1-gcc48.patch
new file mode 100644
index 000000000000..5cb4cf809b12
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-10.1-gcc48.patch
@@ -0,0 +1,18 @@
+https://svnweb.freebsd.org/base?view=revision&revision=281606
+
+diff --git a/sys/crypto/aesni/aesencdec.h b/sys/crypto/aesni/aesencdec.h
+index d4ed8b3..79847ee 100644
+--- a/sys/crypto/aesni/aesencdec.h
++++ b/sys/crypto/aesni/aesencdec.h
+@@ -27,6 +27,11 @@
+ *
+ */
+
++#if defined(__GNUC__) && defined(_KERNEL)
++/* Suppress inclusion of gcc's mm_malloc.h header */
++#define _MM_MALLOC_H_INCLUDED 1
++#endif
++
+ #include <wmmintrin.h>
+
+ static inline void
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-11.0-gentoo-gcc.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-11.0-gentoo-gcc.patch
new file mode 100644
index 000000000000..1d3c8d68a2ee
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-11.0-gentoo-gcc.patch
@@ -0,0 +1,13 @@
+diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
+index e4b2ad4..411bedf 100644
+--- a/sys/conf/newvers.sh
++++ b/sys/conf/newvers.sh
+@@ -110,7 +110,7 @@ else
+ t=`date`
+ fi
+ i=`${MAKE:-make} -V KERN_IDENT`
+-compiler_v=$($(${MAKE:-make} -V CC) -v 2>&1 | grep -w 'version')
++compiler_v=$($(${MAKE:-make} -V CC) -v 2>&1 | grep 'version' | tail -n 1)
+
+ for dir in /usr/bin /usr/local/bin; do
+ if [ ! -z "${svnversion}" ] ; then
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-11.0-gentoo.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-11.0-gentoo.patch
new file mode 100644
index 000000000000..6acd6aab3608
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-11.0-gentoo.patch
@@ -0,0 +1,22 @@
+diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
+index e27ea93..615dbac 100644
+--- a/sys/conf/kern.mk
++++ b/sys/conf/kern.mk
+@@ -5,7 +5,7 @@
+ #
+ CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
+ -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
+- -Wundef -Wno-pointer-sign ${FORMAT_EXTENSIONS} \
++ -Wundef -Wno-pointer-sign \
+ -Wmissing-include-dirs -fdiagnostics-show-option \
+ -Wno-unknown-pragmas \
+ ${CWARNEXTRA}
+@@ -86,7 +86,7 @@ FORMAT_EXTENSIONS= -fformat-extensions
+ # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
+ #
+ .if ${MACHINE_CPUARCH} == "i386"
+-CFLAGS.gcc+= -mno-align-long-strings -mpreferred-stack-boundary=2
++CFLAGS.gcc+= -mpreferred-stack-boundary=2
+ CFLAGS.clang+= -mno-aes -mno-avx
+ CFLAGS+= -mno-mmx -mno-sse -msoft-float
+ INLINE_LIMIT?= 8000
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-6.0-flex-2.5.31.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-6.0-flex-2.5.31.patch
new file mode 100644
index 000000000000..88710cf69dd8
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-6.0-flex-2.5.31.patch
@@ -0,0 +1,22 @@
+Index: fbsd-6/sys/dev/aic7xxx/aicasm/aicasm_scan.l
+===================================================================
+--- fbsd-6.orig/sys/dev/aic7xxx/aicasm/aicasm_scan.l
++++ fbsd-6/sys/dev/aic7xxx/aicasm/aicasm_scan.l
+@@ -528,7 +528,7 @@ expand_macro(struct symbol *macro_symbol
+
+ /* Put back everything up until the replacement. */
+ while (body_pos > next_match)
+- unput(*--body_pos);
++ yyunput(*--body_pos, body_head);
+
+ /* Perform the replacement. */
+ if (match_marg != NULL) {
+@@ -537,7 +537,7 @@ expand_macro(struct symbol *macro_symbol
+ next_match = match_marg->replacement_text;
+ strp = next_match + strlen(next_match);
+ while (strp > next_match)
+- unput(*--strp);
++ yyunput(*--strp, next_match);
+
+ /* Skip past the unexpanded macro arg. */
+ body_pos -= match.rm_eo - match.rm_so;
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-6.1-ntfs.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-6.1-ntfs.patch
new file mode 100644
index 000000000000..e74fcd3f9b88
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-6.1-ntfs.patch
@@ -0,0 +1,32 @@
+--- sys/fs/ntfs/ntfs_vnops.c.orig 2006-10-17 17:31:36 -0300
++++ sys/fs/ntfs/ntfs_vnops.c 2006-10-17 17:30:24 -0300
+@@ -507,8 +507,12 @@
+
+ /* Simulate . in every dir except ROOT */
+ if( ip->i_number != NTFS_ROOTINO ) {
+- struct dirent dot = { NTFS_ROOTINO,
+- sizeof(struct dirent), DT_DIR, 1, "." };
++ struct dirent dot;
++ dot.d_fileno = NTFS_ROOTINO;
++ dot.d_reclen = sizeof(struct dirent);
++ dot.d_type = DT_DIR;
++ dot.d_namlen = 1;
++ bcopy(".", dot.d_name, 1);
+
+ if( uio->uio_offset < sizeof(struct dirent) ) {
+ dot.d_fileno = ip->i_number;
+@@ -522,8 +526,12 @@
+
+ /* Simulate .. in every dir including ROOT */
+ if( uio->uio_offset < 2 * sizeof(struct dirent) ) {
+- struct dirent dotdot = { NTFS_ROOTINO,
+- sizeof(struct dirent), DT_DIR, 2, ".." };
++ struct dirent dotdot;
++ dotdot.d_fileno = NTFS_ROOTINO;
++ dotdot.d_reclen = sizeof(struct dirent);
++ dotdot.d_type = DT_DIR;
++ dotdot.d_namlen = 2;
++ bcopy("..", dotdot.d_name, 2);
+
+ error = uiomove((char *)&dotdot,sizeof(struct dirent),uio);
+ if(error)
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-7.0-tmpfs_whiteout_stub.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.0-tmpfs_whiteout_stub.patch
new file mode 100644
index 000000000000..13524efa6e00
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.0-tmpfs_whiteout_stub.patch
@@ -0,0 +1,44 @@
+diff -ur sys/fs/tmpfs.orig/tmpfs_vnops.c sys/fs/tmpfs/tmpfs_vnops.c
+--- sys/fs/tmpfs.orig/tmpfs_vnops.c 2008-06-22 12:17:48 -0300
++++ sys/fs/tmpfs/tmpfs_vnops.c 2008-06-28 12:05:10 -0300
+@@ -1459,6 +1459,30 @@
+ return (0);
+ }
+
++
++/* --------------------------------------------------------------------- */
++/* This does absolutely nothing */
++#ifdef GENTOO_LIVECD
++static int
++tmpfs_whiteout(struct vop_whiteout_args *ap)
++{
++ switch (ap->a_flags) {
++ case LOOKUP:
++ return (0);
++ break;
++ case CREATE:
++ return(EOPNOTSUPP);
++ break;
++ case DELETE:
++ return (0);
++ break;
++ default:
++ return(EOPNOTSUPP);
++ }
++ return(0);
++}
++#endif
++
+ /* --------------------------------------------------------------------- */
+
+ /*
+@@ -1484,6 +1508,9 @@
+ .vop_mkdir = tmpfs_mkdir,
+ .vop_rmdir = tmpfs_rmdir,
+ .vop_symlink = tmpfs_symlink,
++#ifdef GENTOO_LIVECD
++ .vop_whiteout = tmpfs_whiteout,
++#endif
+ .vop_readdir = tmpfs_readdir,
+ .vop_readlink = tmpfs_readlink,
+ .vop_inactive = tmpfs_inactive,
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-binutils_link.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-binutils_link.patch
new file mode 100644
index 000000000000..43d01baef347
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-binutils_link.patch
@@ -0,0 +1,37 @@
+diff -ruN sys.orig/conf/kern.post.mk sys/conf/kern.post.mk
+--- sys.orig/conf/kern.post.mk 2007-03-23 18:55:59 -0300
++++ sys/conf/kern.post.mk 2008-06-18 19:51:13 -0300
+@@ -85,7 +85,9 @@
+ ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
+ @rm -f ${.TARGET}
+ @echo linking ${.TARGET}
+- ${SYSTEM_LD}
++ ${SYSTEM_LD} -o ${.TARGET}.tmp
++ @sh $S/tools/gen-ld-u-options ${.TARGET}.tmp > ${.TARGET}.lopt
++ ${SYSTEM_LD} "@${.TARGET}.lopt"
+ .if defined(CTFMERGE)
+ ${SYSTEM_CTFMERGE}
+ .endif
+diff -ruN sys.orig/conf/kmod.mk sys/conf/kmod.mk
+--- sys.orig/conf/kmod.mk 2008-06-18 09:11:53 -0300
++++ sys/conf/kmod.mk 2008-06-18 19:50:01 -0300
+@@ -176,7 +176,8 @@
+
+ .if ${MACHINE_ARCH} != amd64
+ ${FULLPROG}: ${KMOD}.kld
+- ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld
++ sh ./@/tools/gen-ld-u-options ${KMOD}.kld > ${KMOD}.lopt
++ ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld "@${KMOD}.lopt"
+ .if !defined(DEBUG_FLAGS)
+ ${OBJCOPY} --strip-debug ${.TARGET}
+ .endif
+diff -ruN sys.orig/tools/gen-ld-u-options sys/tools/gen-ld-u-options
+--- sys.orig/tools/gen-ld-u-options 1969-12-31 21:00:00 -0300
++++ sys/tools/gen-ld-u-options 2008-06-18 19:47:56 -0300
+@@ -0,0 +1,6 @@
++#!/bin/sh
++
++for i in `objdump -h -w $1 | grep set_ | cut -c5- | cut -f1 -d " "`
++do
++ echo -n " -u __start_$i -u __stop_$i "
++done
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-includes.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-includes.patch
new file mode 100644
index 000000000000..3db46fa1d7e3
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-includes.patch
@@ -0,0 +1,13 @@
+Make headers usable alone, include the headers they need.
+There are probably much more missing.
+
+--- sys/net/if.h.old 2009-05-15 10:51:50 +0000
++++ sys/net/if.h 2009-05-15 10:52:05 +0000
+@@ -34,6 +34,7 @@
+ #define _NET_IF_H_
+
+ #include <sys/cdefs.h>
++#include <sys/socket.h>
+
+ #ifdef _KERNEL
+ #include <sys/queue.h>
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-types.h-fix.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-types.h-fix.patch
new file mode 100644
index 000000000000..8de5df2d16a6
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.1-types.h-fix.patch
@@ -0,0 +1,15 @@
+Fixes a compile error if XOPEN_SOURCE 600 is defined.
+
+See: http://www.mailinglistarchive.com/freebsd-current@freebsd.org/msg15011.html
+
+--- sys/sys/types.h.orig
++++ sys/sys/types.h
+@@ -46,7 +46,7 @@
+
+ #include <sys/_pthreadtypes.h>
+
+-#if __BSD_VISIBLE
++#ifndef _POSIX_SOURCE
+ typedef unsigned char u_char;
+ typedef unsigned short u_short;
+ typedef unsigned int u_int;
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-7.2-debug-O2.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.2-debug-O2.patch
new file mode 100644
index 000000000000..4fa3565207ec
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-7.2-debug-O2.patch
@@ -0,0 +1,27 @@
+My UltraSPARC U5 panics on boot about a memory alignment error when compiled
+with gcc4 and -O. Compiling with -O2 fixes this, and it should not adversly
+affect debugging.
+
+NOTE: This does not fix the memory alignment panic when loading kernel modules.
+
+Roy Marples (uberlord@gentoo.org)
+
+--- sys/conf/kern.pre.mk.old 2009-05-22 10:09:46 +0000
++++ sys/conf/kern.pre.mk 2009-05-22 10:10:27 +0000
+@@ -22,15 +22,13 @@
+ COPTFLAGS?= -O
+ .else
+ . if defined(DEBUG)
+-_MINUS_O= -O
+ CTFFLAGS+= -g
+ . else
+-_MINUS_O= -O2
+ . endif
+ . if ${MACHINE_ARCH} == "amd64"
+ COPTFLAGS?=-O2 -frename-registers -pipe
+ . else
+-COPTFLAGS?=${_MINUS_O} -pipe
++COPTFLAGS?=-O2 -pipe
+ . endif
+ . if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
+ COPTFLAGS+= -fno-strict-aliasing
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-gentoo.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-gentoo.patch
new file mode 100644
index 000000000000..0f8d070e9a31
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-gentoo.patch
@@ -0,0 +1,33 @@
+--- sys/conf/kern.mk.old 2007-05-24 23:53:42.000000000 +0200
++++ sys/conf/kern.mk 2008-03-14 14:37:47.216420518 +0100
+@@ -12,7 +12,7 @@
+ .else
+ CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
+ -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
+- ${_wundef} ${_Wno_pointer_sign} -fformat-extensions
++ ${_wundef} ${_Wno_pointer_sign}
+ .if !defined(WITH_GCC3)
+ _Wno_pointer_sign=-Wno-pointer-sign
+ .endif
+@@ -36,7 +36,7 @@
+ # reserved for user applications.
+ #
+ .if ${MACHINE_ARCH} == "i386" && ${CC} != "icc"
+-CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2 \
++CFLAGS+= -mpreferred-stack-boundary=2 \
+ -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3
+ INLINE_LIMIT?= 8000
+ .endif
+Only in ./sys/conf: kern.mk.rej
+Only in ./sys/conf: kern.mk~
+--- sys/dev/aic7xxx/aicasm/Makefile.old 2010-03-10 14:01:50 +0100
++++ sys/dev/aic7xxx/aicasm/Makefile 2010-03-10 14:01:56 +0100
+@@ -14,7 +14,7 @@
+ SRCS= ${GENHDRS} ${CSRCS} ${YSRCS} ${LSRCS}
+ CLEANFILES+= ${GENHDRS} ${YSRCS:R:C/(.*)/\1.output/g}
+ DPADD= ${LIBL}
+-LDADD= -ll
++LDADD= -lfl
+ WARNS?= 6
+
+ # Correct path for kernel builds
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-subnet-route-pr40133.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-subnet-route-pr40133.patch
new file mode 100644
index 000000000000..a7335f6d427f
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-8.0-subnet-route-pr40133.patch
@@ -0,0 +1,21 @@
+Fixes changing the default subnet route after removing an ip address.
+
+See: http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=40133
+and http://mail-index.netbsd.org/tech-net/2008/12/03/msg000896.html
+
+Thanks to Roy Marples.
+--- sys/netinet/in.c.orig
++++ sys/netinet/in.c
+@@ -858,6 +858,12 @@
+ error = rtinit(&target->ia_ifa, (int)RTM_ADD, flags);
+ if (!error)
+ target->ia_flags |= IFA_ROUTE;
++ else if (error == EEXIST) {
++ /*
++ * the fact that the route already exists is not an error.
++ */
++ error = 0;
++ }
+ return (error);
+ }
+
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-8.2-unix2.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-8.2-unix2.patch
new file mode 100644
index 000000000000..50dacd0e5a49
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-8.2-unix2.patch
@@ -0,0 +1,55 @@
+Index: sys/kern/uipc_usrreq.c
+===================================================================
+--- sys/kern/uipc_usrreq.c (revision 225745)
++++ sys/kern/uipc_usrreq.c (working copy)
+@@ -462,6 +462,8 @@
+ unp = sotounpcb(so);
+ KASSERT(unp != NULL, ("uipc_bind: unp == NULL"));
+
++ if (soun->sun_len > sizeof(struct sockaddr_un))
++ return (EINVAL);
+ namelen = soun->sun_len - offsetof(struct sockaddr_un, sun_path);
+ if (namelen <= 0)
+ return (EINVAL);
+@@ -1252,6 +1254,8 @@
+ unp = sotounpcb(so);
+ KASSERT(unp != NULL, ("unp_connect: unp == NULL"));
+
++ if (nam->sa_len > sizeof(struct sockaddr_un))
++ return (EINVAL);
+ len = nam->sa_len - offsetof(struct sockaddr_un, sun_path);
+ if (len <= 0)
+ return (EINVAL);
+Index: sys/compat/linux/linux_socket.c
+===================================================================
+--- sys/compat/linux/linux_socket.c (revision 225919)
++++ sys/compat/linux/linux_socket.c (working copy)
+@@ -104,6 +104,7 @@
+ int oldv6size;
+ struct sockaddr_in6 *sin6;
+ #endif
++ int namelen;
+
+ if (*osalen < 2 || *osalen > UCHAR_MAX || !osa)
+ return (EINVAL);
+@@ -166,6 +167,20 @@
+ }
+ }
+
++ if ((bdom == AF_LOCAL) && (*osalen > sizeof(struct sockaddr_un))) {
++ for (namelen = 0;
++ namelen < *osalen - offsetof(struct sockaddr_un, sun_path);
++ namelen++)
++ if (!((struct sockaddr_un *)kosa)->sun_path[namelen])
++ break;
++ if (namelen + offsetof(struct sockaddr_un, sun_path) >
++ sizeof(struct sockaddr_un)) {
++ error = EINVAL;
++ goto out;
++ }
++ alloclen = sizeof(struct sockaddr_un);
++ }
++
+ sa = (struct sockaddr *) kosa;
+ sa->sa_family = bdom;
+ sa->sa_len = alloclen;
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-disable-optimization.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-disable-optimization.patch
new file mode 100644
index 000000000000..4824ff6e1a09
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-disable-optimization.patch
@@ -0,0 +1,32 @@
+Taken from debian GNU/kFreeBSD.
+
+Regretably, with GCC 4.4 or later this is the only flag combination
+I could find that doesn't cause kernel panics CPU triple-faults or
+other kind of severe breakage. This is Gentoo Bug #410945.
+
+Clang can use -O2, so we do not force -O1 on it
+
+--- a/sys/conf/kern.pre.mk
++++ b/sys/conf/kern.pre.mk
+@@ -41,6 +41,9 @@
+ .if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
+ COPTFLAGS+= -fno-strict-aliasing
+ .endif
++.if ${CC:T:Mclang} != "clang" && !empty(COPTFLAGS:M-O[23s])
++COPTFLAGS+= -O1
++.endif
+ .if !defined(NO_CPU_COPTFLAGS)
+ COPTFLAGS+= ${_CPUCFLAGS}
+ .endif
+--- a/sys/conf/kmod.mk
++++ b/sys/conf/kmod.mk
+@@ -91,6 +91,9 @@
+ .if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing)
+ CFLAGS+= -fno-strict-aliasing
+ .endif
++.if ${CC:T:Mclang} != "clang" && !empty(CFLAGS:M-O[23s])
++CFLAGS+= -O1
++.endif
+ WERROR?= -Werror
+ CFLAGS+= ${WERROR}
+ CFLAGS+= -D_KERNEL
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-ipv6refcount.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-ipv6refcount.patch
new file mode 100644
index 000000000000..f0984f6776c8
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-ipv6refcount.patch
@@ -0,0 +1,128 @@
+Index: sys/netinet6/in6.c
+===================================================================
+--- sys/netinet6/in6.c.orig
++++ sys/netinet6/in6.c
+@@ -1369,6 +1369,8 @@ in6_purgeaddr(struct ifaddr *ifa)
+ }
+
+ cleanup:
++ if (ifa0 != NULL)
++ ifa_free(ifa0);
+
+ plen = in6_mask2len(&ia->ia_prefixmask.sin6_addr, NULL); /* XXX */
+ if ((ia->ia_flags & IFA_ROUTE) && plen == 128) {
+@@ -1393,8 +1395,6 @@ cleanup:
+ return;
+ ia->ia_flags &= ~IFA_ROUTE;
+ }
+- if (ifa0 != NULL)
+- ifa_free(ifa0);
+
+ in6_unlink_ifa(ia, ifp);
+ }
+@@ -1667,14 +1667,19 @@ in6_lifaddr_ioctl(struct socket *so, u_long cmd, c
+ hostid = IFA_IN6(ifa);
+
+ /* prefixlen must be <= 64. */
+- if (64 < iflr->prefixlen)
++ if (64 < iflr->prefixlen) {
++ if (ifa != NULL)
++ ifa_free(ifa);
+ return EINVAL;
++ }
+ prefixlen = iflr->prefixlen;
+
+ /* hostid part must be zero. */
+ sin6 = (struct sockaddr_in6 *)&iflr->addr;
+ if (sin6->sin6_addr.s6_addr32[2] != 0 ||
+ sin6->sin6_addr.s6_addr32[3] != 0) {
++ if (ifa != NULL)
++ ifa_free(ifa);
+ return EINVAL;
+ }
+ } else
+@@ -2265,14 +2265,20 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr
+ IN6_IFADDR_RUNLOCK();
+ return (struct in6_ifaddr *)ifa;
+ }
+- IN6_IFADDR_RUNLOCK();
+
+ /* use the last-resort values, that are, deprecated addresses */
+- if (dep[0])
++ if (dep[0]) {
++ ifa_ref((struct ifaddr *)dep[0]);
++ IN6_IFADDR_RUNLOCK();
+ return dep[0];
+- if (dep[1])
++ }
++ if (dep[1]) {
++ ifa_ref((struct ifaddr *)dep[1]);
++ IN6_IFADDR_RUNLOCK();
+ return dep[1];
++ }
+
++ IN6_IFADDR_RUNLOCK();
+ return NULL;
+ }
+
+Index: sys/netinet6/ip6_input.c
+===================================================================
+--- sys/netinet6/ip6_input.c.orig
++++ sys/netinet6/ip6_input.c
+@@ -879,19 +879,23 @@ passin:
+ * as our interface address (e.g. multicast addresses, addresses
+ * within FAITH prefixes and such).
+ */
+- if (deliverifp && !ip6_getdstifaddr(m)) {
++ if (deliverifp) {
+ struct in6_ifaddr *ia6;
+
+- ia6 = in6_ifawithifp(deliverifp, &ip6->ip6_dst);
+- if (ia6) {
+- if (!ip6_setdstifaddr(m, ia6)) {
+- /*
+- * XXX maybe we should drop the packet here,
+- * as we could not provide enough information
+- * to the upper layers.
+- */
++ if ((ia6 = ip6_getdstifaddr(m)) != NULL) {
++ ifa_free(&ia6->ia_ifa);
++ } else {
++ ia6 = in6_ifawithifp(deliverifp, &ip6->ip6_dst);
++ if (ia6) {
++ if (!ip6_setdstifaddr(m, ia6)) {
++ /*
++ * XXX maybe we should drop the packet here,
++ * as we could not provide enough information
++ * to the upper layers.
++ */
++ }
++ ifa_free(&ia6->ia_ifa);
+ }
+- ifa_free(&ia6->ia_ifa);
+ }
+ }
+
+Index: sys/netinet/tcp_input.c
+===================================================================
+--- sys/netinet/tcp_input.c.orig
++++ sys/netinet/tcp_input.c
+@@ -512,6 +512,8 @@ tcp6_input(struct mbuf **mp, int *offp, int proto)
+ (caddr_t)&ip6->ip6_dst - (caddr_t)ip6);
+ return IPPROTO_DONE;
+ }
++ if (ia6)
++ ifa_free(&ia6->ia_ifa);
+
+ tcp_input(m, *offp);
+ return IPPROTO_DONE;
+@@ -1240,7 +1242,8 @@ relocked:
+ rstreason = BANDLIM_RST_OPENPORT;
+ goto dropwithreset;
+ }
+- ifa_free(&ia6->ia_ifa);
++ if (ia6)
++ ifa_free(&ia6->ia_ifa);
+ }
+ #endif /* INET6 */
+ /*
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-sysctluint.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-sysctluint.patch
new file mode 100644
index 000000000000..751a77c843bb
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.0-sysctluint.patch
@@ -0,0 +1,13 @@
+u_int is defined in sys/types.h
+makes header usable alone.
+
+--- sys/sys/sysctl.h.old 2012-05-25 11:08:53.000000000 -0400
++++ sys/sys/sysctl.h 2012-05-25 11:09:16.000000000 -0400
+@@ -788,6 +788,7 @@
+ struct sysctl_req *);
+ #else /* !_KERNEL */
+ #include <sys/cdefs.h>
++#include <sys/types.h> /* for u_int */
+
+ __BEGIN_DECLS
+ int sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ciss.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ciss.patch
new file mode 100644
index 000000000000..697984b92e74
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ciss.patch
@@ -0,0 +1,65 @@
+Index: sys/dev/ciss/ciss.c
+===================================================================
+--- sys/dev/ciss/ciss.c (revision 264510)
++++ sys/dev/ciss/ciss.c (revision 264511)
+@@ -180,8 +180,6 @@
+ static void ciss_cam_poll(struct cam_sim *sim);
+ static void ciss_cam_complete(struct ciss_request *cr);
+ static void ciss_cam_complete_fixup(struct ciss_softc *sc, struct ccb_scsiio *csio);
+-static struct cam_periph *ciss_find_periph(struct ciss_softc *sc,
+- int bus, int target);
+ static int ciss_name_device(struct ciss_softc *sc, int bus, int target);
+
+ /* periodic status monitoring */
+@@ -3398,27 +3396,6 @@
+
+
+ /********************************************************************************
+- * Find a peripheral attached at (target)
+- */
+-static struct cam_periph *
+-ciss_find_periph(struct ciss_softc *sc, int bus, int target)
+-{
+- struct cam_periph *periph;
+- struct cam_path *path;
+- int status;
+-
+- status = xpt_create_path(&path, NULL, cam_sim_path(sc->ciss_cam_sim[bus]),
+- target, 0);
+- if (status == CAM_REQ_CMP) {
+- periph = cam_periph_find(path, NULL);
+- xpt_free_path(path);
+- } else {
+- periph = NULL;
+- }
+- return(periph);
+-}
+-
+-/********************************************************************************
+ * Name the device at (target)
+ *
+ * XXX is this strictly correct?
+@@ -3427,12 +3404,22 @@
+ ciss_name_device(struct ciss_softc *sc, int bus, int target)
+ {
+ struct cam_periph *periph;
++ struct cam_path *path;
++ int status;
+
+ if (CISS_IS_PHYSICAL(bus))
+ return (0);
+- if ((periph = ciss_find_periph(sc, bus, target)) != NULL) {
++
++ status = xpt_create_path(&path, NULL, cam_sim_path(sc->ciss_cam_sim[bus]),
++ target, 0);
++
++ if (status == CAM_REQ_CMP) {
++ mtx_lock(&sc->ciss_mtx);
++ periph = cam_periph_find(path, NULL);
+ sprintf(sc->ciss_logical[bus][target].cl_name, "%s%d",
+ periph->periph_name, periph->unit_number);
++ mtx_unlock(&sc->ciss_mtx);
++ xpt_free_path(path);
+ return(0);
+ }
+ sc->ciss_logical[bus][target].cl_name[0] = 0;
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3077.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3077.patch
new file mode 100644
index 000000000000..23f68ed9c3db
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3077.patch
@@ -0,0 +1,26 @@
+Index: sys/netinet/in_mcast.c
+===================================================================
+--- sys/netinet/in_mcast.c (revision 254252)
++++ sys/netinet/in_mcast.c (working copy)
+@@ -1648,6 +1648,8 @@
+ * has asked for, but we always tell userland how big the
+ * buffer really needs to be.
+ */
++ if (msfr.msfr_nsrcs > in_mcast_maxsocksrc)
++ msfr.msfr_nsrcs = in_mcast_maxsocksrc;
+ tss = NULL;
+ if (msfr.msfr_srcs != NULL && msfr.msfr_nsrcs > 0) {
+ tss = malloc(sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs,
+Index: sys/netinet6/in6_mcast.c
+===================================================================
+--- sys/netinet6/in6_mcast.c (revision 254252)
++++ sys/netinet6/in6_mcast.c (working copy)
+@@ -1625,6 +1625,8 @@
+ * has asked for, but we always tell userland how big the
+ * buffer really needs to be.
+ */
++ if (msfr.msfr_nsrcs > in6_mcast_maxsocksrc)
++ msfr.msfr_nsrcs = in6_mcast_maxsocksrc;
+ tss = NULL;
+ if (msfr.msfr_srcs != NULL && msfr.msfr_nsrcs > 0) {
+ tss = malloc(sizeof(struct sockaddr_storage) * msfr.msfr_nsrcs,
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3266.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3266.patch
new file mode 100644
index 000000000000..0d1a89419e5f
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-3266.patch
@@ -0,0 +1,13 @@
+Index: sys/fs/nfsserver/nfs_nfsdport.c
+===================================================================
+--- sys/fs/nfsserver/nfs_nfsdport.c (revision 249651)
++++ sys/fs/nfsserver/nfs_nfsdport.c (working copy)
+@@ -1568,6 +1568,8 @@ nfsrvd_readdir(struct nfsrv_descript *nd, int isdg
+ nd->nd_repstat = NFSERR_BAD_COOKIE;
+ #endif
+ }
++ if (!nd->nd_repstat && vp->v_type != VDIR)
++ nd->nd_repstat = NFSERR_NOTDIR;
+ if (nd->nd_repstat == 0 && cnt == 0) {
+ if (nd->nd_flag & ND_NFSV2)
+ /* NFSv2 does not have NFSERR_TOOSMALL */
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5209.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5209.patch
new file mode 100644
index 000000000000..e6710e3bcb8b
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5209.patch
@@ -0,0 +1,19 @@
+Index: sys/netinet/sctp_output.c
+===================================================================
+--- sys/netinet/sctp_output.c (revision 254337)
++++ sys/netinet/sctp_output.c (revision 254338)
+@@ -5406,6 +5406,14 @@
+ }
+ SCTP_BUF_LEN(m) = sizeof(struct sctp_init_chunk);
+
++ /*
++ * We might not overwrite the identification[] completely and on
++ * some platforms time_entered will contain some padding. Therefore
++ * zero out the cookie to avoid putting uninitialized memory on the
++ * wire.
++ */
++ memset(&stc, 0, sizeof(struct sctp_state_cookie));
++
+ /* the time I built cookie */
+ (void)SCTP_GETTIME_TIMEVAL(&stc.time_entered);
+
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5691.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5691.patch
new file mode 100644
index 000000000000..9aef1503f770
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5691.patch
@@ -0,0 +1,89 @@
+Index: sys/net/if.c
+===================================================================
+--- sys/net/if.c (revision 254941)
++++ sys/net/if.c (working copy)
+@@ -2553,11 +2553,23 @@
+ CURVNET_RESTORE();
+ return (EOPNOTSUPP);
+ }
++
++ /*
++ * Pass the request on to the socket control method, and if the
++ * latter returns EOPNOTSUPP, directly to the interface.
++ *
++ * Make an exception for the legacy SIOCSIF* requests. Drivers
++ * trust SIOCSIFADDR et al to come from an already privileged
++ * layer, and do not perform any credentials checks or input
++ * validation.
++ */
+ #ifndef COMPAT_43
+ error = ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd,
+ data,
+ ifp, td));
+- if (error == EOPNOTSUPP && ifp != NULL && ifp->if_ioctl != NULL)
++ if (error == EOPNOTSUPP && ifp != NULL && ifp->if_ioctl != NULL &&
++ cmd != SIOCSIFADDR && cmd != SIOCSIFBRDADDR &&
++ cmd != SIOCSIFDSTADDR && cmd != SIOCSIFNETMASK)
+ error = (*ifp->if_ioctl)(ifp, cmd, data);
+ #else
+ {
+@@ -2601,7 +2613,9 @@
+ data,
+ ifp, td));
+ if (error == EOPNOTSUPP && ifp != NULL &&
+- ifp->if_ioctl != NULL)
++ ifp->if_ioctl != NULL &&
++ cmd != SIOCSIFADDR && cmd != SIOCSIFBRDADDR &&
++ cmd != SIOCSIFDSTADDR && cmd != SIOCSIFNETMASK)
+ error = (*ifp->if_ioctl)(ifp, cmd, data);
+ switch (ocmd) {
+
+Index: sys/netinet6/in6.c
+===================================================================
+--- sys/netinet6/in6.c (revision 254941)
++++ sys/netinet6/in6.c (working copy)
+@@ -431,6 +431,18 @@
+ case SIOCGIFSTAT_ICMP6:
+ sa6 = &ifr->ifr_addr;
+ break;
++ case SIOCSIFADDR:
++ case SIOCSIFBRDADDR:
++ case SIOCSIFDSTADDR:
++ case SIOCSIFNETMASK:
++ /*
++ * Although we should pass any non-INET6 ioctl requests
++ * down to driver, we filter some legacy INET requests.
++ * Drivers trust SIOCSIFADDR et al to come from an already
++ * privileged layer, and do not perform any credentials
++ * checks or input validation.
++ */
++ return (EINVAL);
+ default:
+ sa6 = NULL;
+ break;
+Index: sys/netnatm/natm.c
+===================================================================
+--- sys/netnatm/natm.c (revision 254941)
++++ sys/netnatm/natm.c (working copy)
+@@ -339,6 +339,21 @@
+ npcb = (struct natmpcb *)so->so_pcb;
+ KASSERT(npcb != NULL, ("natm_usr_control: npcb == NULL"));
+
++ switch (cmd) {
++ case SIOCSIFADDR:
++ case SIOCSIFBRDADDR:
++ case SIOCSIFDSTADDR:
++ case SIOCSIFNETMASK:
++ /*
++ * Although we should pass any non-ATM ioctl requests
++ * down to driver, we filter some legacy INET requests.
++ * Drivers trust SIOCSIFADDR et al to come from an already
++ * privileged layer, and do not perform any credentials
++ * checks or input validation.
++ */
++ return (EINVAL);
++ }
++
+ if (ifp == NULL || ifp->if_ioctl == NULL)
+ return (EOPNOTSUPP);
+ return ((*ifp->if_ioctl)(ifp, cmd, arg));
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5710.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5710.patch
new file mode 100644
index 000000000000..83f30e84fe9e
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2013-5710.patch
@@ -0,0 +1,28 @@
+Index: sys/fs/nullfs/null_vnops.c
+===================================================================
+--- sys/fs/nullfs/null_vnops.c (revision 254941)
++++ sys/fs/nullfs/null_vnops.c (working copy)
+@@ -858,6 +858,15 @@
+ return (error);
+ }
+
++static int
++null_link(struct vop_link_args *ap)
++{
++
++ if (ap->a_tdvp->v_mount != ap->a_vp->v_mount)
++ return (EXDEV);
++ return (null_bypass((struct vop_generic_args *)ap));
++}
++
+ /*
+ * Global vfs data structures
+ */
+@@ -871,6 +880,7 @@
+ .vop_getwritemount = null_getwritemount,
+ .vop_inactive = null_inactive,
+ .vop_islocked = vop_stdislocked,
++ .vop_link = null_link,
+ .vop_lock1 = null_lock,
+ .vop_lookup = null_lookup,
+ .vop_open = null_open,
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2014-1453.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2014-1453.patch
new file mode 100644
index 000000000000..fe9e97efd298
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-cve-2014-1453.patch
@@ -0,0 +1,70 @@
+Index: sys/fs/nfsserver/nfs_nfsdserv.c
+===================================================================
+--- sys/fs/nfsserver/nfs_nfsdserv.c (revision 264251)
++++ sys/fs/nfsserver/nfs_nfsdserv.c (working copy)
+@@ -1457,10 +1457,23 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgr
+ nfsvno_relpathbuf(&fromnd);
+ goto out;
+ }
++ /*
++ * Unlock dp in this code section, so it is unlocked before
++ * tdp gets locked. This avoids a potential LOR if tdp is the
++ * parent directory of dp.
++ */
+ if (nd->nd_flag & ND_NFSV4) {
+ tdp = todp;
+ tnes = *toexp;
+- tdirfor_ret = nfsvno_getattr(tdp, &tdirfor, nd->nd_cred, p, 0);
++ if (dp != tdp) {
++ NFSVOPUNLOCK(dp, 0);
++ tdirfor_ret = nfsvno_getattr(tdp, &tdirfor, nd->nd_cred,
++ p, 0); /* Might lock tdp. */
++ } else {
++ tdirfor_ret = nfsvno_getattr(tdp, &tdirfor, nd->nd_cred,
++ p, 1);
++ NFSVOPUNLOCK(dp, 0);
++ }
+ } else {
+ tfh.nfsrvfh_len = 0;
+ error = nfsrv_mtofh(nd, &tfh);
+@@ -1481,10 +1494,12 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgr
+ tnes = *exp;
+ tdirfor_ret = nfsvno_getattr(tdp, &tdirfor, nd->nd_cred,
+ p, 1);
++ NFSVOPUNLOCK(dp, 0);
+ } else {
++ NFSVOPUNLOCK(dp, 0);
+ nd->nd_cred->cr_uid = nd->nd_saveduid;
+ nfsd_fhtovp(nd, &tfh, LK_EXCLUSIVE, &tdp, &tnes, NULL,
+- 0, p);
++ 0, p); /* Locks tdp. */
+ if (tdp) {
+ tdirfor_ret = nfsvno_getattr(tdp, &tdirfor,
+ nd->nd_cred, p, 1);
+@@ -1499,7 +1514,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgr
+ if (error) {
+ if (tdp)
+ vrele(tdp);
+- vput(dp);
++ vrele(dp);
+ nfsvno_relpathbuf(&fromnd);
+ nfsvno_relpathbuf(&tond);
+ goto out;
+@@ -1514,7 +1529,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgr
+ }
+ if (tdp)
+ vrele(tdp);
+- vput(dp);
++ vrele(dp);
+ nfsvno_relpathbuf(&fromnd);
+ nfsvno_relpathbuf(&tond);
+ goto out;
+@@ -1523,7 +1538,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgr
+ /*
+ * Done parsing, now down to business.
+ */
+- nd->nd_repstat = nfsvno_namei(nd, &fromnd, dp, 1, exp, p, &fdirp);
++ nd->nd_repstat = nfsvno_namei(nd, &fromnd, dp, 0, exp, p, &fdirp);
+ if (nd->nd_repstat) {
+ if (nd->nd_flag & ND_NFSV3) {
+ nfsrv_wcc(nd, fdirfor_ret, &fdirfor, fdiraft_ret,
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-exec.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-exec.patch
new file mode 100644
index 000000000000..c36bed59b39e
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-exec.patch
@@ -0,0 +1,66 @@
+Index: sys/kern/kern_exec.c
+===================================================================
+--- sys/kern/kern_exec.c (revision 266979)
++++ sys/kern/kern_exec.c (working copy)
+@@ -280,6 +280,7 @@ kern_execve(td, args, mac_p)
+ struct mac *mac_p;
+ {
+ struct proc *p = td->td_proc;
++ struct vmspace *oldvmspace;
+ int error;
+
+ AUDIT_ARG_ARGV(args->begin_argv, args->argc,
+@@ -296,6 +297,8 @@ kern_execve(td, args, mac_p)
+ PROC_UNLOCK(p);
+ }
+
++ KASSERT((td->td_pflags & TDP_EXECVMSPC) == 0, ("nested execve"));
++ oldvmspace = td->td_proc->p_vmspace;
+ error = do_execve(td, args, mac_p);
+
+ if (p->p_flag & P_HADTHREADS) {
+@@ -310,6 +313,12 @@ kern_execve(td, args, mac_p)
+ thread_single_end();
+ PROC_UNLOCK(p);
+ }
++ if ((td->td_pflags & TDP_EXECVMSPC) != 0) {
++ KASSERT(td->td_proc->p_vmspace != oldvmspace,
++ ("oldvmspace still used"));
++ vmspace_free(oldvmspace);
++ td->td_pflags &= ~TDP_EXECVMSPC;
++ }
+
+ return (error);
+ }
+Index: sys/sys/proc.h
+===================================================================
+--- sys/sys/proc.h (revision 266979)
++++ sys/sys/proc.h (working copy)
+@@ -968,4 +968,5 @@ curthread_pflags_restore(int save)
+
+ #endif /* _KERNEL */
+
++#define TDP_EXECVMSPC 0x40000000 /* Execve destroyed old vmspace */
+ #endif /* !_SYS_PROC_H_ */
+Index: sys/vm/vm_map.c
+===================================================================
+--- sys/vm/vm_map.c (revision 266979)
++++ sys/vm/vm_map.c (working copy)
+@@ -3631,6 +3631,8 @@ vmspace_exec(struct proc *p, vm_offset_t minuser,
+ struct vmspace *oldvmspace = p->p_vmspace;
+ struct vmspace *newvmspace;
+
++ KASSERT((curthread->td_pflags & TDP_EXECVMSPC) == 0,
++ ("vmspace_exec recursed"));
+ newvmspace = vmspace_alloc(minuser, maxuser);
+ if (newvmspace == NULL)
+ return (ENOMEM);
+@@ -3647,7 +3649,7 @@ vmspace_exec(struct proc *p, vm_offset_t minuser,
+ PROC_VMSPACE_UNLOCK(p);
+ if (p == curthread->td_proc)
+ pmap_activate(curthread);
+- vmspace_free(oldvmspace);
++ curthread->td_pflags |= TDP_EXECVMSPC;
+ return (0);
+ }
+
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-gentoo.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-gentoo.patch
new file mode 100644
index 000000000000..b02d8b68870c
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-gentoo.patch
@@ -0,0 +1,21 @@
+diff -Nur sys.orig/conf/kern.mk sys/conf/kern.mk
+--- sys.orig/conf/kern.mk 2012-07-12 13:26:37.000000000 +0900
++++ sys/conf/kern.mk 2012-07-16 02:32:19.000000000 +0900
+@@ -5,7 +5,7 @@
+ #
+ CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
+ -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
+- -Wundef -Wno-pointer-sign -fformat-extensions \
++ -Wundef -Wno-pointer-sign \
+ -Wmissing-include-dirs -fdiagnostics-show-option \
+ ${CWARNEXTRA}
+ #
+@@ -52,7 +52,7 @@
+ #
+ .if ${MACHINE_CPUARCH} == "i386"
+ .if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
+-CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2
++CFLAGS+= -mpreferred-stack-boundary=2
+ .else
+ CFLAGS+= -mno-aes -mno-avx
+ .endif
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ktrace.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ktrace.patch
new file mode 100644
index 000000000000..0fb6df7600ef
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-ktrace.patch
@@ -0,0 +1,12 @@
+Index: sys/kern/kern_ktrace.c
+===================================================================
+--- sys/kern/kern_ktrace.c (revision 266771)
++++ sys/kern/kern_ktrace.c (working copy)
+@@ -119,6 +119,7 @@ static int data_lengths[] = {
+ 0, /* KTR_SYSCTL */
+ sizeof(struct ktr_proc_ctor), /* KTR_PROCCTOR */
+ 0, /* KTR_PROCDTOR */
++ 0, /* unused */
+ sizeof(struct ktr_fault), /* KTR_FAULT */
+ sizeof(struct ktr_faultend), /* KTR_FAULTEND */
+ };
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap-2014.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap-2014.patch
new file mode 100644
index 000000000000..fd4040a88166
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap-2014.patch
@@ -0,0 +1,20 @@
+Index: sys/vm/vm_map.c
+===================================================================
+--- sys/vm/vm_map.c (revision 259950)
++++ sys/vm/vm_map.c (revision 259951)
+@@ -1207,6 +1207,7 @@ charged:
+ }
+ else if ((prev_entry != &map->header) &&
+ (prev_entry->eflags == protoeflags) &&
++ (cow & (MAP_ENTRY_GROWS_DOWN | MAP_ENTRY_GROWS_UP)) == 0 &&
+ (prev_entry->end == start) &&
+ (prev_entry->wired_count == 0) &&
+ (prev_entry->cred == cred ||
+@@ -3339,7 +3340,6 @@ vm_map_stack(vm_map_t map, vm_offset_t addrbos, vm
+ * NOTE: We explicitly allow bi-directional stacks.
+ */
+ orient = cow & (MAP_STACK_GROWS_DOWN|MAP_STACK_GROWS_UP);
+- cow &= ~orient;
+ KASSERT(orient != 0, ("No stack grow direction"));
+
+ if (addrbos < vm_map_min(map) ||
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap.patch
new file mode 100644
index 000000000000..ef2d0a78206b
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-mmap.patch
@@ -0,0 +1,20 @@
+http://www.freebsd.org/security/advisories/FreeBSD-SA-13:06.mmap.asc
+https://bugs.gentoo.org/show_bug.cgi?id=473688
+
+Index: sys/vm/vm_map.c
+===================================================================
+--- sys/vm/vm_map.c (revision 251636)
++++ sys/vm/vm_map.c (working copy)
+@@ -3761,6 +3761,12 @@ RetryLookup:;
+ vm_map_unlock_read(map);
+ return (KERN_PROTECTION_FAILURE);
+ }
++ if ((fault_typea & VM_PROT_COPY) != 0 &&
++ (entry->max_protection & VM_PROT_WRITE) == 0 &&
++ (entry->eflags & MAP_ENTRY_COW) == 0) {
++ vm_map_unlock_read(map);
++ return (KERN_PROTECTION_FAILURE);
++ }
+
+ /*
+ * If this page is not pageable, we have to get it for all possible
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-nfsserver.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-nfsserver.patch
new file mode 100644
index 000000000000..767588fc86f6
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-nfsserver.patch
@@ -0,0 +1,16 @@
+http://www.freebsd.org/security/advisories/FreeBSD-SA-13:08.nfsserver.asc
+https://bugs.gentoo.org/show_bug.cgi?id=478314
+
+Index: sys/kern/vfs_export.c
+===================================================================
+--- sys/kern/vfs_export.c (revision 253367)
++++ sys/kern/vfs_export.c (working copy)
+@@ -208,7 +208,7 @@
+ np->netc_anon = crget();
+ np->netc_anon->cr_uid = argp->ex_anon.cr_uid;
+ crsetgroups(np->netc_anon, argp->ex_anon.cr_ngroups,
+- np->netc_anon->cr_groups);
++ argp->ex_anon.cr_groups);
+ np->netc_anon->cr_prison = &prison0;
+ prison_hold(np->netc_anon->cr_prison);
+ np->netc_numsecflavors = argp->ex_numsecflavors;
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-random.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-random.patch
new file mode 100644
index 000000000000..bb3caba00137
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-random.patch
@@ -0,0 +1,27 @@
+Index: sys/dev/random/probe.c
+===================================================================
+--- sys/dev/random/probe.c (revision 260523)
++++ sys/dev/random/probe.c (working copy)
+@@ -30,6 +30,8 @@ __FBSDID("$FreeBSD$");
+
+ #include <sys/types.h>
+ #include <sys/param.h>
++#include <sys/systm.h>
++#include <sys/kernel.h>
+ #include <sys/malloc.h>
+ #include <sys/random.h>
+ #include <sys/selinfo.h>
+@@ -57,7 +59,12 @@ random_ident_hardware(struct random_systat *systat
+ /* Then go looking for hardware */
+ #if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
+ if (via_feature_rng & VIA_HAS_RNG) {
+- *systat = random_nehemiah;
++ int enable;
++
++ enable = 0;
++ TUNABLE_INT_FETCH("hw.nehemiah_rng_enable", &enable);
++ if (enable)
++ *systat = random_nehemiah;
+ }
+ #endif
+ }
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-tcp.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-tcp.patch
new file mode 100644
index 000000000000..2f82a5f98a58
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.1-tcp.patch
@@ -0,0 +1,32 @@
+Index: sys/netinet/tcp_reass.c
+===================================================================
+--- sys/netinet/tcp_reass.c (revision 264836)
++++ sys/netinet/tcp_reass.c (working copy)
+@@ -211,7 +211,7 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int
+ * Investigate why and re-evaluate the below limit after the behaviour
+ * is understood.
+ */
+- if (th->th_seq != tp->rcv_nxt &&
++ if ((th->th_seq != tp->rcv_nxt || !TCPS_HAVEESTABLISHED(tp->t_state)) &&
+ tp->t_segqlen >= (so->so_rcv.sb_hiwat / tp->t_maxseg) + 1) {
+ V_tcp_reass_overflows++;
+ TCPSTAT_INC(tcps_rcvmemdrop);
+@@ -234,7 +234,7 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int
+ */
+ te = uma_zalloc(V_tcp_reass_zone, M_NOWAIT);
+ if (te == NULL) {
+- if (th->th_seq != tp->rcv_nxt) {
++ if (th->th_seq != tp->rcv_nxt || !TCPS_HAVEESTABLISHED(tp->t_state)) {
+ TCPSTAT_INC(tcps_rcvmemdrop);
+ m_freem(m);
+ *tlenp = 0;
+@@ -282,7 +282,8 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int
+ TCPSTAT_INC(tcps_rcvduppack);
+ TCPSTAT_ADD(tcps_rcvdupbyte, *tlenp);
+ m_freem(m);
+- uma_zfree(V_tcp_reass_zone, te);
++ if (te != &tqs)
++ uma_zfree(V_tcp_reass_zone, te);
+ tp->t_segqlen--;
+ /*
+ * Try to present any queued data
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-9.2-gentoo-gcc.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.2-gentoo-gcc.patch
new file mode 100644
index 000000000000..9076fd2b595d
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-9.2-gentoo-gcc.patch
@@ -0,0 +1,13 @@
+diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
+index e504f75..7aa63df 100644
+--- a/sys/conf/newvers.sh
++++ b/sys/conf/newvers.sh
+@@ -86,7 +86,7 @@ fi
+ touch version
+ v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date`
+ i=`${MAKE:-make} -V KERN_IDENT`
+-compiler_v=$($(${MAKE:-make} -V CC) -v 2>&1 | grep 'version')
++compiler_v=$($(${MAKE:-make} -V CC) -v 2>&1 | grep 'version' | tail -n 1)
+
+ for dir in /bin /usr/bin /usr/local/bin; do
+ if [ -x "${dir}/svnversion" ] ; then
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-sources-cve-2012-0217.patch b/sys-freebsd/freebsd-sources/files/freebsd-sources-cve-2012-0217.patch
new file mode 100644
index 000000000000..0bf1b611a091
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-sources-cve-2012-0217.patch
@@ -0,0 +1,26 @@
+Index: sys/amd64/amd64/trap.c
+===================================================================
+--- sys/amd64/amd64/trap.c.orig
++++ sys/amd64/amd64/trap.c (working copy)
+@@ -972,4 +972,21 @@
+ syscallname(td->td_proc, sa.code)));
+
+ syscallret(td, error, &sa);
++
++ /*
++ * If the user-supplied value of %rip is not a canonical
++ * address, then some CPUs will trigger a ring 0 #GP during
++ * the sysret instruction. However, the fault handler would
++ * execute with the user's %gs and %rsp in ring 0 which would
++ * not be safe. Instead, preemptively kill the thread with a
++ * SIGBUS.
++ */
++ if (td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS) {
++ ksiginfo_init_trap(&ksi);
++ ksi.ksi_signo = SIGBUS;
++ ksi.ksi_code = BUS_OBJERR;
++ ksi.ksi_trapno = T_PROTFLT;
++ ksi.ksi_addr = (void *)td->td_frame->tf_rip;
++ trapsignal(td, &ksi);
++ }
+ }
diff --git a/sys-freebsd/freebsd-sources/files/freebsd-ubin-10.3-bmake-workaround.patch b/sys-freebsd/freebsd-sources/files/freebsd-ubin-10.3-bmake-workaround.patch
new file mode 100644
index 000000000000..c0ca444b042d
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/files/freebsd-ubin-10.3-bmake-workaround.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.bin/bmake/Makefile b/usr.bin/bmake/Makefile
+index 6c6d8c2..22fec7a 100644
+--- a/usr.bin/bmake/Makefile
++++ b/usr.bin/bmake/Makefile
+@@ -5,7 +5,7 @@
+
+ .sinclude "Makefile.inc"
+
+-SRCTOP?= ${.CURDIR:H:H}
++SRCTOP= ${.CURDIR:H:H}
+
+ # look here first for config.h
+ CFLAGS+= -I${.CURDIR}
diff --git a/sys-freebsd/freebsd-sources/freebsd-sources-10.3-r6.ebuild b/sys-freebsd/freebsd-sources/freebsd-sources-10.3-r6.ebuild
new file mode 100644
index 000000000000..a5c5083ebc43
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/freebsd-sources-10.3-r6.ebuild
@@ -0,0 +1,175 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic toolchain-funcs
+
+DESCRIPTION="FreeBSD kernel sources"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+IUSE="+build-kernel debug dtrace zfs"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "SA-16:15/sysarch-01.patch"
+ "SA-16:18/atkbd.patch"
+ "SA-16:19/sendmsg.patch"
+ "SA-16:20/linux.patch"
+ "SA-16:21/stat.patch"
+ "EN-16:07/ipi.patch"
+ "EN-16:08/zfs.patch"
+ "EN-16:11/vmbus.patch"
+ "EN-16:12/hv_storvsc.patch"
+ "EN-16:13/vmbus.patch"
+ "EN-16:14/hv_storvsc.patch"
+ "EN-16:15/vmbus.patch"
+ "EN-16:16/hv_storvsc.patch"
+ "EN-16:17/vm.patch" )
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ sys/
+ contrib/bmake/
+ usr.bin/bmake/
+"
+
+RDEPEND="dtrace? ( >=sys-freebsd/freebsd-cddl-9.2_rc1 )
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ !sys-freebsd/virtio-kmod
+ !sys-fs/fuse4bsd
+ !<sys-freebsd/freebsd-sources-9.2_beta1"
+DEPEND="build-kernel? (
+ dtrace? ( >=sys-freebsd/freebsd-cddl-9.2_rc1 )
+ >=sys-freebsd/freebsd-usbin-9.1
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ )"
+
+RESTRICT="strip binchecks"
+
+S="${WORKDIR}/sys"
+
+KERN_BUILD=GENTOO
+
+PATCHES=( "${FILESDIR}/${PN}-9.0-disable-optimization.patch"
+ "${FILESDIR}/${PN}-10.0-gentoo.patch"
+ "${FILESDIR}/${PN}-6.0-flex-2.5.31.patch"
+ "${FILESDIR}/${PN}-8.0-subnet-route-pr40133.patch"
+ "${FILESDIR}/${PN}-7.1-includes.patch"
+ "${FILESDIR}/${PN}-9.0-sysctluint.patch"
+ "${FILESDIR}/${PN}-9.2-gentoo-gcc.patch"
+ "${FILESDIR}/${PN}-10.1-gcc48.patch" )
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ # WITHOUT_SSP= is required to boot kernel that compiled with newer gcc, bug #477914
+ [[ $(tc-getCC) == *gcc* ]] && mymakeopts="${mymakeopts} WITHOUT_SSP="
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL="
+}
+
+src_prepare() {
+ local conf="${S}/$(tc-arch-kernel)/conf/${KERN_BUILD}"
+
+ cd "${WORKDIR}" || die
+ epatch "${FILESDIR}/freebsd-ubin-10.3-bmake-workaround.patch"
+ cd "${S}" || die
+
+ # This replaces the gentoover patch, it doesn't need reapply every time.
+ sed -i -e 's:^REVISION=.*:REVISION="'${PVR}'":' \
+ -e 's:^BRANCH=.*:BRANCH="Gentoo":' \
+ -e 's:^VERSION=.*:VERSION="${TYPE} ${BRANCH} ${REVISION}":' \
+ "${S}/conf/newvers.sh"
+
+ # __FreeBSD_cc_version comes from FreeBSD's gcc.
+ # on 10.0-RELEASE it's 1000001.
+ # FYI, can get it from gnu/usr.bin/cc/cc_tools/freebsd-native.h.
+ sed -e "s:-D_KERNEL:-D_KERNEL -D__FreeBSD_cc_version=1000001:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die "Couldn't set __FreeBSD_cc_version"
+
+ # Remove -Werror
+ sed -e "s:-Werror:-Wno-error:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die
+
+ # Set the kernel configuration using USE flags.
+ cp -f "${FILESDIR}/config-GENTOO" "${conf}" || die
+ use debug || echo 'nomakeoptions DEBUG' >> "${conf}"
+ use dtrace || echo 'nomakeoptions WITH_CTF' >> "${conf}"
+
+ # Only used with USE=build-kernel, let the kernel build with its own flags, its safer.
+ unset LDFLAGS CFLAGS CXXFLAGS ASFLAGS KERNEL
+}
+
+src_configure() {
+ if use build-kernel ; then
+ tc-export CC
+ cd "${S}/$(tc-arch-kernel)/conf" || die
+ config ${KERN_BUILD} || die
+ fi
+}
+
+src_compile() {
+ if use build-kernel ; then
+ if has_version "<sys-freebsd/freebsd-ubin-10.0"; then
+ cd "${WORKDIR}"/usr.bin/bmake || die
+ CC=${CHOST}-gcc freebsd_src_compile
+ export BMAKE="${WORKDIR}/usr.bin/bmake/make"
+ fi
+ cd "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}" || die
+ freebsd_src_compile depend
+ freebsd_src_compile
+ else
+ einfo "Nothing to compile.."
+ fi
+}
+
+src_install() {
+ if use build-kernel ; then
+ cd "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}" || die
+ freebsd_src_install
+ rm -rf "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}"
+ cd "${S}"
+ fi
+
+ insinto "/usr/src/sys"
+ doins -r "${S}/".
+ if use zfs ; then
+ insinto "/usr/src/cddl"
+ doins -r "${WORKDIR}/cddl/".
+ fi
+}
+
+pkg_preinst() {
+ if [[ -L "${ROOT}/usr/src/sys" ]]; then
+ einfo "/usr/src/sys is a symlink, removing it..."
+ rm -f "${ROOT}/usr/src/sys"
+ fi
+
+ if use sparc-fbsd ; then
+ ewarn "WARNING: kldload currently causes kernel panics"
+ ewarn "on sparc64. This is probably a gcc-4.1 issue, but"
+ ewarn "we need gcc-4.1 to compile the kernel correctly :/"
+ ewarn "Please compile all modules you need into the kernel"
+ fi
+
+ ewarn "If you want manual compile (not recommended), please don't forget the following step."
+ if ! use sparc-fbsd ; then
+ ewarn "export CC=clang"
+ ewarn "export CXX=clang++"
+ fi
+ if ! use zfs ; then
+ ewarn "export WITHOUT_CDDL="
+ ewarn "Note, Please set USE=zfs if you want to enable modules of CDDL license."
+ fi
+ if ! use dtrace && ! has_version '>=sys-freebsd/freebsd-cddl-9.2_beta1' ; then
+ ewarn "GENERIC config require sys-freebsd/freebsd-cddl. Please emerge it."
+ fi
+}
diff --git a/sys-freebsd/freebsd-sources/freebsd-sources-11.0-r1.ebuild b/sys-freebsd/freebsd-sources/freebsd-sources-11.0-r1.ebuild
new file mode 100644
index 000000000000..773c3f974a36
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/freebsd-sources-11.0-r1.ebuild
@@ -0,0 +1,169 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic toolchain-funcs
+
+DESCRIPTION="FreeBSD kernel sources"
+SLOT="0"
+LICENSE="BSD dtrace? ( CDDL ) zfs? ( CDDL )"
+
+IUSE="+build-kernel debug dtrace zfs"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "SA-16:15/sysarch-01.patch" )
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ sys/
+ contrib/bmake/
+ usr.bin/bmake/
+"
+
+RDEPEND="dtrace? ( >=sys-freebsd/freebsd-cddl-9.2_rc1 )
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ !sys-freebsd/virtio-kmod
+ !sys-fs/fuse4bsd
+ !<sys-freebsd/freebsd-sources-9.2_beta1"
+DEPEND="build-kernel? (
+ dtrace? ( >=sys-freebsd/freebsd-cddl-9.2_rc1 )
+ >=sys-freebsd/freebsd-usbin-9.1
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ )"
+
+RESTRICT="strip binchecks"
+
+S="${WORKDIR}/sys"
+
+KERN_BUILD=GENTOO
+
+PATCHES=( "${FILESDIR}/${PN}-9.0-disable-optimization.patch"
+ "${FILESDIR}/${PN}-6.0-flex-2.5.31.patch"
+ "${FILESDIR}/${PN}-8.0-subnet-route-pr40133.patch"
+ "${FILESDIR}/${PN}-7.1-includes.patch"
+ "${FILESDIR}/${PN}-9.0-sysctluint.patch"
+ "${FILESDIR}/${PN}-11.0-gentoo.patch"
+ "${FILESDIR}/${PN}-11.0-gentoo-gcc.patch"
+ "${FILESDIR}/${PN}-10.1-gcc48.patch" )
+
+pkg_setup() {
+ # Add the required source files.
+ use dtrace && EXTRACTONLY+="cddl/ "
+
+ # WITHOUT_SSP= is required to boot kernel that compiled with newer gcc, bug #477914
+ [[ $(tc-getCC) == *gcc* ]] && mymakeopts="${mymakeopts} WITHOUT_SSP= WITHOUT_FORMAT_EXTENSIONS="
+ use dtrace || mymakeopts="${mymakeopts} WITHOUT_CDDL="
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_ZFS="
+}
+
+src_prepare() {
+ local conf="${S}/$(tc-arch-kernel)/conf/${KERN_BUILD}"
+
+ cd "${WORKDIR}" || die
+ epatch "${FILESDIR}/freebsd-ubin-10.3-bmake-workaround.patch"
+ cd "${S}" || die
+
+ # This replaces the gentoover patch, it doesn't need reapply every time.
+ sed -i -e 's:^REVISION=.*:REVISION="'${PVR}'":' \
+ -e 's:^BRANCH=.*:BRANCH="Gentoo":' \
+ -e 's:^VERSION=.*:VERSION="${TYPE} ${BRANCH} ${REVISION}":' \
+ "${S}/conf/newvers.sh"
+
+ # __FreeBSD_cc_version comes from FreeBSD's gcc.
+ # on 11.0-RELEASE it's 1100001.
+ # FYI, can get it from gnu/usr.bin/cc/cc_tools/freebsd-native.h.
+ sed -e "s:-D_KERNEL:-D_KERNEL -D__FreeBSD_cc_version=1100001:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die "Couldn't set __FreeBSD_cc_version"
+
+ # Remove -Werror
+ sed -e "s:-Werror:-Wno-error:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die
+
+ # Set the kernel configuration using USE flags.
+ cp -f "${FILESDIR}/config-GENTOO" "${conf}" || die
+ use debug || echo 'nomakeoptions DEBUG' >> "${conf}"
+ use dtrace || echo 'nomakeoptions WITH_CTF' >> "${conf}"
+
+ # hyperv fails to compile on x86-fbsd.
+ if use x86-fbsd && [[ $(tc-getCC) == *gcc* ]] ; then
+ echo 'nodevice hyperv' >> "${conf}"
+ dummy_mk modules/hyperv
+ fi
+
+ # Only used with USE=build-kernel, let the kernel build with its own flags, its safer.
+ unset LDFLAGS CFLAGS CXXFLAGS ASFLAGS KERNEL
+}
+
+src_configure() {
+ if use build-kernel ; then
+ tc-export CC
+ cd "${S}/$(tc-arch-kernel)/conf" || die
+ config ${KERN_BUILD} || die
+ fi
+}
+
+src_compile() {
+ if use build-kernel ; then
+ if has_version "<sys-freebsd/freebsd-ubin-10.0"; then
+ cd "${WORKDIR}"/usr.bin/bmake || die
+ CC=${CHOST}-gcc freebsd_src_compile
+ export BMAKE="${WORKDIR}/usr.bin/bmake/make"
+ fi
+ cd "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}" || die
+ freebsd_src_compile depend
+ freebsd_src_compile
+ else
+ einfo "Nothing to compile.."
+ fi
+}
+
+src_install() {
+ if use build-kernel ; then
+ cd "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}" || die
+ freebsd_src_install
+ rm -rf "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}"
+ cd "${S}"
+ fi
+
+ insinto "/usr/src/sys"
+ doins -r "${S}/".
+ if use dtrace ; then
+ insinto "/usr/src/cddl"
+ doins -r "${WORKDIR}/cddl/".
+ fi
+}
+
+pkg_preinst() {
+ if [[ -L "${ROOT}/usr/src/sys" ]]; then
+ einfo "/usr/src/sys is a symlink, removing it..."
+ rm -f "${ROOT}/usr/src/sys"
+ fi
+
+ if use sparc-fbsd ; then
+ ewarn "WARNING: kldload currently causes kernel panics"
+ ewarn "on sparc64. This is probably a gcc-4.1 issue, but"
+ ewarn "we need gcc-4.1 to compile the kernel correctly :/"
+ ewarn "Please compile all modules you need into the kernel"
+ fi
+
+ ewarn "If you want manual compile (not recommended), please don't forget the following step."
+ if ! use sparc-fbsd ; then
+ ewarn "export CC=clang"
+ ewarn "export CXX=clang++"
+ fi
+ if ! use zfs ; then
+ ewarn "export WITHOUT_CDDL="
+ ewarn "Note, Please set USE=zfs if you want to enable modules of CDDL license."
+ fi
+ if ! use dtrace && ! has_version '>=sys-freebsd/freebsd-cddl-9.2_beta1' ; then
+ ewarn "GENERIC config require sys-freebsd/freebsd-cddl. Please emerge it."
+ fi
+}
diff --git a/sys-freebsd/freebsd-sources/freebsd-sources-11.1_p1.ebuild b/sys-freebsd/freebsd-sources/freebsd-sources-11.1_p1.ebuild
new file mode 100644
index 000000000000..4c48fd28a2c5
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/freebsd-sources-11.1_p1.ebuild
@@ -0,0 +1,170 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic toolchain-funcs
+
+DESCRIPTION="FreeBSD kernel sources"
+SLOT="0"
+LICENSE="BSD dtrace? ( CDDL ) zfs? ( CDDL )"
+
+IUSE="+build-kernel debug dtrace zfs"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "EN-17:07/vnet.patch"
+ "EN-17:08/pf.patch" )
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ sys/
+ contrib/bmake/
+ usr.bin/bmake/
+"
+
+RDEPEND="dtrace? ( >=sys-freebsd/freebsd-cddl-9.2_rc1 )
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ !sys-freebsd/virtio-kmod
+ !sys-fs/fuse4bsd
+ !<sys-freebsd/freebsd-sources-9.2_beta1"
+DEPEND="build-kernel? (
+ dtrace? ( >=sys-freebsd/freebsd-cddl-9.2_rc1 )
+ >=sys-freebsd/freebsd-usbin-9.1
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ )"
+
+RESTRICT="strip binchecks"
+
+S="${WORKDIR}/sys"
+
+KERN_BUILD=GENTOO
+
+PATCHES=( "${FILESDIR}/${PN}-9.0-disable-optimization.patch"
+ "${FILESDIR}/${PN}-6.0-flex-2.5.31.patch"
+ "${FILESDIR}/${PN}-8.0-subnet-route-pr40133.patch"
+ "${FILESDIR}/${PN}-7.1-includes.patch"
+ "${FILESDIR}/${PN}-9.0-sysctluint.patch"
+ "${FILESDIR}/${PN}-11.0-gentoo.patch"
+ "${FILESDIR}/${PN}-11.0-gentoo-gcc.patch"
+ "${FILESDIR}/${PN}-10.1-gcc48.patch" )
+
+pkg_setup() {
+ # Add the required source files.
+ use dtrace && EXTRACTONLY+="cddl/ "
+
+ # WITHOUT_SSP= is required to boot kernel that compiled with newer gcc, bug #477914
+ [[ $(tc-getCC) == *gcc* ]] && mymakeopts="${mymakeopts} WITHOUT_SSP= WITHOUT_FORMAT_EXTENSIONS="
+ use dtrace || mymakeopts="${mymakeopts} WITHOUT_CDDL="
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_ZFS="
+}
+
+src_prepare() {
+ local conf="${S}/$(tc-arch-kernel)/conf/${KERN_BUILD}"
+
+ cd "${WORKDIR}" || die
+ epatch "${FILESDIR}/freebsd-ubin-10.3-bmake-workaround.patch"
+ cd "${S}" || die
+
+ # This replaces the gentoover patch, it doesn't need reapply every time.
+ sed -i -e 's:^REVISION=.*:REVISION="'${PVR}'":' \
+ -e 's:^BRANCH=.*:BRANCH="Gentoo":' \
+ -e 's:^VERSION=.*:VERSION="${TYPE} ${BRANCH} ${REVISION}":' \
+ "${S}/conf/newvers.sh"
+
+ # __FreeBSD_cc_version comes from FreeBSD's gcc.
+ # on 11.0-RELEASE it's 1100001.
+ # FYI, we can get it from gnu/usr.bin/cc/cc_tools/freebsd-native.h.
+ sed -e "s:-D_KERNEL:-D_KERNEL -D__FreeBSD_cc_version=1100001:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die "Couldn't set __FreeBSD_cc_version"
+
+ # Remove -Werror
+ sed -e "s:-Werror:-Wno-error:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die
+
+ # Set the kernel configuration using USE flags.
+ cp -f "${FILESDIR}/config-GENTOO" "${conf}" || die
+ use debug || echo 'nomakeoptions DEBUG' >> "${conf}"
+ use dtrace || echo 'nomakeoptions WITH_CTF' >> "${conf}"
+
+ # hyperv fails to compile on x86-fbsd.
+ if use x86-fbsd && [[ $(tc-getCC) == *gcc* ]] ; then
+ echo 'nodevice hyperv' >> "${conf}"
+ dummy_mk modules/hyperv
+ fi
+
+ # Only used with USE=build-kernel, let the kernel build with its own flags, its safer.
+ unset LDFLAGS CFLAGS CXXFLAGS ASFLAGS KERNEL
+}
+
+src_configure() {
+ if use build-kernel ; then
+ tc-export CC
+ cd "${S}/$(tc-arch-kernel)/conf" || die
+ config ${KERN_BUILD} || die
+ fi
+}
+
+src_compile() {
+ if use build-kernel ; then
+ if has_version "<sys-freebsd/freebsd-ubin-10.0"; then
+ cd "${WORKDIR}"/usr.bin/bmake || die
+ CC=${CHOST}-gcc freebsd_src_compile
+ export BMAKE="${WORKDIR}/usr.bin/bmake/make"
+ fi
+ cd "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}" || die
+ freebsd_src_compile depend
+ freebsd_src_compile
+ else
+ einfo "Nothing to compile.."
+ fi
+}
+
+src_install() {
+ if use build-kernel ; then
+ cd "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}" || die
+ freebsd_src_install
+ rm -rf "${S}/$(tc-arch-kernel)/compile/${KERN_BUILD}"
+ cd "${S}"
+ fi
+
+ insinto "/usr/src/sys"
+ doins -r "${S}/".
+ if use dtrace ; then
+ insinto "/usr/src/cddl"
+ doins -r "${WORKDIR}/cddl/".
+ fi
+}
+
+pkg_preinst() {
+ if [[ -L "${ROOT}/usr/src/sys" ]]; then
+ einfo "/usr/src/sys is a symlink, removing it..."
+ rm -f "${ROOT}/usr/src/sys"
+ fi
+
+ if use sparc-fbsd ; then
+ ewarn "WARNING: kldload currently causes kernel panics"
+ ewarn "on sparc64. This is probably a gcc-4.1 issue, but"
+ ewarn "we need gcc-4.1 to compile the kernel correctly :/"
+ ewarn "Please compile all modules you need into the kernel"
+ fi
+
+ ewarn "If you want to manually compile (not recommended), please don't forget the following steps."
+ if ! use sparc-fbsd ; then
+ ewarn "export CC=clang"
+ ewarn "export CXX=clang++"
+ fi
+ if ! use zfs ; then
+ ewarn "export WITHOUT_CDDL="
+ ewarn "Note, Please set USE=zfs if you want to enable modules under the CDDL."
+ fi
+ if ! use dtrace && ! has_version '>=sys-freebsd/freebsd-cddl-9.2_beta1' ; then
+ ewarn "The GENERIC config requires sys-freebsd/freebsd-cddl. Please emerge it."
+ fi
+}
diff --git a/sys-freebsd/freebsd-sources/freebsd-sources-8.2-r2.ebuild b/sys-freebsd/freebsd-sources/freebsd-sources-8.2-r2.ebuild
new file mode 100644
index 000000000000..ccb0c43f6faf
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/freebsd-sources-8.2-r2.ebuild
@@ -0,0 +1,108 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd flag-o-matic
+
+DESCRIPTION="FreeBSD kernel sources"
+SLOT="${PVR}"
+KEYWORDS="~sparc-fbsd ~x86-fbsd"
+
+IUSE="symlink"
+
+SRC_URI="mirror://gentoo/${SYS}.tar.bz2"
+
+RDEPEND=">=sys-freebsd/freebsd-mk-defs-8.0"
+DEPEND=""
+
+RESTRICT="strip binchecks"
+
+S="${WORKDIR}/sys"
+
+MY_PVR="${PVR}"
+
+[[ ${MY_PVR} == "${RV}" ]] && MY_PVR="${MY_PVR}-r0"
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+
+ # This replaces the gentoover patch, it doesn't need reapply every time.
+ sed -i -e 's:^REVISION=.*:REVISION="'${PVR}'":' \
+ -e 's:^BRANCH=.*:BRANCH="Gentoo":' \
+ -e 's:^VERSION=.*:VERSION="${TYPE} ${BRANCH} ${REVISION}":' \
+ "${S}/conf/newvers.sh"
+
+ # __FreeBSD_cc_version comes from FreeBSD's gcc.
+ # on 8.2-RELEASE it's 800001.
+ sed -e "s:-D_KERNEL:-D_KERNEL -D__FreeBSD_cc_version=800001:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die "Couldn't set __FreeBSD_cc_version"
+
+ # Remove -Werror
+ sed -e "s:-Werror:-Wno-error:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die
+
+ epatch "${FILESDIR}/${PN}-8.0-gentoo.patch"
+ epatch "${FILESDIR}/${PN}-6.0-flex-2.5.31.patch"
+ sed -e 's/elf64-sparc/elf64-sparc-freebsd/g' -i "${S}/conf/ldscript.sparc64" || die
+ epatch "${FILESDIR}/${PN}-6.1-ntfs.patch"
+ epatch "${FILESDIR}/${PN}-7.2-debug-O2.patch"
+ epatch "${FILESDIR}/${PN}-7.1-types.h-fix.patch"
+ epatch "${FILESDIR}/${PN}-8.0-subnet-route-pr40133.patch"
+ epatch "${FILESDIR}/${PN}-7.1-includes.patch"
+ # http://security.FreeBSD.org/patches/SA-11:05/unix2.patch
+ epatch "${FILESDIR}"/${P}-unix2.patch
+
+ # By adding -DGENTOO_LIVECD to CFLAGS activate this stub
+ # vop_whiteout to tmpfs, so it can be used as an overlay
+ # unionfs filesystem over the cd9660 readonly filesystem.
+ epatch "${FILESDIR}/${PN}-7.0-tmpfs_whiteout_stub.patch"
+
+ # See https://sourceware.org/bugzilla/show_bug.cgi?id=5391
+ # ld doesn't provide symbols constructed as the __start_set_(s) ones
+ # are on FreeBSD modules.
+ # This patch adds code to generate a list of these and adds them
+ # as undefined references to ld's commandline to get them.
+ # Without this kernel modules will not load.
+ epatch "${FILESDIR}/${PN}-7.1-binutils_link.patch"
+
+ epatch "${FILESDIR}/${PN}-cve-2012-0217.patch"
+ epatch "${FILESDIR}/${PN}-9.0-ipv6refcount.patch"
+}
+
+src_compile() {
+ einfo "Nothing to compile.."
+}
+
+src_install() {
+ insinto "/usr/src/sys-${MY_PVR}"
+ doins -r "${S}/"*
+}
+
+pkg_postinst() {
+ if [[ ! -L "${ROOT}/usr/src/sys" ]]; then
+ einfo "/usr/src/sys symlink doesn't exist; creating symlink to sys-${MY_PVR}..."
+ ln -sf "sys-${MY_PVR}" "${ROOT}/usr/src/sys" || \
+ eerror "Couldn't create ${ROOT}/usr/src/sys symlink."
+ # just in case...
+ [[ -L ""${ROOT}/usr/src/sys-${RV}"" ]] && rm "${ROOT}/usr/src/sys-${RV}"
+ ln -sf "sys-${MY_PVR}" "${ROOT}/usr/src/sys-${RV}" || \
+ eerror "Couldn't create ${ROOT}/usr/src/sys-${RV} symlink."
+ elif use symlink; then
+ einfo "Updating /usr/src/sys symlink to sys-${MY_PVR}..."
+ rm "${ROOT}/usr/src/sys" "${ROOT}/usr/src/sys-${RV}" || \
+ eerror "Couldn't remove previous symlinks, please fix manually."
+ ln -sf "sys-${MY_PVR}" "${ROOT}/usr/src/sys" || \
+ eerror "Couldn't create ${ROOT}/usr/src/sys symlink."
+ ln -sf "sys-${MY_PVR}" "${ROOT}/usr/src/sys-${RV}" || \
+ eerror "Couldn't create ${ROOT}/usr/src/sys-${RV} symlink."
+ fi
+
+ if use sparc-fbsd ; then
+ ewarn "WARNING: kldload currently causes kernel panics"
+ ewarn "on sparc64. This is probably a gcc-4.1 issue, but"
+ ewarn "we need gcc-4.1 to compile the kernel correctly :/"
+ ewarn "Please compile all modules you need into the kernel"
+ fi
+}
diff --git a/sys-freebsd/freebsd-sources/freebsd-sources-9.1-r3.ebuild b/sys-freebsd/freebsd-sources/freebsd-sources-9.1-r3.ebuild
new file mode 100644
index 000000000000..a36f195b6947
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/freebsd-sources-9.1-r3.ebuild
@@ -0,0 +1,83 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd flag-o-matic
+
+DESCRIPTION="FreeBSD kernel sources"
+SLOT="${RV}"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+
+IUSE="symlink"
+
+SRC_URI="mirror://gentoo/${SYS}.tar.bz2"
+
+RDEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*"
+DEPEND=""
+
+RESTRICT="strip binchecks"
+
+S="${WORKDIR}/sys"
+
+PATCHES=( "${FILESDIR}/${PN}-9.0-disable-optimization.patch"
+ "${FILESDIR}/${PN}-9.1-gentoo.patch"
+ "${FILESDIR}/${PN}-6.0-flex-2.5.31.patch"
+ "${FILESDIR}/${PN}-6.1-ntfs.patch"
+ "${FILESDIR}/${PN}-7.1-types.h-fix.patch"
+ "${FILESDIR}/${PN}-8.0-subnet-route-pr40133.patch"
+ "${FILESDIR}/${PN}-7.1-includes.patch"
+ "${FILESDIR}/${PN}-9.0-sysctluint.patch"
+ "${FILESDIR}/${PN}-7.0-tmpfs_whiteout_stub.patch"
+ "${FILESDIR}/${PN}-9.1-cve-2013-3266.patch"
+ "${FILESDIR}/${PN}-9.1-mmap.patch"
+ "${FILESDIR}/${PN}-9.1-nfsserver.patch" )
+
+src_unpack() {
+ freebsd_src_unpack
+
+ # This replaces the gentoover patch, it doesn't need reapply every time.
+ sed -i -e 's:^REVISION=.*:REVISION="'${PVR}'":' \
+ -e 's:^BRANCH=.*:BRANCH="Gentoo":' \
+ -e 's:^VERSION=.*:VERSION="${TYPE} ${BRANCH} ${REVISION}":' \
+ "${S}/conf/newvers.sh"
+
+ # __FreeBSD_cc_version comes from FreeBSD's gcc.
+ # on 9.0-RELEASE it's 900001.
+ sed -e "s:-D_KERNEL:-D_KERNEL -D__FreeBSD_cc_version=900001:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die "Couldn't set __FreeBSD_cc_version"
+
+ # Remove -Werror
+ sed -e "s:-Werror:-Wno-error:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die
+}
+
+src_compile() {
+ einfo "Nothing to compile.."
+}
+
+src_install() {
+ insinto "/usr/src/sys-${RV}"
+ doins -r "${S}/"*
+}
+
+pkg_postinst() {
+ if [[ ! -L "${ROOT}/usr/src/sys" ]]; then
+ einfo "/usr/src/sys symlink doesn't exist; creating symlink to sys-${RV}..."
+ ln -sf "sys-${RV}" "${ROOT}/usr/src/sys" || \
+ eerror "Couldn't create ${ROOT}/usr/src/sys symlink."
+ elif use symlink; then
+ einfo "Updating /usr/src/sys symlink to sys-${RV}..."
+ rm "${ROOT}/usr/src/sys" || \
+ eerror "Couldn't remove previous symlinks, please fix manually."
+ ln -sf "sys-${RV}" "${ROOT}/usr/src/sys" || \
+ eerror "Couldn't create ${ROOT}/usr/src/sys symlink."
+ fi
+
+ if use sparc-fbsd ; then
+ ewarn "WARNING: kldload currently causes kernel panics"
+ ewarn "on sparc64. This is probably a gcc-4.1 issue, but"
+ ewarn "we need gcc-4.1 to compile the kernel correctly :/"
+ ewarn "Please compile all modules you need into the kernel"
+ fi
+}
diff --git a/sys-freebsd/freebsd-sources/freebsd-sources-9.1-r9.ebuild b/sys-freebsd/freebsd-sources/freebsd-sources-9.1-r9.ebuild
new file mode 100644
index 000000000000..798f1f370f0b
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/freebsd-sources-9.1-r9.ebuild
@@ -0,0 +1,96 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+inherit bsdmk freebsd flag-o-matic
+
+DESCRIPTION="FreeBSD kernel sources"
+SLOT="${RV}"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+
+IUSE="symlink"
+
+SRC_URI="mirror://gentoo/${SYS}.tar.bz2
+ https://dev.gentoo.org/~naota/patch/${P}-en-13-03.patch"
+
+RDEPEND="=sys-freebsd/freebsd-mk-defs-${RV}*"
+DEPEND=""
+
+RESTRICT="strip binchecks"
+
+S="${WORKDIR}/sys"
+
+PATCHES=( "${FILESDIR}/${PN}-9.0-disable-optimization.patch"
+ "${FILESDIR}/${PN}-9.1-gentoo.patch"
+ "${FILESDIR}/${PN}-6.0-flex-2.5.31.patch"
+ "${FILESDIR}/${PN}-6.1-ntfs.patch"
+ "${FILESDIR}/${PN}-7.1-types.h-fix.patch"
+ "${FILESDIR}/${PN}-8.0-subnet-route-pr40133.patch"
+ "${FILESDIR}/${PN}-7.1-includes.patch"
+ "${FILESDIR}/${PN}-9.0-sysctluint.patch"
+ "${FILESDIR}/${PN}-7.0-tmpfs_whiteout_stub.patch"
+ "${FILESDIR}/${PN}-9.1-cve-2013-3266.patch"
+ "${FILESDIR}/${PN}-9.1-mmap.patch"
+ "${FILESDIR}/${PN}-9.1-nfsserver.patch"
+ "${DISTDIR}/${PN}-9.1-en-13-03.patch"
+ "${FILESDIR}/${PN}-9.1-cve-2013-3077.patch"
+ "${FILESDIR}/${PN}-9.1-cve-2013-5209.patch"
+ "${FILESDIR}/${PN}-9.1-cve-2013-5691.patch"
+ "${FILESDIR}/${PN}-9.1-cve-2013-5710.patch"
+ "${FILESDIR}/${PN}-9.1-cve-2014-1453.patch"
+ "${FILESDIR}/${PN}-9.1-random.patch"
+ "${FILESDIR}/${PN}-9.1-mmap-2014.patch"
+ "${FILESDIR}/${PN}-9.1-tcp.patch"
+ "${FILESDIR}/${PN}-9.1-ciss.patch"
+ "${FILESDIR}/${PN}-9.1-exec.patch"
+ "${FILESDIR}/${PN}-9.1-ktrace.patch" )
+
+src_unpack() {
+ freebsd_src_unpack
+
+ # This replaces the gentoover patch, it doesn't need reapply every time.
+ sed -i -e 's:^REVISION=.*:REVISION="'${PVR}'":' \
+ -e 's:^BRANCH=.*:BRANCH="Gentoo":' \
+ -e 's:^VERSION=.*:VERSION="${TYPE} ${BRANCH} ${REVISION}":' \
+ "${S}/conf/newvers.sh"
+
+ # __FreeBSD_cc_version comes from FreeBSD's gcc.
+ # on 9.0-RELEASE it's 900001.
+ sed -e "s:-D_KERNEL:-D_KERNEL -D__FreeBSD_cc_version=900001:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die "Couldn't set __FreeBSD_cc_version"
+
+ # Remove -Werror
+ sed -e "s:-Werror:-Wno-error:g" \
+ -i "${S}/conf/kern.pre.mk" \
+ -i "${S}/conf/kmod.mk" || die
+}
+
+src_compile() {
+ einfo "Nothing to compile.."
+}
+
+src_install() {
+ insinto "/usr/src/sys-${RV}"
+ doins -r "${S}/"*
+}
+
+pkg_postinst() {
+ if [[ ! -L "${ROOT}/usr/src/sys" ]]; then
+ einfo "/usr/src/sys symlink doesn't exist; creating symlink to sys-${RV}..."
+ ln -sf "sys-${RV}" "${ROOT}/usr/src/sys" || \
+ eerror "Couldn't create ${ROOT}/usr/src/sys symlink."
+ elif use symlink; then
+ einfo "Updating /usr/src/sys symlink to sys-${RV}..."
+ rm "${ROOT}/usr/src/sys" || \
+ eerror "Couldn't remove previous symlinks, please fix manually."
+ ln -sf "sys-${RV}" "${ROOT}/usr/src/sys" || \
+ eerror "Couldn't create ${ROOT}/usr/src/sys symlink."
+ fi
+
+ if use sparc-fbsd ; then
+ ewarn "WARNING: kldload currently causes kernel panics"
+ ewarn "on sparc64. This is probably a gcc-4.1 issue, but"
+ ewarn "we need gcc-4.1 to compile the kernel correctly :/"
+ ewarn "Please compile all modules you need into the kernel"
+ fi
+}
diff --git a/sys-freebsd/freebsd-sources/metadata.xml b/sys-freebsd/freebsd-sources/metadata.xml
new file mode 100644
index 000000000000..3860e8098ad6
--- /dev/null
+++ b/sys-freebsd/freebsd-sources/metadata.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="build-kernel">Build and install a kernel (recommended).</flag>
+ <flag name="dtrace">Enable DTrace support.</flag>
+ <flag name="zfs">Enable ZFS support.</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-ubin/Manifest b/sys-freebsd/freebsd-ubin/Manifest
new file mode 100644
index 000000000000..a07df9c2af70
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/Manifest
@@ -0,0 +1,61 @@
+AUX freebsd-ubin-10.0-atf.patch 424 SHA256 31ac8807f4088b75ae4684316f18f3096363ee2d8bb1d5c47d9caab77e6cd5f5 SHA512 b343441f49d3fd41221766c7b54b8f831cf6e19f4400b6a0913e16476e32fd70603c28fc5a8d82eef54afc50c4a999d5151bdd96b243495bca319a0f69a6e860 WHIRLPOOL e4f2ab98d015c7656d3da2364e9dc9c6f675ac95fed05bbb886edf5efc79c843103ba9eaac13376cb9f5c5f02d37fed485a54db508ca350a13d5de2483403045
+AUX freebsd-ubin-10.0-dtc-gcc46.patch 591 SHA256 0adcc784a7fa6a6d8bd867d39b46149c4b61c3751e1ce5eb0a50d0e07d927b60 SHA512 a47ae1540cf2d7f71b718dad84010f725312bc0308cc61b99ab3560a5a18c67c8a34b54d9b99c0974b0662519c20c43c81843fca10d252178f888a14a6990eae WHIRLPOOL 6ae4e254b78d026e634fc1f26c304fc3026b8ceb7a8f7746a5480f61dbd8676aad07d0571f57b31279df119fbace4e8bb2ef7d246cf5d78566905e056bbf4d77
+AUX freebsd-ubin-10.0-kdump-ioctl.patch 1027 SHA256 7fe03c7e7cdbffdabf64557fa63eae0243a28be9025fc735393048ed2dca12c1 SHA512 6fda9d9ab4210d952277b112a5c4a2e75fcff3f63debde980ca791c6f6471038fda26d1e3ddf809384d95525e9ec9140f7b5af17dee8c11967e0b4bc9ea2b850 WHIRLPOOL 1ae5e229824a4371940ef7a0c9d8bae78aada8bcd73371a4479ced9013c55137bd4b153e296ee5873c8a9042607e86273754589e6a2a38519ba5ac78ee442740
+AUX freebsd-ubin-10.0-mandoc.patch 375 SHA256 c4d14aabe0a39bc2c12ca87b6c83628ea1c46640044bbd6946f3e6af343348b6 SHA512 b2789a57ce9afd5b7fe2989f37d246b2034b1578314ac0f6e7c4af26e81f73d043ea3440edee7c30b82fc0ddf5a4592cc3c3c6871ed0eb5fc6932bdf97a88d68 WHIRLPOOL 8e9fa01e662376225c69b41890c1f518c23116ff105ec45c43958d5749b3e265af5dd799e2c2fed5c078e0ca42f8ac988dfe7acb401875c7a769cfe38b14c56a
+AUX freebsd-ubin-10.2-bsdxml.patch 367 SHA256 3bedd2e3efc7817c446395866e3ec2ca65430624dd4958bc91296d77cfc4fb90 SHA512 234fe495fcefaa9c36d97460da05365ff081661411451ae3d8dca83b3f8b1746450e111ac43baccd15a6c86c03c7cdd37d54d70fed551d694800dc6bca7c5e8d WHIRLPOOL 4946a71b63b05691ede60f15573356d98ef62b44cab40ba40a24d2be11e9655c95c660b62e898ff15ff9cdd8c006402c0dbe43a82d913b7707c1f30a55720863
+AUX freebsd-ubin-10.2-talk-workaround.patch 349 SHA256 8882326b5048b2c2acef041c82f2830ad0eb68684c6773163c6beacae65b12d7 SHA512 5eb04f1769fd4e04a26b9ff69865a6188269d971b83b7e93a5c41def44c9152e5262a192c866e3949cb3aae3b8e0a13663b8e1a438e796b0b923d9171a3e6b27 WHIRLPOOL 3be00db5ef76a3bcf615038cad6a5bd36fdfd349be6b8938a9236fb0ed2a0df6a05b04d73343206905b88ddcbd3c2d1b39928a35f62838f719b28c368adc5770
+AUX freebsd-ubin-10.3-bmake-workaround.patch 301 SHA256 97e14b032622bcc652ede9c5154160e937b3ade0155fddfe19112354bfeb6138 SHA512 8efd4e8199886ec0c647a13a334de54813372d9d6eb09d6b93785000da9a84ec40fb4d28d645a4809b531bee0bb4c11522aaae089285c52e595b2f9749af7dfe WHIRLPOOL 910bb3807c15ee8ced94c508ab2bd1e3112cd890de28bbdf2b152efe5e5ce187e366376938996e2a41e07599d7c76abe741463bbf4475297d604531ac80ea6ae
+AUX freebsd-ubin-11.0-setXid.patch 3527 SHA256 cea92e6c95f14f77b20d7525e7a72e8b7b3870e9deb1ac571b978d30ba41effe SHA512 204ce8a36eae6435d9549de7c45e361715fd50f721ea44aba630fdfad482bf434e8ac34c1bab588b7af2e2c941931e2aeb4690d65904d617b65ecfa7c76c4211 WHIRLPOOL e3b0d02ec8305f2fa3a89fc828b54e9f96515347221e343f0c35fc8666dd68cfb245edca4b17c9313bc00ea12105459f8826cfa8c8d8f2a715505508dff1c0d9
+AUX freebsd-ubin-11.1-fixmakefiles.patch 453 SHA256 8b5b6549836b07c92cd87b884fe40599e33a94ea5541ae0cf6b69528048773a4 SHA512 ec3cd800596998c2bc3499a0cde45a173daf87db2af709bef1ae47e70f88a16a7af7649492e4ab96abba4d9b10b58f82e7d8cb3c2882a738ae7963677fd60f0f WHIRLPOOL bc965015df0b6ca1724c1f050a0d7294cdc2a16a4bcfd4f41a63ab0d0dd6531ec80c4c4ef74d33266215b2dc7ec98691c775385745716f332463278aa18dd924
+AUX freebsd-ubin-6.0-bsdcmp.patch 413 SHA256 a0a99a602538d95ddae2fc4b823150ea58862def87c8196806a379233e3ddb2c SHA512 1516d984e7e17e8a3474ce519c9e5d6fefaee244ad27f1ed21af73335a6a25275e842007e71a60d6b18aa049f84c87b349f3350664cea03885cd55a846a73d50 WHIRLPOOL 7a23988970695ccdeaadfce96a0bf05e986736d0c93079cddf0101c0b17b7e5f3421e5da6c1e2b6e0c96ff025dd8d80effc392064ce9ff1cb2e0bce0e8d90b35
+AUX freebsd-ubin-6.0-fixmakefiles.patch 1457 SHA256 318406fa003c5188163e0dac551d4cc5fed7653cc3ff0f6baa64f23572de6d7b SHA512 65009d59ba9739627afb04f7abf5a55395d7585d2c9c201faf8f7b849ea462b61fee407accfe4460aa33a231d151c9d2aa29be7a0ccd71e969f5235a2635442d WHIRLPOOL f01e4257b06159c18f64960eb5d55a595f357bd0c6fd6974c6db942b6b0cbd6fff9ca7151cffd67bb8dec23d855975c7ab9c39cd28ba9dae098acd6773fb4c79
+AUX freebsd-ubin-6.0-kdump-ioctl.patch 1111 SHA256 71f41de71568dd819e39c871dd5e570141f243dbabb23d855505c38bec4e9de9 SHA512 53f2decb5a695b8daa4db10ac4f72b5a1d4fa58bd151314211f0ce230de5247a64e360855cef10b9e0c195146a704acb7f4cec623501516dfb9dcce09946262e WHIRLPOOL 48d2be90273b6ce1a0b4701a77d5a10e7e26f9f595b54b35cc410d81266c104c67c1fd1d735b659d41e4c3e02261cc79a85f3fe61c45ce79e4dadd1cf17b877a
+AUX freebsd-ubin-8.0-bsdar.patch 556 SHA256 cb81663b4cbb91372b492f2d8c430c166fe4f425fc464a94bb08ea43e23f278d SHA512 46ac4dc366571be48fb6bd131dba49253a3f6e54f68c33bb5b4fede5143c3b96dc107fbd1c3159e15f3816d3b716238c0dc162c958798fbafb5074603c7da430 WHIRLPOOL 32c57b0ccb3b2256e1169da0f7b4d9a3a6300cf703e792ab7286255a12bbaca983bb65ea1c42f6115fc071ee923b5182401e1d14461bf5407269a17361ce003d
+AUX freebsd-ubin-8.0-xinstall.patch 1014 SHA256 124cd30b5f44425d0914c64fd8ae98242c9649e4eb0cb1f786839137532504d6 SHA512 a39843600497876287c13a10ca783041123631ef7a82501df323c6a118eb20d871fa6683b812eeebea220c4cfa1eba81450dc7de7ea08888229f326375ff285d WHIRLPOOL 94e16b120a39e5331fa5db7bcda4ba970c3c92049122e958f4ea378936bd384671955af700053d8ae89d6a0c118abae61751cc2e866f719f882559801c6db359
+AUX freebsd-ubin-8.2-compress.patch 1658 SHA256 19485003b70669399b363c4579cecac7fe0b59e3127a13a2c2bc103526fe226c SHA512 9b94b608e4dffb27cec0e6994a06de710ff2d73125d18fad2c5bbe9cab3e1f626ba2ade0333cac9d72350e30b2746f1ccf096bb67b472d1b9b0b79da68bf43bc WHIRLPOOL de29a9917312d1b2f20bcf01cfc224df626113b7d6eea86e5c6fdc306d04a08042a452b1c03a30874f9da1d48f8a3a3718026c4305a4a0373df18d331fd57d6a
+AUX freebsd-ubin-9.0-fixmakefiles.patch 445 SHA256 88c90ea1e20afb56ae1b62c4e7ca9de8da8aa9b3726059a96e85beea13935d1c SHA512 588b0e7f58504ae338b714fb324b1525ed340b56e2e99a1ebaac2606799c9ff15b8c1a05e2ddaa5dfbdc7328684917de8753d99b0c8929c056d6eb6446aa9955 WHIRLPOOL 35445ccd0d4a63c5ac593157d55b0e08106d37cbab0a0b10a699e63872fd2a5e9bd53fe2c4a94dff7b1441fa27c141c171b6938ee51e7c696de95695938985a0
+AUX freebsd-ubin-9.1-ar-libarchive3.patch 593 SHA256 92a37952790362f73b0c6a1000877e633e7a0055be8397184aa8ad7e15bfecee SHA512 ece840657b425a666af495332a00a57a4c9c353187ee98747651da4ba69227bd0a58dbbdc7af860d49e0d662c9eaca046ec2f087a86c5bf282530bb9cdcf7aaa WHIRLPOOL 4e25ddac55843e725903c28ed009b646ed63eef4b935ee03eb4a60c3fdeb02b158e018ff76adea6ca14a9a40268a1b7347f26f067d407ffb7329fb3c4641da5c
+AUX freebsd-ubin-9.1-bsdar.patch 656 SHA256 86834418e478bc21918d6f310fb422dbfd0aa0df1315bd4fbc0ddd7a8fc62868 SHA512 88fc86fdb0ee6f757cee9b6bd55226517e6b79946f0518904bedd8176230124b40b868dee30049daa7053ea0ebe7d242dc58778e3addae2612ffd53996303bac WHIRLPOOL b66fd0a613cd32f9037c739146e465fd2ddcc56f78a3fdffc67eec9b92b6f2f78d6948906a77c2418e2bae5d782ab70f9c4f473ee8e256f233b237f6a11ae08c
+AUX freebsd-ubin-9.1-grep.patch 549 SHA256 5ab5dafccdc0c64f07742698abe51a24ab0abe10aba7d4bd80afcf4b5a36066f SHA512 2ddec1a02064ee91a177edb78a964d37b5be14c6e92a78ba9ce0a902c40f673eb7a6449042e341dfb3f31be6bef1a19fdf735af0d32526c0891fe6d9cc060101 WHIRLPOOL 3742f0c0612d2158ce2e5afaea7fb15f3f9cbc95f702fd51ea30c0c97a5cccabdffd4b722d1cb1930b362a4d2256bce77d997a69f02304a4d187391c8f8e0734
+AUX freebsd-ubin-9.1-kdump-ioctl.patch 1001 SHA256 03804b82087884efa28157b36781a746349f41164591b46b73785e0b53088e2a SHA512 aadf3a6d97c5822aa9ff0d1ad8a7bfb2d17fc3193851f864bcb847ef05fe5b7e2b852cb95aaf159194a12b26900697f089113ccb15854c8e3bdb43518de9adf8 WHIRLPOOL 904f1c9dee700cab16a6075216e85768c1a146064da10e865caa319850d400b96255f677df70b2ba1766d4d855b553ad58d74f7e139391bb841f7fc0ef39ebef
+AUX freebsd-ubin-9.1-minigzip.patch 336 SHA256 88ad33268fd33012d37ec3f0f915322a536a4868900aa7c19486226e96125723 SHA512 e25cb6b74b17ee3d999321701fcc5a90ab94abac8ea33a155847f99e7836f16203485618be3426e34a1a5895b7582f5f466f997986486637e52dbc0e6c225dd5 WHIRLPOOL 2fa652c4548eb5b305bafca4b788d9f19f1f52903b0e27cbf402e11bcd7ceb78bdf1dfabf79932b8e78b1bbf898308405ccc19b1ca21198446889c8360db24a7
+AUX freebsd-ubin-lint-stdarg.patch 792 SHA256 ec86f4c77b7c57f9f1651bb5f38641d198123594e770cc31d77d6775fd851bd6 SHA512 0f06547b0b90c65466c5c032efe6563dfd32ca56175fbad0885228310f6dc5f973d3adffe93bdb35d42b8af045ecdc23d1198fd8bad0c96c46512dbedbab3059 WHIRLPOOL 853d89f6f35c91718a30c8cbd2fed72a01c01dd03b3fab28c931fd80f71394122f4e5fe240df17b524dffb91829bc0148a605e797b88827d4f5e48730790fa57
+AUX freebsd-ubin-setXid.patch 3723 SHA256 961ac8dcd9efa4f1aab18f56b26c6210d1d5bf441410aae392160e7c0242d16d SHA512 9edaac765405e28b123fa40b708b1ab05af3e151726e6f2b75ab1c0fd17b6c2a428a58726da999f7a63e9550bdd3e0d274ce63517717137872a7e9c77a591501 WHIRLPOOL 36fff3ad1577981b157e4311226540ee9a0eca7f5d623e27b3fbc585bc5585158c21f27c2355ac773ff190817aee2056293d3a1c0306e7743ae72a3a49d1e670
+AUX locate-updatedb-cron 122 SHA256 63cceb90a3abb02e806af6940542f12d397e7600df37f1b7305104f78694cce9 SHA512 c3127d2ebb837d7fd6edc640604ce31c1639c036703b1e923e84b79f9840e13e28327eb7a5d655546ade8efb9188b041434552bcd0b4b76308c0e66132ad7985 WHIRLPOOL a040f971f7406f2dc022aee9e6b4cbfd4bb37931afabcdb58dcbe82539500bf7ae7fdfdf8651113ae3cea5ffa73771bb57a2a0a0e749701563664ccbf87285ca
+AUX login.1.pamd 145 SHA256 c8b81b422104b58afa8b6bb478b1eda77f97c3037030ac09889b7c3bf3de9fcc SHA512 2308d818de388be2973b59fad5a21ffe5a9c9d302b47ccf1a148182ccaf082421c5a277acf0c85649874fd607a8da20222e7a05c15606ee36f6e74d0968a1397 WHIRLPOOL a562ee1210568bdf2339df413ec69eed066738d0d2929c8965f6bfc2b05d60075b23176ca8f744bee2c6a7cfa8448adf4e08a531d36477f78aac78da47f3209c
+AUX login.pamd 300 SHA256 12d55e8d20a929851611acb7643e90844bcad21819efe7b5754992d0717bdceb SHA512 1212ea381853d8fa3a7d8f4e5630f9acf9861c6740b665965de7dcea89510ff89a5c06abe32a68225a4f45cfc62bd02e86661830ef7e6a2fbcf01c432bc7a03d WHIRLPOOL 6af1c052b79caacb12a4d2c55fa1f65be716d3cc48bcbac4f2dc280704b55275c0354b9c3cb7aabf733ca42b7c45fb07acb0080131dfe537b486737bdcae65ef
+AUX passwd.1.pamd 145 SHA256 903a7a623d55ded0e942f92306585d9d64961f0318a1c4ff8170f9ba6e46345e SHA512 89f8a8a7058c2105c71a98099ba79f7169b660633cacc7be5352622481fd0a6c82f6b5403f34bfb059f8cf524671e86d7f0031dd7c89fc98fe5d5f33986a557a WHIRLPOOL f63f3a137b4ff65a637a573691e5700c0ca59e39dd55bcfde2ca2e934ca61da5d03a593c0caeaa6c615fc94849736a085740153889edb7497e52c7a36ca652e5
+AUX passwd.pamd 238 SHA256 f6767b8cda9d738ea95f720a17f2eedd94725516b8f8f8a34b8ae90e0706d0db SHA512 cc6a76b1b5dc7b4a442728155152673abb0dd265ad1d9ec99d5556d723dff89929e60c52b612aff98f5613fe92ebbfbcea53db53557de39194c889619ecf976e WHIRLPOOL e892af61e13fb9148ad13d6434df90d5df35fdeacef096f9c630af3ffe79b6d22a167664f13cc65041b01104b05437369f47b1adf487ff7278b362c2c37c02d6
+AUX su.1.pamd 312 SHA256 d1046ccde74f6fcf96d5f830622a12a15e59c1c3901d79157629d91b96ad85fa SHA512 f7ceb3659313197138d057a67b325fab7a304426ad7b6e8e3fbda2cae47f42a3348eaa1e5153b20626cef63da5096c60cb7f2e1904c3031d9fd13df765fc70b4 WHIRLPOOL 14c4d4a33f41843b0fd1530d6769d1307e97ddefd51fd292fcbb305c5369079714a1c6bc73ee3d513718b3dbf109fe632e1489e7393ac05666d6a88b1f783d1e
+AUX su.pamd 302 SHA256 33d7ea9cb9b2004ab86f555cfde99b6ba91290c434481ce592010609f87e656d SHA512 1df023ab34a7dcef5932db19d2c578f880f0f6b4040de047131397a5744a7bc54d9f496343391f0f22eaaa23507f6aa68c8f71ea60153254e4726ae32a517462 WHIRLPOOL 32905a05c69a317fadc278f9d41e382d332eebc4ff0d4de26219e035dc477b2c644ddcd08859bebd38120898a39629535ef5312018d35636ca1de99d922517b5
+DIST freebsd-bin-8.2.tar.bz2 415900 SHA256 fb31b7fab259bda8396e615246f85dc99c3c9f7e98f4e4a613e20b6a394c4921 SHA512 c39b26f75f7d812f46e907acabd8dfaf45c97adf4488bcafa35fd46c805d821e177609d403cf5e677f3674020290199ac97059a0609f7705bce58a7aab3ee8e3 WHIRLPOOL 49e70b1c09c4b72b3f23850e8c9873556571ec02d70ade8f18f683eff6fa92dc8f6d02d58473fe7b4d8d1f3de96c63df41150b2091caafbc9a0e92e6055b43fd
+DIST freebsd-bin-9.1.tar.bz2 385664 SHA256 0a9524d75a8cb4c9c2654f2f9843087b09e8599bba97b9b59f00bc2e92b87e00 SHA512 fa0571a705befe1cb9c07285d3df55c9b5f4f295760511d668d80fec8cd4d59b70c676f07164f2aa44911decef0fb54fa6d78405ac2ceec822b6b8920abc5ca8 WHIRLPOOL 6f2bfe17604339e8260c49582bc941d255932b5c0a7b604e58187626a3a38766cd1e4aed9fc93a737ec9b4fa661f88aac23769b3542f35eb20da8b260216e985
+DIST freebsd-cddl-8.2.tar.bz2 823706 SHA256 6d2b2362ce60538bcba4afa47bd6baa98b05292babae4b20d6ba08592ce98698 SHA512 9f9728d9bf0f9fb320a0378186b29133e5e9276494f57ac3cffa9917ec94d3b886708406990107f2fbf742c255f9ac716f35ea14f6a6a835712eb55581421721 WHIRLPOOL 0150d972fc5200efcf22b5baded0bc7d826f03420a8328bc9ce1f53f39d1f3cd07dc367fcb3b0c8bdcc3b33bc9045f262928d76532c91820fd3c6bc8c9ee57c9
+DIST freebsd-cddl-9.1.tar.bz2 899348 SHA256 bcc79fb002052128e9e91b16beb3083ee152be0936494715c6c159bfc8d2ca3a SHA512 ae0a969e710785bbcf36a2ec22cc5b1dcdb25398be951e047a1237d0c977e38fc9e05504db51f8bf9ed83bc1f68b04fc88ce18fc48a93f785b8a3f8ef481bacd WHIRLPOOL 2c4a5baf162dbb698af45b9262f104e27c05e6a2630c3e7b1765e76c8987a330c315f741df69c8771d2509708d2934db2a07f2e0218aa59d0100dfc3f952bf72
+DIST freebsd-contrib-8.2.tar.bz2 40931651 SHA256 8b9cb688e81c2980b3fc66411d00ab277a24dadd50d5bdd5e0e6c63ac687b9b6 SHA512 4f7bf825b579fbb88f2aac531d07e531474179c63fa0b66c4e80821290a8c94bf611bb4dcaef51b762aacd25b11dfae798a4ec3bad3b9e3f6b3490ebfaa72476 WHIRLPOOL edd3d9e26e8d22d9028082e107ec1a44402e206dab8722f34b445676959305996c3f699152af42ace249b7f58498492787823b172fb6bcb273119c6bb50a35f0
+DIST freebsd-contrib-9.1.tar.bz2 54751432 SHA256 e7ffa056d4050ce03ee8e23e276e2a9a494326a98d60c43bee2afcc59576deb8 SHA512 71be13049258c6e6b5e4f63cc16da5d349a89d68f04d87446e4ad33ae8bf2a93ea67d9c256b7bec60b61e65db0487268070cfb77a484c3ac0f8ba368b48c2438 WHIRLPOOL a2a84423175499208d34809e802284d6ba649f317c3a9ad8b7312fa19efe142ebadab0048bac0db8e988e59f9a7468ac7c5d0d25e78b82bdb269a20d18153cee
+DIST freebsd-etc-8.2.tar.bz2 188629 SHA256 6bc745fa259f9fa2b65df865d45443a7b23c24445195e33a4ac50bf1040ae238 SHA512 3e5c106754a6a1ac806bd46b711fba7ee9cb31a4eab5262c995a5d59dbeb02f756dd8b495640dda94189d204a5d2c5218de2bd23467172d6a4ebe1048986e89c WHIRLPOOL 23b658a214f1a64c43420351020e32b1182e9aac3ed5253f49ee86f9cee9166ce32bd556cd2a2b3c0e60a165462a8700f37dea19e57ad5716415e17f61da912e
+DIST freebsd-etc-9.1.tar.bz2 207776 SHA256 a317bf85532d6192f5506e8d7bd5d5c201fe24017700e3a974a7712c2c69cdb8 SHA512 4fbe56fde519cf2f44e39a8869efa26c34f703cf540f4a83389da8d170873d7c6fb18e4010e643b8d793cfc5c55d15eeb198057a5b2a8da9d9e8f791801bf314 WHIRLPOOL 0c27019fe140fe96f870697acbaa89ac2f281f55b892c5791b08abf1cfa4da94d9d42a1df1c2091317573ed7234253857aecb797065f911a0a5d57bbf64349a5
+DIST freebsd-include-8.2.tar.bz2 138992 SHA256 fade90621a8e4880c9583c1ee49965400c88e53ac6c07cb5dcf320e4f069271d SHA512 6bc820dde866589ef75f9f0d1c469d815439bdd4c79f0e1a2482ec58f938b638cb9106969b321aa72492f933c95c76895ce489727a5e265798c93adc75dd64e3 WHIRLPOOL 64d3160c4ac46a62f5969058e07bd160c92284f08805ed917f2073ba1cb5907cfca16c5893daf30254d39b4fcdf641ab6afb9817607f65e7789d3049e8103947
+DIST freebsd-include-9.1.tar.bz2 146881 SHA256 861dce3f39e6806762b102361017cbe148f0e2b768b3fca152f8426f44a2942f SHA512 779c8315ce2b10b343bb62e331525d510b0d68ce5d665a1672bd6f4d1eff6445bc6b7a0f178b319828aa203c4e4c04c561ce793052703f4f936ce9711280a0c9 WHIRLPOOL e16ba45d380591ba007ca59579d45f61ffc1aa1a4c08fc11ed2794979b0a189a346c81b4f70a44ee199d50a72024930f28587ad62a9cd6854fc937eb466ec115
+DIST freebsd-lib-8.2.tar.bz2 3323878 SHA256 e3590c12794fcb5ba8eb7a1f58b497587cf19f9200b3254c194a793da3b5bfb0 SHA512 c059cfdd1099bb519b2a5c43fb7e7104c500ef8906229ed7eb9e420cb3a217cdaf8655e9e7a9f45cfadc5491f8115e0e738fd49251d9f0c3a83780845b09f007 WHIRLPOOL 95f98a372f44a89bc8ac3029ec065dbbfec338e6f889d057d75644bfcdfb9d27fdc0421d7e392cad5a823712b97f0857297ec3d321580254c63032c22b95792e
+DIST freebsd-lib-9.1.tar.bz2 3206685 SHA256 f31fa8107b4de711c548f6d0c1bb1f81d09f51bcc3b14a1e9e90bb0e7cc4a35d SHA512 40d0c36b6b889c404fa0e0afa38ba4e84a55bc88ffa2f98a70afbd7a32c4f32c158617ba770567d082a986d62c09b3ec8db3dc5ab853ee1c9bbe0b90bb82396e WHIRLPOOL 581878bf9c43184b043b4293409b85901c9ed1f9bd279e965414aca41ba50950848ebda3ee10a503a028135dfd2765e95a11acd4e62a11c528e104392bbbd8d0
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+DIST freebsd-sys-8.2.tar.bz2 25835329 SHA256 0c6c7b61aae94db2931f985d5899f3bca78fc8ffab6b598fbaa158142d676f16 SHA512 6ea4516a5c52e25c4f993f7acb875463a5caea93dbdf250c5d48eee95fff226956e9f030cab7e341b5e6a132325bc3dbf93dcb4b1185acb011918e50b1a22be3 WHIRLPOOL 870deeff877c6b9fc812a4260e4fdbb6715a5dc2065cab3bfbf2a42d876f6654703ccb124275a4e2c410cef48f3db02b63cc76059eccf9cf90244826f35b7a15
+DIST freebsd-sys-9.1.tar.bz2 32588103 SHA256 b93a7ac8334ac16cc9f60665048e5ef812c0a6c62f10d0b0a674aec3f56516a8 SHA512 7dc9d9e00dde8f592bb171f4386d02b655b73cb4f153fe5ec063d010a148ef0639eae0dcdb3eeb09ecd1e3653c69e49a2d261329fa6d0381d2ddabe258ddde6d WHIRLPOOL c8348344dfb14bad64bd3a78ee615ddd29203175b292233254f8ba175e7a3fb7218af6f95f7b4dbf394c0354bafe9d8bb0c21cdf0ceaeb697214964b280469b3
+DIST freebsd-ubin-8.2.tar.bz2 1808012 SHA256 6b99554f3ad6ee052069b347eb6e6219b71598d7b222acb90a24cbfc805c7b68 SHA512 48d0103323e820c431aa4f62d3be40cb3b200fb62e3de01f36c88760395bf2ba3367c51f3fa72da4dbccc2812176a051a12ca5cb7e84125c3e0fc78d4cab2c29 WHIRLPOOL ea8f3a29a37b42c2b5bcc0f2c343fa1538522157ef075363c94606a4620a590e9a03f856ce2494e3e727935b62431991d0aa9fde71de699e78b4fe225bdf1c2c
+DIST freebsd-ubin-9.1.tar.bz2 1910472 SHA256 ff6e586f213534b6ec2e65002c0dee64063d76ddad515c12221b1a80a1815e48 SHA512 74ae0aceec8597aa66c3f1ab313f0685a3c63d7273c36ae7baf8794275ad9bca241c60c3f6281cccf6d531d250d7611099977d3b1a27279cef3586401b6af05e WHIRLPOOL c85a3c9cf2bceff2c60ff03556bcc81d3aca22b0bce3c9538990071ac0a907236eee5ae7743ad22c5fd309b047ebf392aaaf2fe177ef5790ea869aff3da7e2fe
+DIST freebsd-ubin-EN-1621-localedef.patch 1958 SHA256 4cc2fe1bed57c303f919c1824b8754d7804dcf96bc2c349b5051995995e3a878 SHA512 191661a189dbb33979de04f68cac1701ee0f3af52921be1e0566590b462e475e5883cd0495b001c42b7bfdaf60e0360ea53ddc2ea729cc1bc13cbf228aaa284a WHIRLPOOL 73fa520f2f24fce7dfdefc8b7306e9802936f37296d1dab6339cb86c51a917f1acc60e14070ff71e96d5234fc186a1112c6f7f2196265e367f04a496b739c1bd
+DIST freebsd-ubin-SA-1625-bspatch.patch 286 SHA256 22ab941e324509a1cd2608407ef7ca998ac1b4bd9602c8ef643b4c078c5b4134 SHA512 f2a0210e582076bac93faa3a226cd9301b6d0245938d6c5a17e1aa275401934d7848bcb908f63a689f5e36f961dfbf1d0a0b5717ff54f67a76b5d1908ae39703 WHIRLPOOL 15a1dc7546964556bab0dbaf7054c4644c3be1bce6c2cc3e8baa74ccb49871d0dd3fc4b702c21e0a5a5a68298f225da6b19e1f2736f29cdf394a8a9f081ea507
+DIST freebsd-ubin-SA-1629-bspatch.patch 9323 SHA256 087fcfb0e4f6c63e58656cf6a6f30411bc6183d81e0a1a2dcd40f9b41cb640e4 SHA512 ae061869db3a01e0002b2159306ff72c5629147b8e594f0fda5f6d3aa956f4a73a4a3fbc299ef2c69231cf619049e8eb5bed34067be6d5d419f108958c97f59f WHIRLPOOL 9dd2fab13103bdeca6df6060948b755f8552bd3216167bc417ce137b8f28080e129667f3e483badd5cf2ae3b8926d22493b5654a85cfcbc744915e683b56ec52
+EBUILD freebsd-ubin-10.3-r2.ebuild 6052 SHA256 673a3576b3ae5d57486ae876b492bf56864edff32e3762acd9226efa0ecbe4d2 SHA512 5f3c679b039c8475f18e5626e5b6c30afc93c4b21b8ee659fb6c48208a12ae059799131eb7d1ce71fb312b439c2cffa3cf21040fa4770b98278fc71d6e1205e3 WHIRLPOOL 380885db6941ee6ddebc13deefa9be37b75614ef719b5d2a6a9923c82e29998a7a5a20748741e1468d68cd545272ae36ce3e9dff0c51ba13e0732923405dc34e
+EBUILD freebsd-ubin-11.0-r1.ebuild 6215 SHA256 240b76acc253936df4df0b286abd69be236348d23c53b992233ffdc8d1144818 SHA512 ae7c60695e0eafd8e066ad430d4ecfaeedd95781547e4e39c4202eca4fe41dd61671faf14a6cd6a1c1d95e84a0c3eaf86068dcbfc8d2c544eebb6034ce8d562d WHIRLPOOL f9b1da2d545a2310c48b6114e5482276397fde0034050a5f8d52f6ab08a8151211487a36e60a16bfb0b2b78ebb8a6c333f54c26f359c3fd9b624bf0fe2281eb0
+EBUILD freebsd-ubin-11.1.ebuild 6201 SHA256 fa08e9a5c8bd91dcf93b3ad6b271b27e9a04ca199d7632917c576abb3283965b SHA512 f853ff1cb10810272d3677159204fa1c3f9e22ab6556b17c74b39c1e653d83cc44997878812e5557ce9025befdb9e0005fac37b05ff2386334f00b0e91336b5f WHIRLPOOL 3c7f8b09476ce074cbfcba749e4ba2bb94922fb6257f6f9512fe65b5607c5c73e2fa58513f8b7bcdd61d648cef8c2880dfb67bf7e32f45545730ed1207e905c6
+EBUILD freebsd-ubin-8.2-r1.ebuild 4520 SHA256 1aad9172aca1469d125b5dcdd7e34c44ad8e0b7519c1ac50901d29f25eabb816 SHA512 92a14a5812aafea6a7c772e4da874651babc2fd8e0c03172ed5dfea7ab50c51cde3ace435a7e8ccfcbfdb45e725c9cfdf6b307efd2e2f77f5a00295b5d7c148e WHIRLPOOL 72e25500f403baefde2fbd9c2ab964c9b141c192b45d231aff81286a048e9adbf5cf4cf9b31d591ea6ca291870aaa2157dbe17d00d355dc1753748133d269b8d
+EBUILD freebsd-ubin-9.1-r2.ebuild 5447 SHA256 611256a27827a980775f8423fbbc886443ea5cfe07d4e90e79535ac44dc1215c SHA512 fc4dc85aa3a37cd734e6ff59811e55e4679a178a9feb6f7e99410835cac73fe95730067267e7c808bba718ce9ca1d5f9d532c96080b7b61238e657869ec5027d WHIRLPOOL 50a57b381b62cf9a66df58f0a95906578e492e9ba97a7b3df6d6b2eea1490d5ee609baa725a768e7b3aa09c0771206cab53ff70fda2846df7fd539553b162f5f
+EBUILD freebsd-ubin-9.1-r3.ebuild 5454 SHA256 5b631517accd0504df55523d9b1cd39d563855fd7a188d08a6f0b1258d300796 SHA512 b70bb34cf6536e080f2fc40f3018dce2e1c4061932e6f9137709bea5d0878e6f4625d4d7d7f34b3bd51e48a46ff9f3d352ac112b66579de6d0249bb7a0a3eb57 WHIRLPOOL e8a5a6c45bf3c6c1aab885e28c87c441f8a178b0310791586fb77e8e5293758c86b9a53b8df4a089aac182c62ae413000b5025be13968d0df9b104563442143c
+MISC ChangeLog 6229 SHA256 d1a63a88685345a6a6a5d2b2d1239dc800215c95aba1310a4440b491eeabe8c3 SHA512 5c76f8551305f0e04faedee3f167fcad921f71e385e037082a7494d39718d4af9ad6d4784a5646577c7f63875a709dc3d98f513d0f97fe125c6d89b894b4cb45 WHIRLPOOL 0beba4877702ea625062c28d0e1d955b33f437e641788e4df8622862950cab00e0f715c716dd44a5dab26019e01a3174f53bb04cd366e2b1d90ea782a5133967
+MISC ChangeLog-2015 21300 SHA256 0a85cc6b3f1163e5545522da864fe54a8a6f9a216b366eeb2b12a6c6bf882f1d SHA512 f5b675b1b97227d93be1ca9fae809ec8a5ec6d636aff49d909676cacd2f81faa738aa51a76ef1c4a32f97732ea9e40fe19734b4bb6ea569f36c32b025164092b WHIRLPOOL 08549e9019904a0fd2829a3ab1aac0074a5114d6553965e4d0dc4ab5a75710fe3f15a5448ffcc8cfbbc076b5336ab196989ff696527074f4c0213b240331714b
+MISC metadata.xml 782 SHA256 9d530de89ea94bedcf5f2943f56417fd2a4942bac995425a485acf2ccd01f994 SHA512 50d638f761e118d9892e593dcea9d72805e3968d29cb3bbb1b95cf4eb6a4e3293a3c47b29415a4f9fa937dcccf2c2f09c2af10e62982a15069bad22162d70f3d WHIRLPOOL 8ce25849714014929d8b1b6b6e05a9e88e4671f5a3accb128e266a64994b390395b4d881018090ef778dde7afe6894e15a9047fa591b45bbd31df960cecdea37
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-atf.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-atf.patch
new file mode 100644
index 000000000000..d758c48846ed
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-atf.patch
@@ -0,0 +1,15 @@
+diff --git a/usr.bin/atf/atf-sh/Makefile b/usr.bin/atf/atf-sh/Makefile
+index 4ebdc33..37ff8fa 100644
+--- a/usr.bin/atf/atf-sh/Makefile
++++ b/usr.bin/atf/atf-sh/Makefile
+@@ -33,8 +33,8 @@ PROG_CXX= atf-sh
+ SRCS= atf-sh.cpp
+ MAN= atf-sh.1 atf-sh-api.3
+
+-CFLAGS+= -DHAVE_CONFIG_H
+-CFLAGS+= -I${ATF}
++CXXFLAGS+= -DHAVE_CONFIG_H
++CXXFLAGS+= -I${ATF}
+
+ DPADD+= ${LIBATF_C} ${LIBATF_CXX}
+ LDADD+= -latf-c++ -latf-c
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-dtc-gcc46.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-dtc-gcc46.patch
new file mode 100644
index 000000000000..112523851f90
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-dtc-gcc46.patch
@@ -0,0 +1,25 @@
+diff --git a/usr.bin/dtc/string.hh b/usr.bin/dtc/string.hh
+index 45bc4fd..6eaf8e4 100644
+--- a/usr.bin/dtc/string.hh
++++ b/usr.bin/dtc/string.hh
+@@ -32,6 +32,8 @@
+
+ #ifndef _STRING_HH_
+ #define _STRING_HH_
++#include <cstdio>
++#include <cstring>
+ #include "input_buffer.hh"
+
+ namespace dtc
+diff --git a/usr.bin/dtc/util.hh b/usr.bin/dtc/util.hh
+index 7f2ec67..8e13b1c 100644
+--- a/usr.bin/dtc/util.hh
++++ b/usr.bin/dtc/util.hh
+@@ -33,6 +33,7 @@
+ #ifndef _UTIL_HH_
+ #define _UTIL_HH_
+
++#include <stdint.h>
+ #include <vector>
+
+ // If we aren't using C++11, then just ignore static asserts.
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-kdump-ioctl.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-kdump-ioctl.patch
new file mode 100644
index 000000000000..e10685284cbb
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-kdump-ioctl.patch
@@ -0,0 +1,26 @@
+diff --git a/usr.bin/kdump/Makefile b/usr.bin/kdump/Makefile
+index 38e9df6..5e831c6 100644
+--- a/usr.bin/kdump/Makefile
++++ b/usr.bin/kdump/Makefile
+@@ -22,7 +22,7 @@ CLEANFILES= ioctl.c kdump_subr.c kdump_subr.h linux_syscalls.c
+
+ ioctl.c: mkioctls
+ env MACHINE=${MACHINE} CPP="${CPP}" \
+- sh ${.CURDIR}/mkioctls print ${DESTDIR}/usr/include > ${.TARGET}
++ sh ${.CURDIR}/mkioctls print ${.CURDIR}/../../include > ${.TARGET}
+
+ kdump_subr.h: mksubr
+ sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include | \
+diff --git a/usr.bin/truss/Makefile b/usr.bin/truss/Makefile
+index 7a49497..bc8b61f 100644
+--- a/usr.bin/truss/Makefile
++++ b/usr.bin/truss/Makefile
+@@ -24,7 +24,7 @@ syscalls.h: syscalls.master
+
+ ioctl.c: ${.CURDIR}/../kdump/mkioctls
+ env MACHINE=${MACHINE} CPP="${CPP}" \
+- /bin/sh ${.CURDIR}/../kdump/mkioctls return ${DESTDIR}/usr/include > ${.TARGET}
++ /bin/sh ${.CURDIR}/../kdump/mkioctls return ${.CURDIR}/../../include > ${.TARGET}
+
+ .if ${MACHINE_CPUARCH} == "i386"
+ SRCS+= i386-linux.c linux_syscalls.h
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-mandoc.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-mandoc.patch
new file mode 100644
index 000000000000..c5f7706024c4
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.0-mandoc.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile
+index 0995534..1bcb3e0 100644
+--- a/usr.bin/mandoc/Makefile
++++ b/usr.bin/mandoc/Makefile
+@@ -1,7 +1,7 @@
+ # $FreeBSD$
+
+ MDOCMLDIR= ${.CURDIR}/../../contrib/mdocml
+-LIBMANDOC= ${.OBJDIR}/../../lib/libmandoc/libmandoc.a
++LIBMANDOC= ${.CURDIR}/../../lib/libmandoc/libmandoc.a
+ .PATH: ${MDOCMLDIR}
+
+ PROG= mandoc
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-bsdxml.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-bsdxml.patch
new file mode 100644
index 000000000000..606471713fba
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-bsdxml.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.bin/mt/mt.c b/usr.bin/mt/mt.c
+index af6562b..3121c81 100644
+--- a/usr.bin/mt/mt.c
++++ b/usr.bin/mt/mt.c
+@@ -92,7 +92,7 @@ __FBSDID("$FreeBSD: stable/10/usr.bin/mt/mt.c 280438 2015-03-24 14:36:10Z ken $"
+ #include <unistd.h>
+ #include <stdint.h>
+ #include <errno.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <mtlib.h>
+
+ #include <cam/cam.h>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-talk-workaround.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-talk-workaround.patch
new file mode 100644
index 000000000000..3a65b3714b72
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.2-talk-workaround.patch
@@ -0,0 +1,12 @@
+diff --git a/usr.bin/talk/io.c b/usr.bin/talk/io.c
+index 4daad7a..1fb9105 100644
+--- a/usr.bin/talk/io.c
++++ b/usr.bin/talk/io.c
+@@ -50,6 +50,7 @@ static const char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93";
+ #include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
++#include <wctype.h>
+ #define _XOPEN_SOURCE_EXTENDED
+ #include <curses.h>
+
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.3-bmake-workaround.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.3-bmake-workaround.patch
new file mode 100644
index 000000000000..c0ca444b042d
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-10.3-bmake-workaround.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.bin/bmake/Makefile b/usr.bin/bmake/Makefile
+index 6c6d8c2..22fec7a 100644
+--- a/usr.bin/bmake/Makefile
++++ b/usr.bin/bmake/Makefile
+@@ -5,7 +5,7 @@
+
+ .sinclude "Makefile.inc"
+
+-SRCTOP?= ${.CURDIR:H:H}
++SRCTOP= ${.CURDIR:H:H}
+
+ # look here first for config.h
+ CFLAGS+= -I${.CURDIR}
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-11.0-setXid.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-11.0-setXid.patch
new file mode 100644
index 000000000000..946cc5b125f9
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-11.0-setXid.patch
@@ -0,0 +1,147 @@
+diff --git a/usr.bin/at/Makefile b/usr.bin/at/Makefile
+index d199a85..dc5cafd 100644
+--- a/usr.bin/at/Makefile
++++ b/usr.bin/at/Makefile
+@@ -17,6 +17,8 @@ BINOWN= root
+ BINMODE= 4555
+ CLEANFILES+= at.1
+
++LDFLAGS+=-Wl,-z,now
++
+ at.1: at.man
+ @${ECHO} Making ${.TARGET:T} from ${.ALLSRC:T}; \
+ sed -e \
+diff --git a/usr.bin/chpass/Makefile b/usr.bin/chpass/Makefile
+index 4427417..4f774a1 100644
+--- a/usr.bin/chpass/Makefile
++++ b/usr.bin/chpass/Makefile
+@@ -17,6 +17,8 @@ CFLAGS+= -DYP
+ #CFLAGS+=-DRESTRICT_FULLNAME_CHANGE
+ CFLAGS+=-I${.CURDIR}/../../usr.sbin/pwd_mkdb -I${.CURDIR}/../../lib/libc/gen -I.
+
++LDFLAGS+=-Wl,-z,now
++
+ LIBADD= crypt util
+ .if ${MK_NIS} != "no"
+ LIBADD+= ypclnt
+diff --git a/usr.bin/fstat/Makefile b/usr.bin/fstat/Makefile
+index cd03a51..9a0fe6e 100644
+--- a/usr.bin/fstat/Makefile
++++ b/usr.bin/fstat/Makefile
+@@ -9,3 +9,5 @@ LIBADD= procstat
+ MAN1= fuser.1 fstat.1
+
+ .include <bsd.prog.mk>
++LDFLAGS+=-Wl,-z,now
++
+diff --git a/usr.bin/lock/Makefile b/usr.bin/lock/Makefile
+index 07321f7..ed2c786 100644
+--- a/usr.bin/lock/Makefile
++++ b/usr.bin/lock/Makefile
+@@ -7,4 +7,6 @@ BINMODE=4555
+
+ LIBADD= crypt
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff --git a/usr.bin/login/Makefile b/usr.bin/login/Makefile
+index 3499575..62a7356 100644
+--- a/usr.bin/login/Makefile
++++ b/usr.bin/login/Makefile
+@@ -16,6 +16,8 @@ CFLAGS+= -DUSE_BSM_AUDIT
+ LIBADD+= bsm
+ .endif
+
++LDFLAGS+=-Wl,-z,now
++
+ .if ${MK_SETUID_LOGIN} != "no"
+ BINOWN= root
+ BINMODE=4555
+diff --git a/usr.bin/netstat/Makefile b/usr.bin/netstat/Makefile
+index 52cc3c7..11ebb2f 100644
+--- a/usr.bin/netstat/Makefile
++++ b/usr.bin/netstat/Makefile
+@@ -57,6 +57,8 @@ BINGRP= kmem
+ BINMODE=2555
+ LIBADD= kvm memstat xo util
+
++LDFLAGS+=-Wl,-z,now
++
+ .if ${MK_NETGRAPH_SUPPORT} != "no"
+ SRCS+= netgraph.c
+ LIBADD+= netgraph
+diff --git a/usr.bin/opieinfo/Makefile b/usr.bin/opieinfo/Makefile
+index 3114a92..5c41213 100644
+--- a/usr.bin/opieinfo/Makefile
++++ b/usr.bin/opieinfo/Makefile
+@@ -12,6 +12,8 @@ WARNS?= 0
+
+ LIBADD= opie
+
++LDFLAGS+=-Wl,-z,now
++
+ BINOWN= root
+ BINMODE=4555
+ PRECIOUSPROG=
+diff --git a/usr.bin/opiepasswd/Makefile b/usr.bin/opiepasswd/Makefile
+index ae35b20..32ba59b 100644
+--- a/usr.bin/opiepasswd/Makefile
++++ b/usr.bin/opiepasswd/Makefile
+@@ -12,6 +12,8 @@ WARNS?= 0
+
+ LIBADD= opie
+
++LDFLAGS+=-Wl,-z,now
++
+ BINOWN= root
+ BINMODE=4555
+ PRECIOUSPROG=
+diff --git a/usr.bin/passwd/Makefile b/usr.bin/passwd/Makefile
+index 758be2d..ebde1a6 100644
+--- a/usr.bin/passwd/Makefile
++++ b/usr.bin/passwd/Makefile
+@@ -13,6 +13,8 @@ SYMLINKS = ${BINDIR}/passwd ${BINDIR}/yppasswd
+ MLINKS = passwd.1 yppasswd.1
+ .endif
+
++LDFLAGS+=-Wl,-z,now
++
+ beforeinstall:
+ .for i in passwd yppasswd
+ [ ! -e ${DESTDIR}${BINDIR}/$i ] || \
+diff --git a/usr.bin/su/Makefile b/usr.bin/su/Makefile
+index b3dd829..26eaa63 100644
+--- a/usr.bin/su/Makefile
++++ b/usr.bin/su/Makefile
+@@ -10,6 +10,8 @@ WARNS?= 5
+ LIBADD= util pam
+
+ .if ${MK_AUDIT} != "no"
++LDFLAGS+=-Wl,-z,now
++
+ CFLAGS+= -DUSE_BSM_AUDIT
+ LIBADD+= bsm
+ .endif
+diff --git a/usr.bin/wall/Makefile b/usr.bin/wall/Makefile
+index 0579add..571be8d 100644
+--- a/usr.bin/wall/Makefile
++++ b/usr.bin/wall/Makefile
+@@ -6,4 +6,6 @@ SRCS= ttymsg.c wall.c
+ BINGRP= tty
+ BINMODE=2555
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff --git a/usr.bin/write/Makefile b/usr.bin/write/Makefile
+index ba06110..ba6ce04 100644
+--- a/usr.bin/write/Makefile
++++ b/usr.bin/write/Makefile
+@@ -5,4 +5,6 @@ PROG= write
+ BINMODE=2555
+ BINGRP= tty
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-11.1-fixmakefiles.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-11.1-fixmakefiles.patch
new file mode 100644
index 000000000000..c8589fc24347
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-11.1-fixmakefiles.patch
@@ -0,0 +1,12 @@
+diff --git a/usr.bin/calendar/Makefile b/usr.bin/calendar/Makefile
+index c21fff9..06c0fe1 100644
+--- a/usr.bin/calendar/Makefile
++++ b/usr.bin/calendar/Makefile
+@@ -15,6 +15,7 @@ FR_LINKS= fr_FR.ISO8859-15
+ TEXTMODE?= 444
+
+ beforeinstall:
++ ${INSTALL} -d ${DESTDIR}${SHAREDIR}/calendar
+ ${INSTALL} ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m ${TEXTMODE} \
+ ${.CURDIR}/calendars/calendar.* ${DESTDIR}${SHAREDIR}/calendar
+ .for lang in ${INTER}
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-bsdcmp.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-bsdcmp.patch
new file mode 100644
index 000000000000..1a8552909653
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-bsdcmp.patch
@@ -0,0 +1,13 @@
+Index: fbsd-6.0/usr.bin/cmp/Makefile
+===================================================================
+--- fbsd-6.0.orig/usr.bin/cmp/Makefile
++++ fbsd-6.0/usr.bin/cmp/Makefile
+@@ -1,7 +1,7 @@
+ # @(#)Makefile 8.1 (Berkeley) 6/6/93
+ # $FreeBSD: src/usr.bin/cmp/Makefile,v 1.6.14.1 2005/09/17 11:33:41 brian Exp $
+
+-PROG= cmp
++PROG= bsdcmp
+ SRCS= cmp.c link.c misc.c regular.c special.c
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-fixmakefiles.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-fixmakefiles.patch
new file mode 100644
index 000000000000..b135a82a5238
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-fixmakefiles.patch
@@ -0,0 +1,35 @@
+Index: usr.bin/calendar/Makefile
+===================================================================
+--- usr.bin/calendar/Makefile.orig
++++ usr.bin/calendar/Makefile
+@@ -10,6 +10,7 @@ FR_LINKS= fr_FR.ISO8859-15
+ TEXTMODE?= 444
+
+ beforeinstall:
++ ${INSTALL} -d ${DESTDIR}${SHAREDIR}/calendar
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${TEXTMODE} \
+ ${.CURDIR}/calendars/calendar.* ${DESTDIR}${SHAREDIR}/calendar
+ .for lang in ${INTER}
+Index: usr.bin/ee/Makefile
+===================================================================
+--- usr.bin/ee/Makefile.orig
++++ usr.bin/ee/Makefile
+@@ -12,12 +12,12 @@ LDADD= -lncurses
+ NLS= en_US.US-ASCII fr_FR.ISO8859-1 de_DE.ISO8859-1 pl_PL.ISO8859-2 \
+ uk_UA.KOI8-U ru_RU.KOI8-R
+
+-NLSLINKS_en_US.US-ASCII= en_US.ISO8859-1 en_US.ISO8859-15
+-NLSLINKS_fr_FR.ISO8859-1= fr_BE.ISO8859-1 fr_BE.ISO8859-15 \
+- fr_CA.ISO8859-1 fr_CA.ISO8859-15 fr_CH.ISO8859-1 fr_CH.ISO8859-15 \
+- fr_FR.ISO8859-15
+-NLSLINKS_de_DE.ISO8859-1= de_AT.ISO8859-1 de_AT.ISO8859-15 de_CH.ISO8859-1 \
+- de_CH.ISO8859-15 de_DE.ISO8859-15
++#NLSLINKS_en_US.US-ASCII= en_US.ISO8859-1 en_US.ISO8859-15
++#NLSLINKS_fr_FR.ISO8859-1= fr_BE.ISO8859-1 fr_BE.ISO8859-15 \
++# fr_CA.ISO8859-1 fr_CA.ISO8859-15 fr_CH.ISO8859-1 fr_CH.ISO8859-15 \
++# fr_FR.ISO8859-15
++#NLSLINKS_de_DE.ISO8859-1= de_AT.ISO8859-1 de_AT.ISO8859-15 de_CH.ISO8859-1 \
++# de_CH.ISO8859-15 de_DE.ISO8859-15
+
+ NLSSRCFILES=ee.msg
+ .for lang in ${NLS}
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-kdump-ioctl.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-kdump-ioctl.patch
new file mode 100644
index 000000000000..a89cf52dfc4c
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-6.0-kdump-ioctl.patch
@@ -0,0 +1,28 @@
+By default the mkioctl program that generates code for kdump does look for
+ioctls in the whole /usr/include tree, but this does break when xorg is merged.
+This patch allows to look for include files only in the source tree.
+
+Index: fbsd-6/usr.bin/kdump/Makefile
+===================================================================
+--- fbsd-6.orig/usr.bin/kdump/Makefile
++++ fbsd-6/usr.bin/kdump/Makefile
+@@ -10,6 +10,6 @@ CFLAGS+= -I${.CURDIR}/../ktrace -I${.CUR
+ CLEANFILES= ioctl.c
+
+ ioctl.c: mkioctls
+- sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
++ sh ${.CURDIR}/mkioctls ${.CURDIR}/../../include > ${.TARGET}
+
+ .include <bsd.prog.mk>
+Index: fbsd-6/usr.bin/truss/Makefile
+===================================================================
+--- fbsd-6.orig/usr.bin/truss/Makefile
++++ fbsd-6/usr.bin/truss/Makefile
+@@ -29,6 +29,6 @@ syscalls.h: syscalls.master
+ ${.CURDIR}/i386.conf
+
+ ioctl.c: ${.CURDIR}/../kdump/mkioctls
+- sh ${.CURDIR}/../kdump/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
++ sh ${.CURDIR}/../kdump/mkioctls ${.CURDIR}/../../include > ${.TARGET}
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-bsdar.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-bsdar.patch
new file mode 100644
index 000000000000..c966b9b88ad7
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-bsdar.patch
@@ -0,0 +1,21 @@
+--- usr.bin/ar/Makefile.old 2010-03-12 14:50:30 +0100
++++ usr.bin/ar/Makefile 2010-03-12 14:50:53 +0100
+@@ -1,6 +1,6 @@
+ # $FreeBSD: src/usr.bin/ar/Makefile,v 1.22.2.1.2.1 2009/10/25 01:10:29 kensmith Exp $
+
+-PROG= ar
++PROG= freebsd-ar
+ SRCS= ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h
+
+ WARNS?= 5
+@@ -10,8 +10,7 @@
+
+ CFLAGS+=-I. -I${.CURDIR}
+
+-NO_SHARED?= yes
+-LINKS= ${BINDIR}/ar ${BINDIR}/ranlib
+-MLINKS= ar.1 ranlib.1
++LINKS= ${BINDIR}/freebsd-ar ${BINDIR}/freebsd-ranlib
++MLINKS= freebsd-ar.1 freebsd-ranlib.1
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-xinstall.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-xinstall.patch
new file mode 100644
index 000000000000..e8f978aabc9e
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.0-xinstall.patch
@@ -0,0 +1,26 @@
+Parallel make installs often cause 2 concurrent install -d to fail
+while they are creating the path to the target dirs.
+This patch changes the failure to a warning so that a make -j6 install doesn't
+fails as often as it does on Gentoo/FreeBSD, if it uses /usr/bin/install.
+
+--- usr.bin/xinstall/xinstall.c.orig
++++ usr.bin/xinstall/xinstall.c
+@@ -748,9 +748,17 @@
+ ch = *p;
+ *p = '\0';
+ if (stat(path, &sb)) {
+- if (errno != ENOENT || mkdir(path, 0755) < 0) {
++ if (errno != ENOENT) {
+ err(EX_OSERR, "mkdir %s", path);
+ /* NOTREACHED */
++ } else if (mkdir(path, 0755) < 0) {
++ /* Previous errno from stat() says that the directory didn't exist (ENOENT)
++ * But if errno is now EEXIST, then we just hit a parallel make bug.
++ */
++ if (errno == EEXIST)
++ warn("mkdir: %s now exists!", path); /* let me know when this happens */
++ else
++ err(EX_OSERR, "mkdir %s", path);
+ } else if (verbose)
+ (void)printf("install: mkdir %s\n",
+ path);
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.2-compress.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.2-compress.patch
new file mode 100644
index 000000000000..5bd1d5524c31
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-8.2-compress.patch
@@ -0,0 +1,55 @@
+Index: usr.bin/compress/zopen.c
+===================================================================
+--- usr.bin/compress/zopen.c (revision 225020)
++++ usr.bin/compress/zopen.c (working copy)
+@@ -486,7 +486,7 @@ zread(void *cookie, char *rbp, int num)
+ block_compress = maxbits & BLOCK_MASK;
+ maxbits &= BIT_MASK;
+ maxmaxcode = 1L << maxbits;
+- if (maxbits > BITS) {
++ if (maxbits > BITS || maxbits < 12) {
+ errno = EFTYPE;
+ return (-1);
+ }
+@@ -513,17 +513,28 @@ zread(void *cookie, char *rbp, int num)
+ for (code = 255; code >= 0; code--)
+ tab_prefixof(code) = 0;
+ clear_flg = 1;
+- free_ent = FIRST - 1;
+- if ((code = getcode(zs)) == -1) /* O, untimely death! */
+- break;
++ free_ent = FIRST;
++ oldcode = -1;
++ continue;
+ }
+ incode = code;
+
+- /* Special case for KwKwK string. */
++ /* Special case for kWkWk string. */
+ if (code >= free_ent) {
++ if (code > free_ent || oldcode == -1) {
++ /* Bad stream. */
++ errno = EINVAL;
++ return (-1);
++ }
+ *stackp++ = finchar;
+ code = oldcode;
+ }
++ /*
++ * The above condition ensures that code < free_ent.
++ * The construction of tab_prefixof in turn guarantees that
++ * each iteration decreases code and therefore stack usage is
++ * bound by 1 << BITS - 256.
++ */
+
+ /* Generate output characters in reverse order. */
+ while (code >= 256) {
+@@ -540,7 +551,7 @@ middle: do {
+ } while (stackp > de_stack);
+
+ /* Generate the new entry. */
+- if ((code = free_ent) < maxmaxcode) {
++ if ((code = free_ent) < maxmaxcode && oldcode != -1) {
+ tab_prefixof(code) = (u_short) oldcode;
+ tab_suffixof(code) = finchar;
+ free_ent = code + 1;
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.0-fixmakefiles.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.0-fixmakefiles.patch
new file mode 100644
index 000000000000..d34eb9ef91af
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.0-fixmakefiles.patch
@@ -0,0 +1,11 @@
+diff -uNr usr.bin.old/calendar/Makefile usr.bin/calendar/Makefile
+--- usr.bin.old/calendar/Makefile 2011-11-02 18:22:09.000000000 +0000
++++ usr.bin/calendar/Makefile 2011-11-02 18:22:48.000000000 +0000
+@@ -15,6 +15,7 @@
+ WARNS?= 7
+
+ beforeinstall:
++ ${INSTALL} -d ${DESTDIR}${SHAREDIR}/calendar
+ ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${TEXTMODE} \
+ ${.CURDIR}/calendars/calendar.* ${DESTDIR}${SHAREDIR}/calendar
+ .for lang in ${INTER}
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-ar-libarchive3.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-ar-libarchive3.patch
new file mode 100644
index 000000000000..d4d89e12e9e1
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-ar-libarchive3.patch
@@ -0,0 +1,19 @@
+diff -Nur usr.bin.orig/ar/ar.c usr.bin/ar/ar.c
+--- usr.bin.orig/ar/ar.c 2012-01-03 12:23:45.000000000 +0900
++++ usr.bin/ar/ar.c 2012-12-25 20:50:29.000000000 +0900
+@@ -386,13 +386,13 @@
+ static void
+ bsdar_version(void)
+ {
+- (void)printf("BSD ar %s - %s\n", BSDAR_VERSION, archive_version());
++ (void)printf("BSD ar %s - %s\n", BSDAR_VERSION, archive_version_string());
+ exit(EX_OK);
+ }
+
+ static void
+ ranlib_version(void)
+ {
+- (void)printf("ranlib %s - %s\n", BSDAR_VERSION, archive_version());
++ (void)printf("ranlib %s - %s\n", BSDAR_VERSION, archive_version_string());
+ exit(EX_OK);
+ }
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-bsdar.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-bsdar.patch
new file mode 100644
index 000000000000..a65185fb7576
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-bsdar.patch
@@ -0,0 +1,25 @@
+diff -Nur work.orig/usr.bin/ar/Makefile work/usr.bin/ar/Makefile
+--- work.orig/usr.bin/ar/Makefile 2012-07-16 03:59:48.000000000 +0900
++++ work/usr.bin/ar/Makefile 2012-07-16 04:02:38.000000000 +0900
+@@ -2,7 +2,7 @@
+
+ .include <bsd.own.mk>
+
+-PROG= ar
++PROG= freebsd-ar
+ SRCS= ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h
+
+ DPADD= ${LIBARCHIVE} ${LIBELF}
+@@ -10,10 +10,7 @@
+
+ CFLAGS+=-I. -I${.CURDIR}
+
+-.if ${MK_SHARED_TOOLCHAIN} == "no"
+-NO_SHARED?= yes
+-.endif
+-LINKS= ${BINDIR}/ar ${BINDIR}/ranlib
+-MLINKS= ar.1 ranlib.1
++LINKS= ${BINDIR}/freebsd-ar ${BINDIR}/freebsd-ranlib
++MLINKS= freebsd-ar.1 freebsd-ranlib.1
+
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-grep.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-grep.patch
new file mode 100644
index 000000000000..06cc5d28df80
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-grep.patch
@@ -0,0 +1,17 @@
+diff -Nur work.orig/usr.bin/grep/Makefile work/usr.bin/grep/Makefile
+--- work.orig/usr.bin/grep/Makefile 2012-07-16 04:59:01.000000000 +0900
++++ work/usr.bin/grep/Makefile 2012-07-16 05:00:15.000000000 +0900
+@@ -40,13 +40,6 @@
+ grep.1 lzfgrep.1
+ .endif
+
+-LINKS+= ${BINDIR}/${PROG} ${BINDIR}/xzgrep \
+- ${BINDIR}/${PROG} ${BINDIR}/xzegrep \
+- ${BINDIR}/${PROG} ${BINDIR}/xzfgrep \
+- ${BINDIR}/${PROG} ${BINDIR}/lzgrep \
+- ${BINDIR}/${PROG} ${BINDIR}/lzegrep \
+- ${BINDIR}/${PROG} ${BINDIR}/lzfgrep
+-
+ LDADD= -lz -llzma
+ DPADD= ${LIBZ} ${LIBLZMA}
+
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-kdump-ioctl.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-kdump-ioctl.patch
new file mode 100644
index 000000000000..d98e599a280a
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-kdump-ioctl.patch
@@ -0,0 +1,24 @@
+diff -Nur work.orig/usr.bin/kdump/Makefile work/usr.bin/kdump/Makefile
+--- work.orig/usr.bin/kdump/Makefile 2012-07-12 13:24:01.000000000 +0900
++++ work/usr.bin/kdump/Makefile 2012-07-16 03:54:14.000000000 +0900
+@@ -21,7 +21,7 @@
+
+ ioctl.c: mkioctls
+ env CPP="${CPP}" \
+- sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
++ sh ${.CURDIR}/mkioctls ${.CURDIR}/../../include > ${.TARGET}
+
+ kdump_subr.c: mksubr
+ sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include > ${.TARGET}
+diff -Nur work.orig/usr.bin/truss/Makefile work/usr.bin/truss/Makefile
+--- work.orig/usr.bin/truss/Makefile 2012-07-12 13:24:03.000000000 +0900
++++ work/usr.bin/truss/Makefile 2012-07-16 03:54:40.000000000 +0900
+@@ -24,7 +24,7 @@
+
+ ioctl.c: ${.CURDIR}/../kdump/mkioctls
+ env CPP="${CPP}" \
+- sh ${.CURDIR}/../kdump/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
++ sh ${.CURDIR}/../kdump/mkioctls ${.CURDIR}/../../include > ${.TARGET}
+
+ .if ${MACHINE_CPUARCH} == "i386"
+ SRCS+= i386-linux.c linux_syscalls.h
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-minigzip.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-minigzip.patch
new file mode 100644
index 000000000000..a9c062229ac1
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-9.1-minigzip.patch
@@ -0,0 +1,10 @@
+diff -Nur work.orig/usr.bin/minigzip/Makefile work/usr.bin/minigzip/Makefile
+--- work.orig/usr.bin/minigzip/Makefile 2012-07-16 04:39:31.000000000 +0900
++++ work/usr.bin/minigzip/Makefile 2012-07-16 04:45:30.000000000 +0900
+@@ -10,4 +10,6 @@
+ DPADD= ${LIBZ}
+ LDADD= -lz
+
++CFLAGS+= -I${.CURDIR}/../../lib/libz
++
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-lint-stdarg.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-lint-stdarg.patch
new file mode 100644
index 000000000000..97747245552d
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-lint-stdarg.patch
@@ -0,0 +1,24 @@
+diff -ur usr.bin.orig/xlint/llib/llib-lposix usr.bin/xlint/llib/llib-lposix
+--- usr.bin.orig/xlint/llib/llib-lposix 2005-04-29 17:30:03 +0000
++++ usr.bin/xlint/llib/llib-lposix 2005-05-03 14:12:26 +0000
+@@ -42,7 +42,7 @@
+ #include <sys/utsname.h>
+ #include <sys/times.h>
+ #include <stdio.h>
+-#include <stdarg.h>
++#include <machine/stdarg.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ #include <math.h>
+diff -ur usr.bin.orig/xlint/llib/llib-lstdc usr.bin/xlint/llib/llib-lstdc
+--- usr.bin.orig/xlint/llib/llib-lstdc 2005-04-29 17:30:03 +0000
++++ usr.bin/xlint/llib/llib-lstdc 2005-05-03 14:12:35 +0000
+@@ -44,7 +44,7 @@
+ #include <math.h>
+ #include <setjmp.h>
+ #include <signal.h>
+-#include <stdarg.h>
++#include <machine/stdarg.h>
+ #include <stddef.h>
+ #include <stdio.h>
+ #include <stdlib.h>
diff --git a/sys-freebsd/freebsd-ubin/files/freebsd-ubin-setXid.patch b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-setXid.patch
new file mode 100644
index 000000000000..631ee4f7b4f7
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/freebsd-ubin-setXid.patch
@@ -0,0 +1,129 @@
+diff -ur usr.bin.orig/at/Makefile usr.bin.setXid/at/Makefile
+--- usr.bin.orig/at/Makefile Thu Apr 7 20:52:57 2005
++++ usr.bin.setXid/at/Makefile Thu Apr 7 21:21:02 2005
+@@ -15,6 +15,8 @@
+ BINMODE= 4555
+ CLEANFILES+= at.1
+
++LDFLAGS+=-Wl,-z,now
++
+ at.1: at.man
+ @${ECHO} Making ${.TARGET:T} from ${.ALLSRC:T}; \
+ sed -e \
+diff -ur usr.bin.orig/chpass/Makefile usr.bin.setXid/chpass/Makefile
+--- usr.bin.orig/chpass/Makefile Thu Apr 7 20:52:57 2005
++++ usr.bin.setXid/chpass/Makefile Thu Apr 7 21:22:40 2005
+@@ -15,6 +15,8 @@
+ #CFLAGS+=-DRESTRICT_FULLNAME_CHANGE
+ CFLAGS+=-I${.CURDIR}/../../usr.sbin/pwd_mkdb -I${.CURDIR}/../../lib/libc/gen -I.
+
++LDFLAGS+=-Wl,-z,now
++
+ DPADD= ${LIBCRYPT} ${LIBUTIL}
+ LDADD= -lcrypt -lutil
+ .if !defined(NO_NIS)
+diff -ur usr.bin.orig/fstat/Makefile usr.bin.setXid/fstat/Makefile
+--- usr.bin.orig/fstat/Makefile Thu Apr 7 20:52:57 2005
++++ usr.bin.setXid/fstat/Makefile Thu Apr 7 21:24:35 2005
+@@ -9,4 +9,6 @@
+ BINMODE=2555
+ WARNS?= 6
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur usr.bin.orig/lock/Makefile usr.bin.setXid/lock/Makefile
+--- usr.bin.orig/lock/Makefile Thu Apr 7 20:52:57 2005
++++ usr.bin.setXid/lock/Makefile Thu Apr 7 21:24:45 2005
+@@ -7,4 +7,6 @@
+ DPADD= ${LIBCRYPT}
+ LDADD= -lcrypt
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur usr.bin.orig/login/Makefile usr.bin.setXid/login/Makefile
+--- usr.bin.orig/login/Makefile Thu Apr 7 20:52:57 2005
++++ usr.bin.setXid/login/Makefile Thu Apr 7 21:24:55 2005
+@@ -13,4 +13,6 @@
+ INSTALLFLAGS=-fschg
+ .endif
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur usr.bin.orig/netstat/Makefile usr.bin.setXid/netstat/Makefile
+--- usr.bin.orig/netstat/Makefile Thu Apr 7 20:52:58 2005
++++ usr.bin.setXid/netstat/Makefile Thu Apr 7 21:25:08 2005
+@@ -14,4 +14,6 @@
+ DPADD= ${LIBKVM} ${LIBIPX} ${LIBNETGRAPH} ${LIBUTIL}
+ LDADD= -lkvm -lipx -lnetgraph -lutil
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur usr.bin.orig/opieinfo/Makefile usr.bin.setXid/opieinfo/Makefile
+--- usr.bin.orig/opieinfo/Makefile Thu Apr 7 20:52:58 2005
++++ usr.bin.setXid/opieinfo/Makefile Thu Apr 7 21:25:20 2005
+@@ -11,6 +11,8 @@
+ DPADD= ${LIBOPIE} ${LIBMD}
+ LDADD= -lopie -lmd
+
++LDFLAGS+=-Wl,-z,now
++
+ BINOWN= root
+ BINMODE=4555
+ INSTALLFLAGS=-fschg
+diff -ur usr.bin.orig/opiepasswd/Makefile usr.bin.setXid/opiepasswd/Makefile
+--- usr.bin.orig/opiepasswd/Makefile Thu Apr 7 20:52:58 2005
++++ usr.bin.setXid/opiepasswd/Makefile Thu Apr 7 21:25:29 2005
+@@ -11,6 +11,8 @@
+ DPADD= ${LIBOPIE} ${LIBMD}
+ LDADD= -lopie -lmd
+
++LDFLAGS+=-Wl,-z,now
++
+ BINOWN= root
+ BINMODE=4555
+ INSTALLFLAGS=-fschg
+diff -ur usr.bin.orig/passwd/Makefile usr.bin.setXid/passwd/Makefile
+--- usr.bin.orig/passwd/Makefile Thu Apr 7 20:52:58 2005
++++ usr.bin.setXid/passwd/Makefile Thu Apr 7 21:25:37 2005
+@@ -10,6 +10,8 @@
+ MLINKS = passwd.1 yppasswd.1
+ WARNS ?= 4
+
++LDFLAGS+=-Wl,-z,now
++
+ beforeinstall:
+ .for i in passwd yppasswd
+ [ ! -e ${DESTDIR}${BINDIR}/$i ] || \
+--- usr.bin.orig/su/Makefile Thu Apr 7 20:52:58 2005
++++ usr.bin.setXid/su/Makefile Thu Apr 7 21:26:00 2005
+@@ -10,4 +10,6 @@
+ BINMODE=4555
+ INSTALLFLAGS=-fschg
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur usr.bin.orig/wall/Makefile usr.bin.setXid/wall/Makefile
+--- usr.bin.orig/wall/Makefile Thu Apr 7 20:52:59 2005
++++ usr.bin.setXid/wall/Makefile Thu Apr 7 21:26:07 2005
+@@ -5,4 +5,6 @@
+ BINGRP= tty
+ BINMODE=2555
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
+diff -ur usr.bin.orig/write/Makefile usr.bin.setXid/write/Makefile
+--- usr.bin.orig/write/Makefile Thu Apr 7 20:52:59 2005
++++ usr.bin.setXid/write/Makefile Thu Apr 7 21:26:13 2005
+@@ -4,4 +4,6 @@
+ BINMODE=2555
+ BINGRP= tty
+
++LDFLAGS+=-Wl,-z,now
++
+ .include <bsd.prog.mk>
diff --git a/sys-freebsd/freebsd-ubin/files/locate-updatedb-cron b/sys-freebsd/freebsd-ubin/files/locate-updatedb-cron
new file mode 100644
index 000000000000..323f455e9ba1
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/locate-updatedb-cron
@@ -0,0 +1,6 @@
+#! /bin/sh
+
+if [ -x /usr/libexec/locate.updatedb ]
+then
+ echo /usr/libexec/locate.updatedb | nice -n 5 su -fm nobody
+fi
diff --git a/sys-freebsd/freebsd-ubin/files/login.1.pamd b/sys-freebsd/freebsd-ubin/files/login.1.pamd
new file mode 100644
index 000000000000..2c09584f762c
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/login.1.pamd
@@ -0,0 +1,4 @@
+auth include system-local-login
+account include system-local-login
+session include system-local-login
+password include system-local-login
diff --git a/sys-freebsd/freebsd-ubin/files/login.pamd b/sys-freebsd/freebsd-ubin/files/login.pamd
new file mode 100644
index 000000000000..ff1b6a8af1cf
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/login.pamd
@@ -0,0 +1,18 @@
+#
+# PAM configuration for the "login" service
+#
+
+# auth
+auth required pam_nologin.so no_warn
+auth sufficient pam_self.so no_warn
+auth include system
+
+# account
+account requisite pam_securetty.so
+account include system
+
+# session
+session include system
+
+# password
+password include system
diff --git a/sys-freebsd/freebsd-ubin/files/passwd.1.pamd b/sys-freebsd/freebsd-ubin/files/passwd.1.pamd
new file mode 100644
index 000000000000..9c2938657679
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/passwd.1.pamd
@@ -0,0 +1,7 @@
+#
+# PAM configuration for the "passwd" service
+#
+
+# passwd(1) does not use the auth, account or session services.
+
+password include system-auth
diff --git a/sys-freebsd/freebsd-ubin/files/passwd.pamd b/sys-freebsd/freebsd-ubin/files/passwd.pamd
new file mode 100644
index 000000000000..a2a928686dc1
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/passwd.pamd
@@ -0,0 +1,9 @@
+#
+# PAM configuration for the "passwd" service
+#
+
+# passwd(1) does not use the auth, account or session services.
+
+# password
+#password requisite pam_passwdqc.so enforce=users
+password required pam_unix.so no_warn try_first_pass nullok
diff --git a/sys-freebsd/freebsd-ubin/files/su.1.pamd b/sys-freebsd/freebsd-ubin/files/su.1.pamd
new file mode 100644
index 000000000000..33b35e285b0b
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/su.1.pamd
@@ -0,0 +1,15 @@
+#
+# PAM configuration for the "su" service
+#
+
+# auth
+auth sufficient pam_rootok.so no_warn
+auth sufficient pam_self.so no_warn
+auth requisite pam_group.so no_warn group=wheel root_only fail_safe
+auth include system-auth
+
+# account
+account include system-auth
+
+# session
+session required pam_permit.so
diff --git a/sys-freebsd/freebsd-ubin/files/su.pamd b/sys-freebsd/freebsd-ubin/files/su.pamd
new file mode 100644
index 000000000000..be70c96a96a5
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/files/su.pamd
@@ -0,0 +1,15 @@
+#
+# PAM configuration for the "su" service
+#
+
+# auth
+auth sufficient pam_rootok.so no_warn
+auth sufficient pam_self.so no_warn
+auth requisite pam_group.so no_warn group=wheel root_only fail_safe
+auth include system
+
+# account
+account include system
+
+# session
+session required pam_permit.so
diff --git a/sys-freebsd/freebsd-ubin/freebsd-ubin-10.3-r2.ebuild b/sys-freebsd/freebsd-ubin/freebsd-ubin-10.3-r2.ebuild
new file mode 100644
index 000000000000..3a6db423d7ee
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/freebsd-ubin-10.3-r2.ebuild
@@ -0,0 +1,210 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic pam multilib multibuild multilib-build
+
+DESCRIPTION="FreeBSD's base system source for /usr/bin"
+SLOT="0"
+IUSE="ar atm audit bluetooth ipv6 kerberos netware nis ssl usb build zfs"
+LICENSE="BSD zfs? ( CDDL )"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "SA-16:25/bspatch.patch"
+ "SA-16:29/bspatch.patch" )
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ usr.bin/
+ contrib/
+ lib/
+ etc/
+ bin/
+ include/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?,${MULTILIB_USEDEP}]
+ ssl? ( dev-libs/openssl:0= )
+ kerberos? ( virtual/krb5 )
+ ar? ( >=app-arch/libarchive-3 )
+ virtual/pam
+ sys-libs/zlib
+ >=sys-libs/ncurses-5.9:0=
+ !sys-process/fuser-bsd
+ !dev-util/csup
+ !dev-libs/libiconv
+ !sys-freebsd/freebsd-contrib"
+
+DEPEND="${RDEPEND}
+ sys-devel/flex
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-sbin-${RV}*
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+RDEPEND="${RDEPEND}
+ >=sys-auth/pambase-20080219.1
+ sys-process/cronbase"
+
+S="${WORKDIR}/usr.bin"
+
+PATCHES=( "${FILESDIR}/${PN}-6.0-bsdcmp.patch"
+ "${FILESDIR}/${PN}-9.0-fixmakefiles.patch"
+ "${FILESDIR}/${PN}-setXid.patch"
+ "${FILESDIR}/${PN}-lint-stdarg.patch"
+ "${FILESDIR}/${PN}-8.0-xinstall.patch"
+ "${FILESDIR}/${PN}-9.1-bsdar.patch"
+ "${FILESDIR}/${PN}-9.1-minigzip.patch"
+ "${FILESDIR}/${PN}-10.0-atf.patch"
+ "${FILESDIR}/${PN}-10.0-dtc-gcc46.patch"
+ "${FILESDIR}/${PN}-10.0-kdump-ioctl.patch"
+ "${FILESDIR}/${PN}-10.0-mandoc.patch"
+ "${FILESDIR}/${PN}-10.2-bsdxml.patch"
+ "${FILESDIR}/${PN}-10.2-talk-workaround.patch"
+ "${FILESDIR}/${PN}-10.3-bmake-workaround.patch" )
+
+# Here we remove some sources we don't need because they are already
+# provided by portage's packages or similar. In order:
+# - Archiving tools, provided by their own ebuilds
+# - ncurses stuff
+# - less stuff
+# - bind utils
+# - rsh stuff
+# - binutils gprof
+# - dc stuff
+# and the rest are misc utils we already provide somewhere else.
+REMOVE_SUBDIRS="bzip2 bzip2recover tar cpio
+ gzip gprof
+ lzmainfo xz xzdec
+ unzip
+ tput tset tabs
+ less lessecho lesskey
+ hesinfo host
+ rsh rlogin rusers rwho ruptime
+ compile_et lex vi smbutil file vacation nc ftp telnet
+ c99 c89
+ bc dc
+ whois tftp man"
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+ use build && EXTRACTONLY+="sys/ "
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ mymakeopts="${mymakeopts} WITHOUT_CLANG= WITHOUT_LZMA_SUPPORT= WITHOUT_SVN= WITHOUT_SVNLITE= WITHOUT_OPENSSH= WITHOUT_LDNS_UTILS= "
+}
+
+pkg_preinst() {
+ # bison installs a /usr/bin/yacc symlink ...
+ # we need to remove it to avoid triggering
+ # collision-protect errors
+ if [[ -L ${ROOT}/usr/bin/yacc ]] ; then
+ rm -f "${ROOT}"/usr/bin/yacc
+ fi
+}
+
+src_prepare() {
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ use build || ln -s "/usr/src/sys" "${WORKDIR}/sys"
+ fi
+
+ # Rename manpage for renamed cmp
+ mv "${S}"/cmp/cmp.1 "${S}"/cmp/bsdcmp.1 || die
+ # Rename manpage for renamed ar
+ mv "${S}"/ar/ar.1 "${S}"/ar/freebsd-ar.1 || die
+ # Fix whereis(1) manpath search.
+ sed -i -e 's:"manpath -q":"manpath":' "${S}/whereis/pathnames.h"
+
+ # Build a dynamic make
+ sed -i -e '/^NO_SHARED/ s/^/#/' "${S}"/make/Makefile || die
+
+ # Disable it here otherwise our patch wont apply
+ use ar || dummy_mk ar
+
+ # Preparing to build xlint
+ export LINT=xlint
+}
+
+setup_multilib_vars() {
+ if ! multilib_is_native_abi ; then
+ cd "${WORKDIR}/usr.bin/ldd" || die
+ export mymakeopts="${mymakeopts} PROG=ldd32 WITHOUT_MAN="
+ else
+ cd "${S}" || die
+ fi
+ "$@"
+}
+
+src_compile() {
+ # Preparing to build mandoc
+ cd "${WORKDIR}/lib/libmandoc" || die
+ freebsd_src_compile -j1
+
+ cd "${S}" || die
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_compile -j1
+}
+
+src_install() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_install
+
+ # baselayout requires these in /bin
+ dodir /bin
+ for bin in sed printf ; do
+ mv "${D}/usr/bin/${bin}" "${D}/bin/" || die "mv ${bin} failed"
+ dosym /bin/${bin} /usr/bin/${bin} || die "dosym ${bin} failed"
+ done
+
+ for pamdfile in login passwd su; do
+ newpamd "${FILESDIR}/${pamdfile}.1.pamd" ${pamdfile} || die
+ done
+
+ cd "${WORKDIR}/etc" || die
+ insinto /etc
+ doins remote phones opieaccess fbtab || die
+
+ exeinto /etc/cron.daily
+ newexe "${FILESDIR}/locate-updatedb-cron" locate.updatedb || die
+
+ # tip requires /var/spool/lock/, bug #200700
+ keepdir /var/spool/lock
+
+ # create locate database #472468
+ local f=/var/db/locate.database
+ mkdir "${ED}${f%/*}" || die
+ touch "${ED}${f}" || die
+ fowners nobody:nobody ${f}
+}
+
+pkg_postinst() {
+ # We need to ensure that login.conf.db is up-to-date.
+ if [[ -e "${ROOT}"etc/login.conf ]] ; then
+ einfo "Updating ${ROOT}etc/login.conf.db"
+ "${ROOT}"usr/bin/cap_mkdb -f "${ROOT}"etc/login.conf "${ROOT}"etc/login.conf
+ elog "Remember to run cap_mkdb /etc/login.conf after making changes to it"
+ fi
+}
+
+pkg_postrm() {
+ # and if we uninstall yacc but keep bison,
+ # lets restore the /usr/bin/yacc symlink
+ if [[ ! -e ${ROOT}/usr/bin/yacc ]] && [[ -e ${ROOT}/usr/bin/yacc.bison ]] ; then
+ ln -s yacc.bison "${ROOT}"/usr/bin/yacc
+ fi
+}
diff --git a/sys-freebsd/freebsd-ubin/freebsd-ubin-11.0-r1.ebuild b/sys-freebsd/freebsd-ubin/freebsd-ubin-11.0-r1.ebuild
new file mode 100644
index 000000000000..7c9aac54f997
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/freebsd-ubin-11.0-r1.ebuild
@@ -0,0 +1,212 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic pam multilib multibuild multilib-build
+
+DESCRIPTION="FreeBSD's base system source for /usr/bin"
+SLOT="0"
+IUSE="ar atm audit bluetooth ipv6 kerberos netware nis ssl usb build zfs"
+LICENSE="BSD zfs? ( CDDL )"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "EN-16:21/localedef.patch" )
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ usr.bin/
+ contrib/
+ lib/
+ etc/
+ bin/
+ include/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?,${MULTILIB_USEDEP}]
+ ssl? ( dev-libs/openssl:0= )
+ kerberos? ( virtual/krb5 )
+ ar? ( >=app-arch/libarchive-3 )
+ virtual/pam
+ sys-libs/zlib
+ >=sys-libs/ncurses-5.9:0=
+ !sys-process/fuser-bsd
+ !dev-util/csup
+ !dev-libs/libiconv
+ !sys-freebsd/freebsd-contrib"
+
+DEPEND="${RDEPEND}
+ sys-devel/flex
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-sbin-${RV}*
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+RDEPEND="${RDEPEND}
+ >=sys-auth/pambase-20080219.1
+ sys-process/cronbase"
+
+S="${WORKDIR}/usr.bin"
+
+PATCHES=( "${FILESDIR}/${PN}-6.0-bsdcmp.patch"
+ "${FILESDIR}/${PN}-9.0-fixmakefiles.patch"
+ "${FILESDIR}/${PN}-11.0-setXid.patch"
+ "${FILESDIR}/${PN}-lint-stdarg.patch"
+ "${FILESDIR}/${PN}-9.1-bsdar.patch"
+ "${FILESDIR}/${PN}-9.1-minigzip.patch"
+ "${FILESDIR}/${PN}-10.0-dtc-gcc46.patch"
+ "${FILESDIR}/${PN}-10.2-talk-workaround.patch"
+ "${FILESDIR}/${PN}-10.2-bsdxml.patch" )
+
+# Here we remove some sources we don't need because they are already
+# provided by portage's packages or similar. In order:
+# - Archiving tools, provided by their own ebuilds
+# - ncurses stuff
+# - less stuff
+# - bind utils
+# - rsh stuff
+# - binutils gprof
+# - dc stuff
+# and the rest are misc utils we already provide somewhere else.
+REMOVE_SUBDIRS="bzip2 bzip2recover tar cpio
+ gzip gprof
+ lzmainfo xz xzdec
+ unzip
+ tput tset tabs
+ less lessecho lesskey
+ hesinfo host
+ rsh rlogin rusers rwho ruptime
+ compile_et lex vi smbutil file vacation nc ftp telnet
+ c99 c89
+ bc dc
+ whois tftp man
+ addr2line bsdcat cxxfilt cxxfilt elfcopy nm readelf sdiff size soelim strings"
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+ use build && EXTRACTONLY+="sys/ "
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ mymakeopts="${mymakeopts} WITHOUT_CLANG= WITHOUT_LZMA_SUPPORT= WITHOUT_SVN= WITHOUT_SVNLITE= WITHOUT_OPENSSH= WITHOUT_LDNS_UTILS= WITHOUT_MANDOCDB= "
+}
+
+pkg_preinst() {
+ # bison installs a /usr/bin/yacc symlink ...
+ # we need to remove it to avoid triggering
+ # collision-protect errors
+ if [[ -L ${ROOT}/usr/bin/yacc ]] ; then
+ rm -f "${ROOT}"/usr/bin/yacc
+ fi
+}
+
+src_prepare() {
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ use build || ln -s "/usr/src/sys" "${WORKDIR}/sys"
+ fi
+
+ # Rename manpage for renamed cmp
+ mv "${S}"/cmp/cmp.1 "${S}"/cmp/bsdcmp.1 || die
+ # Rename manpage for renamed ar
+ mv "${S}"/ar/ar.1 "${S}"/ar/freebsd-ar.1 || die
+ # Fix whereis(1) manpath search.
+ sed -i -e 's:"manpath -q":"manpath":' "${S}/whereis/pathnames.h"
+
+ # Build a dynamic make
+ sed -i -e '/^NO_SHARED/ s/^/#/' "${S}"/bmake/Makefile.inc || die
+
+ # Disable it here otherwise our patch wont apply
+ use ar || dummy_mk ar
+
+ # Preparing to build xlint
+ export LINT=xlint
+}
+
+setup_multilib_vars() {
+ if ! multilib_is_native_abi ; then
+ cd "${WORKDIR}/usr.bin/ldd" || die
+ export mymakeopts="${mymakeopts} PROG=ldd32 WITHOUT_MAN="
+ else
+ cd "${S}" || die
+ fi
+ "$@"
+}
+
+src_compile() {
+ local MULTIBUILD_VARIANTS="${DEFAULT_ABI}"
+ # Preparing to build addr2line, elfcopy, m4
+ for dir in libelftc libpe libopenbsd ; do
+ cd "${WORKDIR}/lib/${dir}" || die
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper freebsd_src_compile -j1
+ done
+
+ MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_compile -j1
+}
+
+src_install() {
+ cd "${S}"/calendar/calendars || die
+ for dir in $(find . -type d ! -name "." ) ; do
+ dodir /usr/share/calendar/"$(basename ${dir})"
+ done
+
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_install
+
+ # baselayout requires these in /bin
+ dodir /bin
+ for bin in sed printf ; do
+ mv "${D}/usr/bin/${bin}" "${D}/bin/" || die "mv ${bin} failed"
+ dosym /bin/${bin} /usr/bin/${bin} || die "dosym ${bin} failed"
+ done
+
+ for pamdfile in login passwd su; do
+ newpamd "${FILESDIR}/${pamdfile}.1.pamd" ${pamdfile} || die
+ done
+
+ cd "${WORKDIR}/etc" || die
+ insinto /etc
+ doins remote phones opieaccess fbtab || die
+
+ exeinto /etc/cron.daily
+ newexe "${FILESDIR}/locate-updatedb-cron" locate.updatedb || die
+
+ # tip requires /var/spool/lock/, bug #200700
+ keepdir /var/spool/lock
+
+ # create locate database #472468
+ local f=/var/db/locate.database
+ mkdir "${ED}${f%/*}" || die
+ touch "${ED}${f}" || die
+ fowners nobody:nobody ${f}
+}
+
+pkg_postinst() {
+ # We need to ensure that login.conf.db is up-to-date.
+ if [[ -e "${ROOT}"etc/login.conf ]] ; then
+ einfo "Updating ${ROOT}etc/login.conf.db"
+ "${ROOT}"usr/bin/cap_mkdb -f "${ROOT}"etc/login.conf "${ROOT}"etc/login.conf
+ elog "Remember to run cap_mkdb /etc/login.conf after making changes to it"
+ fi
+}
+
+pkg_postrm() {
+ # and if we uninstall yacc but keep bison,
+ # lets restore the /usr/bin/yacc symlink
+ if [[ ! -e ${ROOT}/usr/bin/yacc ]] && [[ -e ${ROOT}/usr/bin/yacc.bison ]] ; then
+ ln -s yacc.bison "${ROOT}"/usr/bin/yacc
+ fi
+}
diff --git a/sys-freebsd/freebsd-ubin/freebsd-ubin-11.1.ebuild b/sys-freebsd/freebsd-ubin/freebsd-ubin-11.1.ebuild
new file mode 100644
index 000000000000..e55479c3e21c
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/freebsd-ubin-11.1.ebuild
@@ -0,0 +1,211 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic pam multilib multibuild multilib-build
+
+DESCRIPTION="FreeBSD's base system source for /usr/bin"
+SLOT="0"
+IUSE="ar atm audit bluetooth ipv6 kerberos netware nis ssl usb build zfs"
+LICENSE="BSD zfs? ( CDDL )"
+
+# Security Advisory and Errata patches.
+# UPSTREAM_PATCHES=()
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ usr.bin/
+ contrib/
+ lib/
+ etc/
+ bin/
+ include/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?,${MULTILIB_USEDEP}]
+ ssl? ( dev-libs/openssl:0= )
+ kerberos? ( virtual/krb5 )
+ ar? ( >=app-arch/libarchive-3 )
+ virtual/pam
+ sys-libs/zlib
+ >=sys-libs/ncurses-5.9:0=
+ !sys-process/fuser-bsd
+ !dev-util/csup
+ !dev-libs/libiconv
+ !sys-freebsd/freebsd-contrib"
+
+DEPEND="${RDEPEND}
+ sys-devel/flex
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-sbin-${RV}*
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+RDEPEND="${RDEPEND}
+ >=sys-auth/pambase-20080219.1
+ sys-process/cronbase"
+
+S="${WORKDIR}/usr.bin"
+
+PATCHES=( "${FILESDIR}/${PN}-6.0-bsdcmp.patch"
+ "${FILESDIR}/${PN}-11.1-fixmakefiles.patch"
+ "${FILESDIR}/${PN}-11.0-setXid.patch"
+ "${FILESDIR}/${PN}-lint-stdarg.patch"
+ "${FILESDIR}/${PN}-9.1-bsdar.patch"
+ "${FILESDIR}/${PN}-10.2-talk-workaround.patch"
+ "${FILESDIR}/${PN}-10.2-bsdxml.patch" )
+
+# Here we remove some sources we don't need because they are already
+# provided by portage's packages or similar. In order:
+# - Archiving tools, provided by their own ebuilds
+# - ncurses stuff
+# - less stuff
+# - bind utils
+# - rsh stuff
+# - binutils gprof
+# - dc stuff
+# and the rest are misc utils we already provide somewhere else.
+REMOVE_SUBDIRS="bzip2 bzip2recover tar cpio
+ gzip gprof minigzip
+ lzmainfo xz xzdec
+ unzip
+ tput tset tabs
+ less lessecho lesskey
+ hesinfo host
+ rsh rlogin rusers rwho ruptime
+ compile_et lex vi smbutil file vacation nc ftp telnet
+ c99 c89
+ bc dc
+ whois tftp man
+ addr2line bsdcat cxxfilt cxxfilt elfcopy nm readelf sdiff size soelim strings"
+
+pkg_setup() {
+ # Add the required source files.
+ use zfs && EXTRACTONLY+="cddl/ "
+ use build && EXTRACTONLY+="sys/ "
+ use nis && EXTRACTONLY+="usr.sbin/ypserv/ "
+
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ mymakeopts="${mymakeopts} WITHOUT_CLANG= WITHOUT_LZMA_SUPPORT= WITHOUT_SVN= WITHOUT_SVNLITE= WITHOUT_OPENSSH= WITHOUT_LDNS_UTILS= WITHOUT_MANDOCDB= WITHOUT_GPL_DTC= "
+}
+
+pkg_preinst() {
+ # bison installs a /usr/bin/yacc symlink ...
+ # we need to remove it to avoid triggering
+ # collision-protect errors
+ if [[ -L ${ROOT}/usr/bin/yacc ]] ; then
+ rm -f "${ROOT}"/usr/bin/yacc
+ fi
+}
+
+src_prepare() {
+ if [[ ! -e "${WORKDIR}/sys" ]]; then
+ use build || ln -s "/usr/src/sys" "${WORKDIR}/sys"
+ fi
+
+ # Rename manpage for renamed cmp
+ mv "${S}"/cmp/cmp.1 "${S}"/cmp/bsdcmp.1 || die
+ # Rename manpage for renamed ar
+ mv "${S}"/ar/ar.1 "${S}"/ar/freebsd-ar.1 || die
+ # Fix whereis(1) manpath search.
+ sed -i -e 's:"manpath -q":"manpath":' "${S}/whereis/pathnames.h"
+
+ # Build a dynamic make
+ sed -i -e '/^NO_SHARED/ s/^/#/' "${S}"/bmake/Makefile.inc || die
+
+ # Disable it here otherwise our patch wont apply
+ use ar || dummy_mk ar
+
+ # Preparing to build xlint
+ export LINT=xlint
+}
+
+setup_multilib_vars() {
+ if ! multilib_is_native_abi ; then
+ cd "${WORKDIR}/usr.bin/ldd" || die
+ export mymakeopts="${mymakeopts} PROG=ldd32 WITHOUT_MAN="
+ else
+ cd "${S}" || die
+ fi
+ "$@"
+}
+
+src_compile() {
+ local MULTIBUILD_VARIANTS="${DEFAULT_ABI}"
+ # Preparing to build addr2line, elfcopy, m4, getaddrinfo
+ for dir in libelftc libpe libopenbsd libnetbsd; do
+ cd "${WORKDIR}/lib/${dir}" || die
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper freebsd_src_compile -j1
+ done
+
+ MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_compile -j1
+}
+
+src_install() {
+ cd "${S}"/calendar/calendars || die
+ for dir in $(find . -type d ! -name "." ) ; do
+ dodir /usr/share/calendar/"$(basename ${dir})"
+ done
+
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_install
+
+ # baselayout requires these in /bin
+ dodir /bin
+ for bin in sed printf ; do
+ mv "${D}/usr/bin/${bin}" "${D}/bin/" || die "mv ${bin} failed"
+ dosym /bin/${bin} /usr/bin/${bin} || die "dosym ${bin} failed"
+ done
+
+ for pamdfile in login passwd su; do
+ newpamd "${FILESDIR}/${pamdfile}.1.pamd" ${pamdfile} || die
+ done
+
+ cd "${WORKDIR}/etc" || die
+ insinto /etc
+ doins remote phones opieaccess fbtab || die
+
+ exeinto /etc/cron.daily
+ newexe "${FILESDIR}/locate-updatedb-cron" locate.updatedb || die
+
+ # tip requires /var/spool/lock/, bug #200700
+ keepdir /var/spool/lock
+
+ # create locate database #472468
+ local f=/var/db/locate.database
+ mkdir "${ED}${f%/*}" || die
+ touch "${ED}${f}" || die
+ fowners nobody:nobody ${f}
+}
+
+pkg_postinst() {
+ # We need to ensure that login.conf.db is up-to-date.
+ if [[ -e "${ROOT}"etc/login.conf ]] ; then
+ einfo "Updating ${ROOT}etc/login.conf.db"
+ "${ROOT}"usr/bin/cap_mkdb -f "${ROOT}"etc/login.conf "${ROOT}"etc/login.conf
+ elog "Remember to run cap_mkdb /etc/login.conf after making changes to it"
+ fi
+}
+
+pkg_postrm() {
+ # and if we uninstall yacc but keep bison,
+ # lets restore the /usr/bin/yacc symlink
+ if [[ ! -e ${ROOT}/usr/bin/yacc ]] && [[ -e ${ROOT}/usr/bin/yacc.bison ]] ; then
+ ln -s yacc.bison "${ROOT}"/usr/bin/yacc
+ fi
+}
diff --git a/sys-freebsd/freebsd-ubin/freebsd-ubin-8.2-r1.ebuild b/sys-freebsd/freebsd-ubin/freebsd-ubin-8.2-r1.ebuild
new file mode 100644
index 000000000000..cafa7605cf93
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/freebsd-ubin-8.2-r1.ebuild
@@ -0,0 +1,151 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=2
+
+inherit bsdmk freebsd flag-o-matic pam
+
+DESCRIPTION="FreeBSD's base system source for /usr/bin"
+SLOT="0"
+KEYWORDS="~sparc-fbsd ~x86-fbsd"
+IUSE="ar atm audit bluetooth ipv6 kerberos netware nis ssl usb build zfs"
+LICENSE="BSD zfs? ( CDDL )"
+
+SRC_URI="mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2
+ mirror://gentoo/${BIN}.tar.bz2
+ mirror://gentoo/${INCLUDE}.tar.bz2
+ zfs? ( mirror://gentoo/${CDDL}.tar.bz2 )
+ build? ( mirror://gentoo/${SYS}.tar.bz2 )"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?]
+ ssl? ( dev-libs/openssl )
+ kerberos? ( virtual/krb5 )
+ ar? ( app-arch/libarchive )
+ virtual/pam
+ sys-libs/zlib
+ >=sys-libs/ncurses-5.9
+ !dev-util/csup"
+
+DEPEND="${RDEPEND}
+ sys-devel/flex
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+RDEPEND="${RDEPEND}
+ >=sys-auth/pambase-20080219.1
+ sys-process/cronbase"
+
+S="${WORKDIR}/usr.bin"
+
+PATCHES=( "${FILESDIR}/${PN}-6.0-bsdcmp.patch"
+ "${FILESDIR}/${PN}-6.0-fixmakefiles.patch"
+ "${FILESDIR}/${PN}-setXid.patch"
+ "${FILESDIR}/${PN}-lint-stdarg.patch"
+ "${FILESDIR}/${PN}-6.0-kdump-ioctl.patch"
+ "${FILESDIR}/${PN}-8.0-xinstall.patch"
+ "${FILESDIR}/${PN}-8.0-bsdar.patch"
+ "${FILESDIR}/${P}-compress.patch" )
+
+# Here we remove some sources we don't need because they are already
+# provided by portage's packages or similar. In order:
+# - Archiving tools, provided by their own ebuilds
+# - ncurses stuff
+# - less stuff
+# - bind utils
+# - rsh stuff
+# - binutils gprof
+# and the rest are misc utils we already provide somewhere else.
+REMOVE_SUBDIRS="bzip2 bzip2recover tar cpio
+ gzip gprof
+ lzmainfo xz xzdec
+ tput tset tabs
+ less lessecho lesskey
+ dig hesinfo nslookup nsupdate host
+ rsh rlogin rusers rwho ruptime
+ compile_et lex vi smbutil file vacation nc ftp telnet
+ c99 c89
+ whois tftp"
+
+pkg_setup() {
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+}
+
+pkg_preinst() {
+ # bison installs a /usr/bin/yacc symlink ...
+ # we need to remove it to avoid triggering
+ # collision-protect errors
+ if [[ -L ${ROOT}/usr/bin/yacc ]] ; then
+ rm -f "${ROOT}"/usr/bin/yacc
+ fi
+}
+
+src_prepare() {
+ use build || ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys"
+
+ # Rename manpage for renamed cmp
+ mv "${S}"/cmp/cmp.1 "${S}"/cmp/bsdcmp.1 || die
+ # Rename manpage for renamed ar
+ mv "${S}"/ar/ar.1 "${S}"/ar/freebsd-ar.1 || die
+ # Fix whereis(1) manpath search.
+ sed -i -e 's:"manpath -q":"manpath":' "${S}/whereis/pathnames.h"
+
+ # Build a dynamic make
+ sed -i -e '/^NO_SHARED/ s/^/#/' "${S}"/make/Makefile || die
+
+ # Disable it here otherwise our patch wont apply
+ use ar || dummy_mk ar
+}
+
+src_install() {
+ freebsd_src_install
+
+ # baselayout requires these in /bin
+ dodir /bin
+ for bin in sed printf; do
+ mv "${D}/usr/bin/${bin}" "${D}/bin/" || die "mv ${bin} failed"
+ dosym /bin/${bin} /usr/bin/${bin} || die "dosym ${bin} failed"
+ done
+
+ for pamdfile in login passwd su; do
+ newpamd "${FILESDIR}/${pamdfile}.1.pamd" ${pamdfile} || die
+ done
+
+ cd "${WORKDIR}/etc"
+ insinto /etc
+ doins remote phones opieaccess fbtab || die
+
+ exeinto /etc/cron.daily
+ newexe "${FILESDIR}/locate-updatedb-cron" locate.updatedb || die
+
+ # tip requires /var/spool/lock/, bug #200700
+ keepdir /var/spool/lock
+}
+
+pkg_postinst() {
+ # We need to ensure that login.conf.db is up-to-date.
+ if [[ -e "${ROOT}"etc/login.conf ]] ; then
+ einfo "Updating ${ROOT}etc/login.conf.db"
+ "${ROOT}"usr/bin/cap_mkdb -f "${ROOT}"etc/login.conf "${ROOT}"etc/login.conf
+ elog "Remember to run cap_mkdb /etc/login.conf after making changes to it"
+ fi
+}
+
+pkg_postrm() {
+ # and if we uninstall yacc but keep bison,
+ # lets restore the /usr/bin/yacc symlink
+ if [[ ! -e ${ROOT}/usr/bin/yacc ]] && [[ -e ${ROOT}/usr/bin/yacc.bison ]] ; then
+ ln -s yacc.bison "${ROOT}"/usr/bin/yacc
+ fi
+}
diff --git a/sys-freebsd/freebsd-ubin/freebsd-ubin-9.1-r2.ebuild b/sys-freebsd/freebsd-ubin/freebsd-ubin-9.1-r2.ebuild
new file mode 100644
index 000000000000..2b7bb22a77f1
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/freebsd-ubin-9.1-r2.ebuild
@@ -0,0 +1,180 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic pam multilib multibuild multilib-build
+
+DESCRIPTION="FreeBSD's base system source for /usr/bin"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+IUSE="ar atm audit bluetooth ipv6 kerberos netware nis ssl usb build zfs"
+LICENSE="BSD zfs? ( CDDL )"
+
+SRC_URI="mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2
+ mirror://gentoo/${BIN}.tar.bz2
+ mirror://gentoo/${INCLUDE}.tar.bz2
+ zfs? ( mirror://gentoo/${CDDL}.tar.bz2 )
+ build? ( mirror://gentoo/${SYS}.tar.bz2 )"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?,${MULTILIB_USEDEP}]
+ ssl? ( dev-libs/openssl )
+ kerberos? ( virtual/krb5 )
+ ar? ( >=app-arch/libarchive-3 )
+ virtual/pam
+ sys-libs/zlib
+ >=sys-libs/ncurses-5.9
+ !sys-process/fuser-bsd
+ !dev-util/csup"
+
+DEPEND="${RDEPEND}
+ sys-devel/flex
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+RDEPEND="${RDEPEND}
+ >=sys-auth/pambase-20080219.1
+ sys-process/cronbase"
+
+S="${WORKDIR}/usr.bin"
+
+PATCHES=( "${FILESDIR}/${PN}-6.0-bsdcmp.patch"
+ "${FILESDIR}/${PN}-9.0-fixmakefiles.patch"
+ "${FILESDIR}/${PN}-setXid.patch"
+ "${FILESDIR}/${PN}-lint-stdarg.patch"
+ "${FILESDIR}/${PN}-9.1-kdump-ioctl.patch"
+ "${FILESDIR}/${PN}-8.0-xinstall.patch"
+ "${FILESDIR}/${PN}-9.1-bsdar.patch"
+ "${FILESDIR}/${PN}-9.1-minigzip.patch"
+ "${FILESDIR}/${PN}-9.1-grep.patch"
+ "${FILESDIR}/${PN}-9.1-ar-libarchive3.patch" )
+
+# Here we remove some sources we don't need because they are already
+# provided by portage's packages or similar. In order:
+# - Archiving tools, provided by their own ebuilds
+# - ncurses stuff
+# - less stuff
+# - bind utils
+# - rsh stuff
+# - binutils gprof
+# - dc stuff
+# and the rest are misc utils we already provide somewhere else.
+REMOVE_SUBDIRS="bzip2 bzip2recover tar cpio
+ gzip gprof
+ lzmainfo xz xzdec
+ unzip
+ tput tset tabs
+ less lessecho lesskey
+ dig hesinfo nslookup nsupdate host
+ rsh rlogin rusers rwho ruptime
+ compile_et lex vi smbutil file vacation nc ftp telnet
+ c99 c89
+ bc dc
+ whois tftp man"
+
+pkg_setup() {
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ mymakeopts="${mymakeopts} WITHOUT_CLANG= "
+}
+
+pkg_preinst() {
+ # bison installs a /usr/bin/yacc symlink ...
+ # we need to remove it to avoid triggering
+ # collision-protect errors
+ if [[ -L ${ROOT}/usr/bin/yacc ]] ; then
+ rm -f "${ROOT}"/usr/bin/yacc
+ fi
+}
+
+src_prepare() {
+ use build || ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys"
+
+ # Rename manpage for renamed cmp
+ mv "${S}"/cmp/cmp.1 "${S}"/cmp/bsdcmp.1 || die
+ # Rename manpage for renamed ar
+ mv "${S}"/ar/ar.1 "${S}"/ar/freebsd-ar.1 || die
+ # Fix whereis(1) manpath search.
+ sed -i -e 's:"manpath -q":"manpath":' "${S}/whereis/pathnames.h"
+
+ # Build a dynamic make
+ sed -i -e '/^NO_SHARED/ s/^/#/' "${S}"/make/Makefile || die
+
+ # Disable it here otherwise our patch wont apply
+ use ar || dummy_mk ar
+}
+
+setup_multilib_vars() {
+ if ! multilib_is_native_abi ; then
+ cd "${WORKDIR}/usr.bin/ldd" || die
+ export mymakeopts="${mymakeopts} PROG=ldd32 WITHOUT_MAN="
+ else
+ cd "${S}"
+ fi
+ "$@"
+}
+
+src_compile() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_compile
+}
+
+src_install() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_install
+
+ # baselayout requires these in /bin
+ dodir /bin
+ for bin in sed printf fuser; do
+ mv "${D}/usr/bin/${bin}" "${D}/bin/" || die "mv ${bin} failed"
+ dosym /bin/${bin} /usr/bin/${bin} || die "dosym ${bin} failed"
+ done
+
+ for pamdfile in login passwd su; do
+ newpamd "${FILESDIR}/${pamdfile}.1.pamd" ${pamdfile} || die
+ done
+
+ cd "${WORKDIR}/etc"
+ insinto /etc
+ doins remote phones opieaccess fbtab || die
+
+ exeinto /etc/cron.daily
+ newexe "${FILESDIR}/locate-updatedb-cron" locate.updatedb || die
+
+ # tip requires /var/spool/lock/, bug #200700
+ keepdir /var/spool/lock
+
+ # create locate database #472468
+ local f=/var/db/locate.database
+ mkdir "${ED}${f%/*}" || die
+ touch "${ED}${f}" || die
+ fowners nobody:nobody ${f}
+}
+
+pkg_postinst() {
+ # We need to ensure that login.conf.db is up-to-date.
+ if [[ -e "${ROOT}"etc/login.conf ]] ; then
+ einfo "Updating ${ROOT}etc/login.conf.db"
+ "${ROOT}"usr/bin/cap_mkdb -f "${ROOT}"etc/login.conf "${ROOT}"etc/login.conf
+ elog "Remember to run cap_mkdb /etc/login.conf after making changes to it"
+ fi
+}
+
+pkg_postrm() {
+ # and if we uninstall yacc but keep bison,
+ # lets restore the /usr/bin/yacc symlink
+ if [[ ! -e ${ROOT}/usr/bin/yacc ]] && [[ -e ${ROOT}/usr/bin/yacc.bison ]] ; then
+ ln -s yacc.bison "${ROOT}"/usr/bin/yacc
+ fi
+}
diff --git a/sys-freebsd/freebsd-ubin/freebsd-ubin-9.1-r3.ebuild b/sys-freebsd/freebsd-ubin/freebsd-ubin-9.1-r3.ebuild
new file mode 100644
index 000000000000..f292b7e8ba5a
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/freebsd-ubin-9.1-r3.ebuild
@@ -0,0 +1,180 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic pam multilib multibuild multilib-build
+
+DESCRIPTION="FreeBSD's base system source for /usr/bin"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+IUSE="ar atm audit bluetooth ipv6 kerberos netware nis ssl usb build zfs"
+LICENSE="BSD zfs? ( CDDL )"
+
+SRC_URI="mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2
+ mirror://gentoo/${BIN}.tar.bz2
+ mirror://gentoo/${INCLUDE}.tar.bz2
+ zfs? ( mirror://gentoo/${CDDL}.tar.bz2 )
+ build? ( mirror://gentoo/${SYS}.tar.bz2 )"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?,${MULTILIB_USEDEP}]
+ ssl? ( dev-libs/openssl )
+ kerberos? ( virtual/krb5 )
+ ar? ( >=app-arch/libarchive-3 )
+ virtual/pam
+ sys-libs/zlib
+ >=sys-libs/ncurses-5.9
+ !sys-process/fuser-bsd
+ !dev-util/csup"
+
+DEPEND="${RDEPEND}
+ sys-devel/flex
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ =sys-freebsd/freebsd-mk-defs-${RV}*"
+
+RDEPEND="${RDEPEND}
+ >=sys-auth/pambase-20080219.1
+ sys-process/cronbase"
+
+S="${WORKDIR}/usr.bin"
+
+PATCHES=( "${FILESDIR}/${PN}-6.0-bsdcmp.patch"
+ "${FILESDIR}/${PN}-9.0-fixmakefiles.patch"
+ "${FILESDIR}/${PN}-setXid.patch"
+ "${FILESDIR}/${PN}-lint-stdarg.patch"
+ "${FILESDIR}/${PN}-9.1-kdump-ioctl.patch"
+ "${FILESDIR}/${PN}-8.0-xinstall.patch"
+ "${FILESDIR}/${PN}-9.1-bsdar.patch"
+ "${FILESDIR}/${PN}-9.1-minigzip.patch"
+ "${FILESDIR}/${PN}-9.1-grep.patch"
+ "${FILESDIR}/${PN}-9.1-ar-libarchive3.patch" )
+
+# Here we remove some sources we don't need because they are already
+# provided by portage's packages or similar. In order:
+# - Archiving tools, provided by their own ebuilds
+# - ncurses stuff
+# - less stuff
+# - bind utils
+# - rsh stuff
+# - binutils gprof
+# - dc stuff
+# and the rest are misc utils we already provide somewhere else.
+REMOVE_SUBDIRS="bzip2 bzip2recover tar cpio
+ gzip gprof
+ lzmainfo xz xzdec
+ unzip
+ tput tset tabs
+ less lessecho lesskey
+ dig hesinfo nslookup nsupdate host
+ rsh rlogin rusers rwho ruptime
+ compile_et lex vi smbutil file vacation nc ftp telnet
+ c99 c89
+ bc dc
+ whois tftp man catman"
+
+pkg_setup() {
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_KERBEROS_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+ mymakeopts="${mymakeopts} WITHOUT_CLANG= "
+}
+
+pkg_preinst() {
+ # bison installs a /usr/bin/yacc symlink ...
+ # we need to remove it to avoid triggering
+ # collision-protect errors
+ if [[ -L ${ROOT}/usr/bin/yacc ]] ; then
+ rm -f "${ROOT}"/usr/bin/yacc
+ fi
+}
+
+src_prepare() {
+ use build || ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys"
+
+ # Rename manpage for renamed cmp
+ mv "${S}"/cmp/cmp.1 "${S}"/cmp/bsdcmp.1 || die
+ # Rename manpage for renamed ar
+ mv "${S}"/ar/ar.1 "${S}"/ar/freebsd-ar.1 || die
+ # Fix whereis(1) manpath search.
+ sed -i -e 's:"manpath -q":"manpath":' "${S}/whereis/pathnames.h"
+
+ # Build a dynamic make
+ sed -i -e '/^NO_SHARED/ s/^/#/' "${S}"/make/Makefile || die
+
+ # Disable it here otherwise our patch wont apply
+ use ar || dummy_mk ar
+}
+
+setup_multilib_vars() {
+ if ! multilib_is_native_abi ; then
+ cd "${WORKDIR}/usr.bin/ldd" || die
+ export mymakeopts="${mymakeopts} PROG=ldd32 WITHOUT_MAN="
+ else
+ cd "${S}"
+ fi
+ "$@"
+}
+
+src_compile() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_compile
+}
+
+src_install() {
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ multibuild_foreach_variant freebsd_multilib_multibuild_wrapper setup_multilib_vars freebsd_src_install
+
+ # baselayout requires these in /bin
+ dodir /bin
+ for bin in sed printf fuser; do
+ mv "${D}/usr/bin/${bin}" "${D}/bin/" || die "mv ${bin} failed"
+ dosym /bin/${bin} /usr/bin/${bin} || die "dosym ${bin} failed"
+ done
+
+ for pamdfile in login passwd su; do
+ newpamd "${FILESDIR}/${pamdfile}.1.pamd" ${pamdfile} || die
+ done
+
+ cd "${WORKDIR}/etc"
+ insinto /etc
+ doins remote phones opieaccess fbtab || die
+
+ exeinto /etc/cron.daily
+ newexe "${FILESDIR}/locate-updatedb-cron" locate.updatedb || die
+
+ # tip requires /var/spool/lock/, bug #200700
+ keepdir /var/spool/lock
+
+ # create locate database #472468
+ local f=/var/db/locate.database
+ mkdir "${ED}${f%/*}" || die
+ touch "${ED}${f}" || die
+ fowners nobody:nobody ${f}
+}
+
+pkg_postinst() {
+ # We need to ensure that login.conf.db is up-to-date.
+ if [[ -e "${ROOT}"etc/login.conf ]] ; then
+ einfo "Updating ${ROOT}etc/login.conf.db"
+ "${ROOT}"usr/bin/cap_mkdb -f "${ROOT}"etc/login.conf "${ROOT}"etc/login.conf
+ elog "Remember to run cap_mkdb /etc/login.conf after making changes to it"
+ fi
+}
+
+pkg_postrm() {
+ # and if we uninstall yacc but keep bison,
+ # lets restore the /usr/bin/yacc symlink
+ if [[ ! -e ${ROOT}/usr/bin/yacc ]] && [[ -e ${ROOT}/usr/bin/yacc.bison ]] ; then
+ ln -s yacc.bison "${ROOT}"/usr/bin/yacc
+ fi
+}
diff --git a/sys-freebsd/freebsd-ubin/metadata.xml b/sys-freebsd/freebsd-ubin/metadata.xml
new file mode 100644
index 000000000000..a7fa78a99dc3
--- /dev/null
+++ b/sys-freebsd/freebsd-ubin/metadata.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="audit">
+ Build auditing tools.
+ </flag>
+ <flag name="netware">
+ Build libraries and tools to work with NetWare protocols (IPX
+ and NCP).
+ </flag>
+ <flag name="ar">
+ Build FreeBSD's ar and ranlib replacements based on libarchive. The
+ toolchain will still use binutils' version but you can play with it.
+ They have been renamed to freebsd-ar and freebsd-ranlib not to collide
+ with binutils.
+ </flag>
+ <flag name="zfs">Enable ZFS support (for fstat actually).</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/freebsd-usbin/Manifest b/sys-freebsd/freebsd-usbin/Manifest
new file mode 100644
index 000000000000..745e3a068f95
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/Manifest
@@ -0,0 +1,52 @@
+AUX freebsd-usbin-10.0-bsdxml2expat.patch 835 SHA256 765ab05ef6d5d828d2cc54e78e0676dc2b6caac7193788524a7dd4cc5a983c8c SHA512 23bcfdc1657c1dd7fdb59c3717af5a5560c8f3c10d498aaae539e1779838a0a33cf247ae806c72c09d298fc9be3c02b5c3d1d9f1a879493c0e5d1aeb4dbf3509 WHIRLPOOL 2342438a26ef915f29d487aecedfd0920baa6c2130b3efd6fbd64d7a2bf81f74444e7409ceaceb29d4c5ad210af4cee0a4d98b0935131ff577a6103023f83f44
+AUX freebsd-usbin-10.3-bsdxml2expat.patch 406 SHA256 ddf45cbb311c6b1ba49617db48c54eac1f4d5279a40f038e64aef52732a04049 SHA512 91a2323b5007e2381fb58d608dd19dcc010afb398a4b2285b53cae4157268fb6aa232323280cec72cccdb2010610f73e048b06bae76418b7db8cd1f34b7ad8dd WHIRLPOOL fad08c17acc523e240a6ef9c0fbf79e12bd048d9bf4e688cad58ebd5f5b7ec69a39b8786e67f73c5baee4d606abae48a204b94a5b7753e25bc7d137e614a890b
+AUX freebsd-usbin-11.0-workaround.patch 374 SHA256 ecba0a19f110d07e76f1750441a62e22cfa00104bd9bae4cd3764fc07c9e9c6c SHA512 c9e8b493d99581dd7beac48def291843e31649a2962f720ed06ef095a128b039e8308662cfbbfcbecfbd0265132bb7a4df9d895ffe69aac09c129389ba5be518 WHIRLPOOL 44955062b41a72cc5671ca6b3911a0722860dae904ba9d0996d1c424b597ecedcbd8af053bfe017e1428b5ed857ef2be05d1836eafb6642a2e4747b4692cbdb5
+AUX freebsd-usbin-11.1-bsdxml2expat.patch 841 SHA256 709cfb3db2ca2eb2986f1269a1a3f1754a492fa7eee819b24477ff6816b74efc SHA512 69f9055dc536132f1ec46389b53e25261632d726bc74857210ecb5511114f07d4b550e5e4a7a6e066a4a68c4a4bb4e44309d01f569b154fc773247dbd7f3fb23 WHIRLPOOL ce1455e70a0ce5c1bd7977261231ed1748a01d08a08cd4833a32336b5ece86fa9807f17affb5a4f08befafeedd5a82002d6021b02a5b41a72a6e14b6007ea87c
+AUX freebsd-usbin-7.0-nowrap.patch 1185 SHA256 a3c35cd997a22f4d212c3fe08d20fa7552b6de64527fee0166249ae76a3e49c8 SHA512 4374954aecddaf51acc8121b58ea28a4b411652c1deaea05cb600dac3d27a7e42bae1b2ad6f90ffc503d40f296ce627106545c8ad0f2dd23231d454e71f83fee WHIRLPOOL 7049020fc9383c374ca33b4b4ad5d8eb8b9f014922362fe67be1423da649c6ae2afbfeb6e8e0a13e5f77cc4b8f214b8e60d1ddb848a96213e65a2a77220db66b
+AUX freebsd-usbin-8.2-newsyslog.patch 400 SHA256 f13d5ea43531f42ff0cb42438b58875afce4046c650a7459fd2eac62dc11696e SHA512 f013a8911aaf1da759fae307276c482480d3938183f583d1c78c2711bf81e8cb9ebefa004112d4eb1fe7d9620527a49326e49186f0dfd9a9af9e0ff29d4aad56 WHIRLPOOL eb011fcc84e20873e8e86a0bbd101e4651c087b2f22716599bccd55b7ba28607520a450a2c98461ea7d78b2b52f233e6bfc4bf44cb11ec002ad7db631273ca24
+AUX freebsd-usbin-9.0-newsyslog.patch 507 SHA256 d5f910655c66a3e766f227c25837347d11d796655d71480c3cf3526f4136d557 SHA512 5423fc577035c2a272d4cb4305c5ee5e1e910a68af44595524665f7b867bd0a48bab0349b2fa13eabc385b2ec29c8f578d018cd8196f3ad20a13a68d36a335ae WHIRLPOOL 0551fde1581f3642535d1e34f2b111ed1404fc153ed14f4d7d4c75bc96715ed1eb3f218fc55fb2bb038616a929e106b8d8355f2de95447f7a93c09c515cdd511
+AUX freebsd-usbin-9.1-bsdxml2expat.patch 431 SHA256 43f0ebe5406f6065d7dad45b4270f0645e7dc1d6db1bcdf1443e32aede9d7af6 SHA512 ef1e9be49796b50e8dd818ac1a6f363eaa54d767ac9477e3df09354df78dff887a31a3c793288f321b7976bd98de79821742550ee8e7f9fcf3b1a42cccbc68b0 WHIRLPOOL 17c14ef758cede73619f774710afd38862609da6302e0d2378e7b5124d38dd60c427218f140f67e1ea255a24f7eb6d900df1ad5835d23a135cef7cb5cc94bc73
+AUX freebsd-usbin-9.1-kldxref.patch 756 SHA256 b9021def1c9e1a6ffcd66cc86e4086e75b3630e9d6ce40bd8c29b961bd0c570b SHA512 8d1e0c80a6698729bdf40e60ac0373ed76e4c394f7fc93e9ae78e9e8bb06d63c99d04dbb942e90cc9240fc429be7048c4fee22c3ce593b49be90c9df3fc549ec WHIRLPOOL ec37a7350499f5ad5225f3b41151d2b8b060e210cd441cac56e2d87471b08ef0e8cdcca6daad299988808b9c1083afcbbe4c281885a003bca95177b3de0e6c86
+AUX freebsd-usbin-adduser.patch 428 SHA256 2e91737ffefd3b7ce3b55da4ce98eb0425961bba2d4a7c4e7c7ffabc1d38f2af SHA512 51720e3db9bf3728afc0dc370a469746cb1bf61623c44a20c58e27d647e5a5d0360145b1d174382176d803f2558afa2f2a29eca6c85c638529d0e11e2859c0c3 WHIRLPOOL 15a5a7e2c123a3103546134a27baad0a459758ec66bb0a7011684f367c7dd46435688f837d9d5fb5a9a51e95a58d6ce0e672c57a9dc2ef16a1e094a4b6e78931
+AUX iscsid.initd 429 SHA256 b6b387111050dbca190ac0bd338de3c32ed8c1fd65121b0811fe01632431282e SHA512 49a90719aa0279e19899a2107113cad0784a2cf3b57a0c24ad08549fa4b44dcb1aceecd71027e363b8d2cbbe1b590480ef7806cb05d8b00c1830c2d77b8a8540 WHIRLPOOL ff71e62ac3ebaf749815856674702ac321c67f661609bd11bf702a2c62a800bed71f845942845fc508235d25f9b13c2682d84ff763d27806ecae55f4069dc97f
+AUX mountd.patch 542 SHA256 da895dabdb52c63d876c13605aa1ef446f8babb47100932b5b451155181a759f SHA512 c7a77ea1df0bd9c0a75b899a306aeb7fbee5ed4fb67a230d6348edbd238dc176267f19cd345f51b26ceef11b4657821ab752b333da5b03fc973bce3253e036e5 WHIRLPOOL a57f31ff146950d5aba5998dbd163f98321373dde5f731584c81bb841a8594422bb2ec44c63bd9e2742dbed3a03e200497948777a12b471d6dd7af9998578ad3
+AUX nfs.confd 303 SHA256 5714e0cbcc45a077ab2348ee4fea521ce9f739927094dccb4b91817f1edaccb8 SHA512 4224c7f525e39b105b8d80caa7db0f3e0b07d6c521970b2aacfd707ef524262cbdb9ed8aa5151022d571a759151dd25a280fc765a38e67864b0c446ee9fd6b5a WHIRLPOOL 70bfff7d5288c692ed767c1e09d48db6c8546d90955a1957de87fd67cb42ed5b1efa0101cf2eea71e4702e1170eadeed9cc45937b742e51cee42c9edd00a1ee9
+AUX nfs.initd 1424 SHA256 060a57ac9cb68d580405dcc7bc35b95aab3b97a0dea1f7c13a58dfa1fabb24a2 SHA512 1d85de665dfea1845189f2ad2e7205ab6185ce228f7140ccaafa22c84f8b9f0b4b4c5a26bd53895f1f2c4639bbeb8d5b76106d2e64851eb62f229028dc61cb5c WHIRLPOOL 1c5fee08af5cfd96153b98500f01c90123fcbc2c8e109d6b6e9c63bb5e4194eb004d03f80d9bf3f943050b37f3f9d84a72240784026024f679a174ca74c2a799
+AUX nfsuserd.confd 153 SHA256 9575adaba684100f78ff1d60ca5e7b6f5be6fcda9e2d8fac2a1ab4aaf8944a59 SHA512 47bf885dc80a61c9f8aab5890a360063fc2e846ce8abefb84e9d504f62c455cd759af753c7a5ab8cdd624842200f6b0ec7d177ddfdc1e7564460764eb4d4d073 WHIRLPOOL 4e4aabc4c936c067d99133620a117d9c1fc539e23acfe9b15b4a7ebb57e3cb55b4ffab34b2af93fcfdf7fe81e4372e3afa38994ee999093aa1ec0a80c3c12175
+AUX nfsuserd.initd 447 SHA256 34bf516e11f3b948f9df6d9833dbd18707c86238f3ee13bcf114587ebb8bf336 SHA512 e18cbd9efa3bf9e7283a9633bebfadfa9160b6eb668f48723bb9f1b37c5476b75b71b505046025a185a74d409ce09fd305257cdcb6e953c795ed1397fbe76323 WHIRLPOOL e77f07aaa3d9fdef566f206248c266a9d6f3e9aee3f5ca9e2c195ce9c35d4953d7152d47f95e6a3a5738b79afc3982140837837bb66d8b9e42c8e960d5d08d7a
+AUX pw.conf 179 SHA256 0aa508e3911a80ccd1dc5005ec6f2e86e7c4fc5c99ca127f4d7e479d133c69ef SHA512 042b7c7805d891f453da58f607edb3174fddc8443d6995ebe833185ab313328c131bae87dbbc9db95bf69a9ee71548d350191b34a8b2bf41a56416aff03c3891 WHIRLPOOL 4edd4ba1aa0c2255fbd38dc9120a673d8e0b5a8fea50d95aa13c08df448c3fc584adfe8330cfce5bb5b06385d5855c2fed9beb210f8fb5f8e4d695bdedb6909c
+AUX rpc.lockd.initd 530 SHA256 56ddc340ce6d65292d17962fd475ded591fd80aeec312d9d2423dbae77bf170e SHA512 930c42b63a230f6f64ecdaec95f61e43b463abe109f926c298507fa3c6b090edba1f8dcc95046a0a5b8c0378d336fbf728f9db77b8b0822d0e2b36713fefc9e5 WHIRLPOOL dc5eb15dc4485cd2e24f69114521ea7b5e54e8ba3f48292137bc5ec91b9046255d7af9c3fec6a8597935b2d540933265de88e3cd45d9ea7660ea3c9c27a9a292
+AUX rpc.statd.initd 520 SHA256 5f59ed36bc583821fb91431f6a3dce0094cfa8a90b2a93d76678d415f589f3ce SHA512 62c3bef69ca0619e3492050379a4c8b490305ab0ee7620143c31be7af414b1f1cbd79feaee345bd5e6bfdfa6c93bcce3cc9ff61a2f63e235a3807920e260cb7a WHIRLPOOL 737d7cad221b443929cd1f5cd7ec2b1a7d4dc3c091be5b871ca6b04bd57bccc7de49d4c7942baaa1b146c5a05034451d1977f6619fc1631eff582323bf7c0930
+DIST freebsd-contrib-8.2.tar.bz2 40931651 SHA256 8b9cb688e81c2980b3fc66411d00ab277a24dadd50d5bdd5e0e6c63ac687b9b6 SHA512 4f7bf825b579fbb88f2aac531d07e531474179c63fa0b66c4e80821290a8c94bf611bb4dcaef51b762aacd25b11dfae798a4ec3bad3b9e3f6b3490ebfaa72476 WHIRLPOOL edd3d9e26e8d22d9028082e107ec1a44402e206dab8722f34b445676959305996c3f699152af42ace249b7f58498492787823b172fb6bcb273119c6bb50a35f0
+DIST freebsd-contrib-9.1.tar.bz2 54751432 SHA256 e7ffa056d4050ce03ee8e23e276e2a9a494326a98d60c43bee2afcc59576deb8 SHA512 71be13049258c6e6b5e4f63cc16da5d349a89d68f04d87446e4ad33ae8bf2a93ea67d9c256b7bec60b61e65db0487268070cfb77a484c3ac0f8ba368b48c2438 WHIRLPOOL a2a84423175499208d34809e802284d6ba649f317c3a9ad8b7312fa19efe142ebadab0048bac0db8e988e59f9a7468ac7c5d0d25e78b82bdb269a20d18153cee
+DIST freebsd-etc-8.2.tar.bz2 188629 SHA256 6bc745fa259f9fa2b65df865d45443a7b23c24445195e33a4ac50bf1040ae238 SHA512 3e5c106754a6a1ac806bd46b711fba7ee9cb31a4eab5262c995a5d59dbeb02f756dd8b495640dda94189d204a5d2c5218de2bd23467172d6a4ebe1048986e89c WHIRLPOOL 23b658a214f1a64c43420351020e32b1182e9aac3ed5253f49ee86f9cee9166ce32bd556cd2a2b3c0e60a165462a8700f37dea19e57ad5716415e17f61da912e
+DIST freebsd-etc-9.1.tar.bz2 207776 SHA256 a317bf85532d6192f5506e8d7bd5d5c201fe24017700e3a974a7712c2c69cdb8 SHA512 4fbe56fde519cf2f44e39a8869efa26c34f703cf540f4a83389da8d170873d7c6fb18e4010e643b8d793cfc5c55d15eeb198057a5b2a8da9d9e8f791801bf314 WHIRLPOOL 0c27019fe140fe96f870697acbaa89ac2f281f55b892c5791b08abf1cfa4da94d9d42a1df1c2091317573ed7234253857aecb797065f911a0a5d57bbf64349a5
+DIST freebsd-gnu-8.2.tar.bz2 815379 SHA256 34be1326b8e188427ea4a59de5dd24049f99adb5e172d61a645db1b7124f7876 SHA512 8b278e386b22b22658eef18341073c1c757b86ecdef5c5b543fb781cfee295d71cef599544eda5f8cf273fc22d28a1ab14d912086ff8398c36ee2b71281617d4 WHIRLPOOL aaf91562f147095e09a9f6aa2d4c33494f430cbe7340377edff1b8a44cc60edfe4af7ef90350018f0c80e82f5518110689cb582bb227d2360488dfbdd7bcb7c8
+DIST freebsd-gnu-9.1.tar.bz2 795778 SHA256 3b99c1fa1087bf69549e0990a0d7997954533ac9d7938c4760ec2b01aa509a5f SHA512 b05f2a5a10bdaeef19dfd0e962bc09f1571288a831e9345f404b920037f47db5c0ca3d620d1cbdd138b18bca1c3feab5b211b57e3041727341e5238cb9feb4fd WHIRLPOOL 4f776b99296c4fcc0d6f4d30a12b0773f6704292e1361826b260ce34dcc8e537ef7eb7c6332c4988e0e03bc84ca07fb18e6b2785fe4c6f175c08865b72d6bb0b
+DIST freebsd-include-8.2.tar.bz2 138992 SHA256 fade90621a8e4880c9583c1ee49965400c88e53ac6c07cb5dcf320e4f069271d SHA512 6bc820dde866589ef75f9f0d1c469d815439bdd4c79f0e1a2482ec58f938b638cb9106969b321aa72492f933c95c76895ce489727a5e265798c93adc75dd64e3 WHIRLPOOL 64d3160c4ac46a62f5969058e07bd160c92284f08805ed917f2073ba1cb5907cfca16c5893daf30254d39b4fcdf641ab6afb9817607f65e7789d3049e8103947
+DIST freebsd-include-9.1.tar.bz2 146881 SHA256 861dce3f39e6806762b102361017cbe148f0e2b768b3fca152f8426f44a2942f SHA512 779c8315ce2b10b343bb62e331525d510b0d68ce5d665a1672bd6f4d1eff6445bc6b7a0f178b319828aa203c4e4c04c561ce793052703f4f936ce9711280a0c9 WHIRLPOOL e16ba45d380591ba007ca59579d45f61ffc1aa1a4c08fc11ed2794979b0a189a346c81b4f70a44ee199d50a72024930f28587ad62a9cd6854fc937eb466ec115
+DIST freebsd-lib-8.2.tar.bz2 3323878 SHA256 e3590c12794fcb5ba8eb7a1f58b497587cf19f9200b3254c194a793da3b5bfb0 SHA512 c059cfdd1099bb519b2a5c43fb7e7104c500ef8906229ed7eb9e420cb3a217cdaf8655e9e7a9f45cfadc5491f8115e0e738fd49251d9f0c3a83780845b09f007 WHIRLPOOL 95f98a372f44a89bc8ac3029ec065dbbfec338e6f889d057d75644bfcdfb9d27fdc0421d7e392cad5a823712b97f0857297ec3d321580254c63032c22b95792e
+DIST freebsd-lib-9.1.tar.bz2 3206685 SHA256 f31fa8107b4de711c548f6d0c1bb1f81d09f51bcc3b14a1e9e90bb0e7cc4a35d SHA512 40d0c36b6b889c404fa0e0afa38ba4e84a55bc88ffa2f98a70afbd7a32c4f32c158617ba770567d082a986d62c09b3ec8db3dc5ab853ee1c9bbe0b90bb82396e WHIRLPOOL 581878bf9c43184b043b4293409b85901c9ed1f9bd279e965414aca41ba50950848ebda3ee10a503a028135dfd2765e95a11acd4e62a11c528e104392bbbd8d0
+DIST freebsd-libexec-8.2.tar.bz2 289147 SHA256 10b996d1d8cd044ee2e7a877e5e6ad2bf050cce9b3bd402a5e0dea7d290b595d SHA512 abe6cf5a268675d7dcb1c214c46fef47a3fb09b31947f5d8a0b938d352295efe0249beb5007649c52187bf4c221b6ebf074d18dfe9bafd168cae09ee02ab608d WHIRLPOOL 27e854fe465eb933dd8e27c5a09b063e4d3798b54e0914c79a9120dcdc34cc5d525a0c92da7b645ff7ab2ab4f34c7f7b2783012dfa5004407acd11150062b7ad
+DIST freebsd-libexec-9.1.tar.bz2 304592 SHA256 71e6e9e41328c2148c54b81ad9b59f912a1d5f0d52e17ac07f223aa7a94b82be SHA512 7baa4160dda2610250dd52f445e24478e0f1ea10bce21fcd0e5d1b856f399b896adc334114de0c7f61a5637e4349bb1688fdbe5c72798d8568ae791114710b92 WHIRLPOOL d800f477ac5c9ad6dae3e0091c83e107609b5a1e3aa79e9533fcd10a8dd34ff7733ab9523eae7c292310fe94f6a529209cae6b9e8bac6b47244e59834593e74b
+DIST freebsd-sbin-8.2.tar.bz2 1211665 SHA256 8b7e21a66b4696e8763d29b8b02b2d35f29fc51820a194d1e469e7cace84c527 SHA512 c6643c29ab62344c98d8991708798730ee1c17e6478071718beeaa79788300a1f4ed2e6aeb8e39e3c216877d4ed2ac85b2a9531d534f1ac5125a508927898959 WHIRLPOOL 2a21cd0f15f95d66718031680ac87f1fe73f1e1b03cb012e1db1dd1bd2fe2bb7897457a8ba2f5a28c8806775611dca542cbadec16566c47ab9efa673e2cb53f3
+DIST freebsd-sbin-9.1.tar.bz2 1273913 SHA256 45008b0733b232ef03707ef5fa3e5c889e3b3728393d736bd9a869ea83be6447 SHA512 9f186602b7de96f268c352ca386986652fddf5570e7eca1afa8c0d2bdc83b57df1198efe47f36dd5c7a6abf4f9c935f1c8207a4a12a6b2153bd6c3c6292719dc WHIRLPOOL 20920dfa9607a0ce854319cef29bbd77fb1b31f6f6cfd5ac60cbd678169e43929e215743fe636d0c224443f3e6149a8f07c292d647f7f901592795ac292699f9
+DIST freebsd-src-10.3.tar.xz 126900216 SHA256 f50763dcac88e9b7ec616b77d537bf338f470350e2c85e0cc7decfcc8372b54d SHA512 a0c95fc4bbc5ad7599d0a83651a497e85cd85a5c433e5e175c57480b466c9eb5aa0390804d6336da8301c75ad499484399d39b8f7efbcfda8cafb09b1aa12d8f WHIRLPOOL bf5320bc506fb73a63d0fb324b60667a196ca2fef5d0215637a657c613f2052d76d002deb205e258f6d4e2aaea15490b26679e59a102606a34b58ab1f6b755ad
+DIST freebsd-src-11.0.tar.xz 140252356 SHA256 0725a7f1d3e8985f4b2e31a2ad714334463a5016b203073a8fc196649f3d5a27 SHA512 ee1271bb38ee46fbab3d49b33f5b5afd76f9402b2e792581d63f02272df8e2a4011fac97ad550434f0c2fc5fe241940276629bde55e75f8638896a81339870cd WHIRLPOOL e1cda77189990c1d2187ab2d9e842ff3c619d8235f1ade56819fadc52f680a871de17cf05f8119614557c615ad19d41d1b6080c4b3768e7252889546b865d827
+DIST freebsd-src-11.1.tar.xz 147661560 SHA256 7e1186c2b3f6d070995b88bef5aded34089fed227c7b584c30b28cecaf428154 SHA512 b97707ec7a601ca6bcb682c45f6d94a38484301ac24630d7285eff6f88b027ce6900c93fc62f8ce36e0cf32c91f73a9d1c999db397b7f8782fd74a8551a03aca WHIRLPOOL 3f88b15153c25c7878d1a730213e5bc8c200c05427895ae97280c4412680bb8e67cf4f8170f9e2b0f21d63ec42365f44f7d5eafe614e9b8726f4bc3cc3825202
+DIST freebsd-sys-8.2.tar.bz2 25835329 SHA256 0c6c7b61aae94db2931f985d5899f3bca78fc8ffab6b598fbaa158142d676f16 SHA512 6ea4516a5c52e25c4f993f7acb875463a5caea93dbdf250c5d48eee95fff226956e9f030cab7e341b5e6a132325bc3dbf93dcb4b1185acb011918e50b1a22be3 WHIRLPOOL 870deeff877c6b9fc812a4260e4fdbb6715a5dc2065cab3bfbf2a42d876f6654703ccb124275a4e2c410cef48f3db02b63cc76059eccf9cf90244826f35b7a15
+DIST freebsd-sys-9.1.tar.bz2 32588103 SHA256 b93a7ac8334ac16cc9f60665048e5ef812c0a6c62f10d0b0a674aec3f56516a8 SHA512 7dc9d9e00dde8f592bb171f4386d02b655b73cb4f153fe5ec063d010a148ef0639eae0dcdb3eeb09ecd1e3653c69e49a2d261329fa6d0381d2ddabe258ddde6d WHIRLPOOL c8348344dfb14bad64bd3a78ee615ddd29203175b292233254f8ba175e7a3fb7218af6f95f7b4dbf394c0354bafe9d8bb0c21cdf0ceaeb697214964b280469b3
+DIST freebsd-ubin-8.2.tar.bz2 1808012 SHA256 6b99554f3ad6ee052069b347eb6e6219b71598d7b222acb90a24cbfc805c7b68 SHA512 48d0103323e820c431aa4f62d3be40cb3b200fb62e3de01f36c88760395bf2ba3367c51f3fa72da4dbccc2812176a051a12ca5cb7e84125c3e0fc78d4cab2c29 WHIRLPOOL ea8f3a29a37b42c2b5bcc0f2c343fa1538522157ef075363c94606a4620a590e9a03f856ce2494e3e727935b62431991d0aa9fde71de699e78b4fe225bdf1c2c
+DIST freebsd-ubin-9.1.tar.bz2 1910472 SHA256 ff6e586f213534b6ec2e65002c0dee64063d76ddad515c12221b1a80a1815e48 SHA512 74ae0aceec8597aa66c3f1ab313f0685a3c63d7273c36ae7baf8794275ad9bca241c60c3f6281cccf6d531d250d7611099977d3b1a27279cef3586401b6af05e WHIRLPOOL c85a3c9cf2bceff2c60ff03556bcc81d3aca22b0bce3c9538990071ac0a907236eee5ae7743ad22c5fd309b047ebf392aaaf2fe177ef5790ea869aff3da7e2fe
+DIST freebsd-usbin-8.2.tar.bz2 2443024 SHA256 aa7cabf10f5c3a9daabea32e4de24d04ec312247842981476da666eff5054603 SHA512 bcb8ff3df54848b9107bbb52e5ced7a91e24bb181f06769b6997221729b8064ec17652eaf7500de3268cbcb63ff5760beb54d15fc78c27b02687b5b1067c74a6 WHIRLPOOL 20f5278e2a1dd387a75b44f10507958d6c0e84a2faa1bddbf808c14ab86d8dd14a956192911bbc1880f5f5f7bd05972dcbb4aec85d241f0dcf91bf4246883f0a
+DIST freebsd-usbin-9.1.tar.bz2 2670916 SHA256 b938c20b8c09aa9a610e13b69b9afeea72f561ab3636a59fba2bdac290f4db75 SHA512 21c234312f70eb35cd2926519efc1f61592892f5d0940786dbeb959c3c5ec7819a51ae95c6e8a1a06aa01f669350fe0fd3dd7c4ec8a84dd6b90f24cb192356ca WHIRLPOOL 7f6ad2eb5410cc5e685881654a788807848af026b1277a974682755ab7c9db28f576bfd1576441ea10c5f1e9edb7d30a4a23fb8eccd6d69d86ecc9ce4c9adc7e
+DIST freebsd-usbin-SA-1630-portsnap-10.patch 1660 SHA256 c1efafadbba72324c4addf3fd07223119361f335a192cc33f21a4c4e756e5cd3 SHA512 43814a98a29b8ef0176de949ad513f16f4ac2cbea23eb260a6c5484b16d0dcc525569e44cfd00bce1f7aa3ecf6c537220098f6514790457372849da941d38d4a WHIRLPOOL 3f61afb6071c2b4f5b2bae995de5edb2b7c62729cdba06f3b97f870b3608a967065f0f6d8553116ab2ee959128f5953f32abcd832c5f4e7491901ca3d9eb79dd
+DIST freebsd-usbin-SA-1632-bhyve.patch 402 SHA256 f19ded569b5079e1e2093107e680ee3a17f7a76bc22134da09d2f42e9367e993 SHA512 8261f070c282a4ff0123e90150bb5605615d86e74adc557b8d187dfc5acf74900751ac4f24e2b86bb1dbfeda34a86c694e31ec3a21788ce7994f1dacb21a9362 WHIRLPOOL 7c7efe3313e804a99a4ac5474a6e09099f5a31dccf76cfd0cbe030f657d6aaa3e92641de1049d46e3591e9bad794152548bc4520e79fdb4463702e1236729863
+EBUILD freebsd-usbin-10.3-r1.ebuild 5592 SHA256 c5e4d62482c423630bae25d636ed1675973f0b18f134f6e7a0b13ee8c1d0a52b SHA512 cb6de60b4367f07b9731a9a7b587a34f108699b69a0c9e6697324fc22dbd2354440ae4a274a171920a2a547d46f4ce493e0a1506fea62857dc409441929c1c8f WHIRLPOOL 03f0c74e727fa4c05d0a957775497ed43d6a457c0508faf981bd06c37ddb457e3661854248939243ec2d84f58f2c80b1400ce30303002b6030fe79be465ebfa5
+EBUILD freebsd-usbin-11.0-r1.ebuild 5501 SHA256 1af86d7017aad655bc92d6963b84bd838f40d4983af2097e57a73d8921b4474f SHA512 de237a356cd35329245396d55f3621b10fbcc80eb703fac0223a4e2b9b9c64a9be5a04663cdfe945eaed0d2ffd6ff78c1141be2234025e4f80613562b88dd9f7 WHIRLPOOL 48689988ffde1e38c936cb13447b4aaadf17fbaa9932928aac8931952d81193b82a17fae303962c5b41bc63760decc562965ab70fea3ecba32807d38ae99d653
+EBUILD freebsd-usbin-11.1.ebuild 5496 SHA256 fe068e73fbbd15730fc786d8ec66654be1b2f12ecb8fed4e296b33332a8208e2 SHA512 4529a8cd2c429a11eb19047ccb88d0bfba4aa202656f9576a70501fd5137faea68c54e0e00fc0465966f8c004ff702688d3ee71c0823c14483b4eeaf201b63f5 WHIRLPOOL 3678a9ed067abcb40123561e52eec5af7b2715064c14ee3a817723832b1fa036a871329b8efc006a150a1c319a53414cdf287822ea83b07d4c434de50bb8b239
+EBUILD freebsd-usbin-8.2-r2.ebuild 5093 SHA256 507dd2f91d114ddd8010b184376c44935891e61d3a72d0a8475e8a14f9c7eca9 SHA512 77a75c88f844eb51896b1021fbb9690771e80cdba214c6f3d7ae8dbfac9bfd9f5db2af587839612d485818243451b50a61596aa457bfa92b2f5008a5ae203ed2 WHIRLPOOL fadd6f9a941cccc78373e1be627bc4fae45b2c334a6048a8ee6c890f04a0939b1002d3d9fa907ce265dfedc97580140debb7b72ea037a4546acdcd9681866eb4
+EBUILD freebsd-usbin-9.1-r1.ebuild 5359 SHA256 bf7a02c7e003cd9fed1b0e4cd17b71a0bbfbb29f279697410f5a215b13580846 SHA512 e59ef89170cde0cfa4802ee20c94c4bed6d71f695f0f961cdd7ff6667af719561f156f1f0f6ba5be5395a00020c4f419c354e8cb48fcaec307dd5247b3750dec WHIRLPOOL e744111c6ee8fb088aa0f5583d3e58f913d74b4b28386e0f333a8ace7dfb00858c8e899d9cd6d2ce8f2a6d34181167745a1b69c5b4b8e272f35d792c9c51f8bc
+MISC ChangeLog 6805 SHA256 ee7ec69cd8c28f4b5813cb525cb56a27ee1cde4084c68186199d025c19c8c07c SHA512 41c382562ed9607535c8271148fad7bc1d8dcad5948c32e776823c8f195ddd251cf58c14536bf339a497496a57686d9ca92dee54a52619f7f8db22b3e83263ce WHIRLPOOL 5cb65d949c7a23aca51f198ff6751f4a0239aea4566cc1641880e3c699d6e8a85bfcd8e5477c15a90ef0ed744f3147eea2abfa6e799679760cd13fe350c3ae0a
+MISC ChangeLog-2015 23602 SHA256 d7e90d28f8fad482b52a94e37f3276f2f14bdd55e4e4f4f927ceeb0c4d80ce2f SHA512 ca34518f803f0292c8b1d324d7f78b2f0dbfe8dc91e125f5e3f93311f6849ec85fe908d80a5a4a0212b102b0b513f7a770f3e512a09d6a02cc28a76d72874f7b WHIRLPOOL 5bc82fb3f0a42cb5e9648f76fc102dc330433644c8783409fcba69496baa718035082f1e5026dbd94f42a86da973e405b73341971ce7f3dfce88bb447875109f
+MISC metadata.xml 599 SHA256 3f2851ed1214525bc9fd9887db068c00324b466bc9f54342517f3101d34f2659 SHA512 afe1f9e8ccacac89bcd308b6476bba009035542f86d71f70f27df029ff20dda7ff7ff8c9510e6939d502a31750c6bf69de608440fb61b1d590d018446aa14f99 WHIRLPOOL 3514ef434513a233cd7e525442c9a4de763deb680c2d2a3e380a5d69f2f31e397a97c5e0d4512045c957c650777e8b66a803b0a6c008cf1e79f0c87d597f7ae5
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.0-bsdxml2expat.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.0-bsdxml2expat.patch
new file mode 100644
index 000000000000..a84f96d405b2
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.0-bsdxml2expat.patch
@@ -0,0 +1,24 @@
+diff -Nur work.orig/usr.sbin/ctladm/ctladm.c work/usr.sbin/ctladm/ctladm.c
+--- work.orig/usr.sbin/ctladm/ctladm.c 2012-07-12 13:25:58.000000000 +0900
++++ work/usr.sbin/ctladm/ctladm.c 2012-07-16 05:37:14.000000000 +0900
+@@ -60,7 +60,7 @@
+ #include <errno.h>
+ #include <err.h>
+ #include <ctype.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <cam/scsi/scsi_all.h>
+ #include <cam/scsi/scsi_message.h>
+ #include <cam/ctl/ctl.h>
+diff -Nur work.orig/usr.sbin/ctld/kernel.c work/usr.sbin/ctld/kernel.c
+--- work.orig/usr.sbin/ctld/kernel.c 2013-09-20 21:55:45.000000000 +0900
++++ work/usr.sbin/ctld/kernel.c 2013-09-20 22:01:17.000000000 +0900
+@@ -45,7 +45,7 @@
+ #include <sys/sbuf.h>
+ #include <sys/capability.h>
+ #include <assert.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <ctype.h>
+ #include <errno.h>
+ #include <fcntl.h>
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.3-bsdxml2expat.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.3-bsdxml2expat.patch
new file mode 100644
index 000000000000..207b6ab6a50d
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-10.3-bsdxml2expat.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.sbin/camdd/camdd.c b/usr.sbin/camdd/camdd.c
+index 88c648e..edf9c8b 100644
+--- a/usr.sbin/camdd/camdd.c
++++ b/usr.sbin/camdd/camdd.c
+@@ -71,7 +71,7 @@ __FBSDID("$FreeBSD: stable/10/usr.sbin/camdd/camdd.c 293409 2016-01-08 02:56:21Z
+ #include <libutil.h>
+ #include <pthread.h>
+ #include <assert.h>
+-#include <bsdxml.h>
++#include <expat.h>
+
+ #include <cam/cam.h>
+ #include <cam/cam_debug.h>
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-11.0-workaround.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-11.0-workaround.patch
new file mode 100644
index 000000000000..04ba75a17ec5
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-11.0-workaround.patch
@@ -0,0 +1,13 @@
+diff --git a/usr.sbin/nmtree/Makefile b/usr.sbin/nmtree/Makefile
+index 033002c..d198f10 100644
+--- a/usr.sbin/nmtree/Makefile
++++ b/usr.sbin/nmtree/Makefile
+@@ -5,7 +5,7 @@
+ .PATH: ${.CURDIR}/../../contrib/mtree
+
+ PROG= mtree
+-MAN= mtree.5 mtree.8
++MAN= mtree.8
+ SRCS= compare.c crc.c create.c excludes.c getid.c misc.c mtree.c \
+ only.c spec.c specspec.c verify.c
+
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-11.1-bsdxml2expat.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-11.1-bsdxml2expat.patch
new file mode 100644
index 000000000000..5317b256cb4c
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-11.1-bsdxml2expat.patch
@@ -0,0 +1,26 @@
+diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c
+index 9a9d3ff..bf6b1b2 100644
+--- a/usr.sbin/ctladm/ctladm.c
++++ b/usr.sbin/ctladm/ctladm.c
+@@ -51,7 +51,7 @@ __FBSDID("$FreeBSD: stable/11/usr.sbin/ctladm/ctladm.c 319152 2017-05-29 18:17:3
+ #include <sys/queue.h>
+ #include <sys/sbuf.h>
+ #include <sys/stat.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <ctype.h>
+ #include <err.h>
+ #include <errno.h>
+diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.c
+index 7054a04..ee05214 100644
+--- a/usr.sbin/ctld/kernel.c
++++ b/usr.sbin/ctld/kernel.c
+@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD: stable/11/usr.sbin/ctld/kernel.c 319152 2017-05-29 18:17:34Z
+ #include <sys/sbuf.h>
+ #include <sys/stat.h>
+ #include <assert.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <ctype.h>
+ #include <errno.h>
+ #include <fcntl.h>
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-7.0-nowrap.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-7.0-nowrap.patch
new file mode 100644
index 000000000000..9b11104e8337
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-7.0-nowrap.patch
@@ -0,0 +1,45 @@
+diff -ur usr.sbin.orig/rpcbind/Makefile usr.sbin/rpcbind/Makefile
+--- usr.sbin.orig/rpcbind/Makefile 2007-04-21 12:02:30 +0000
++++ usr.sbin/rpcbind/Makefile 2007-04-21 12:05:32 +0000
+@@ -8,13 +8,20 @@
+ SRCS= check_bound.c rpcb_stat.c rpcb_svc_4.c rpcbind.c pmap_svc.c \
+ rpcb_svc.c rpcb_svc_com.c security.c warmstart.c util.c
+
+-CFLAGS+= -DPORTMAP -DLIBWRAP
++CFLAGS+= -DPORTMAP
+
+ .if ${MK_INET6_SUPPORT} != "no"
+ CFLAGS+= -DINET6
+ .endif
+
+-DPADD= ${LIBWRAP} ${LIBUTIL}
+-LDADD= -lwrap -lutil
++DPADD= ${LIBUTIL}
++LDADD= -lutil
++
++.if !defined(NO_WRAP)
++CFLAGS+= -DLIBWRAP
++DPADD+= ${LIBWRAP}
++LDADD+= -lwrap
++.endif
++
+
+ .include <bsd.prog.mk>
+diff -ur usr.sbin.orig/ypserv/Makefile usr.sbin/ypserv/Makefile
+--- usr.sbin.orig/ypserv/Makefile 2007-04-21 12:02:31 +0000
++++ usr.sbin/ypserv/Makefile 2007-04-21 12:06:53 +0000
+@@ -8,10 +8,13 @@
+ SRCS= yp_svc.c yp_server.c yp_dblookup.c yp_dnslookup.c \
+ ypxfr_clnt.c yp.h yp_main.c yp_error.c yp_access.c yp_svc_udp.c
+
+-CFLAGS+= -DDB_CACHE -DTCP_WRAPPER -I.
++CFLAGS+= -DDB_CACHE -I.
+
++.if !defined(NO_WRAP)
++CFLAGS+= -DTCP_WRAPPER
+ DPADD= ${LIBWRAP}
+ LDADD= -lwrap
++.endif
+
+ CLEANFILES= yp_svc.c ypxfr_clnt.c yp.h
+
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-8.2-newsyslog.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-8.2-newsyslog.patch
new file mode 100644
index 000000000000..a0983912178f
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-8.2-newsyslog.patch
@@ -0,0 +1,10 @@
+--- usr.sbin/newsyslog/pathnames.h.orig 2001-07-30 18:17:17.000000000 +0300
++++ usr.sbin/newsyslog/pathnames.h 2009-09-11 08:32:57.508226240 +0300
+@@ -24,5 +24,5 @@
+
+ #define _PATH_CONF "/etc/newsyslog.conf"
+ #define _PATH_SYSLOGPID _PATH_VARRUN "syslog.pid"
+-#define _PATH_BZIP2 "/usr/bin/bzip2"
+-#define _PATH_GZIP "/usr/bin/gzip"
++#define _PATH_BZIP2 "/bin/bzip2"
++#define _PATH_GZIP "/bin/gzip"
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.0-newsyslog.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.0-newsyslog.patch
new file mode 100644
index 000000000000..1d838655c88e
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.0-newsyslog.patch
@@ -0,0 +1,12 @@
+diff -uNr usr.sbin/newsyslog.old/pathnames.h usr.sbin/newsyslog/pathnames.h
+--- usr.sbin/newsyslog.old/pathnames.h 2011-11-02 20:12:37.000000000 +0000
++++ usr.sbin/newsyslog/pathnames.h 2011-11-02 20:12:50.000000000 +0000
+@@ -24,6 +24,6 @@
+
+ #define _PATH_CONF "/etc/newsyslog.conf"
+ #define _PATH_SYSLOGPID _PATH_VARRUN "syslog.pid"
+-#define _PATH_BZIP2 "/usr/bin/bzip2"
+-#define _PATH_GZIP "/usr/bin/gzip"
++#define _PATH_BZIP2 "/bin/bzip2"
++#define _PATH_GZIP "/bin/gzip"
+ #define _PATH_XZ "/usr/bin/xz"
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-bsdxml2expat.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-bsdxml2expat.patch
new file mode 100644
index 000000000000..bddc0c77f210
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-bsdxml2expat.patch
@@ -0,0 +1,12 @@
+diff -Nur work.orig/usr.sbin/ctladm/ctladm.c work/usr.sbin/ctladm/ctladm.c
+--- work.orig/usr.sbin/ctladm/ctladm.c 2012-07-12 13:25:58.000000000 +0900
++++ work/usr.sbin/ctladm/ctladm.c 2012-07-16 05:37:14.000000000 +0900
+@@ -60,7 +60,7 @@
+ #include <errno.h>
+ #include <err.h>
+ #include <ctype.h>
+-#include <bsdxml.h>
++#include <expat.h>
+ #include <cam/scsi/scsi_all.h>
+ #include <cam/scsi/scsi_message.h>
+ #include <cam/ctl/ctl.h>
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-kldxref.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-kldxref.patch
new file mode 100644
index 000000000000..95bd665ded6f
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-9.1-kldxref.patch
@@ -0,0 +1,30 @@
+Index: usr.sbin/kldxref/kldxref.c
+===================================================================
+--- usr.sbin/kldxref/kldxref.c (revision 265111)
++++ usr.sbin/kldxref/kldxref.c (working copy)
+@@ -274,6 +274,16 @@ usage(void)
+ exit(1);
+ }
+
++static int
++compare(const FTSENT *const *a, const FTSENT *const *b)
++{
++ if ((*a)->fts_info == FTS_D && (*b)->fts_info != FTS_D)
++ return 1;
++ if ((*a)->fts_info != FTS_D && (*b)->fts_info == FTS_D)
++ return -1;
++ return strcmp((*a)->fts_name, (*b)->fts_name);
++}
++
+ int
+ main(int argc, char *argv[])
+ {
+@@ -315,7 +325,7 @@ main(int argc, char *argv[])
+ err(1, "%s", argv[0]);
+ }
+
+- ftsp = fts_open(argv, fts_options, 0);
++ ftsp = fts_open(argv, fts_options, compare);
+ if (ftsp == NULL)
+ exit(1);
+
diff --git a/sys-freebsd/freebsd-usbin/files/freebsd-usbin-adduser.patch b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-adduser.patch
new file mode 100644
index 000000000000..39177b4a987d
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/freebsd-usbin-adduser.patch
@@ -0,0 +1,20 @@
+--- usr.sbin/adduser/adduser.sh.old 2006-10-01 13:41:16 +0000
++++ usr.sbin/adduser/adduser.sh 2006-10-01 13:41:38 +0000
+@@ -809,7 +809,7 @@
+ NOHOME="/nonexistent"
+ NOLOGIN="nologin"
+ NOLOGIN_PATH="/usr/sbin/nologin"
+-GREPCMD="/usr/bin/grep"
++GREPCMD="/bin/grep"
+ DATECMD="/bin/date"
+
+ # Set default values
+@@ -823,7 +823,7 @@
+ uhome=
+ upass=
+ ushell=
+-udotdir=/usr/share/skel
++udotdir=/etc/skel
+ ugroups=
+ uexpire=
+ upwexpire=
diff --git a/sys-freebsd/freebsd-usbin/files/iscsid.initd b/sys-freebsd/freebsd-usbin/files/iscsid.initd
new file mode 100644
index 000000000000..f16d00e876ab
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/iscsid.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting iscsid"
+ start-stop-daemon --start --quiet --exec \
+ /usr/sbin/iscsid -- $iscsidopts
+ eend $? "Error starting iscsid"
+}
+
+stop() {
+ ebegin "Stopping iscsid"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/iscsid
+ eend $? "Error stopping iscsid"
+}
diff --git a/sys-freebsd/freebsd-usbin/files/mountd.patch b/sys-freebsd/freebsd-usbin/files/mountd.patch
new file mode 100644
index 000000000000..3cb9f03e9d8f
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/mountd.patch
@@ -0,0 +1,15 @@
+http://security.freebsd.org/advisories/FreeBSD-SA-11:01.mountd.asc
+
+Index: usr.sbin/mountd/mountd.c
+===================================================================
+--- usr.sbin/mountd/mountd.c 20 Dec 2010 09:28:28 -0000 1.107
++++ usr.sbin/mountd/mountd.c 1 Mar 2011 11:47:16 -0000 1.108
+@@ -2875,7 +2875,7 @@ makemask(struct sockaddr_storage *ssp, i
+
+ for (i = 0; i < len; i++) {
+ bits = (bitlen > CHAR_BIT) ? CHAR_BIT : bitlen;
+- *p++ = (1 << bits) - 1;
++ *p++ = (u_char)~0 << (CHAR_BIT - bits);
+ bitlen -= bits;
+ }
+ return 0;
diff --git a/sys-freebsd/freebsd-usbin/files/nfs.confd b/sys-freebsd/freebsd-usbin/files/nfs.confd
new file mode 100644
index 000000000000..844252fdc54d
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/nfs.confd
@@ -0,0 +1,10 @@
+# Config file for /etc/init.d/nfs
+# Options for nfsd (see man nfsd)
+# Example: 8 nfsd servers started:
+#nfsdopts="-n 8"
+
+# Options for mountd (see man mountd)
+# Example: allow non-root users to mount shares:
+#mountdopts="-n"
+# Specify t he exports file, this is the default:
+#exportsfile="/etc/exports"
diff --git a/sys-freebsd/freebsd-usbin/files/nfs.initd b/sys-freebsd/freebsd-usbin/files/nfs.initd
new file mode 100644
index 000000000000..17974ca0998a
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/nfs.initd
@@ -0,0 +1,54 @@
+#!/sbin/openrc-run
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+#---------------------------------------------------------------------------
+# This script starts/stops nfsd and mountd
+# Daemons rpc.rquotad, rpc.rstatd, rpc.rusersd, rpc.rwalld and rpc.sprayd
+# should be started from inetd on FreeBSD.
+#---------------------------------------------------------------------------
+
+extra_started_commands="reload"
+
+# The binary locations
+nfsd=/usr/sbin/nfsd
+mountd=/usr/sbin/mountd
+
+depend() {
+ use ypbind net rpc.lockd
+ need rpcbind
+ after quota
+}
+
+start() {
+ ebegin "Starting NFS daemon"
+ start-stop-daemon --start --quiet --exec \
+ $nfsd -- ${nfsdopts}
+ eend $? "Error starting NFS daemon"
+
+ # Start mountd
+ ebegin "Starting NFS mountd"
+ start-stop-daemon --start --quiet --exec \
+ $mountd -- ${mountdopts} ${exportsfile}
+ eend $? "Error starting NFS mountd"
+}
+
+stop() {
+ ebegin "Stopping NFS mountd"
+ start-stop-daemon --stop --quiet --exec $mountd \
+ --pidfile /var/run/mountd.pid
+ eend $? "Error stopping NFS mountd"
+
+ ebegin "Stopping NFS daemon"
+ start-stop-daemon --stop --signal USR1 --quiet \
+ --name nfsd --user root
+ eend $? "Error stopping NFS daemon"
+}
+
+reload() {
+ # Hangup signal to mountd reloads /etc/exports.
+ ebegin "Reloading /etc/exports"
+ start-stop-daemon --signal 1 --quiet --exec $mountd \
+ --pidfile /var/run/mountd.pid
+ eend $?
+}
diff --git a/sys-freebsd/freebsd-usbin/files/nfsuserd.confd b/sys-freebsd/freebsd-usbin/files/nfsuserd.confd
new file mode 100644
index 000000000000..f8f3ea1e31de
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/nfsuserd.confd
@@ -0,0 +1,5 @@
+# Config file for /etc/init.d/nfsuserd
+# Options for nfsuserd (see man nfsuserd)
+# Example: set domain example.com:
+#nfsuserdopts="-domain example.com"
+
diff --git a/sys-freebsd/freebsd-usbin/files/nfsuserd.initd b/sys-freebsd/freebsd-usbin/files/nfsuserd.initd
new file mode 100644
index 000000000000..d69007412fc6
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/nfsuserd.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net nfs
+}
+
+start() {
+ ebegin "Starting nfsuserd"
+ start-stop-daemon --start --quiet --exec \
+ /usr/sbin/nfsuserd -- $nfsuserdopts
+ eend $? "Error starting nfsuserd"
+}
+
+stop() {
+ ebegin "Stopping nfsuserd"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/nfsuserd
+ eend $? "Error stopping nfsuserd"
+}
diff --git a/sys-freebsd/freebsd-usbin/files/pw.conf b/sys-freebsd/freebsd-usbin/files/pw.conf
new file mode 100644
index 000000000000..29a246f72b8f
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/pw.conf
@@ -0,0 +1,5 @@
+# Change this to Gentoo's Default, instead of FreeBSD's default of
+# /usr/share/skel, so that bash and other packages installs the files on the
+# right place.
+skeleton /etc/skel
+
diff --git a/sys-freebsd/freebsd-usbin/files/rpc.lockd.initd b/sys-freebsd/freebsd-usbin/files/rpc.lockd.initd
new file mode 100644
index 000000000000..dd2fdbe8a756
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/rpc.lockd.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net rpcbind rpc.statd
+}
+
+start() {
+ ebegin "Starting NFS lockd"
+ start-stop-daemon --start --quiet --exec \
+ /usr/sbin/rpc.lockd -- $rpclockdopts
+ eend $? "Error starting NFS lockd"
+}
+
+stop() {
+ ebegin "Stopping NFS lockd"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/rpc.lockd
+ eend $? "Error stopping NFS lockd"
+}
diff --git a/sys-freebsd/freebsd-usbin/files/rpc.statd.initd b/sys-freebsd/freebsd-usbin/files/rpc.statd.initd
new file mode 100644
index 000000000000..163af5a4b4a1
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/files/rpc.statd.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need net rpcbind
+}
+
+start() {
+ ebegin "Starting NFS statd"
+ start-stop-daemon --start --quiet --exec \
+ /usr/sbin/rpc.statd -- $rpcstatdopts
+ eend $? "Error starting NFS statd"
+}
+
+stop() {
+ ebegin "Stopping NFS statd"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/rpc.statd
+ eend $? "Error stopping NFS statd"
+}
diff --git a/sys-freebsd/freebsd-usbin/freebsd-usbin-10.3-r1.ebuild b/sys-freebsd/freebsd-usbin/freebsd-usbin-10.3-r1.ebuild
new file mode 100644
index 000000000000..13fcabab5a41
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/freebsd-usbin-10.3-r1.ebuild
@@ -0,0 +1,189 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic eutils
+
+DESCRIPTION="FreeBSD /usr/sbin tools"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "SA-16:30/portsnap-10.patch" )
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ usr.sbin/
+ contrib/
+ usr.bin/
+ lib/
+ sbin/
+ etc/
+ gnu/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?,netware?]
+ =sys-freebsd/freebsd-libexec-${RV}*
+ build? ( sys-apps/baselayout )
+ ssl? ( dev-libs/openssl:0 )
+ >=app-arch/libarchive-3
+ sys-apps/tcp-wrappers
+ dev-util/dialog
+ >=dev-libs/libedit-20120311.3.0-r1
+ net-libs/libpcap
+ kerberos? ( app-crypt/heimdal )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-ubin-${RV}*
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ sys-apps/texinfo
+ sys-devel/flex"
+
+S="${WORKDIR}/usr.sbin"
+
+IUSE="acpi atm audit bluetooth floppy ipv6 kerberos minimal netware nis pam ssl usb build zfs"
+
+pkg_setup() {
+ # Add the required source files.
+ use nis && EXTRACTONLY+="libexec/ "
+ use build && EXTRACTONLY+="sys/ include/ "
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ # Release crunch is something like minimal. It seems to remove everything
+ # which is not needed to work.
+ use minimal && mymakeopts="${mymakeopts} RELEASE_CRUNCH= "
+
+ use acpi || mymakeopts="${mymakeopts} WITHOUT_ACPI= "
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use floppy || mymakeopts="${mymakeopts} WITHOUT_FLOPPY= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_GSSAPI= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_PF= WITHOUT_LPR= WITHOUT_SENDMAIL= WITHOUT_AUTHPF= WITHOUT_MAILWRAPPER= WITHOUT_UNBOUND= "
+
+ append-flags $(test-flags -fno-strict-aliasing)
+}
+
+PATCHES=(
+ "${FILESDIR}/${PN}-adduser.patch"
+ "${FILESDIR}/${PN}-9.0-newsyslog.patch"
+ "${FILESDIR}/${PN}-10.0-bsdxml2expat.patch"
+ "${FILESDIR}/${PN}-10.3-bsdxml2expat.patch"
+ )
+
+REMOVE_SUBDIRS="
+ tcpdchk tcpdmatch
+ sendmail praliases editmap mailstats makemap
+ pc-sysinstall cron mailwrapper ntp bsnmpd
+ tcpdump ndp inetd
+ wpa/wpa_supplicant wpa/hostapd wpa/hostapd_cli wpa/wpa_cli wpa/wpa_passphrase
+ zic amd
+ pkg pkg_install freebsd-update service sysrc bsdinstall"
+
+src_prepare() {
+ if ! use build; then
+ [[ ! -e "${WORKDIR}/sys" ]] && ln -s "/usr/src/sys" "${WORKDIR}/sys"
+ [[ ! -e "${WORKDIR}/include" ]] && ln -s "/usr/include" "${WORKDIR}/include"
+ else
+ dummy_mk mount_smbfs
+ fi
+ # Don't install mtree format manpage
+ # it's installed by libarchive.
+ sed -e "s: mtree.5::g" -i "${S}"/mtree/Makefile
+}
+
+src_compile() {
+ # Preparing to build nmtree
+ cd "${WORKDIR}/lib/libnetbsd" || die
+ freebsd_src_compile
+
+ cd "${S}" || die
+ freebsd_src_compile
+}
+
+src_install() {
+ # By creating these directories we avoid having to do a
+ # more complex hack
+ dodir /usr/share/doc
+ dodir /sbin
+ dodir /usr/libexec
+ dodir /usr/bin
+
+ # FILESDIR is used by some makefiles which will install files
+ # in the wrong place, just put it in the doc directory.
+ mkinstall DOCDIR=/usr/share/doc/${PF} || die "Install failed"
+
+ # Most of these now come from openrc.
+ for util in iscsid nfs nfsuserd rpc.statd rpc.lockd; do
+ newinitd "${FILESDIR}/"${util}.initd ${util} || die
+ if [[ -e "${FILESDIR}"/${util}.confd ]]; then \
+ newconfd "${FILESDIR}"/${util}.confd ${util} || die
+ fi
+ done
+
+ for class in daily monthly weekly; do
+ cat - > "${T}/periodic.${class}" <<EOS
+#!/bin/sh
+/usr/sbin/periodic ${class}
+EOS
+ exeinto /etc/cron.${class}
+ newexe "${T}/periodic.${class}" periodic
+ done
+
+ # Install the pw.conf file to let pw use Gentoo's skel location
+ insinto /etc
+ doins "${FILESDIR}/pw.conf" || die
+
+ cd "${WORKDIR}/etc" || die
+ doins apmd.conf syslog.conf newsyslog.conf nscd.conf || die
+
+ insinto /etc/ppp
+ doins ppp/ppp.conf || die
+
+ if use bluetooth; then
+ insinto /etc/bluetooth
+ doins bluetooth/* || die
+ rm -f "${D}"/etc/bluetooth/Makefile
+ fi
+
+ # Install the periodic stuff (needs probably to be ported in a more
+ # gentooish way)
+ cd "${WORKDIR}/etc/periodic" || die
+
+ doperiodic daily daily/*.accounting
+ doperiodic monthly monthly/*.accounting
+}
+
+pkg_postinst() {
+ # We need to run pwd_mkdb if key files are not present
+ # If they are, then there is no need to run pwd_mkdb
+ if [[ ! -e "${ROOT}etc/passwd" || ! -e "${ROOT}etc/pwd.db" || ! -e "${ROOT}etc/spwd.db" ]] ; then
+ if [[ -e "${ROOT}etc/master.passwd" ]] ; then
+ einfo "Generating passwd files from ${ROOT}etc/master.passwd"
+ "${ROOT}"usr/sbin/pwd_mkdb -p -d "${ROOT}etc" "${ROOT}etc/master.passwd"
+ else
+ eerror "${ROOT}etc/master.passwd does not exist!"
+ eerror "You will no be able to log into your system!"
+ fi
+ fi
+
+ for logfile in messages security auth.log maillog lpd-errs xferlog cron \
+ debug.log slip.log ppp.log; do
+ [[ -f "${ROOT}/var/log/${logfile}" ]] || touch "${ROOT}/var/log/${logfile}"
+ done
+}
diff --git a/sys-freebsd/freebsd-usbin/freebsd-usbin-11.0-r1.ebuild b/sys-freebsd/freebsd-usbin/freebsd-usbin-11.0-r1.ebuild
new file mode 100644
index 000000000000..4050a75bdf59
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/freebsd-usbin-11.0-r1.ebuild
@@ -0,0 +1,188 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic eutils
+
+DESCRIPTION="FreeBSD /usr/sbin tools"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+# Security Advisory and Errata patches.
+UPSTREAM_PATCHES=( "SA-16:32/bhyve.patch" )
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ usr.sbin/
+ contrib/
+ usr.bin/
+ lib/
+ sbin/
+ etc/
+ gnu/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?,netware?]
+ =sys-freebsd/freebsd-libexec-${RV}*
+ build? ( sys-apps/baselayout )
+ ssl? ( dev-libs/openssl:0 )
+ >=app-arch/libarchive-3
+ sys-apps/tcp-wrappers
+ dev-util/dialog
+ >=dev-libs/libedit-20120311.3.0-r1
+ net-libs/libpcap
+ kerberos? ( app-crypt/heimdal )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-ubin-${RV}*
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ sys-apps/texinfo
+ sys-devel/flex"
+
+S="${WORKDIR}/usr.sbin"
+
+IUSE="acpi atm audit bluetooth floppy ipv6 kerberos minimal netware nis pam ssl usb build zfs"
+
+pkg_setup() {
+ # Add the required source files.
+ use nis && EXTRACTONLY+="libexec/ "
+ use build && EXTRACTONLY+="sys/ include/ "
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ # Release crunch is something like minimal. It seems to remove everything
+ # which is not needed to work.
+ use minimal && mymakeopts="${mymakeopts} RELEASE_CRUNCH= "
+
+ use acpi || mymakeopts="${mymakeopts} WITHOUT_ACPI= "
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use floppy || mymakeopts="${mymakeopts} WITHOUT_FLOPPY= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_GSSAPI= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_PF= WITHOUT_LPR= WITHOUT_SENDMAIL= WITHOUT_AUTHPF= WITHOUT_MAILWRAPPER= WITHOUT_UNBOUND= "
+
+ append-flags $(test-flags -fno-strict-aliasing)
+}
+
+PATCHES=(
+ "${FILESDIR}/${PN}-adduser.patch"
+ "${FILESDIR}/${PN}-9.0-newsyslog.patch"
+ "${FILESDIR}/${PN}-10.0-bsdxml2expat.patch"
+ "${FILESDIR}/${PN}-10.3-bsdxml2expat.patch"
+ "${FILESDIR}/${PN}-11.0-workaround.patch"
+ )
+
+REMOVE_SUBDIRS="
+ tcpdchk tcpdmatch
+ sendmail praliases editmap mailstats makemap
+ pc-sysinstall cron mailwrapper ntp bsnmpd
+ tcpdump ndp inetd
+ wpa/wpa_supplicant wpa/hostapd wpa/hostapd_cli wpa/wpa_cli wpa/wpa_passphrase
+ zic amd
+ pkg freebsd-update service sysrc bsdinstall"
+
+src_prepare() {
+ if ! use build; then
+ [[ ! -e "${WORKDIR}/sys" ]] && ln -s "/usr/src/sys" "${WORKDIR}/sys"
+ [[ ! -e "${WORKDIR}/include" ]] && ln -s "/usr/include" "${WORKDIR}/include"
+ else
+ dummy_mk mount_smbfs
+ fi
+}
+
+src_compile() {
+ # Preparing to build nmtree
+ cd "${WORKDIR}/lib/libnetbsd" || die
+ freebsd_src_compile
+
+ cd "${S}" || die
+ freebsd_src_compile
+}
+
+src_install() {
+ # By creating these directories we avoid having to do a
+ # more complex hack
+ dodir /usr/share/doc
+ dodir /sbin
+ dodir /usr/libexec
+ dodir /usr/bin
+
+ # FILESDIR is used by some makefiles which will install files
+ # in the wrong place, just put it in the doc directory.
+ freebsd_src_install DOCDIR=/usr/share/doc/${PF}
+
+ # Most of these now come from openrc.
+ for util in iscsid nfs nfsuserd rpc.statd rpc.lockd; do
+ newinitd "${FILESDIR}/"${util}.initd ${util} || die
+ if [[ -e "${FILESDIR}"/${util}.confd ]]; then \
+ newconfd "${FILESDIR}"/${util}.confd ${util} || die
+ fi
+ done
+
+ for class in daily monthly weekly; do
+ cat - > "${T}/periodic.${class}" <<EOS
+#!/bin/sh
+/usr/sbin/periodic ${class}
+EOS
+ exeinto /etc/cron.${class}
+ newexe "${T}/periodic.${class}" periodic
+ done
+
+ # Install the pw.conf file to let pw use Gentoo's skel location
+ insinto /etc
+ doins "${FILESDIR}/pw.conf" || die
+
+ cd "${WORKDIR}/etc" || die
+ doins apmd.conf syslog.conf newsyslog.conf nscd.conf || die
+
+ if use bluetooth; then
+ insinto /etc/bluetooth
+ doins bluetooth/* || die
+ rm -f "${D}"/etc/bluetooth/Makefile
+ fi
+
+ cd "${S}"/ppp || die
+ insinto /etc/ppp
+ doins ppp.conf || die
+
+ # Install the periodic stuff (needs probably to be ported in a more
+ # gentooish way)
+ cd "${WORKDIR}/etc/periodic" || die
+
+ doperiodic daily daily/*.accounting
+ doperiodic monthly monthly/*.accounting
+}
+
+pkg_postinst() {
+ # We need to run pwd_mkdb if key files are not present
+ # If they are, then there is no need to run pwd_mkdb
+ if [[ ! -e "${ROOT}etc/passwd" || ! -e "${ROOT}etc/pwd.db" || ! -e "${ROOT}etc/spwd.db" ]] ; then
+ if [[ -e "${ROOT}etc/master.passwd" ]] ; then
+ einfo "Generating passwd files from ${ROOT}etc/master.passwd"
+ "${ROOT}"usr/sbin/pwd_mkdb -p -d "${ROOT}etc" "${ROOT}etc/master.passwd"
+ else
+ eerror "${ROOT}etc/master.passwd does not exist!"
+ eerror "You will no be able to log into your system!"
+ fi
+ fi
+
+ for logfile in messages security auth.log maillog lpd-errs xferlog cron \
+ debug.log slip.log ppp.log; do
+ [[ -f "${ROOT}/var/log/${logfile}" ]] || touch "${ROOT}/var/log/${logfile}"
+ done
+}
diff --git a/sys-freebsd/freebsd-usbin/freebsd-usbin-11.1.ebuild b/sys-freebsd/freebsd-usbin/freebsd-usbin-11.1.ebuild
new file mode 100644
index 000000000000..522032984c5f
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/freebsd-usbin-11.1.ebuild
@@ -0,0 +1,189 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit bsdmk freebsd flag-o-matic eutils
+
+DESCRIPTION="FreeBSD /usr/sbin tools"
+SLOT="0"
+LICENSE="BSD zfs? ( CDDL )"
+
+# Security Advisory and Errata patches.
+# UPSTREAM_PATCHES=()
+
+if [[ ${PV} != *9999* ]]; then
+ KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+ SRC_URI="${SRC_URI}
+ $(freebsd_upstream_patches)"
+fi
+
+EXTRACTONLY="
+ usr.sbin/
+ contrib/
+ usr.bin/
+ lib/
+ sbin/
+ etc/
+ gnu/
+"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?,netware?]
+ build? ( sys-apps/baselayout )
+ ssl? ( dev-libs/openssl:0 )
+ >=app-arch/libarchive-3
+ sys-apps/tcp-wrappers
+ dev-util/dialog
+ >=dev-libs/libedit-20120311.3.0-r1
+ net-libs/libpcap
+ kerberos? ( app-crypt/heimdal )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-ubin-${RV}*
+ zfs? ( =sys-freebsd/freebsd-cddl-${RV}* )
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ sys-apps/texinfo
+ sys-devel/flex"
+
+S="${WORKDIR}/usr.sbin"
+
+IUSE="acpi atm audit bluetooth floppy ipv6 kerberos minimal netware nis pam ssl usb build zfs"
+
+pkg_setup() {
+ # Add the required source files.
+ use nis && EXTRACTONLY+="libexec/ "
+ use build && EXTRACTONLY+="sys/ include/ "
+ use zfs && EXTRACTONLY+="cddl/ "
+
+ # Release crunch is something like minimal. It seems to remove everything
+ # which is not needed to work.
+ use minimal && mymakeopts="${mymakeopts} RELEASE_CRUNCH= "
+
+ use acpi || mymakeopts="${mymakeopts} WITHOUT_ACPI= "
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use floppy || mymakeopts="${mymakeopts} WITHOUT_FLOPPY= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_GSSAPI= "
+ use zfs || mymakeopts="${mymakeopts} WITHOUT_CDDL= "
+
+ mymakeopts="${mymakeopts} WITHOUT_PF= WITHOUT_LPR= WITHOUT_SENDMAIL= WITHOUT_AUTHPF= WITHOUT_MAILWRAPPER= WITHOUT_UNBOUND= "
+
+ append-flags $(test-flags -fno-strict-aliasing)
+}
+
+PATCHES=(
+ "${FILESDIR}/${PN}-adduser.patch"
+ "${FILESDIR}/${PN}-9.0-newsyslog.patch"
+ "${FILESDIR}/${PN}-11.1-bsdxml2expat.patch"
+ "${FILESDIR}/${PN}-10.3-bsdxml2expat.patch"
+ "${FILESDIR}/${PN}-11.0-workaround.patch"
+ )
+
+REMOVE_SUBDIRS="
+ tcpdchk tcpdmatch
+ sendmail praliases editmap mailstats makemap
+ pc-sysinstall cron mailwrapper ntp bsnmpd
+ tcpdump ndp inetd
+ wpa/wpa_supplicant wpa/hostapd wpa/hostapd_cli wpa/wpa_cli wpa/wpa_passphrase
+ zic amd
+ pkg freebsd-update service sysrc bsdinstall"
+
+src_prepare() {
+ if ! use build; then
+ [[ ! -e "${WORKDIR}/sys" ]] && ln -s "/usr/src/sys" "${WORKDIR}/sys"
+ [[ ! -e "${WORKDIR}/include" ]] && ln -s "/usr/include" "${WORKDIR}/include"
+ else
+ dummy_mk mount_smbfs
+ fi
+}
+
+src_compile() {
+ # Preparing to build nmtree, ypldap
+ for dir in libnetbsd libopenbsd; do
+ cd "${WORKDIR}/lib/${dir}" || die
+ freebsd_src_compile -j1
+ done
+
+ cd "${S}" || die
+ freebsd_src_compile
+}
+
+src_install() {
+ # By creating these directories we avoid having to do a
+ # more complex hack
+ dodir /usr/share/doc
+ dodir /sbin
+ dodir /usr/libexec
+ dodir /usr/bin
+
+ # FILESDIR is used by some makefiles which will install files
+ # in the wrong place, just put it in the doc directory.
+ freebsd_src_install DOCDIR=/usr/share/doc/${PF}
+
+ # Most of these now come from openrc.
+ for util in iscsid nfs nfsuserd rpc.statd rpc.lockd; do
+ newinitd "${FILESDIR}/"${util}.initd ${util} || die
+ if [[ -e "${FILESDIR}"/${util}.confd ]]; then \
+ newconfd "${FILESDIR}"/${util}.confd ${util} || die
+ fi
+ done
+
+ for class in daily monthly weekly; do
+ cat - > "${T}/periodic.${class}" <<EOS
+#!/bin/sh
+/usr/sbin/periodic ${class}
+EOS
+ exeinto /etc/cron.${class}
+ newexe "${T}/periodic.${class}" periodic
+ done
+
+ # Install the pw.conf file to let pw use Gentoo's skel location
+ insinto /etc
+ doins "${FILESDIR}/pw.conf" || die
+
+ cd "${WORKDIR}/etc" || die
+ doins apmd.conf syslog.conf newsyslog.conf nscd.conf || die
+
+ if use bluetooth; then
+ insinto /etc/bluetooth
+ doins bluetooth/* || die
+ rm -f "${D}"/etc/bluetooth/Makefile
+ fi
+
+ cd "${S}"/ppp || die
+ insinto /etc/ppp
+ doins ppp.conf || die
+
+ # Install the periodic stuff (needs probably to be ported in a more
+ # gentooish way)
+ cd "${WORKDIR}/etc/periodic" || die
+
+ doperiodic daily daily/*.accounting
+ doperiodic monthly monthly/*.accounting
+}
+
+pkg_postinst() {
+ # We need to run pwd_mkdb if key files are not present
+ # If they are, then there is no need to run pwd_mkdb
+ if [[ ! -e "${ROOT}etc/passwd" || ! -e "${ROOT}etc/pwd.db" || ! -e "${ROOT}etc/spwd.db" ]] ; then
+ if [[ -e "${ROOT}etc/master.passwd" ]] ; then
+ einfo "Generating passwd files from ${ROOT}etc/master.passwd"
+ "${ROOT}"usr/sbin/pwd_mkdb -p -d "${ROOT}etc" "${ROOT}etc/master.passwd"
+ else
+ eerror "${ROOT}etc/master.passwd does not exist!"
+ eerror "You will no be able to log into your system!"
+ fi
+ fi
+
+ for logfile in messages security auth.log maillog lpd-errs xferlog cron \
+ debug.log slip.log ppp.log; do
+ [[ -f "${ROOT}/var/log/${logfile}" ]] || touch "${ROOT}/var/log/${logfile}"
+ done
+}
diff --git a/sys-freebsd/freebsd-usbin/freebsd-usbin-8.2-r2.ebuild b/sys-freebsd/freebsd-usbin/freebsd-usbin-8.2-r2.ebuild
new file mode 100644
index 000000000000..2bf4b1f35f0a
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/freebsd-usbin-8.2-r2.ebuild
@@ -0,0 +1,162 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=2
+
+inherit bsdmk freebsd flag-o-matic eutils
+
+DESCRIPTION="FreeBSD /usr/sbin tools"
+SLOT="0"
+KEYWORDS="~sparc-fbsd ~x86-fbsd"
+
+SRC_URI="mirror://gentoo/${P}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2
+ mirror://gentoo/${GNU}.tar.bz2
+ nis? ( mirror://gentoo/${LIBEXEC}.tar.bz2 )
+ build? ( mirror://gentoo/${SYS}.tar.bz2
+ mirror://gentoo/${INCLUDE}.tar.bz2 )"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?,netware?]
+ =sys-freebsd/freebsd-libexec-${RV}*
+ acpi? ( sys-power/iasl )
+ build? ( sys-apps/baselayout )
+ ssl? ( dev-libs/openssl )
+ dev-libs/libelf
+ dev-libs/libedit
+ net-libs/libpcap"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-ubin-${RV}*
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ sys-apps/texinfo
+ sys-devel/flex"
+
+S="${WORKDIR}/usr.sbin"
+
+IUSE="acpi atm audit bluetooth floppy ipv6 minimal netware nis pam ssl usb build"
+
+pkg_setup() {
+ # Release crunch is something like minimal. It seems to remove everything
+ # which is not needed to work.
+ use minimal && mymakeopts="${mymakeopts} RELEASE_CRUNCH= "
+
+ use acpi || mymakeopts="${mymakeopts} WITHOUT_ACPI= "
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use floppy || mymakeopts="${mymakeopts} WITHOUT_FLOPPY= "
+
+ mymakeopts="${mymakeopts} WITHOUT_BIND_NAMED= WITHOUT_BIND_DNSSEC= WITHOUT_PF= WITHOUT_LPR= WITHOUT_SENDMAIL= WITHOUT_AUTHPF= WITHOUT_MAILWRAPPER= "
+
+ append-flags $(test-flags -fno-strict-aliasing)
+}
+
+PATCHES=( "${FILESDIR}/${PN}-7.0-nowrap.patch"
+ "${FILESDIR}/${PN}-adduser.patch"
+ "${FILESDIR}/mountd.patch"
+ "${FILESDIR}/${PN}-8.2-newsyslog.patch" )
+
+REMOVE_SUBDIRS="
+ named named-checkzone named-checkconf rndc rndc-confgen
+ dnssec-keygen dnssec-signzone
+ tcpdchk tcpdmatch
+ sendmail praliases editmap mailstats makemap
+ sysinstall cron mailwrapper ntp bsnmpd
+ tcpdump ndp inetd
+ wpa/wpa_supplicant wpa/hostapd wpa/hostapd_cli wpa/wpa_cli wpa/wpa_passphrase
+ zic amd
+ pkg_install freebsd-update"
+
+src_prepare() {
+ if ! use build; then
+ ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys"
+ ln -s "/usr/include" "${WORKDIR}/include"
+ else
+ dummy_mk mount_smbfs
+ fi
+ # Don't install mtree format manpage
+ # it's installed by libarchive.
+ sed -e "s: mtree.5::g" -i "${S}"/mtree/Makefile
+}
+
+src_install() {
+ # By creating these directories we avoid having to do a
+ # more complex hack
+ dodir /usr/share/doc
+ dodir /sbin
+ dodir /usr/libexec
+ dodir /usr/bin
+
+ # FILESDIR is used by some makefiles which will install files
+ # in the wrong place, just put it in the doc directory.
+ mkinstall DOCDIR=/usr/share/doc/${PF} || die "Install failed"
+
+ # Most of these now come from openrc.
+ for util in nfs rpc.statd rpc.lockd; do
+ newinitd "${FILESDIR}/"${util}.initd ${util} || die
+ if [[ -e "${FILESDIR}"/${util}.confd ]]; then \
+ newconfd "${FILESDIR}"/${util}.confd ${util} || die
+ fi
+ done
+
+ for class in daily monthly weekly; do
+ cat - > "${T}/periodic.${class}" <<EOS
+#!/bin/sh
+/usr/sbin/periodic ${class}
+EOS
+ exeinto /etc/cron.${class}
+ newexe "${T}/periodic.${class}" periodic
+ done
+
+ # Install the pw.conf file to let pw use Gentoo's skel location
+ insinto /etc
+ doins "${FILESDIR}/pw.conf" || die
+
+ cd "${WORKDIR}/etc"
+ doins apmd.conf syslog.conf newsyslog.conf nscd.conf || die
+
+ insinto /etc/ppp
+ doins ppp/ppp.conf || die
+
+ if use bluetooth; then
+ insinto /etc/bluetooth
+ doins bluetooth/* || die
+ rm -f "${D}"/etc/bluetooth/Makefile
+ fi
+
+ # Install the periodic stuff (needs probably to be ported in a more
+ # gentooish way)
+ cd "${WORKDIR}/etc/periodic"
+
+ doperiodic daily daily/*.accounting
+ doperiodic monthly monthly/*.accounting
+}
+
+pkg_postinst() {
+ # We need to run pwd_mkdb if key files are not present
+ # If they are, then there is no need to run pwd_mkdb
+ if [[ ! -e "${ROOT}etc/passwd" || ! -e "${ROOT}etc/pwd.db" || ! -e "${ROOT}etc/spwd.db" ]] ; then
+ if [[ -e "${ROOT}etc/master.passwd" ]] ; then
+ einfo "Generating passwd files from ${ROOT}etc/master.passwd"
+ "${ROOT}"usr/sbin/pwd_mkdb -p -d "${ROOT}etc" "${ROOT}etc/master.passwd"
+ else
+ eerror "${ROOT}etc/master.passwd does not exist!"
+ eerror "You will no be able to log into your system!"
+ fi
+ fi
+
+ for logfile in messages security auth.log maillog lpd-errs xferlog cron \
+ debug.log slip.log ppp.log; do
+ [[ -f "${ROOT}/var/log/${logfile}" ]] || touch "${ROOT}/var/log/${logfile}"
+ done
+}
diff --git a/sys-freebsd/freebsd-usbin/freebsd-usbin-9.1-r1.ebuild b/sys-freebsd/freebsd-usbin/freebsd-usbin-9.1-r1.ebuild
new file mode 100644
index 000000000000..11c304685cfb
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/freebsd-usbin-9.1-r1.ebuild
@@ -0,0 +1,170 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=2
+
+inherit bsdmk freebsd flag-o-matic eutils
+
+DESCRIPTION="FreeBSD /usr/sbin tools"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+
+SRC_URI="mirror://gentoo/${P}.tar.bz2
+ mirror://gentoo/${CONTRIB}.tar.bz2
+ mirror://gentoo/${UBIN}.tar.bz2
+ mirror://gentoo/${LIB}.tar.bz2
+ mirror://gentoo/${SBIN}.tar.bz2
+ mirror://gentoo/${ETC}.tar.bz2
+ mirror://gentoo/${GNU}.tar.bz2
+ nis? ( mirror://gentoo/${LIBEXEC}.tar.bz2 )
+ build? ( mirror://gentoo/${SYS}.tar.bz2
+ mirror://gentoo/${INCLUDE}.tar.bz2 )"
+
+RDEPEND="=sys-freebsd/freebsd-lib-${RV}*[usb?,bluetooth?,netware?]
+ =sys-freebsd/freebsd-libexec-${RV}*
+ =sys-freebsd/freebsd-contrib-${RV}*
+ acpi? ( sys-power/iasl )
+ build? ( sys-apps/baselayout )
+ ssl? ( dev-libs/openssl )
+ >=app-arch/libarchive-3
+ sys-apps/tcp-wrappers
+ dev-util/dialog
+ dev-libs/libelf
+ >=dev-libs/libedit-20120311.3.0-r1
+ net-libs/libpcap
+ kerberos? ( app-crypt/heimdal )"
+DEPEND="${RDEPEND}
+ =sys-freebsd/freebsd-mk-defs-${RV}*
+ =sys-freebsd/freebsd-ubin-${RV}*
+ !build? ( =sys-freebsd/freebsd-sources-${RV}* )
+ sys-apps/texinfo
+ sys-devel/flex"
+
+S="${WORKDIR}/usr.sbin"
+
+IUSE="acpi atm audit bluetooth floppy ipv6 kerberos minimal netware nis pam ssl usb build"
+
+pkg_setup() {
+ # Release crunch is something like minimal. It seems to remove everything
+ # which is not needed to work.
+ use minimal && mymakeopts="${mymakeopts} RELEASE_CRUNCH= "
+
+ use acpi || mymakeopts="${mymakeopts} WITHOUT_ACPI= "
+ use atm || mymakeopts="${mymakeopts} WITHOUT_ATM= "
+ use audit || mymakeopts="${mymakeopts} WITHOUT_AUDIT= "
+ use bluetooth || mymakeopts="${mymakeopts} WITHOUT_BLUETOOTH= "
+ use ipv6 || mymakeopts="${mymakeopts} WITHOUT_INET6= WITHOUT_INET6_SUPPORT= "
+ use netware || mymakeopts="${mymakeopts} WITHOUT_IPX= WITHOUT_IPX_SUPPORT= WITHOUT_NCP= "
+ use nis || mymakeopts="${mymakeopts} WITHOUT_NIS= "
+ use pam || mymakeopts="${mymakeopts} WITHOUT_PAM_SUPPORT= "
+ use ssl || mymakeopts="${mymakeopts} WITHOUT_OPENSSL= "
+ use usb || mymakeopts="${mymakeopts} WITHOUT_USB= "
+ use floppy || mymakeopts="${mymakeopts} WITHOUT_FLOPPY= "
+ use kerberos || mymakeopts="${mymakeopts} WITHOUT_GSSAPI= "
+
+ mymakeopts="${mymakeopts} WITHOUT_BIND_NAMED= WITHOUT_BIND_DNSSEC= WITHOUT_PF= WITHOUT_LPR= WITHOUT_SENDMAIL= WITHOUT_AUTHPF= WITHOUT_MAILWRAPPER= "
+
+ append-flags $(test-flags -fno-strict-aliasing)
+}
+
+PATCHES=(
+ "${FILESDIR}/${PN}-adduser.patch"
+ "${FILESDIR}/${PN}-9.0-newsyslog.patch"
+ "${FILESDIR}/${PN}-9.1-bsdxml2expat.patch"
+ "${FILESDIR}/${PN}-9.1-kldxref.patch"
+ )
+
+REMOVE_SUBDIRS="
+ named named-checkzone named-checkconf rndc rndc-confgen
+ dnssec-keygen dnssec-signzone
+ tcpdchk tcpdmatch
+ sendmail praliases editmap mailstats makemap
+ sysinstall cron mailwrapper ntp bsnmpd
+ tcpdump ndp inetd
+ wpa/wpa_supplicant wpa/hostapd wpa/hostapd_cli wpa/wpa_cli wpa/wpa_passphrase
+ zic amd
+ pkg pkg_install freebsd-update service"
+
+src_prepare() {
+ if ! use build; then
+ ln -s "/usr/src/sys-${RV}" "${WORKDIR}/sys"
+ ln -s "/usr/include" "${WORKDIR}/include"
+ else
+ dummy_mk mount_smbfs
+ fi
+ # Don't install mtree format manpage
+ # it's installed by libarchive.
+ sed -e "s: mtree.5::g" -i "${S}"/mtree/Makefile
+}
+
+src_install() {
+ # By creating these directories we avoid having to do a
+ # more complex hack
+ dodir /usr/share/doc
+ dodir /sbin
+ dodir /usr/libexec
+ dodir /usr/bin
+
+ # FILESDIR is used by some makefiles which will install files
+ # in the wrong place, just put it in the doc directory.
+ mkinstall DOCDIR=/usr/share/doc/${PF} || die "Install failed"
+
+ # Most of these now come from openrc.
+ for util in nfs rpc.statd rpc.lockd; do
+ newinitd "${FILESDIR}/"${util}.initd ${util} || die
+ if [[ -e "${FILESDIR}"/${util}.confd ]]; then \
+ newconfd "${FILESDIR}"/${util}.confd ${util} || die
+ fi
+ done
+
+ for class in daily monthly weekly; do
+ cat - > "${T}/periodic.${class}" <<EOS
+#!/bin/sh
+/usr/sbin/periodic ${class}
+EOS
+ exeinto /etc/cron.${class}
+ newexe "${T}/periodic.${class}" periodic
+ done
+
+ # Install the pw.conf file to let pw use Gentoo's skel location
+ insinto /etc
+ doins "${FILESDIR}/pw.conf" || die
+
+ cd "${WORKDIR}/etc"
+ doins apmd.conf syslog.conf newsyslog.conf nscd.conf || die
+
+ insinto /etc/ppp
+ doins ppp/ppp.conf || die
+
+ if use bluetooth; then
+ insinto /etc/bluetooth
+ doins bluetooth/* || die
+ rm -f "${D}"/etc/bluetooth/Makefile
+ fi
+
+ # Install the periodic stuff (needs probably to be ported in a more
+ # gentooish way)
+ cd "${WORKDIR}/etc/periodic"
+
+ doperiodic daily daily/*.accounting
+ doperiodic monthly monthly/*.accounting
+}
+
+pkg_postinst() {
+ # We need to run pwd_mkdb if key files are not present
+ # If they are, then there is no need to run pwd_mkdb
+ if [[ ! -e "${ROOT}etc/passwd" || ! -e "${ROOT}etc/pwd.db" || ! -e "${ROOT}etc/spwd.db" ]] ; then
+ if [[ -e "${ROOT}etc/master.passwd" ]] ; then
+ einfo "Generating passwd files from ${ROOT}etc/master.passwd"
+ "${ROOT}"usr/sbin/pwd_mkdb -p -d "${ROOT}etc" "${ROOT}etc/master.passwd"
+ else
+ eerror "${ROOT}etc/master.passwd does not exist!"
+ eerror "You will no be able to log into your system!"
+ fi
+ fi
+
+ for logfile in messages security auth.log maillog lpd-errs xferlog cron \
+ debug.log slip.log ppp.log; do
+ [[ -f "${ROOT}/var/log/${logfile}" ]] || touch "${ROOT}/var/log/${logfile}"
+ done
+}
diff --git a/sys-freebsd/freebsd-usbin/metadata.xml b/sys-freebsd/freebsd-usbin/metadata.xml
new file mode 100644
index 000000000000..45c930b831cb
--- /dev/null
+++ b/sys-freebsd/freebsd-usbin/metadata.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>bsd@gentoo.org</email>
+ <name>BSD Project</name>
+ </maintainer>
+ <use>
+ <flag name="floppy">Enable floppy disk utilities (fdcontrol, fdformat, fdread, fdwrite).</flag>
+ <flag name="audit">
+ Build auditing tools.
+ </flag>
+ <flag name="netware">
+ Build libraries and tools to work with NetWare protocols (IPX
+ and NCP).
+ </flag>
+ <flag name='zfs'>Enable ZFS support.</flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-freebsd/metadata.xml b/sys-freebsd/metadata.xml
new file mode 100644
index 000000000000..f03a55473120
--- /dev/null
+++ b/sys-freebsd/metadata.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE catmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<catmetadata>
+ <longdescription lang="en">
+ Ebuilds for the Gentoo/FreeBSD base system software.
+ </longdescription>
+ <longdescription lang="it">
+ Ebuild per il software di sistema base di Gentoo/FreeBSD.
+ </longdescription>
+ <longdescription lang="es">
+ Ebuilds para el software base del sistema Gentoo/FreeBSD.
+ </longdescription>
+</catmetadata>
+
diff --git a/sys-freebsd/ubin-wrappers/Manifest b/sys-freebsd/ubin-wrappers/Manifest
new file mode 100644
index 000000000000..56d8b55df991
--- /dev/null
+++ b/sys-freebsd/ubin-wrappers/Manifest
@@ -0,0 +1,4 @@
+EBUILD ubin-wrappers-0.ebuild 781 SHA256 3194f775c3b2b185e7009e944dac21f2dfd1e4cf8bfd10f31fdb8b40d4d66f48 SHA512 a438b6e683273b7f832e2e2cf41ad644cf4a5006ea493886e46b3008a3e158372c179d8836b54f1d258a5562157b774098e5a4758f107f48af1c97b597d7411f WHIRLPOOL bb5fed192e10fcaf406f093405de1555f84e5f39e6c4e6b9261707c161c91542287d75dc18c2b6c7e8c0fa302c95e09e42bd8493077d41f8644a23049dda490d
+MISC ChangeLog 2215 SHA256 8292b9417f30596a6fc23a35bac0d6fee646b1cd0e476b53180d5e2c06ab1bd0 SHA512 667b3292dce8f1ac2cb9854656e8f96817f017b9c81e4523b44c2504166337b19a4dd6847cedc018494a15781858bee583b83536077fb9ad335f379f891d98a0 WHIRLPOOL 37a9e920d1f6500acc6f7494963197b68ae2d5b2cd9313c1c55d73eb9feda4d7d329974b972f82a4d3a0266891095f8f8f28d624db6fee4624a01af6228ce2fd
+MISC ChangeLog-2015 740 SHA256 7b6bc7e69e64037e55a4142db3ad2af4d22de27be7103cd359a5f841435358f3 SHA512 b484591639d7bced237e5e30ba665c26ebbcd091a03da0aa2baa1190b0156d5f634908bb9b4ddb52faffb9cfe07a32d73ef174ef2b964853634ebc03c384fb5e WHIRLPOOL 91c24cc24bbca8a0d7fdea5239541756d2c9c93a07265dfe3c14ed6d01a920b1b1240e16b072fafd5f33cb18cb0639c81037650657af6a1a703d57b34dd1bec8
+MISC metadata.xml 242 SHA256 4fee4ee5d638742311a933b0a4379778e28dbb80bed349a39182d016c4c7ddad SHA512 b854e91958adbf3787c2f322ff793e9a7e1881eed7018e83935a99a6a68db80996eb87786d5162c8d66460801f601bc477071baa4010152abff68668e36047d3 WHIRLPOOL 3f964504553fe43c3fde93a0465fab6839207539a9868c4247a9602c6d8cd042dcc7859130f57d1558eeb907353824115ed116c22ca936eb7479f66b1023f10a
diff --git a/sys-freebsd/ubin-wrappers/metadata.xml b/sys-freebsd/ubin-wrappers/metadata.xml
new file mode 100644
index 000000000000..3aa6e83a4933
--- /dev/null
+++ b/sys-freebsd/ubin-wrappers/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>ryao@gentoo.org</email>
+ <name>Richard Yao</name>
+ </maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/ubin-wrappers/ubin-wrappers-0.ebuild b/sys-freebsd/ubin-wrappers/ubin-wrappers-0.ebuild
new file mode 100644
index 000000000000..ad8aabbca3e8
--- /dev/null
+++ b/sys-freebsd/ubin-wrappers/ubin-wrappers-0.ebuild
@@ -0,0 +1,36 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+DESCRIPTION="/usr/bin wrapper scripts for FreeBSD script compatibility"
+HOMEPAGE="https://www.gentoo.org"
+SRC_URI=""
+
+LICENSE="public-domain"
+SLOT="0"
+KEYWORDS="~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+IUSE="userland_BSD userland_GNU"
+
+DEPEND=""
+RDEPEND="${DEPEND}"
+
+S="${WORKDIR}"
+
+dowrap() {
+ local x
+ for x do
+ [[ -e ${x} ]] || die "${x} does not exist"
+ newbin - "$(basename "${x}")" <<-EOF
+ #!/bin/sh
+ exec ${x} \${1:+"\$@"}
+ EOF
+ done
+}
+
+src_install() {
+ dowrap \
+ "${EPREFIX}"/bin/{bunzip2,bzcat,cpio,egrep,fgrep,grep,gunzip,gzip,zcat}
+ use userland_BSD && dowrap "${EPREFIX}"/bin/sort
+ use userland_GNU && dowrap "${EPREFIX}"/bin/{fuser,sed,uncompress}
+}
diff --git a/sys-freebsd/virtio-kmod/Manifest b/sys-freebsd/virtio-kmod/Manifest
new file mode 100644
index 000000000000..b82981969791
--- /dev/null
+++ b/sys-freebsd/virtio-kmod/Manifest
@@ -0,0 +1,6 @@
+AUX pkg-message 684 SHA256 06f89ecca2745a367c883e8e92af10097717807b5bcde619d5e3c3e39a372dae SHA512 9a72e268012d85e712aaab647a7b1a0ece4fbaa8eb63169def42cc313363f7a0a67dcf9ea7db2363bf4891192b309ead2db10da696d571db1032bd812a5cfa14 WHIRLPOOL f79cb223314b1f044cde3049f993d5da642eb3d458e65c15aa36958a7927723ae3f010afd18c6a845e1bd356e4700d0e3c22181292b48cf081fb3fed94602620
+DIST virtio-0.228301.tar.gz 47262 SHA256 022b05ce98a88096aacc331fb7ba122d935432a87100fcba6a3b3d7e9e9aa0d6 SHA512 675b2fbb13be4e77597c8221a10aa8a87f53f642882cd7534f76f9928452bcd0f914acbbe70a43d1550caa148b8944e6587481d2a599bcccaf3a4486dc69016e WHIRLPOOL af7535a04d01f7925942c986e8f306f387af48cf06cf7efffd43e9cf19e566135b6d6f96a90b9a1d505f2c6ca534ffaf360e3304372c56eadc248c917af6b40b
+EBUILD virtio-kmod-0.228301-r1.ebuild 1589 SHA256 4d9c67e2b0e1f85677a678933fcdaf1f0894fcbff315c97180ee030e33557010 SHA512 11e60dc7cd6dec65a669627dce07898712828bf9b67946f929f2a985e54c8cf9fcf415ecd621477befa975c1711541571462561a049e1e6d626d1f0f7d6eaaa7 WHIRLPOOL bba3cd1e45f3b23c19b73368a9b57b368cb467e2d9f6273987e4f567293b67c2ce923a50c0b28de03a98d6494b76f0ea48414b66a4dcfe11bd45b7881f34c61f
+MISC ChangeLog 2223 SHA256 f58ef1359498084d049ce727974c7bc5bbe966fb02bc49ffc0732d19aed4b686 SHA512 e9ff9f5fc2797bc769a52880d460e38cb59f67f14e6702cb2020c27914c20ecfe5791d8879f4c57e87361cc3ef3f22c40eda06c380873d5a93d70fd837731882 WHIRLPOOL 3c491bb5ebac3cc28274ddb360f59b58a60ec5f2a1f6b04d2a065b8df9439adab228ec230680ea39f11f48054d826609821accfab0900c558353b7f7b28d640b
+MISC ChangeLog-2015 813 SHA256 5b76a9c1e271c991efdefb1098a9a40baa06a6f26bd2f160e1729557ec42efbd SHA512 f9425fc8c78c5a3fd8fca75984cdae3379c2672ae3257c0f89b50a24340d6d188a5b51d19a269cd20683dfa21d6731840631758784e2f469229b32b044a22274 WHIRLPOOL 62de9b4664bd7cfb8c1ff6ca667dc64f49ad773e1a6bdd40e632b7ebc4be86b0e84eb729928cd5af08928ba6716bdb3ca1f797d9e696b30a71f76a9ba4d52910
+MISC metadata.xml 242 SHA256 4fee4ee5d638742311a933b0a4379778e28dbb80bed349a39182d016c4c7ddad SHA512 b854e91958adbf3787c2f322ff793e9a7e1881eed7018e83935a99a6a68db80996eb87786d5162c8d66460801f601bc477071baa4010152abff68668e36047d3 WHIRLPOOL 3f964504553fe43c3fde93a0465fab6839207539a9868c4247a9602c6d8cd042dcc7859130f57d1558eeb907353824115ed116c22ca936eb7479f66b1023f10a
diff --git a/sys-freebsd/virtio-kmod/files/pkg-message b/sys-freebsd/virtio-kmod/files/pkg-message
new file mode 100644
index 000000000000..6b628d3de91a
--- /dev/null
+++ b/sys-freebsd/virtio-kmod/files/pkg-message
@@ -0,0 +1,22 @@
+To use these modules, add loading lines in /boot/loader.conf:
+
+virtio_load="YES"
+virtio_pci_load="YES"
+virtio_blk_load="YES"
+if_vtnet_load="YES"
+virtio_balloon_load="YES"
+
+Also, edit fstab and make openrc start vtnet0 instead of em0:
+
+# sed -i.bak -Ee 's|/dev/ada?|/dev/vtbd|' /etc/fstab
+# mv /etc/init.d/em0 /etc/init.d/vtnet0
+
+and enable virtio devices in host's domain.xml:
+
+- <target dev='hda' bus='ide'/>
++ <target dev='vda' bus='virtio'/>
+...
+- <model type='e1000'/>
+- <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
++ <model type='virtio'/>
++ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
diff --git a/sys-freebsd/virtio-kmod/metadata.xml b/sys-freebsd/virtio-kmod/metadata.xml
new file mode 100644
index 000000000000..3aa6e83a4933
--- /dev/null
+++ b/sys-freebsd/virtio-kmod/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>ryao@gentoo.org</email>
+ <name>Richard Yao</name>
+ </maintainer>
+</pkgmetadata>
diff --git a/sys-freebsd/virtio-kmod/virtio-kmod-0.228301-r1.ebuild b/sys-freebsd/virtio-kmod/virtio-kmod-0.228301-r1.ebuild
new file mode 100644
index 000000000000..841048382ed4
--- /dev/null
+++ b/sys-freebsd/virtio-kmod/virtio-kmod-0.228301-r1.ebuild
@@ -0,0 +1,70 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=4
+
+inherit bsdmk flag-o-matic
+
+DESCRIPTION="Virtio drivers from FreeBSD Ports' emulators/virtio-kmod"
+HOMEPAGE="http://www.freshports.org/emulators/virtio-kmod/"
+SRC_URI="mirror://freebsd/ports/local-distfiles/kuriyama/virtio-${PV}.tar.gz"
+
+SLOT="0"
+KEYWORDS="~x86-fbsd ~amd64-fbsd"
+IUSE="custom-cflags +debug"
+LICENSE="BSD-2"
+
+DEPEND=">=sys-freebsd/freebsd-sources-8.2
+ app-arch/cpio"
+RDEPEND=""
+
+QA_TEXTRELS="*"
+RESTRICT="strip"
+S="${WORKDIR}"
+
+NEEDSUBDIRS="conf contrib dev/pci geom kern net netinet netinet6 sys tools vm
+ x86 i386 amd64"
+
+src_unpack() {
+ default
+ CPIO_ARGS="-dump"
+
+ # When hardlinks are possible, use them to avoid copies when FEATURES=userpriv
+ test $UID != 0 && export CPIO_ARGS+=l
+
+ cd /usr/src/sys/
+ for d in $NEEDSUBDIRS; do
+ find $d ! -name @ | cpio --quiet "${CPIO_ARGS}" "${WORKDIR}"
+ done
+
+}
+
+src_compile() {
+
+ use debug && export DEBUG_FLAGS="-g"
+ use custom-cflags || strip-flags
+ append-cflags "-I${WORKDIR}"
+
+ cd "${WORKDIR}/modules/virtio"
+ mkmake SYSDIR="${WORKDIR}" LDFLAGS="$(raw-ldflags)" || die "mkmake failed"
+
+}
+
+src_install() {
+ # Upstream does not provide an install target
+ dodir /boot/modules
+ cp "${WORKDIR}"/modules/virtio/*/*.ko{,.symbols} "${ED}/boot/modules"
+}
+
+pkg_postinst() {
+ # Update linker.hints file
+ /usr/sbin/kldxref "${EPREFIX}/boot/modules"
+
+ # Print message from FreeBSD Ports
+ elog "$(cat "${FILESDIR}/pkg-message")"
+}
+
+pkg_postrm() {
+ # Update linker.hints file
+ /usr/sbin/kldxref "${EPREFIX}/boot/modules"
+}