1## $(#) i.template.sh 1.12 07/12/12 SMI
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19NAME="i.none"
20FILELIST=${PKGSAV:?undefined}/filelist
21BD=${BASEDIR:-/}
22MAXLIST=550
23count=0
24
25is_an_archive=0
26is_a_filelist=0
27list_empty=1
28local_install=0
29Spcl_init=0
30Rm_alt_sav=0
31Tmp_xpath=/usr/tmp$$dir
32
33MV_xpath=/usr/bin
34MV_cmd=$MV_xpath/mv
35CPIO_xpath=/usr/bin
36CPIO_cmd=$CPIO_xpath/cpio
37UNZIP_xpath=/usr/bin
38UNZIP_cmd=$UNZIP_xpath/unzip
39BZCAT_xpath=/usr/bin
40BZCAT_cmd=$BZCAT_xpath/bzcat
41P7ZIP_xpath=/usr/bin
42P7ZIP_cmd=$P7ZIP_xpath/7za
43ZCAT_xpath=/usr/bin
44ZCAT_cmd=$ZCAT_xpath/zcat
45LN_xpath=/usr/bin
46LN_cmd=$LN_xpath/ln
47NAWK_xpath=/usr/bin
48NAWK_cmd=$NAWK_xpath/nawk
49RM_xpath=/usr/bin
50RM_cmd=$RM_xpath/rm
51
52
53
54eval_pkg() {
55	read path	# get the package source directory
56
57	if [ ${path:-NULL} != NULL ]; then
58		PKGSRC=${path:?undefined}
59
60
61
62		if [ -r $PKGSRC/archive/none -o \
63			-r $PKGSRC/archive/none.Z -o \
64			-r $PKGSRC/archive/none.7z -o \
65			-r $PKGSRC/archive/none.bz2 ]; then
66			is_an_archive=1
67		fi
68	else
69		exit 0	# empty pipe, we're done
70	fi
71
72}
73
74
75eval_pkg
76
77if [ "$is_an_archive" -eq 0 ]; then
78	echo "ERROR : $NAME cannot find archived files in $PKGSRC/archive."
79	exit 1
80fi
81
82Reloc_Arch=$PKGSRC/archive/none
83
84if [ ! -d "$PKGSAV" ]; then
85	echo "WARNING : $NAME cannot find save directory $PKGSAV."
86	PKGSAV=$Tmp_xpath/$PKG.sav
87
88	if [ ! -d "$PKGSAV" ]; then
89		/usr/bin/mkdir $PKGSAV
90	fi
91
92	if [ $? -eq 0 ]; then
93		echo "  Using alternate save directory" $PKGSAV
94		FILELIST=$PKGSAV/filelist
95		Rm_alt_sav=1
96	else
97		echo "ERROR : cannot create alternate save directory" $PKGSAV
98		exit 1
99	fi
100fi
101
102if [ -f "$FILELIST" ]; then
103	rm $FILELIST
104fi
105
106cd $BD
107
108if [ ${PKG_INIT_INSTALL:-null} = null ]; then
109	is_a_filelist=1
110	while	read path
111	do
112		count=`expr $count + 1`
113if [ "$count" -gt "$MAXLIST" ]; then
114	is_a_filelist=0
115	break
116fi
117
118		echo $path >> $FILELIST
119		list_empty=0
120	done
121fi
122
123
124if [ ! -x "$P7ZIP_cmd" ]; then
125	echo "Cannot find required executable $P7ZIP_cmd"
126	exit 1
127fi
128if [ "$is_a_filelist" -eq 1 ]; then
129	$P7ZIP_cmd x -so "$Reloc_Arch".7z 2> /dev/null | $CPIO_cmd -C 512 -idukm -E $FILELIST
130	status=$?
131	if [ "$status" -ne 0 ]; then
132		echo "Unarchiving of $Reloc_Arch failed with error $status"
133		exit 1
134	fi
135else
136	$P7ZIP_cmd x -so "$Reloc_Arch".7z 2> /dev/null | $CPIO_cmd -C 512 -idukm
137	status=$?
138	if [ "$status" -ne 0 ]; then
139		echo "Unarchiving of $Reloc_Arch failed with error $status"
140		exit 1
141	fi
142fi
143
144
145if [ -f "$FILELIST" ]; then
146	$RM_cmd $FILELIST
147fi
148
149if [ "$Rm_alt_sav" -eq 1 ]; then
150	$RM_cmd -r $PKGSAV
151fi
152
153
154exit 0
155