github.com/olljanat/moby@v1.13.1/contrib/mkimage/solaris (about)

     1  #!/usr/bin/env bash
     2  #
     3  # Solaris 12 base image build script. 
     4  #
     5  set -e
     6  
     7  # TODO add optional package publisher origin
     8  
     9  rootfsDir="$1"
    10  shift
    11  
    12  # base install
    13  (
    14  	set -x
    15  
    16  	pkg image-create --full --zone \
    17  		--facet facet.locale.*=false \
    18  		--facet facet.locale.POSIX=true \
    19  		--facet facet.doc=false \
    20  		--facet facet.doc.*=false \
    21  		"$rootfsDir"
    22  
    23  	pkg -R "$rootfsDir" set-property use-system-repo true
    24  
    25  	pkg -R "$rootfsDir" set-property flush-content-cache-on-success true
    26  
    27  	pkg -R "$rootfsDir" install core-os
    28  )
    29  
    30  # Lay in stock configuration, set up milestone
    31  # XXX This all may become optional in a base image
    32  (
    33  	# faster to build repository database on tmpfs
    34  	REPO_DB=/system/volatile/repository.$$
    35  	export SVCCFG_REPOSITORY=${REPO_DB}
    36  	export SVCCFG_DOOR_PATH=$rootfsDir/system/volatile/tmp_repo_door
    37  
    38  	# Import base manifests. NOTE These are a combination of basic requirement
    39  	# and gleaned from container milestone manifest. They may change.
    40  	for m in $rootfsDir/lib/svc/manifest/system/environment.xml \
    41  		$rootfsDir/lib/svc/manifest/system/svc/global.xml \
    42  		$rootfsDir/lib/svc/manifest/system/svc/restarter.xml \
    43  		$rootfsDir/lib/svc/manifest/network/dns/client.xml \
    44  		$rootfsDir/lib/svc/manifest/system/name-service/switch.xml \
    45  		$rootfsDir/lib/svc/manifest/system/name-service/cache.xml \
    46  		$rootfsDir/lib/svc/manifest/milestone/container.xml ; do
    47  		svccfg import $m
    48  	done
    49  
    50  	# Apply system layer profile, deleting unnecessary dependencies
    51  	svccfg apply $rootfsDir/etc/svc/profile/generic_container.xml 
    52  
    53  	# XXX Even if we keep a repo in the base image, this is definitely optional
    54  	svccfg apply $rootfsDir/etc/svc/profile/sysconfig/container_sc.xml
    55  
    56  	for s in svc:/system/svc/restarter \
    57  		svc:/system/environment \
    58  		svc:/network/dns/client \
    59  		svc:/system/name-service/switch \
    60  		svc:/system/name-service/cache \
    61  		svc:/system/svc/global \
    62  		svc:/milestone/container ;do
    63  		svccfg -s $s refresh
    64  	done
    65  
    66  	# now copy the built up repository into the base rootfs
    67  	mv $REPO_DB $rootfsDir/etc/svc/repository.db
    68  )
    69  
    70  # pkg(1) needs the zoneproxy-client running in the container.
    71  # use a simple wrapper to run it as needed.
    72  # XXX maybe we go back to running this in SMF?
    73  mv "$rootfsDir/usr/bin/pkg" "$rootfsDir/usr/bin/wrapped_pkg"
    74  cat > "$rootfsDir/usr/bin/pkg" <<-'EOF'
    75  #!/bin/sh
    76  #
    77  # THIS FILE CREATED DURING DOCKER BASE IMAGE CREATION
    78  # 
    79  # The Solaris base image uses the sysrepo proxy mechanism. The
    80  # IPS client pkg(1) requires the zoneproxy-client to reach the
    81  # remote publisher origins through the host. This wrapper script
    82  # enables and disables the proxy client as needed. This is a
    83  # temporary solution.
    84  
    85  /usr/lib/zones/zoneproxy-client -s localhost:1008
    86  PKG_SYSREPO_URL=http://localhost:1008 /usr/bin/wrapped_pkg "$@"
    87  pkill -9 zoneproxy-client
    88  EOF
    89  chmod +x "$rootfsDir/usr/bin/pkg"