Add firstboot-pkgs:

When the system first boots, install the pkg(8) tools (if not already
installed) and packages listed in the $firstboot_pkgs_list rc.conf
variable.

Obviously, this port is not useful after a system is already running; it is
intended to be included as part of the installation or disk image building
process.
This commit is contained in:
Colin Percival 2013-11-30 00:17:00 +00:00
parent d45a10307d
commit eee107ae75
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=335251
4 changed files with 76 additions and 0 deletions

View file

@ -243,6 +243,7 @@
SUBDIR += filewatcherd
SUBDIR += finfo
SUBDIR += firstboot-freebsd-update
SUBDIR += firstboot-pkgs
SUBDIR += flasher
SUBDIR += flashrom
SUBDIR += flexbackup

View file

@ -0,0 +1,26 @@
# $FreeBSD$
PORTNAME= firstboot-pkgs
PORTVERSION= 1.0
CATEGORIES= sysutils
MASTER_SITES= # none
DISTFILES= # none
MAINTAINER= cperciva@FreeBSD.org
COMMENT= Install packages when the system first boots
NO_WRKSUBDIR= yes
NO_BUILD= yes
USE_RC_SUBR= firstboot_pkgs
.include <bsd.port.pre.mk>
.if ${OSVERSION} < 902504 || ( ${OSVERSION} >= 1000000 && ${OSVERSION} < 1000501 ) || ( ${OSVERSION} >= 1100000 && ${OSVERSION} < 1100001 )
IGNORE= first boot rc.d scripts not supported on this version of FreeBSD
.endif
do-fetch do-install:
@${DO_NADA}
.include <bsd.port.post.mk>

View file

@ -0,0 +1,42 @@
#!/bin/sh
# $FreeBSD$
# KEYWORD: firstboot
# PROVIDE: firstboot_pkgs
# REQUIRE: NETWORKING
# BEFORE: LOGIN
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf (in the disk
# image, since this only runs on the first boot) to enable this:
#
# firstboot_pkgs_enable="YES"
#
# and place a list of packages in firstboot_pkgs_list, e.g.,
#
# firstboot_pkgs_list="apache22 php5 mysql56-server"
. /etc/rc.subr
: ${firstboot_pkgs_enable:="NO"}
name="firstboot_pkgs"
rcvar=firstboot_pkgs_enable
start_cmd="firstboot_pkgs_run"
stop_cmd=":"
firstboot_pkgs_run()
{
# Bootstrap if necessary
if ! pkg -N 2>/dev/null; then
env ASSUME_ALWAYS_YES=YES pkg bootstrap
fi
# Install requested packages, if any
if ! [ -z "$firstboot_pkgs_list" ]; then
env ASSUME_ALWAYS_YES=YES pkg install $firstboot_pkgs_list
fi
}
load_rc_config $name
run_rc_command "$1"

View file

@ -0,0 +1,7 @@
When the system first boots, install the pkg(8) tools (if not already
installed) and packages listed in the $firstboot_pkgs_list rc.conf
variable.
Obviously, this port is not useful after a system is already running; it is
intended to be included as part of the installation or disk image building
process.