]> git.saurik.com Git - apple/configd.git/blob - configd.tproj/update-mach-services
configd-963.270.3.tar.gz
[apple/configd.git] / configd.tproj / update-mach-services
1 #!/bin/sh
2
3 CONFIGD_LAUNCHD_PLIST=${DSTROOT}/System/Library/LaunchDaemons/${1}
4 CONFIGD_PLUGINS=/tmp/plugins.$$
5 EMBEDDED_PROJECTS=/tmp/projects.$$
6 PLUGIN_MACHSERVICES=/tmp/plugin.$$
7
8 HAVE_CONFIGD_PLUGINS="MISSING"
9 HAVE_IPCONFIGURATION="MISSING"
10
11 cp /dev/null ${CONFIGD_PLUGINS}
12 if [ -d ${DSTROOT}/System/Library/SystemConfiguration ]; then
13 (cd ${DSTROOT}/System/Library/SystemConfiguration ; ls -1d *.bundle >> ${CONFIGD_PLUGINS} 2>/dev/null )
14 fi
15
16 cp /dev/null ${EMBEDDED_PROJECTS}
17 if [ -n "${RC_EMBEDDEDPROJECT_DIR}" -a -d "${RC_EMBEDDEDPROJECT_DIR}" ]; then
18 ( cd ${RC_EMBEDDEDPROJECT_DIR} \
19 ; ls -1d */System/Library/SystemConfiguration 2>/dev/null \
20 | sed -e 's:/System/Library/SystemConfiguration::' \
21 >> ${EMBEDDED_PROJECTS} )
22
23 if [ -s ${EMBEDDED_PROJECTS} ]; then
24 for PROJECT in `cat ${EMBEDDED_PROJECTS}`
25 do
26 ( cd ${RC_EMBEDDEDPROJECT_DIR}/${PROJECT}/System/Library/SystemConfiguration ; ls -1d *.bundle >> ${CONFIGD_PLUGINS} 2>/dev/null )
27 done
28 fi
29 fi
30
31 if [ -d ${SDKROOT}/System/Library/SystemConfiguration ]; then
32 ( cd ${SDKROOT}/System/Library/SystemConfiguration ; ls -1d *.bundle >> ${CONFIGD_PLUGINS} 2>/dev/null )
33 fi
34
35 if [ -n "${EXTRA_SYSTEMCONFIGURATION_PLUGIN_DIR}" -a -d "${EXTRA_SYSTEMCONFIGURATION_PLUGIN_DIR}" ]; then
36 ( cd ${EXTRA_SYSTEMCONFIGURATION_PLUGIN_DIR} ; ls -1d *.bundle >> ${CONFIGD_PLUGINS} 2>/dev/null )
37 fi
38
39 for PLUGIN in `sort -u ${CONFIGD_PLUGINS}`
40 do
41 PLUGIN_PLIST=""
42
43 # if [ -z "${PLUGIN_PLIST}" ]; then
44 PLUGIN_INF=${DSTROOT}/System/Library/SystemConfiguration/${PLUGIN}/Contents/Info.plist
45 if [ -f ${PLUGIN_INF} ]; then
46 PLUGIN_PLIST=${PLUGIN_INF}
47 fi
48 # fi
49
50 if [ -z "${PLUGIN_PLIST}" ]; then
51 PLUGIN_INF=${DSTROOT}/System/Library/SystemConfiguration/${PLUGIN}/Info.plist
52 if [ -f ${PLUGIN_INF} ]; then
53 PLUGIN_PLIST=${PLUGIN_INF}
54 fi
55 fi
56
57 if [ -z "${PLUGIN_PLIST}" -a -s ${EMBEDDED_PROJECTS} ]; then
58 for PROJECT in `cat ${EMBEDDED_PROJECTS}`
59 do
60 PROJECT_INF=${RC_EMBEDDEDPROJECT_DIR}/${PROJECT}/System/Library/SystemConfiguration/${PLUGIN}/Contents/Info.plist
61 if [ -f ${PROJECT_INF} ]; then
62 PLUGIN_PLIST=${PROJECT_INF}
63 break
64 fi
65
66 PROJECT_INF=${RC_EMBEDDEDPROJECT_DIR}/${PROJECT}/System/Library/SystemConfiguration/${PLUGIN}/Info.plist
67 if [ -f ${PROJECT_INF} ]; then
68 PLUGIN_PLIST=${PROJECT_INF}
69 break
70 fi
71 done
72 fi
73
74 if [ -z "${PLUGIN_PLIST}" ]; then
75 PLUGIN_INF=${SDKROOT}/System/Library/SystemConfiguration/${PLUGIN}/Contents/Info.plist
76 if [ -f ${PLUGIN_INF} ]; then
77 PLUGIN_PLIST=${PLUGIN_INF}
78 fi
79 fi
80
81 if [ -z "${PLUGIN_PLIST}" ]; then
82 PLUGIN_INF=${SDKROOT}/System/Library/SystemConfiguration/${PLUGIN}/Info.plist
83 if [ -f ${PLUGIN_INF} ]; then
84 PLUGIN_PLIST=${PLUGIN_INF}
85 fi
86 fi
87
88 if [ -n "${EXTRA_SYSTEMCONFIGURATION_PLUGIN_DIR}" ]; then
89 if [ -z "${PLUGIN_PLIST}" ]; then
90 PLUGIN_INF=${EXTRA_SYSTEMCONFIGURATION_PLUGIN_DIR}/${PLUGIN}/Contents/Info.plist
91 if [ -f ${PLUGIN_INF} ]; then
92 PLUGIN_PLIST=${PLUGIN_INF}
93 fi
94 fi
95
96 if [ -z "${PLUGIN_PLIST}" ]; then
97 PLUGIN_INF=${EXTRA_SYSTEMCONFIGURATION_PLUGIN_DIR}/${PLUGIN}/Info.plist
98 if [ -f ${PLUGIN_INF} ]; then
99 PLUGIN_PLIST=${PLUGIN_INF}
100 fi
101 fi
102 fi
103
104 if [ -z "${PLUGIN_PLIST}" ]; then
105 continue
106 fi
107
108 /usr/libexec/PlistBuddy -c "Print :MachServices" -x ${PLUGIN_PLIST} > ${PLUGIN_MACHSERVICES} 2>/dev/null
109 if [ $? -eq 0 ]; then
110 echo "Merging \"MachServices\" from: ${PLUGIN_INF}"
111 /usr/libexec/PlistBuddy -c "Merge ${PLUGIN_MACHSERVICES} :MachServices" ${CONFIGD_LAUNCHD_PLIST} 2>/dev/null
112 if [ -n "${MACOSX_DEPLOYMENT_TARGET}" ]; then
113 /usr/bin/plutil -convert xml1 ${CONFIGD_LAUNCHD_PLIST}
114 else
115 /usr/bin/plutil -convert binary1 ${CONFIGD_LAUNCHD_PLIST}
116 fi
117 fi
118
119 case "${PLUGIN}" in
120 "IPMonitor.bundle" )
121 HAVE_CONFIGD_PLUGINS="OK"
122 ;;
123 "IPConfiguration.bundle" )
124 HAVE_IPCONFIGURATION="OK"
125 ;;
126 esac
127 done
128
129 rm -f ${PLUGIN_MACHSERVICES} ${CONFIGD_PLUGINS} ${EMBEDDED_PROJECTS}
130
131 MISSING=""
132 if [ "${HAVE_CONFIGD_PLUGINS}" != "OK" ]; then
133 MISSING="configd_plugins"
134 elif [ "${HAVE_IPCONFIGURATION}" != "OK" ]; then
135 case "${PLATFORM_NAME}" in
136 *simulator )
137 ;;
138 * )
139 MISSING="bootp"
140 ;;
141 esac
142 fi
143
144 if [ -n "${MISSING}" ]; then
145 echo ""
146 echo "**************************************************************************************"
147 echo "* THE BUILD ENVIRONMENT IS MISSING THE ROOT FOR AN ESSENTIAL PROJECT (${MISSING})"
148 echo "**************************************************************************************"
149 if [ -z "${RC_RELEASE}" ]; then
150 echo "* REMOVING CONFIGD's LAUNCHD .plist FROM INSTALL ROOT"
151 echo "**************************************************************************************"
152 rm -f ${CONFIGD_LAUNCHD_PLIST}
153 else
154 # if B&I or "buildit", configd's launchd .plist is required (and must be viable)
155 exit 1
156 fi
157 fi
158