Magellan Linux

Contents of /trunk/toolchain/minstallpkg.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 153 - (show annotations) (download) (as text)
Mon Jul 4 00:41:38 2005 UTC (18 years, 10 months ago) by niro
File MIME type: application/x-sh
File size: 5140 byte(s)
new toolchain create utilities and smages

1 #!/bin/bash
2 # 26.08.2004 <niro@magellan-linux.de>
3
4 ###################################################
5 # function install_direcories #
6 # install_direcories $PKGNAME #
7 ###################################################
8 install_directories() {
9 local PKGNAME
10 PKGNAME=$1
11
12 if [ -e ${BUILDDIR}/${PKGNAME}/.dirs ]
13 then
14
15 #sets fieldseperator to "§" instead of " "
16 IFS=§
17
18 while read pathto posix user group
19 do
20 if [ ! -z $pathto ]
21 then
22 echo -e "\t>>> DIR: ${ROOT}$pathto"
23 install -m $posix -o $user -g $group -d ${ROOT}${pathto}
24 fi
25 done < ${BUILDDIR}/${PKGNAME}/.dirs
26
27 #very important: unsetting the '§' fieldseperator
28 unset IFS
29 else
30 fatal_error .dir
31 fi
32 }
33
34
35 ###################################################
36 # function install_files #
37 # install_files $PKGNAME #
38 ###################################################
39 install_files(){
40 local PKGNAME
41 local RETVAL
42 local COUNTER
43 local FILENAME
44 local DESTINATION
45
46 PKGNAME=$1
47
48 if [ -e ${BUILDDIR}/${PKGNAME}/.files ]
49 then
50 #sets fieldseperator to "§" instead of " "
51 IFS=§
52
53 while read pathto posix user group mtime md5sum
54 do
55 if [ ! -z $pathto ]
56 then
57 echo -e "\t>>> FILE: ${ROOT}${pathto}"
58
59 ### kleiner notfall fix ###
60 if [ ! -d `dirname $pathto` ]
61 then
62 install -d `dirname ${ROOT}${pathto}`
63 fi
64
65 FILE="${pathto}"
66 install -m ${posix} -o ${user} -g ${group} \
67 ${BUILDDIR}/${PKGNAME}/binfiles/$FILE \
68 ${ROOT}${pathto}
69 fi
70 done < ${BUILDDIR}/${PKGNAME}/.files
71
72 #very important: unsetting the '§' fieldseperator
73 unset IFS
74 else
75 fatal_error .files
76 fi
77 }
78
79
80 ###################################################
81 # function install_symlinks #
82 # install_symlinks $PKGNAME #
83 ###################################################
84 install_symlinks() {
85 local PKGNAME
86 PKGNAME=$1
87
88 if [ -e ${BUILDDIR}/${PKGNAME}/.symlinks ]
89 then
90 #sets fieldseperator to "§" instead of " "
91 IFS=§
92
93 while read pathto posix link mtime
94 do
95 if [ ! -z $pathto ]
96 then
97 echo -e "\t>>> LINK: ${ROOT}${pathto}"
98 ln -snf $link ${ROOT}${pathto}
99 fi
100 done < ${BUILDDIR}/${PKGNAME}/.symlinks
101
102 #very important: unsetting the '§' fieldseperator
103 unset IFS
104 else
105 fatal_error .symlinks
106 fi
107 }
108
109
110 ###################################################
111 # function install_blockdevices #
112 # install_blockdevices $PKGNAME #
113 ###################################################
114 install_blockdevices() {
115 local PKGNAME
116 PKGNAME=$1
117
118 if [ -e ${BUILDDIR}/${PKGNAME}/.pipes ]
119 then
120 #sets fieldseperator to "§" instead of " "
121 IFS=§
122
123 while read pathto posix
124 do
125 if [ ! -z $pathto ]
126 then
127 echo -e "\t>>> PIPE: ${ROOT}${pathto}"
128 mkfifo -m $posix ${ROOT}${pathto}
129 fi
130 done < ${BUILDDIR}/${PKGNAME}/.pipes
131
132 #very important: unsetting the '§' fieldseperator
133 unset IFS
134 else
135 fatal_error .pipes
136 fi
137 }
138
139
140 ###################################################
141 # function install_characterdevices #
142 # install_characterdevices $PKGNAME #
143 ###################################################
144 install_characterdevices() {
145 local PKGNAME
146 PKGNAME=$1
147
148 if [ -e ${BUILDDIR}/${PKGNAME}/.char ]
149 then
150 #sets fieldseperator to "§" instead of " "
151 IFS=§
152
153 while read pathto posix
154 do
155 if [ ! -z $pathto ]
156 then
157 echo -e "\t>>> CHAR: ${ROOT}${pathto}"
158 mknode -m $posix -c ${ROOT}${pathto}
159 fi
160 done < ${BUILDDIR}/${PKGNAME}/.char
161
162 #very important: unsetting the '§' fieldseperator
163 unset IFS
164 else
165 fatal_error .char
166 fi
167
168 #very important: unsetting the '§' fieldseperator
169 unset IFS
170 }
171
172
173 ###################################################
174 # function build_doinstall #
175 # build_doinstall $PKGNAME #
176 # NOTE: this is an wrapper do install packages #
177 ###################################################
178 build_doinstall() {
179 #this is only a wrapper
180
181 # NOTE:
182 # !! we use § as field seperator !!
183 # doing so prevent us to get errors by filenames with spaces
184
185 local PKGNAME
186 PKGNAME=$1
187
188 install_directories ${PKGNAME}
189 install_files ${PKGNAME}
190 install_symlinks ${PKGNAME}
191 install_blockdevices ${PKGNAME}
192 install_characterdevices ${PKGNAME}
193 }
194
195 usage(){
196 echo
197 echo -e "Usage:"
198 echo -e "$(basename $0) /path/to/foo.mpk"
199 echo
200 echo -e "Use ROOT=/path/to/install-location"
201 echo -e "to overide the default-root '/'"
202 echo
203
204 exit 1
205 }
206
207 [ -z "$1" ] && usage
208
209 PKGFILE=$1
210 PKGNAME=$(basename ${PKGFILE} .mpk)
211
212
213 if [ -z "${BUILDDIR}" ]
214 then
215 export BUILDDIR=/var/tmp/magebuild
216 install -d ${BUILDDIR}
217 fi
218
219 echo -e "\nInstallation of Package: ${COLGREEN}${PKGNAME/-${ARCH}/}${COLDEFAULT}\n"
220 echo -en "Unpacking Package ... "
221 tar xjmf ${PKGFILE} -C ${BUILDDIR}
222 echo "done"
223
224 #fake root ?
225 if [ -n "${ROOT}" ]
226 then
227 echo
228 echo "Installing package to fake ROOT '${ROOT}'"
229 echo
230 fi
231
232 #build_doinstall
233 build_doinstall ${PKGNAME}
234
235 #cleanup
236 if [ -d ${BUILDDIR}/${PKGNAME} ]
237 then
238 rm -rf ${BUILDDIR}/${PKGNAME}
239 fi
240
241 echo -e "\nPackage '${PKGNAME/-${ARCH}/}' sucessfully installed.\n"

Properties

Name Value
svn:executable *