File: makepackage

package info (click to toggle)
dnssec-trigger 0.13~svn685-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,784 kB
  • ctags: 1,423
  • sloc: ansic: 15,773; sh: 1,788; makefile: 453; xml: 444; objc: 421; python: 334; cpp: 18
file content (627 lines) | stat: -rwxr-xr-x 23,592 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
#!/bin/bash
# makepackage
# builds a mac package
# version 201110 cas
# changed for dnssec-trigger, 201110, wouter.

# put installed files in DESTDIR=DEST.
# start in osx/pkg dir with osx/pkg/DEST for distfiles.

PRODUCT="dnssectrigger"
OS=`uname`
DESTDIR=$(pwd)/DEST
VERSION=`grep " PACKAGE_VERSION" ../../config.h | sed -e 's/.*"\(.*\)"/\1/'`
FILELIST=/usr/share/dnssec-trigger/files.list

if [[ "$OS" == 'Darwin' ]]; then
   PLATFORM='MacOSX'
   LAYOUT="MAC"
   OSVERSION=`sw_vers -productVersion | cut -d . -f 1,2`
   ARCH=`uname -p`
   if [ -z "${CPUARCH}" ]; then
       CPUARCH="${ARCH}"
   fi
fi

VERSION2=`echo $VERSION | sed s'/[\.\-]//'g`
echo "Preparing binary package for $PLATFORM ${OSVERSION} on ${CPUARCH}"

ORIG="$(pwd)"

macpackage_commands()
{ :

    cd ${DESTDIR}
    rm -f $ORIG/${PRODUCT}-${VERSION}-binary-${CPUARCH}-${OSVERSION}.tar.gz
    rm -rf package-manager
    echo "create tarball"
    # the disable avoids ._blabla files with resource forks that store
    # extended attributes for the files.
    COPYFILE_DISABLE=true tar czf $ORIG/${PRODUCT}-${VERSION}-binary-${CPUARCH}-${OSVERSION}.tar.gz .

    # create package manager dir structure
    echo "create package manager dir structure"
    PKGDIR=`pwd`
    mkdir -p package-manager/${PRODUCT}.pmdoc
    mkdir package-manager/packages
    mkdir -p package-manager/packages/Package_Root/tmp
    mkdir package-manager/packages/Resources

    # write postflight script
    cat <<EOF > package-manager/packages/Resources/postflight
#!/bin/bash
# stop unbound if launch plist exists
OSVERS=\`sw_vers -productVersion | cut -d . -f 1,2\`
INSTLOG=/tmp/${PRODUCT}-${VERSION}-install.log

doinstall() {

if [[ -f /Library/LaunchDaemons/nl.nlnetlabs.unbound.plist ]]; then
    launchctl unload -w /Library/LaunchDaemons/nl.nlnetlabs.unbound.plist
fi

guiuser="\`stat -f "%Su" /dev/console\`"
if test -z "\$guiuser" -o "\$guiuser" = "root"; then
	# if installer was created on 10.6, it runs with devconsole root,
	# but HOME is set to the users homedir. On 10.7 devconsole is user.
	guiuser="\`basename \$HOME\`"
fi
if test -f /Library/LaunchAgents/nl.nlnetlabs.dnssec-trigger-panel.plist; then
	if test -n "\$guiuser" -a "\$guiuser" != "root"; then
		if sudo -u "\$guiuser" launchctl list | grep nl.nlnetlabs.dnssec-trigger-panel >/dev/null; then
			# panel loaded as user, remove as user.
			sudo -u "\$guiuser" launchctl unload -w /Library/LaunchAgents/nl.nlnetlabs.dnssec-trigger-panel.plist
		fi
	fi
	if launchctl list | grep nl.nlnetlabs.dnssec-trigger-panel >/dev/null; then
		# panel loaded as root, unload as root.
		launchctl unload -w /Library/LaunchAgents/nl.nlnetlabs.dnssec-trigger-panel.plist
	fi

	# try to really stop the panels, otherwise they will show popups
	# if the new daemon starts and when we then stop them this is strange
	# with double popups.
	# If possible, tell launchd to stop the LaunchAgent. This will fail on 10.4.
	# \$F[0] is the pid
	# \$F[1] is the username
	# \$F[2] is the first word of the command
	ps -ww -A -opid,user,command | perl -nae 'if(\$F[2] =~ /\\bloginwindow\\b/) { system(qq(launchctl bsexec \$F[0] su \$F[1] -c "launchctl unload -w /Library/LaunchAgents/nl.nlnetlabs.dnssec-trigger-panel.plist")) }'

fi

if test -f /Library/LaunchDaemons/nl.nlnetlabs.dnssec-triggerd.plist; then
    launchctl unload -w /Library/LaunchDaemons/nl.nlnetlabs.dnssec-trigger-hook.plist
    launchctl unload -w /Library/LaunchDaemons/nl.nlnetlabs.dnssec-triggerd.plist
fi

# stop BIND if launch plist exists
if [[ -f /System/Library/LaunchDaemons/org.isc.named.plist ]]; then
    launchctl unload -w /System/Library/LaunchDaemons/org.isc.named.plist
fi

mkdir -p "\`dirname ${FILELIST}\`"
tar xzopC / -f /tmp/${PRODUCT}-${VERSION}-binary-${CPUARCH}-${OSVERSION}.tar.gz
tar tzf /tmp/${PRODUCT}-${VERSION}-binary-${CPUARCH}-${OSVERSION}.tar.gz > "${FILELIST}"
echo "\`dirname ${FILELIST}\`" >> "${FILELIST}"

# random guess for free id, but run script to find one
freeid=2045
getfreeid()
{ :
  MAXID=1000
  freeid=\$(dscl localhost -list /Local/Default/Users UniqueID | awk '{ if ( \$2 > max && \$2<300 ) max = \$2 } END { print max+1 }' )
  while [ \$freeid -le \$MAXID ]
  do
	  zgid=\$(dscl localhost -search /Local/Default/Groups PrimaryGroupID \$freeid)
	  zuid=\$(dscl localhost -search /Local/Default/Users UniqueID \$freeid)
	  if [ -z "\$zgid\$zuid" ]; then break; fi
	  freeid=\$((\$freeid+1))
  done
}

# add unbound user
if [[ "\${OSVERS}" == '10.4' ]]; then
    # Tiger
    dscl / -create /Users/unbound
    dscl / -create /Users/unbound UserShell /bin/nologin
elif [[ "\${OSVERS}" == '10.5' ]]; then
    # Leopard
    if dscl localhost -read /Local/Default/Users/unbound UniqueID; then
	    echo "unbound user already exists"
    else
	dscl localhost -create /Local/Default/Users/unbound
	dscl localhost -create /Local/Default/Users/unbound UserShell /bin/nologin
	dscl localhost -create /Local/Default/Users/unbound RealName "unbound daemon"
	dscl localhost -create /Local/Default/Users/unbound NFSHomeDirectory /etc/unbound/
	getfreeid
	dscl localhost -create /Local/Default/Users/unbound PrimaryGroupID \$freeid
	dscl localhost -create /Local/Default/Users/unbound UniqueID \$freeid
    fi
elif [[ "\${OSVERS}" == '10.6' ]]; then
    # SnowLeopard
    if dscl localhost -read /Local/Default/Users/unbound UniqueID; then
	    echo "unbound user already exists"
    else
	dscl localhost -create /Local/Default/Users/unbound
	dscl localhost -create /Local/Default/Users/unbound UserShell /bin/nologin
	dscl localhost -create /Local/Default/Users/unbound RealName "unbound daemon"
	dscl localhost -create /Local/Default/Users/unbound NFSHomeDirectory /etc/unbound/
	getfreeid
	dscl localhost -create /Local/Default/Users/unbound PrimaryGroupID \$freeid
	dscl localhost -create /Local/Default/Users/unbound UniqueID \$freeid
    fi
elif [[ "\${OSVERS}" == '10.7' ]]; then
    # Lion
    if dscl localhost -read /Local/Default/Users/unbound UniqueID; then
	    echo "unbound user already exists"
    else
	dscl localhost -create /Local/Default/Users/unbound
	dscl localhost -create /Local/Default/Users/unbound UserShell /bin/nologin
	dscl localhost -create /Local/Default/Users/unbound RealName "unbound daemon"
	dscl localhost -create /Local/Default/Users/unbound NFSHomeDirectory /etc/unbound/
	getfreeid
	dscl localhost -create /Local/Default/Users/unbound PrimaryGroupID \$freeid
	dscl localhost -create /Local/Default/Users/unbound UniqueID \$freeid
    fi
elif [[ "\${OSVERS}" == '10.8' ]]; then
    # Mountain Lion
    if dscl localhost -read /Local/Default/Users/unbound UniqueID; then
	    echo "unbound user already exists"
    else
	dscl localhost -create /Local/Default/Users/unbound
	dscl localhost -create /Local/Default/Users/unbound UserShell /bin/nologin
	dscl localhost -create /Local/Default/Users/unbound RealName "unbound daemon"
	dscl localhost -create /Local/Default/Users/unbound NFSHomeDirectory /etc/unbound/
	getfreeid
	dscl localhost -create /Local/Default/Users/unbound PrimaryGroupID \$freeid
	dscl localhost -create /Local/Default/Users/unbound UniqueID \$freeid
    fi
else
    # guess
    if dscl localhost -read /Local/Default/Users/unbound UniqueID; then
	    echo "unbound user already exists"
    else
	dscl localhost -create /Local/Default/Users/unbound
	dscl localhost -create /Local/Default/Users/unbound UserShell /bin/nologin
	dscl localhost -create /Local/Default/Users/unbound RealName "unbound daemon"
	dscl localhost -create /Local/Default/Users/unbound NFSHomeDirectory /etc/unbound/
	getfreeid
	dscl localhost -create /Local/Default/Users/unbound PrimaryGroupID \$freeid
	dscl localhost -create /Local/Default/Users/unbound UniqueID \$freeid
    fi
fi

# write unbound launcher script
cat << 'EOF2' > /usr/libexec/unbound-launch.sh
#!/bin/bash
# update root anchor (if offline for long)
/usr/sbin/unbound-anchor || logger "/etc/unbound/root.key has been changed"
chown unbound /etc/unbound/root.key
# exec so the shell does not hang around.
exec /usr/sbin/unbound -d
EOF2
chmod +x /usr/libexec/unbound-launch.sh
echo /usr/libexec/unbound-launch.sh >> "${FILELIST}"

# write unbound plist
cat << 'EOF2' > /Library/LaunchDaemons/nl.nlnetlabs.unbound.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>nl.nlnetlabs.unbound</string>
        <key>ProgramArguments</key>
        <array>
           <string>/usr/libexec/unbound-launch.sh</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>OnDemand</key>
        <false/>
</dict>
</plist>
EOF2
echo /Library/LaunchDaemons/nl.nlnetlabs.unbound.plist >> "${FILELIST}"

# fetch root DNS key
if [[ ! -f /etc/unbound/root.key ]]; then
   /usr/sbin/unbound-anchor
fi
# make it writable by unbound
chown unbound /etc/unbound/root.key

runsetupi="no"
# setup default configuration file and keys
if [[ ! -f /etc/dnssec-trigger/dnssec-trigger.conf ]]; then
	cp /etc/dnssec-trigger/dnssec-trigger.conf-default /etc/dnssec-trigger/dnssec-trigger.conf
else
	if grep ssl443 /etc/dnssec-trigger/dnssec-trigger.conf >/dev/null && grep "url:" /etc/dnssec-trigger/dnssec-trigger.conf >/dev/null && grep "login-location" /etc/dnssec-trigger/dnssec-trigger.conf >/dev/null; then
		# config looks okay, check more
		if grep 185.49.140.67 /etc/dnssec-trigger/dnssec-trigger.conf >/dev/null; then
			:
		else
			# need new IPs. add them, keeps existing settings
			mv /etc/dnssec-trigger/dnssec-trigger.conf /etc/dnssec-trigger/dnssec-trigger.conf.old
			grep -v -e "213.154.224.3" -e "2001:7b8:206:1:bb::" < /etc/dnssec-trigger/dnssec-trigger.conf.old > /etc/dnssec-trigger/dnssec-trigger.conf
			echo "tcp80: 185.49.140.67" >> /etc/dnssec-trigger/dnssec-trigger.conf
			echo "tcp80: 2a04:b900::10:0:0:67" >> /etc/dnssec-trigger/dnssec-trigger.conf
			echo "ssl443: 185.49.140.67 7E:CF:B4:BE:B9:9A:56:0D:F7:3B:40:51:A4:78:E6:A6:FD:66:0F:10:58:DC:A8:2E:C0:43:D4:77:5A:71:8A:CF" >> /etc/dnssec-trigger/dnssec-trigger.conf
			echo "ssl443: 2a04:b900::10:0:0:67 7E:CF:B4:BE:B9:9A:56:0D:F7:3B:40:51:A4:78:E6:A6:FD:66:0F:10:58:DC:A8:2E:C0:43:D4:77:5A:71:8A:CF" >> /etc/dnssec-trigger/dnssec-trigger.conf
		fi
	else
		# need the new setting, copy anyway.
		cp /etc/dnssec-trigger/dnssec-trigger.conf /etc/dnssec-trigger/dnssec-trigger.conf.old
		cp /etc/dnssec-trigger/dnssec-trigger.conf-default /etc/dnssec-trigger/dnssec-trigger.conf
		runsetupi="yes"
	fi
fi
if [[ ! -f /etc/unbound/unbound.conf ]]; then
	cp /etc/unbound/unbound.conf-default /etc/unbound/unbound.conf
	/usr/sbin/unbound-control-setup
	/usr/sbin/dnssec-trigger-control-setup
	/usr/sbin/dnssec-trigger-control-setup -i
elif test "\$runsetupi" = "yes"; then
	/usr/sbin/dnssec-trigger-control-setup -i
fi

# clean up
rm -rf /tmp/${PRODUCT}-${VERSION}-binary*

chown root /Library/LaunchDaemons/nl.nlnetlabs.unbound.plist
chown root /Library/LaunchDaemons/nl.nlnetlabs.dnssec-triggerd.plist
chown root /Library/LaunchDaemons/nl.nlnetlabs.dnssec-trigger-hook.plist
chown root /Library/LaunchAgents/nl.nlnetlabs.dnssec-trigger-panel.plist
chown unbound /etc/unbound

# start unbound
launchctl load -w /Library/LaunchDaemons/nl.nlnetlabs.unbound.plist
sleep 1

# start dnssec-trigger (-panel and -hooks)
launchctl load -w /Library/LaunchDaemons/nl.nlnetlabs.dnssec-triggerd.plist
launchctl load -w /Library/LaunchDaemons/nl.nlnetlabs.dnssec-trigger-hook.plist

# start panel in GUI user space.
# this is really difficult, because as root would show the user widget now,
# but not after a reboot.  If as user, then it would show up after reboot.
# but maybe not now, because sudo -u user is not good enough, thus this:

# If possible, tell launchd to start the LaunchAgent. This will fail on 10.4.
# \$F[0] is the pid
# \$F[1] is the username
# \$F[2] is the first word of the command
ps -ww -A -opid,user,command | perl -nae 'if(\$F[2] =~ /\\bloginwindow\\b/) { system(qq(launchctl bsexec \$F[0] su \$F[1] -c "launchctl load -w /Library/LaunchAgents/nl.nlnetlabs.dnssec-trigger-panel.plist")) }'

}

# for test create logfile: doinstall 2>&1 | tee \$INSTLOG
doinstall
exit 0

EOF

# write uninstall script
cat <<EOF > ../uninstall-${PRODUCT}-${VERSION}.command
#!/bin/bash
# uninstall dnssec-trigger.

question () {
	printf "%s (y/n) " "\$*"
	read answer
	case "\$answer" in
	    [Yy]|[Yy][Ee][Ss])
		return 0
		;;
	    *)
		return 1
		;;
	esac
}

do_uninstall() {
	if test -f /Library/LaunchAgents/nl.nlnetlabs.dnssec-trigger-panel.plist; then
		if launchctl list | grep nl.nlnetlabs.dnssec-trigger-panel >/dev/null; then
			echo "unload user panel plist"
			launchctl unload -w /Library/LaunchAgents/nl.nlnetlabs.dnssec-trigger-panel.plist
		fi
	fi
	echo "run with root permission"
	sudo bash "\$0" uninstall 
}

# see if file list exists
if test ! -f "${FILELIST}"; then
	echo "error: ${FILELIST} does not exist, nothing to uninstall"
	exit 1
fi

if test "\$*" = "uninstall"; then
	echo ""
	echo "proceeding with uninstall of ${PRODUCT} ${VERSION}"
else
	echo "uninstall ${PRODUCT} ${VERSION}"
	echo ""
	question "Are you sure you want to uninstall?" && do_uninstall || echo "stop."
	exit 0
fi

# from root dir.
cd /

if launchctl list | grep nl.nlnetlabs.dnssec-trigger-panel >/dev/null; then
	echo "unload user panel plist (as root)"
	launchctl unload -w /Library/LaunchAgents/nl.nlnetlabs.dnssec-trigger-panel.plist
fi

echo "stop panel"
/usr/sbin/dnssec-trigger-control stoppanels

# stop daemons if exist
echo "unload plists ..."
if [[ -f /Library/LaunchDaemons/nl.nlnetlabs.unbound.plist ]]; then
    launchctl unload -w /Library/LaunchDaemons/nl.nlnetlabs.unbound.plist
fi

if test -f /Library/LaunchDaemons/nl.nlnetlabs.dnssec-triggerd.plist; then
    launchctl unload -w /Library/LaunchDaemons/nl.nlnetlabs.dnssec-trigger-hook.plist
    launchctl unload -w /Library/LaunchDaemons/nl.nlnetlabs.dnssec-triggerd.plist
fi

# uninit the resolv.conf override
/usr/sbin/dnssec-triggerd -u

# remove files.
echo "delete files ..."
cat "${FILELIST}" | while read f; do
	# remove files not directories.
	if test -f "\$f"; then
		rm -f "\$f"
	fi
	echo -n "."
done
echo " done"

echo "delete directories ..."
cat "${FILELIST}" | while read f; do
	# remove empty directories
	if test -d "\$f"; then
		# error is piped into devnull if directory not empty.
		rmdir "\$f" >/dev/null 2>&1
	fi
	echo -n "."
done
echo " done"

# remove filelist
rm -f "${FILELIST}"
rmdir "\`dirname "${FILELIST}"\`"  >/dev/null 2>&1

echo "uninstall done"

EOF
chmod +x ../uninstall-${PRODUCT}-${VERSION}.command

# write the background picture
cp $ORIG/package-bg.png package-manager/packages/Resources/unbound.png

cp $ORIG/${PRODUCT}-${VERSION}-binary-${CPUARCH}-${OSVERSION}.tar.gz package-manager/packages/Package_Root/tmp
cat <<EOF > package-manager/${PRODUCT}.pmdoc/01package.xml
<pkgref spec="1.12" uuid="2F9BC3A8-16DF-486E-9FB0-1B702DA93B5A">
<config>
 <identifier>nl.nlnetlabs${PRODUCT}${VERSION2}ForMacosX${OSVERSION}.Package_Root.pkg</identifier>
 <version>${VERSION}</version>
 <description></description>
 <post-install type="none"/>
 <requireAuthorization/>
 <installFrom>${PKGDIR}/package-manager/packages/Package_Root</installFrom>
 <installTo>/</installTo>
 <flags>
   <followSymbolicLinks/>
 </flags>
 <packageStore type="internal"></packageStore>
 <mod>identifier</mod>
 <mod>version</mod>
 <mod>parent</mod>
</config>
<scripts>
  <postflight mod="true">${PKGDIR}/package-manager/packages/Resources/postflight</postflight>
</scripts>
<contents>
  <file-list>01package-contents.xml</file-list>
  <filter>/CVS$</filter>
  <filter>/\.svn$</filter>
  <filter>/\.cvsignore$</filter>
  <filter>/\.cvspass$</filter>
  <filter>/\.DS_Store$</filter>
</contents>
</pkgref> 
EOF

cat <<EOF > package-manager/${PRODUCT}.pmdoc/01package-contents.xml
<pkg-contents spec="1.12">
  <f n="Package_Root" o="root" g="admin" p="16877" pt="${PKGDIR}/package-manager/packages/Package_Root" m="false" t="file">
    <f n="tmp" o="root" g="admin" p="16877">
      <f n="${PRODUCT}-${VERSION}-binary-${CPUARCH}-${OSVERSION}.tar.gz" o="root" g="admin" p="33188"/>
    </f>
  </f>
</pkg-contents>
EOF


cat <<EOF > package-manager/${PRODUCT}.pmdoc/index.xml
<pkmkdoc spec="1.12">
	<properties>
		<title>NLnet Labs DnssecTrigger ${VERSION} for MacOS X</title>
		<build>$(pwd)/NLnet Labs Unbound ${VERSION} for MacOS X.mpkg</build>
		<organization>nl.nlnetlabs</organization>
		<userSees ui="both"/>
		<min-target os="2"/>
		<domain system="true"/>
	</properties>
	<distribution>
		<versions min-spec="1.000000"/>
		<scripts></scripts>
	</distribution>
	<description>
DnssecTrigger configures a local DNSSEC validating resolver.

Dnssec-trigger reconfigures the local unbound DNS server. This unbound DNS server performs DNSSEC validation, but dnssec-trigger will signal it to to use the DHCP obtained forwarders if possible, and fallback to doing its own AUTH queries if that fails, and if that fails prompt the user via dnssec-trigger-applet the option to go with insecure DNS only.

The source code is under a BSD License.
	</description>
	<contents>
		<choice title="Package_Root" id="choice1" starts_selected="true" starts_enabled="true" starts_hidden="false">
			<pkgref id="nl.nlnetlabs${PRODUCT}${VERSION2}ForMacosX${OSVERSION}.Package_Root.pkg"/>
		</choice>
	</contents>
	<resources bg-scale="none" bg-align="topleft">
		<locale lang="en">
      		<resource mod="true" type="background">${PKGDIR}/package-manager/packages/Resources/unbound.png</resource>
			<resource mime-type="text/rtf" kind="embedded" type="license"><![CDATA[{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\f0\fs18 \cf0 Copyright (c) 2011, NLnet Labs. All rights reserved.\\
\\
This software is open source.\\
\\
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:\\
\\
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.\\
\\
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.\\
\\
Neither the name of the NLNET LABS nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.\\
\\
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.}]]></resource>
<resource mime-type="text/rtf" kind="embedded" type="readme"><![CDATA[{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\f0\fs26 \cf0 This installs DnssecTrigger ${VERSION} for MacOS X (${CPUARCH}). \\
\\
This creates a local validating DNSSEC resolver on your machine (unbound, included in the package).\\
\\
A tray icon appears, where you can see technical results and manage it. A dialog pops up if the network DNSSEC fails.  For some (for-pay) wifi hot-spots you may have to signon-while-insecure, then reprobe.\\
\\
Please subscribe to the user mailing list, to hear about software updates http://www.nlnetlabs.nl/mailman/listinfo/dnssec-trigger\\
\\
The source code is under a BSD License.}]]></resource><resource mime-type="text/rtf" kind="embedded" type="welcome"><![CDATA[{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;\f1\fnil\fcharset0 Monaco;}
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\f0\fs26 \cf0 Welcome to the DnssecTrigger for MacOS X installer.\\
\\
This installer installs: libldns, unbound and dnssec-trigger.  It starts a validating DNSSEC cache on this system.\\
\\
The configuration files are \f1 /etc/unbound/unbound.conf \f0 and \f1 /etc/dnssec-trigger/dnssec-trigger.conf \f0 \\
\\
The trust anchor for the Internet root zone will be downloaded and configured with \f1 unbound-anchor \f0 if the file \f1 /etc/unbound/root.key \f0 does not exist.\\
\\
Information about DnssecTrigger can be found at \\
http://www.nlnetlabs.nl/projects/dnssec-trigger\\
Information about Unbound can be found at \\
http://unbound.net}]]>
	</resource>
	</locale>
	</resources>
	<requirements>
		<requirement id="filt" operator="eq" value="true">
			<file>/usr/bin/openssl</file>
			<message>Unbound requires OpenSSL to be installed</message>
		</requirement>
	</requirements>
	<flags/>
	<item type="file">01package.xml</item>
	<mod>properties.title</mod>
	<mod>properties.customizeOption</mod>
	<mod>description</mod>
	<mod>properties.anywhereDomain</mod>
	<mod>properties.systemDomain</mod>
</pkmkdoc>
EOF

# build package
echo "build package"
/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker --doc package-manager/${PRODUCT}.pmdoc
rm -rf ../${PRODUCT}-${VERSION}-${CPUARCH}.mpkg
mv ${PRODUCT}.mpkg ../${PRODUCT}-${VERSION}-${CPUARCH}.mpkg
#rm -f ../${PRODUCT}-${VERSION}-${CPUARCH}-${OSVERSION}.zip
#zip -r ../${PRODUCT}-${VERSION}-${CPUARCH}-${OSVERSION}.zip ../${PRODUCT}-${VERSION}-${CPUARCH}-${OSVERSION}.mpkg

# create DMG
echo "create pack.dmg"
rm -f ../${PRODUCT}-${VERSION}-${CPUARCH}-${OSVERSION}.dmg pack.dmg
cp $ORIG/dmg-template.dmg.gz pack.dmg.gz
gzip -d pack.dmg.gz
hdiline=`hdiutil attach -readwrite "pack.dmg" | egrep '^/dev/' | sed 1q `
device=`echo $hdiline | awk '{print $1}' `
hdimnt=`echo $hdiline | sed -e 'sX^.*/VolumesX/VolumesX' `
echo "hdiutil attach to device ${device} at ${hdimnt}"
sleep 5
sync
# attempt to keep the same icon
echo "copy files"
rm -rf "$hdimnt"/*.mpkg
cp -R ../${PRODUCT}-${VERSION}-${CPUARCH}.mpkg "$hdimnt"
cp ../uninstall-${PRODUCT}-${VERSION}.command "$hdimnt"
sleep 5
echo "detach"
sync
hdiutil detach ${device}
sync
sleep 5
echo "convert"
sync
hdiutil convert "pack.dmg" -format UDZO -imagekey zlib-level=9 -o "../${PRODUCT}-${VERSION}-${CPUARCH}-${OSVERSION}.dmg"
rm pack.dmg
rm ../uninstall-${PRODUCT}-${VERSION}.command

}

test_pipe()
{
    for i in "${PIPESTATUS[@]}"
    do
        [ $i == 0 ] || { echo FAILED! ; exit 1 ; }
    done
    echo successful!
    return 0
}

go()
{
    { ${1}_commands 3>&1 1>&2 2>&3 | \
        tee "$ORIG/${VERSION}-logs/${1}.err" ;} \
        &>"$ORIG/${VERSION}-logs/${1}.log"
    test_pipe || exit 1
};

# Here we go:
#mkdir -p $ORIG/${VERSION}-logs
#echo -n "MacOS X Packaging... "  && go macpackage      || exit 7
macpackage_commands || exit 7

# All done