Skip to content
Browse files

- Welcome to FreeBSD in packages.

  • Loading branch information...
0 parents commit 7cb288ec6eb5fe3478157965d6ea7a75512bc3fa @z0nt committed
Showing with 520 additions and 0 deletions.
  1. +8 −0 README.md
  2. +176 −0 builder
  3. +9 −0 defaults.conf
  4. +147 −0 freebsd-base.conf
  5. +16 −0 freebsd-kernel-symbols.conf
  6. +18 −0 freebsd-kernel.conf
  7. +32 −0 freebsd-lib32.conf
  8. +16 −0 freebsd-rescue.conf
  9. +16 −0 freebsd-zoneinfo.conf
  10. +82 −0 helper
8 README.md
@@ -0,0 +1,8 @@
+FreeBSD in packages
+===================
+
+To build and put world in packages run the following:
+./builder -r /repo world
+
+To build and put kernel in packages run the following:
+./builder -r /repo -k /sys/amd64/conf/GENERIC kernel
176 builder
@@ -0,0 +1,176 @@
+#!/bin/sh
+#
+
+umask 0022
+
+pre()
+{
+
+ workdir="`mktemp -d -t builder`" || exit 1
+ mount -o size=$((1<<30)) -t tmpfs tmpfs $workdir
+}
+
+post()
+{
+
+ umount $workdir || true
+ rmdir $workdir
+}
+
+mk_kernel()
+{
+ local _conf
+
+ make -s -C $src -j $jobs buildkernel KERNCONF=$kernconf KERNCONFDIR=$kernconfdir
+ make -s -C $src installkernel KERNCONF=$kernconf KERNCONFDIR=$kernconfdir DESTDIR=$workdir
+
+ for _conf in $conf; do
+ $pkgdir/helper $pkgdir/${_conf} $workdir $repo
+ done
+}
+
+mk_rescue()
+{
+ local _conf
+
+ make -s -C $src/rescue
+ make -s -C $src hierarchy DESTDIR=$workdir > /dev/null
+ make -s -C $src/rescue install DESTDIR=$workdir
+ make -s -C $src/rescue clean
+ make -s -C $src/rescue cleandepend
+
+ cp /usr/local/sbin/pkg-static $workdir/rescue/pkg
+
+ for _conf in $conf; do
+ $pkgdir/helper $pkgdir/${_conf} $workdir $repo
+ done
+}
+
+mk_world()
+{
+ local _conf
+
+ make -s -C $src -j $jobs buildworld
+ make -s -C $src installworld DESTDIR=$workdir
+ make -s -C $src distribution DESTDIR=$workdir
+
+ cp $workdir/etc/master.passwd $workdir/usr/share/examples/etc
+ cp /usr/local/sbin/pkg-static $workdir/rescue/pkg
+
+ for _conf in $conf; do
+ $pkgdir/helper $pkgdir/${_conf} $workdir $repo
+ done
+}
+
+mk_zoneinfo()
+{
+ local _conf
+
+ make -s -C $src/share/zoneinfo
+ make -s -C $src hierarchy DESTDIR=$workdir > /dev/null
+ make -s -C $src/share/zoneinfo install DESTDIR=$workdir
+ make -s -C $src/share/zoneinfo clean
+
+ for _conf in $conf; do
+ $pkgdir/helper $pkgdir/${_conf} $workdir $repo
+ done
+}
+
+usage()
+{
+
+ echo 1>&2 "usage: buidler [options] <kernel|rescue|world|zoneinfo>"
+ echo 1>&2 ""
+ echo 1>&2 " Options:"
+ echo 1>&2 " -c path List of configuration files"
+ echo 1>&2 " -j num Number of parallel jobs (default: number of CPUs)"
+ echo 1>&2 " -k path Path to kernel configuration file"
+ echo 1>&2 " -r path Path to pkgng repo"
+ echo 1>&2 " -s path Alternate path to src (default: /usr/src)"
+ echo 1>&2 ""
+
+ exit 1
+}
+
+if [ $# -lt 1 ]; then
+ usage
+fi
+
+kernel_conf="freebsd-kernel.conf freebsd-kernel-symbols.conf"
+rescue_conf="freebsd-rescue.conf"
+world_conf="freebsd-base.conf freebsd-lib32.conf freebsd-rescue.conf freebsd-zoneinfo.conf"
+zoneinfo_conf="freebsd-zoneinfo.conf"
+
+jobs="`sysctl -n hw.ncpu`"
+src="/usr/src"
+
+pkgdir="`dirname $0`" # XXX
+
+while getopts "c:j:hk:r:s:" opt; do
+ case "$opt" in
+ c) conf="$OPTARG" ;;
+ j) jobs="$OPTARG" ;;
+ k) kernconf="$OPTARG" ;;
+ r) repo="$OPTARG" ;;
+ s) src="$OPTARG" ;;
+ *) usage ;;
+ esac
+
+ shift $(($OPTIND - 1))
+done
+
+if [ $# -ne 1 ]; then
+ usage
+fi
+
+target="$1"
+
+if [ "$target" = "kernel" -a -z "${kernconf:-}" ]; then
+ echo 1>&2 "Please specify kernel config file"
+ exit 1
+fi
+
+if [ -z "${repo:-}" ]; then
+ echo 1>&2 "Please specify repo directory"
+ exit 1
+fi
+
+repo="`realpath $repo`"
+
+if [ ! -d "$repo" -o ! -d "$repo/All" ]; then
+ echo 1>&2 "Please create \"$repo\" and \"$repo/All\""
+ exit 1
+fi
+
+set -eux
+
+trap "post" EXIT
+trap "exit 0" SIGINT
+pre
+
+case "$target" in
+kernel)
+ kernconf="`realpath $kernconf`"
+ kernconfdir="`dirname $kernconf`"
+ kernconf="`basename $kernconf`"
+ : ${conf:=$kernel_conf}
+ mk_kernel
+ ;;
+rescue)
+ : ${conf:=$rescue_conf}
+ mk_rescue
+ ;;
+world)
+ : ${conf:=$world_conf}
+ mk_world
+ ;;
+zoneinfo)
+ : ${conf:=$zoneinfo_conf}
+ mk_zoneinfo
+ ;;
+*)
+ usage
+ ;;
+esac
+
+pkg repo $repo
9 defaults.conf
@@ -0,0 +1,9 @@
+#
+
+www="http://www.freebsd.org/"
+maintainer="andrey@zonov.org"
+prefix="/"
+arch="freebsd:9:x86:64"
+licenses="BSD"
+licenselogic="single"
+categories="local"
147 freebsd-base.conf
@@ -0,0 +1,147 @@
+#
+
+. defaults.conf
+
+_fakeroot="$fakeroot"
+
+exclude_files_kernel="/boot/kernel/.*"
+exclude_files_lib32="/libexec/ld-elf32.so.1|\
+/usr/bin/ldd32|\
+/usr/lib32/.*|\
+/usr/libexec/ld-elf32.so.1"
+exclude_files_pkg_install="/usr/sbin/pkg_.*|\
+/usr/share/man/man1/pkg_.*"
+exclude_files_rescue="/rescue/.*"
+exclude_files_zoneinfo="/usr/share/zoneinfo/.*"
+
+exclude_files="^${_fakeroot}(\
+${exclude_files_kernel}|\
+${exclude_files_lib32}|\
+${exclude_files_pkg_install}|\
+${exclude_files_rescue}|\
+${exclude_files_zoneinfo}|\
+/etc/[^/]*|\
+/etc/mail/aliases|\
+/etc/pam.d/sshd|\
+/etc/ssh/ssh_config|\
+/etc/ssh/sshd_config|\
+/var/db/locate.database|\
+/var/log/sendmail.st|\
+/var/named/etc/namedb/named.conf\
+)"
+
+exclude_dirs_kernel="/boot/kernel"
+exclude_dirs_lib32="/usr/lib32|\
+/usr/lib32/.*"
+exclude_dirs_rescue="/rescue"
+exclude_dirs_zoneinfo="/usr/share/zoneinfo|\
+/usr/share/zoneinfo/.*"
+
+exclude_dirs="^${_fakeroot}(\
+${exclude_dirs_kernel}|\
+${exclude_dirs_lib32}|\
+${exclude_dirs_rescue}|\
+${exclude_dirs_zoneinfo}|\
+/dev|\
+/proc|\
+/var|\
+/var/tmp|\
+/var/tmp/vi.recover\
+)"
+
+find_files="find -E ${_fakeroot} \( -type f -or -type l \) -and -not -regex \"$exclude_files\""
+find_dirs="find -E ${_fakeroot} -type d -and -not -regex \"$exclude_dirs\""
+find_size="find -E ${_fakeroot} \( -type f -or -type l \) -and -not -regex \"$exclude_files\" -exec stat -f %z {} \+"
+
+name="freebsd-base"
+version="9.0"
+origin="local/freebsd-base"
+comment="FreeBSD base"
+desc="|-
+ FreeBSD base"
+scripts="pre-install: |-
+ chflags noschg /bin/rcp /lib/libc.so.7 /lib/libcrypt.so.5 /lib/libthr.so.3 /libexec/ld-elf.so.1 /sbin/init /usr/bin/chfn /usr/bin/chpass /usr/bin/chsh /usr/bin/crontab /usr/bin/login /usr/bin/opieinfo /usr/bin/opiepasswd /usr/bin/passwd /usr/bin/rlogin /usr/bin/rsh /usr/bin/su /usr/bin/ypchfn /usr/bin/ypchpass /usr/bin/ypchsh /usr/bin/yppasswd /usr/lib/librt.so.1 /var/empty/ 2> /dev/null
+ for src in /usr/share/examples/etc/*; do
+ dst=\${src#/usr/share/examples}
+ case \$dst in
+ /etc/README.examples|/etc/bsd-style-copyright|/etc/make.conf|/etc/wpa_supplicant.conf)
+ continue
+ ;;
+ esac
+ if [ -f \$src -a -f \$dst ]; then
+ if cmp -s \$src \$dst; then
+ rm -f \$dst
+ case \$dst in
+ /etc/login.conf)
+ rm -f /etc/login.conf.db
+ ;;
+ /etc/master.passwd)
+ rm -f /etc/passwd /etc/pwd.db /etc/spwd.db
+ ;;
+ esac
+ fi
+ fi
+ done
+ post-install: |-
+ for d in /dev /proc; do
+ [ ! -d \$d/ ] && mkdir -m 0555 -p \$d/
+ done
+ for d in /var; do
+ [ ! -d \$d/ ] && mkdir -m 0755 -p \$d/
+ done
+ for d in /var/tmp /var/tmp/vi.recover; do
+ [ ! -d \$d/ ] && mkdir -m 1777 -p \$d/
+ done
+ for src in /usr/share/examples/etc/*; do
+ dst=\${src#/usr/share/examples}
+ case \$dst in
+ /etc/README.examples|/etc/bsd-style-copyright|/etc/make.conf|/etc/motd|/etc/wpa_supplicant.conf)
+ continue
+ ;;
+ esac
+ if [ -f \$src -a ! -f \$dst ]; then
+ install -o 0 -g 0 -m0644 \$src \$dst
+ case \$dst in
+ /etc/netstart|/etc/pccard_ether|/etc/rc.suspend|/etc/rc.resume)
+ chmod 0755 \$dst
+ ;;
+ /etc/login.conf)
+ cap_mkdb /etc/login.conf
+ ;;
+ /etc/master.passwd)
+ pwd_mkdb -p /etc/master.passwd
+ ;;
+ esac
+ fi
+ done
+ install -o root -g wheel -m 0644 -b /usr/share/examples/etc/motd /etc/motd && sed -e '5,\$d' -i '' /etc/motd
+ [ ! -L /etc/aliases ] && ln -sf mail/aliases /etc/aliases || true
+ [ ! -f /etc/dumpdates ] && install -o root -g operator -m 0664 /dev/null /etc/dumpdates
+ [ ! -L /etc/namedb ] && ln -sf ../var/named/etc/namedb /etc/namedb || true
+ [ ! -L /etc/rmt ] && ln -sf /usr/sbin/rmt /etc/rmt || true
+ [ ! -L /etc/termcap ] && ln -sf /usr/share/misc/termcap /etc/termcap || true
+ [ ! -f /var/log/sendmail.st ] && install -o root -g wheel -m 0640 /dev/null /var/log/sendmail.st
+ [ ! -f /var/db/locate.database ] && install -o nobody -g wheel -m 0644 /dev/null /var/db/locate.database
+ pre-deinstall: |-
+ chflags noschg /bin/rcp /lib/libc.so.7 /lib/libcrypt.so.5 /lib/libthr.so.3 /libexec/ld-elf.so.1 /sbin/init /usr/bin/chfn /usr/bin/chpass /usr/bin/chsh /usr/bin/crontab /usr/bin/login /usr/bin/opieinfo /usr/bin/opiepasswd /usr/bin/passwd /usr/bin/rlogin /usr/bin/rsh /usr/bin/su /usr/bin/ypchfn /usr/bin/ypchpass /usr/bin/ypchsh /usr/bin/yppasswd /usr/lib/librt.so.1 /var/empty/
+ for src in /usr/share/examples/etc/*; do
+ dst=\${src#/usr/share/examples}
+ case \$dst in
+ /etc/README.examples|/etc/bsd-style-copyright|/etc/make.conf|/etc/wpa_supplicant.conf)
+ continue
+ ;;
+ esac
+ if [ -f \$src -a -f \$dst ]; then
+ if cmp -s \$src \$dst; then
+ rm -f \$dst
+ case \$dst in
+ /etc/login.conf)
+ rm -f /etc/login.conf.db
+ ;;
+ /etc/master.passwd)
+ rm -f /etc/passwd /etc/pwd.db /etc/spwd.db
+ ;;
+ esac
+ fi
+ fi
+ done"
16 freebsd-kernel-symbols.conf
@@ -0,0 +1,16 @@
+#
+
+. defaults.conf
+
+_fakeroot="$fakeroot"
+
+find_files="find ${_fakeroot}/boot/kernel -type f -and -name \"*.symbols\""
+find_dirs="find ${_fakeroot}/boot/kernel -type d"
+find_size="find ${_fakeroot}/boot/kernel -type f -and -name \"*.symbols\" -exec stat -f %z {} \+"
+
+name="freebsd-kernel-symbols"
+version="9.0"
+origin="local/freebsd-kernel-symbols"
+comment="FreeBSD kernel GDB symbols"
+desc="|-
+ FreeBSD kernel GDB symbols"
18 freebsd-kernel.conf
@@ -0,0 +1,18 @@
+#
+
+. defaults.conf
+
+_fakeroot="$fakeroot"
+
+find_files="find ${_fakeroot}/boot/kernel -type f -and -name kernel -or -name \"*.ko\""
+find_dirs="find ${_fakeroot}/boot/kernel -type d"
+find_size="find ${_fakeroot}/boot/kernel -type f -and -name kernel -or -name \"*.ko\" -exec stat -f %z {} \+"
+
+name="freebsd-kernel"
+version="9.0"
+origin="local/freebsd-kernel"
+comment="FreeBSD kernel"
+desc="|-
+ FreeBSD kernel"
+scripts="post-install: |-
+ kldxref /boot/kernel"
32 freebsd-lib32.conf
@@ -0,0 +1,32 @@
+#
+
+. defaults.conf
+
+_fakeroot="$fakeroot"
+
+include_files="^${_fakeroot}(\
+/libexec/ld-elf32.so.1|\
+/usr/bin/ldd32|\
+/usr/lib32/.*|\
+/usr/libexec/ld-elf32.so.1\
+)"
+
+include_dirs="^${_fakeroot}(\
+/usr/lib32|\
+/usr/lib32/.*\
+)"
+
+find_files="find -E ${_fakeroot} \( -type f -or -type l \) -and -regex \"$include_files\""
+find_dirs="find -E ${_fakeroot} -type d -and -regex \"$include_dirs\""
+find_size="find -E ${_fakeroot} \( -type f -or -type l \) -and -regex \"$include_files\" -exec stat -f %z {} \+"
+
+name="freebsd-lib32"
+version="9.0"
+origin="local/freebsd-lib32"
+comment="FreeBSD lib32"
+desc="|-
+ FreeBSD lib32"
+scripts="pre-install: |-
+ chflags noschg /libexec/ld-elf32.so.1 /usr/lib32/libc.so.7 /usr/lib32/libcrypt.so.5 /usr/lib32/librt.so.1 /usr/lib32/libthr.so.3 2> /dev/null
+ pre-deinstall: |-
+ chflags noschg /libexec/ld-elf32.so.1 /usr/lib32/libc.so.7 /usr/lib32/libcrypt.so.5 /usr/lib32/librt.so.1 /usr/lib32/libthr.so.3"
16 freebsd-rescue.conf
@@ -0,0 +1,16 @@
+#
+
+. defaults.conf
+
+_fakeroot="$fakeroot"
+
+find_files="find ${_fakeroot}/rescue -type f"
+find_dirs="find ${_fakeroot}/rescue -type d"
+find_size="find ${_fakeroot}/rescue -type f -and \( -name rescue -or -name pkg \) -exec stat -f %z {} \+"
+
+name="freebsd-rescue"
+version="9.0"
+origin="local/freebsd-rescue"
+comment="FreeBSD rescue"
+desc="|-
+ FreeBSD rescue"
16 freebsd-zoneinfo.conf
@@ -0,0 +1,16 @@
+#
+
+. defaults.conf
+
+_fakeroot="$fakeroot"
+
+find_files="find ${_fakeroot}/usr/share/zoneinfo -type f"
+find_dirs="find ${_fakeroot}/usr/share/zoneinfo -type d"
+find_size="find ${_fakeroot}/usr/share/zoneinfo -type f -exec stat -f %z {} \+"
+
+name="freebsd-zoneinfo"
+version="2012.a"
+origin="local/freebsd-zoneinfo"
+comment="FreeBSD zoneinfo"
+desc="|-
+ FreeBSD zoneinfo"
82 helper
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+
+set -eu
+
+if [ $# -ne 3 ]; then
+ echo "usage: helper conf workdir repo"
+ exit 1
+fi
+
+conf="$1"
+fakeroot="$2"
+repo="$3"
+
+. $conf
+
+set_files()
+{
+ local _files _file
+
+ _files=`eval $find_files`
+ for _file in ${_files}; do
+ files="${files:-}${files:+
+} ${_file#$fakeroot}: '-'"
+ done
+}
+
+set_dirs()
+{
+ local _dirs _dir
+
+ _dirs=`eval $find_dirs`
+ for _dir in ${_dirs}; do
+ if [ "${_dir}" = "$fakeroot" ]; then
+ continue
+ fi
+ dirs="${dirs:-}${dirs:+
+} ${_dir#$fakeroot}/: y"
+ done
+}
+
+
+set_flatsize()
+{
+
+ flatsize=`eval $find_size | awk 'BEGIN {s=0} {s+=$1} END {print s}'`
+}
+
+set_files
+set_dirs
+set_flatsize
+
+pkgroot="`mktemp -d $fakeroot/pkg.XXXXX`"
+pkgdir="${pkgroot#$fakeroot}"
+
+echo "\
+name: $name
+version: $version
+origin: $origin
+comment: $comment
+arch: $arch
+www: $www
+maintainer: $maintainer
+prefix: $prefix
+licenselogic: $licenselogic
+licenses: [$licenses]
+flatsize: $flatsize
+desc: $desc
+categories: [$categories]
+files:
+$files
+directories:
+$dirs
+${scripts:+scripts:
+ }${scripts:-}
+" > $pkgroot/+MANIFEST
+
+trap "rm $pkgroot/+MANIFEST; rmdir $pkgroot" EXIT
+
+pkg -c $fakeroot create -m $pkgdir -o $pkgdir none
+
+mv $pkgroot/$name-$version.txz $repo/All

0 comments on commit 7cb288e

Please sign in to comment.
Something went wrong with that request. Please try again.