solaris 2.7 KB

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