From e0558bb9903e1784e8ab01b0aeb92cca681351aa Mon Sep 17 00:00:00 2001 From: Julian Elischer Date: Wed, 1 Nov 2006 01:25:51 +0000 Subject: [PATCH] Reworking of how to add ports. submitted by: Jean Milanez Melo --- tools/tools/tinybsd/README | 8 ++- .../tinybsd/conf/bridge/tinybsd.localfiles | 6 -- tools/tools/tinybsd/conf/bridge/tinybsd.ports | 9 +++ .../tinybsd/conf/default/tinybsd.localfiles | 6 -- .../tools/tinybsd/conf/default/tinybsd.ports | 9 +++ .../tinybsd/conf/firewall/tinybsd.localfiles | 6 -- .../tools/tinybsd/conf/firewall/tinybsd.ports | 9 +++ .../tinybsd/conf/minimal/tinybsd.localfiles | 6 -- .../tools/tinybsd/conf/minimal/tinybsd.ports | 9 +++ .../tools/tinybsd/conf/vpn/tinybsd.localfiles | 6 -- tools/tools/tinybsd/conf/vpn/tinybsd.ports | 9 +++ .../tinybsd/conf/wireless/tinybsd.localfiles | 6 -- .../tools/tinybsd/conf/wireless/tinybsd.ports | 9 +++ .../tinybsd/conf/wrap/tinybsd.localfiles | 6 -- tools/tools/tinybsd/conf/wrap/tinybsd.ports | 9 +++ tools/tools/tinybsd/tinybsd | 68 ++++++++++++++++--- 16 files changed, 126 insertions(+), 55 deletions(-) delete mode 100644 tools/tools/tinybsd/conf/bridge/tinybsd.localfiles create mode 100644 tools/tools/tinybsd/conf/bridge/tinybsd.ports delete mode 100644 tools/tools/tinybsd/conf/default/tinybsd.localfiles create mode 100644 tools/tools/tinybsd/conf/default/tinybsd.ports delete mode 100644 tools/tools/tinybsd/conf/firewall/tinybsd.localfiles create mode 100644 tools/tools/tinybsd/conf/firewall/tinybsd.ports delete mode 100644 tools/tools/tinybsd/conf/minimal/tinybsd.localfiles create mode 100644 tools/tools/tinybsd/conf/minimal/tinybsd.ports delete mode 100644 tools/tools/tinybsd/conf/vpn/tinybsd.localfiles create mode 100644 tools/tools/tinybsd/conf/vpn/tinybsd.ports delete mode 100644 tools/tools/tinybsd/conf/wireless/tinybsd.localfiles create mode 100644 tools/tools/tinybsd/conf/wireless/tinybsd.ports delete mode 100644 tools/tools/tinybsd/conf/wrap/tinybsd.localfiles create mode 100644 tools/tools/tinybsd/conf/wrap/tinybsd.ports diff --git a/tools/tools/tinybsd/README b/tools/tools/tinybsd/README index df19e526d54b..eec7944663ff 100644 --- a/tools/tools/tinybsd/README +++ b/tools/tools/tinybsd/README @@ -69,9 +69,11 @@ usr/sbin/pw usr/sbin/pwd_mkdb usr/sbin/setkey -tinybsd.localfiles: Similar to tinybsd.basefiles but for /usr/local/. The -difference is that directories will have to be created by TinyBSD because -they are not handle by mtree(1). +tinybsd.ports: Here you can add the applications from the FreeBSD Ports Collection +which you want TinyBSD ports system to install in your embedded system. You whould +list one application per line, mentioning its category and name, like the examples: +www/mini_httpd +net-mgmt/rate etc/: This is the directory where you can put your custom /etc configuration. diff --git a/tools/tools/tinybsd/conf/bridge/tinybsd.localfiles b/tools/tools/tinybsd/conf/bridge/tinybsd.localfiles deleted file mode 100644 index 1ad7bdc11f24..000000000000 --- a/tools/tools/tinybsd/conf/bridge/tinybsd.localfiles +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ -# Add here your third-party applications that are already installed on /usr/local -# Make sure you have enough space to add it. -# Example: -# usr/local/sbin/httpd - diff --git a/tools/tools/tinybsd/conf/bridge/tinybsd.ports b/tools/tools/tinybsd/conf/bridge/tinybsd.ports new file mode 100644 index 000000000000..49bb52175241 --- /dev/null +++ b/tools/tools/tinybsd/conf/bridge/tinybsd.ports @@ -0,0 +1,9 @@ +# $FreeBSD$ +# Here you can add the applications from the FreeBSD Ports Collection which you +# want TinyBSD ports system to install in your embedded system. You whould list +# one application per line, mentioning its category and name, like the examples: +# +# www/mini_httpd +# net-mgmt/rate +# +# Make sure you have enough space to add it. diff --git a/tools/tools/tinybsd/conf/default/tinybsd.localfiles b/tools/tools/tinybsd/conf/default/tinybsd.localfiles deleted file mode 100644 index 1ad7bdc11f24..000000000000 --- a/tools/tools/tinybsd/conf/default/tinybsd.localfiles +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ -# Add here your third-party applications that are already installed on /usr/local -# Make sure you have enough space to add it. -# Example: -# usr/local/sbin/httpd - diff --git a/tools/tools/tinybsd/conf/default/tinybsd.ports b/tools/tools/tinybsd/conf/default/tinybsd.ports new file mode 100644 index 000000000000..49bb52175241 --- /dev/null +++ b/tools/tools/tinybsd/conf/default/tinybsd.ports @@ -0,0 +1,9 @@ +# $FreeBSD$ +# Here you can add the applications from the FreeBSD Ports Collection which you +# want TinyBSD ports system to install in your embedded system. You whould list +# one application per line, mentioning its category and name, like the examples: +# +# www/mini_httpd +# net-mgmt/rate +# +# Make sure you have enough space to add it. diff --git a/tools/tools/tinybsd/conf/firewall/tinybsd.localfiles b/tools/tools/tinybsd/conf/firewall/tinybsd.localfiles deleted file mode 100644 index 1ad7bdc11f24..000000000000 --- a/tools/tools/tinybsd/conf/firewall/tinybsd.localfiles +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ -# Add here your third-party applications that are already installed on /usr/local -# Make sure you have enough space to add it. -# Example: -# usr/local/sbin/httpd - diff --git a/tools/tools/tinybsd/conf/firewall/tinybsd.ports b/tools/tools/tinybsd/conf/firewall/tinybsd.ports new file mode 100644 index 000000000000..49bb52175241 --- /dev/null +++ b/tools/tools/tinybsd/conf/firewall/tinybsd.ports @@ -0,0 +1,9 @@ +# $FreeBSD$ +# Here you can add the applications from the FreeBSD Ports Collection which you +# want TinyBSD ports system to install in your embedded system. You whould list +# one application per line, mentioning its category and name, like the examples: +# +# www/mini_httpd +# net-mgmt/rate +# +# Make sure you have enough space to add it. diff --git a/tools/tools/tinybsd/conf/minimal/tinybsd.localfiles b/tools/tools/tinybsd/conf/minimal/tinybsd.localfiles deleted file mode 100644 index 1ad7bdc11f24..000000000000 --- a/tools/tools/tinybsd/conf/minimal/tinybsd.localfiles +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ -# Add here your third-party applications that are already installed on /usr/local -# Make sure you have enough space to add it. -# Example: -# usr/local/sbin/httpd - diff --git a/tools/tools/tinybsd/conf/minimal/tinybsd.ports b/tools/tools/tinybsd/conf/minimal/tinybsd.ports new file mode 100644 index 000000000000..49bb52175241 --- /dev/null +++ b/tools/tools/tinybsd/conf/minimal/tinybsd.ports @@ -0,0 +1,9 @@ +# $FreeBSD$ +# Here you can add the applications from the FreeBSD Ports Collection which you +# want TinyBSD ports system to install in your embedded system. You whould list +# one application per line, mentioning its category and name, like the examples: +# +# www/mini_httpd +# net-mgmt/rate +# +# Make sure you have enough space to add it. diff --git a/tools/tools/tinybsd/conf/vpn/tinybsd.localfiles b/tools/tools/tinybsd/conf/vpn/tinybsd.localfiles deleted file mode 100644 index 1ad7bdc11f24..000000000000 --- a/tools/tools/tinybsd/conf/vpn/tinybsd.localfiles +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ -# Add here your third-party applications that are already installed on /usr/local -# Make sure you have enough space to add it. -# Example: -# usr/local/sbin/httpd - diff --git a/tools/tools/tinybsd/conf/vpn/tinybsd.ports b/tools/tools/tinybsd/conf/vpn/tinybsd.ports new file mode 100644 index 000000000000..49bb52175241 --- /dev/null +++ b/tools/tools/tinybsd/conf/vpn/tinybsd.ports @@ -0,0 +1,9 @@ +# $FreeBSD$ +# Here you can add the applications from the FreeBSD Ports Collection which you +# want TinyBSD ports system to install in your embedded system. You whould list +# one application per line, mentioning its category and name, like the examples: +# +# www/mini_httpd +# net-mgmt/rate +# +# Make sure you have enough space to add it. diff --git a/tools/tools/tinybsd/conf/wireless/tinybsd.localfiles b/tools/tools/tinybsd/conf/wireless/tinybsd.localfiles deleted file mode 100644 index 1ad7bdc11f24..000000000000 --- a/tools/tools/tinybsd/conf/wireless/tinybsd.localfiles +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ -# Add here your third-party applications that are already installed on /usr/local -# Make sure you have enough space to add it. -# Example: -# usr/local/sbin/httpd - diff --git a/tools/tools/tinybsd/conf/wireless/tinybsd.ports b/tools/tools/tinybsd/conf/wireless/tinybsd.ports new file mode 100644 index 000000000000..49bb52175241 --- /dev/null +++ b/tools/tools/tinybsd/conf/wireless/tinybsd.ports @@ -0,0 +1,9 @@ +# $FreeBSD$ +# Here you can add the applications from the FreeBSD Ports Collection which you +# want TinyBSD ports system to install in your embedded system. You whould list +# one application per line, mentioning its category and name, like the examples: +# +# www/mini_httpd +# net-mgmt/rate +# +# Make sure you have enough space to add it. diff --git a/tools/tools/tinybsd/conf/wrap/tinybsd.localfiles b/tools/tools/tinybsd/conf/wrap/tinybsd.localfiles deleted file mode 100644 index 1ad7bdc11f24..000000000000 --- a/tools/tools/tinybsd/conf/wrap/tinybsd.localfiles +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ -# Add here your third-party applications that are already installed on /usr/local -# Make sure you have enough space to add it. -# Example: -# usr/local/sbin/httpd - diff --git a/tools/tools/tinybsd/conf/wrap/tinybsd.ports b/tools/tools/tinybsd/conf/wrap/tinybsd.ports new file mode 100644 index 000000000000..49bb52175241 --- /dev/null +++ b/tools/tools/tinybsd/conf/wrap/tinybsd.ports @@ -0,0 +1,9 @@ +# $FreeBSD$ +# Here you can add the applications from the FreeBSD Ports Collection which you +# want TinyBSD ports system to install in your embedded system. You whould list +# one application per line, mentioning its category and name, like the examples: +# +# www/mini_httpd +# net-mgmt/rate +# +# Make sure you have enough space to add it. diff --git a/tools/tools/tinybsd/tinybsd b/tools/tools/tinybsd/tinybsd index 52a33cb24d2c..da953c9d23f5 100755 --- a/tools/tools/tinybsd/tinybsd +++ b/tools/tools/tinybsd/tinybsd @@ -15,7 +15,10 @@ fi WORKDIR=/usr/obj/tinybsdbuild KERNCONF=TINYBSD BASEFILE="tinybsd.basefiles" -LOCALFILE="tinybsd.localfiles" +PORTSFILE="tinybsd.ports" +PORTSDIR=/usr/ports +PKGDIRS=/tmp/pkg.dirs +PKGFILES=/tmp/pkg.files DEFINSTARGS="-o 0 -g 0 -m 555" TS="=====>" @@ -272,13 +275,49 @@ create_tree() { copy_binaries() { cd ${CURRENTDIR}/conf/${CONF} - for file in `cat ${BASEFILE} ${LOCALFILE} | grep -v "#" | \ + for file in `cat ${BASEFILE} | grep -v "#" | \ cut -f1 -d":" | sort | uniq` ; do echo "${TS} Copying "/${file}" to "${WORKDIR}/${file} cp -fp /${file} ${WORKDIR}/${file} ; done } +install_ports() { + for portname in `cat ${PORTSFILE} | grep -v '#'` ; do + cd ${PORTSDIR}/${portname} + pkgname=`make -V PKGNAME` + pkg_info -VQ ${pkgname} + install=`echo $?` + if [ ${install} -eq 0 ] ; then + echo "$portname is already installed..." + create_missingdir + copy_ports + else + make install clean + create_missingdir + copy_ports + fi + done +} + +create_missingdir() { +pkg_info -L ${pkgname} | egrep -v '(Information|Files|www|share|doc|man|include)' | sort | uniq >> ${PKGDIRS} + for dir in `cat ${PKGDIRS}`; do + if [ ! -d `dirname ${WORKDIR}/${dir}` ] ; then + mkdir -p `dirname ${WORKDIR}/${dir}` + fi + done + rm ${PKGDIRS} +} + +copy_ports() { +pkg_info -L ${pkgname} | egrep -v '(Information|Files|www|share|doc|man|include)' >> ${PKGFILES} + for port in `cat ${PKGFILES}` ; do + echo "${TS} Copying "${port}" to "${WORKDIR}${port} + cp -fp ${port} ${WORKDIR}${port} ; + done +} + make_kernel() { echo "${TS} Building customized tiny beastie kernel... " cp -p ${CURRENTDIR}/conf/${CONF}/${KERNCONF} /usr/src/sys/i386/conf @@ -292,21 +331,21 @@ make_kernel() { install -o 0 -g 0 -m 444 /sys/i386/conf/GENERIC.hints ${WORKDIR}/boot/device.hints } - copy_libraries() { -#set -xv TDEPFILE="`mktemp -t deps`" TDEPFILES="`mktemp -t depsymlnk`" cd ${CURRENTDIR}/conf/${CONF} - for file in `cat ${BASEFILE} ${LOCALFILE} | grep -v "#" | cut -f1 -d":"`; do + for file in `cat ${BASEFILE} ${PKGFILES} | grep -v "#" | cut -f1 -d":"`; do ldd -f "%p\n" /${file} >> ${TDEPFILE} ; # don't worry on progs been "not dynamic" done + rm ${PKGFILES} + for libdeplib in `cat ${TDEPFILE} | sort | uniq`; do ldd -f "%p\n" /${libdeplib} >> ${TDEPFILE} ; done - + for pamdep in `ls -1 /usr/lib/pam*`; do echo $pamdep >> ${TDEPFILE} ; ldd -f "%p\n" /${pamdep} >> ${TDEPFILE} ; @@ -336,9 +375,16 @@ copy_libraries() { echo -n "${TS} Unlinking " rm -fv ${TDEPFILE} ${TDEPFILES} -#set +xv } +deinstall_ports() { + for portname in `cat ${PORTSFILE} | grep -v '#'` ; do + cd ${PORTSDIR}/${portname} + if [ $? -ne ${install} ] ; then + make deinstall + fi + done +} create_etc() { cd /usr/src/etc/sendmail/ @@ -368,13 +414,13 @@ personal_conf() { } symlinks() { -set -xv - for i in `cat ${BASEFILE} ${LOCALFILE} | grep -v "#" | grep ":"`; do +#set -xv + for i in `cat ${BASEFILE} ${PORTSFILE} | grep -v "#" | grep ":"`; do SOURCE_FILE=`echo $i | awk -F ":" {'print $1'}` TARGET_FILE=`echo $i | awk -F ":" {'print $2'}` chroot ${WORKDIR} /bin/ln -vs /${SOURCE_FILE} ${TARGET_FILE} done -set +xv +#set +xv } @@ -467,9 +513,11 @@ rotate_buidlog check_alt_imgname create_tree copy_binaries + install_ports make_kernel copy_libraries symlinks + deinstall_ports create_etc create_ssh_keys personal_conf