]> git.saurik.com Git - apple/configd.git/blob - configd.tproj/update-mach-services
configd-699.1.5.tar.gz
[apple/configd.git] / configd.tproj / update-mach-services
1 #!/bin/sh
2
3 CONFIGD_LAUNCHD_PLIST=${INSTALL_DIR}/../../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 ${INSTALL_DIR}/../../System/Library/SystemConfiguration ]; then
13 (cd ${INSTALL_DIR}/../../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=${INSTALL_DIR}/../../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=${INSTALL_DIR}/../../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 "${IPHONEOS_DEPLOYMENT_TARGET}" ]; then
113 /usr/bin/plutil -convert binary1 ${CONFIGD_LAUNCHD_PLIST}
114 else
115 /usr/bin/plutil -convert xml1 ${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 if [ "${HAVE_CONFIGD_PLUGINS}" != "OK" ]; then
132 echo ""
133 echo "**************************************************************************************"
134 echo "* THE BUILD ENVIRONMENT IS MISSING THE ROOT FOR AN ESSENTIAL PROJECT (configd_plugins)"
135 echo "**************************************************************************************"
136 exit 1
137 elif [ "${HAVE_IPCONFIGURATION}" != "OK" -a "${PLATFORM_NAME}" != "iphonesimulator" ] ; then
138 echo ""
139 echo "****************************************************************************"
140 echo "* THE BUILD ENVIRONMENT IS MISSING THE ROOT FOR AN ESSENTIAL PROJECT (bootp)"
141 echo "****************************************************************************"
142 exit 1
143 fi