345 lines
		
	
	
	
		
			80 KiB
		
	
	
	
		
			Text
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			345 lines
		
	
	
	
		
			80 KiB
		
	
	
	
		
			Text
		
	
	
		
			Executable file
		
	
	
	
	
#!/bin/sh
 | 
						||
THISFILE="$0"
 | 
						||
CC=cc
 | 
						||
PMEXEC=./.pm-exec-`arch`
 | 
						||
set -e
 | 
						||
 | 
						||
extract_section() {
 | 
						||
	sed -e "0,/^XXXXSTART$1/d" "$THISFILE" | (
 | 
						||
		read size
 | 
						||
		dd bs=1 count=$size 2>/dev/null
 | 
						||
	) | zcat
 | 
						||
}
 | 
						||
 | 
						||
# If the bootstrap's built, run it.
 | 
						||
 | 
						||
if [ $PMEXEC -nt $0 ]; then
 | 
						||
	extract_section script | $PMEXEC /dev/stdin "$@"
 | 
						||
	exit $?
 | 
						||
fi
 | 
						||
 | 
						||
# Otherwise, compile it and restart.
 | 
						||
 | 
						||
echo "pm: bootstrapping..."
 | 
						||
 | 
						||
CFILE=/tmp/pm-$$.c
 | 
						||
trap "rm -f $CFILE" EXIT
 | 
						||
 | 
						||
extract_section interpreter > /tmp/pm-$$.c
 | 
						||
$CC $CFILE -o $PMEXEC && exec "$THISFILE" "$@"
 | 
						||
 | 
						||
echo "pm: bootstrap failed."
 | 
						||
exit 1
 | 
						||
 | 
						||
XXXXSTARTscript
 | 
						||
9949
 | 
						||
‹ |