Magellan Linux

Contents of /trunk/mage/usr/lib/mage/fixdatabase_ifs.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 24 - (show annotations) (download) (as text)
Wed Jan 5 05:08:01 2005 UTC (19 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 4057 byte(s)
mage-0.3.6-r8 import

1 #!/bin/bash
2
3 #fixdatabase_ifs.sh
4 # version: 0.3.6-r5
5 #(deprecated; used to upgrade systems prior 0.3.6-r1 )
6
7 #fixes the ifs of included db_files in given package
8
9 MLIBDIR=/usr/lib/mage
10
11 usage(){
12 echo
13 echo "$(basename $0) OLD_IFS NEW_IFS /path/to/PACKAGEFILE.mpk"
14 echo
15 }
16
17 if [ $# -ne 3 ]
18 then
19 usage
20 exit 1
21 fi
22
23 #some needed infos
24 source ${MLIBDIR}/mage3.functions.sh
25 source /etc/mage.rc
26
27 PKGFILE=$3
28 PKGNAME=$(basename ${PKGFILE} .mpk)
29 OLD_IFS=$1
30 NEW_IFS=$2
31
32 DB_ENTRY=${BUILDDIR}/${PKGNAME}
33
34 echo -n "Unpacking ${PKGNAME} ... "
35 tar xjmf ${PKGFILE} -C ${BUILDDIR}
36 echo "done"
37
38
39 echo -n "Updating ${PKGNAME}/.files ... "
40 #updating .files db entries
41 if [ -e ${DB_ENTRY}/.files ]
42 then
43 #make backup
44 mv ${DB_ENTRY}/.files \
45 ${DB_ENTRY}/.files-old
46
47 #sets fieldseperator to "$OLD_IFS" instead of " "
48 IFS=${OLD_IFS}
49
50 #update
51 while read pathto posix user group mtime md5sum
52 do
53 echo "${pathto}${NEW_IFS}${posix}${NEW_IFS}${user}${NEW_IFS}${group}${NEW_IFS}${mtime}${NEW_IFS}${md5sum}" \
54 >> ${DB_ENTRY}/.files
55 done < ${DB_ENTRY}/.files-old
56
57 #remove old list
58 rm -f ${DB_ENTRY}/.files-old
59
60 #very important: unsetting the fieldseperator
61 unset IFS
62 else
63 fatal_error .files
64 fi
65 #recreate if .files was zero
66 if [ ! -e ${DB_ENTRY}/.files ]
67 then
68 touch ${DB_ENTRY}/.files
69 fi
70 echo "done"
71
72
73 echo -n "Updating ${PKGNAME}/.symlinks ... "
74 #updating .symlinks db entries
75 if [ -e ${DB_ENTRY}/.symlinks ]
76 then
77 #make backup
78 mv ${DB_ENTRY}/.symlinks \
79 ${DB_ENTRY}/.symlinks-old
80
81 #sets fieldseperator to "$OLD_IFS" instead of " "
82 IFS=${OLD_IFS}
83
84 #update
85 while read pathto posix link mtime
86 do
87 echo "${pathto}${NEW_IFS}${posix}${NEW_IFS}${link}${NEW_IFS}${mtime}" \
88 >> ${DB_ENTRY}/.symlinks
89 done < ${DB_ENTRY}/.symlinks-old
90
91 #remove old list
92 rm -f ${DB_ENTRY}/.symlinks-old
93
94 #very important: unsetting the fieldseperator
95 unset IFS
96 else
97 fatal_error .symlinks
98 fi
99 #recreate if .symlinks was zero
100 if [ ! -e ${DB_ENTRY}/.symlinks ]
101 then
102 touch ${DB_ENTRY}/.symlinks
103 fi
104 echo "done"
105
106
107 echo -n "Updating ${PKGNAME}/.dirs ... "
108 #updating .dirs db entries
109 if [ -e ${DB_ENTRY}/.dirs ]
110 then
111 #make backup
112 mv ${DB_ENTRY}/.dirs \
113 ${DB_ENTRY}/.dirs-old
114
115 #sets fieldseperator to "$OLD_IFS" instead of " "
116 IFS=${OLD_IFS}
117
118 #update
119 while read pathto posix user group
120 do
121 echo "${pathto}${NEW_IFS}${posix}${NEW_IFS}${user}${NEW_IFS}${group}" \
122 >> ${DB_ENTRY}/.dirs
123 done < ${DB_ENTRY}/.dirs-old
124
125 #remove old list
126 rm -f ${DB_ENTRY}/.dirs-old
127
128 #very important: unsetting the fieldseperator
129 unset IFS
130 else
131 fatal_error .dirs
132 fi
133 #recreate if .dirs was zero
134 if [ ! -e ${DB_ENTRY}/.dirs ]
135 then
136 touch ${DB_ENTRY}/.dirs
137 fi
138 echo "done"
139
140
141 echo -n "Updating ${PKGNAME}/.pipes ... "
142 #updating .pipes db entries
143 if [ -e ${DB_ENTRY}/.pipes ]
144 then
145 #make backup
146 mv ${DB_ENTRY}/.pipes \
147 ${DB_ENTRY}/.pipes-old
148
149 #sets fieldseperator to "$OLD_IFS" instead of " "
150 IFS=${OLD_IFS}
151
152 #update
153 while read pathto posix
154 do
155 echo "${pathto}${NEW_IFS}${posix}" \
156 >> ${DB_ENTRY}/.pipes
157 done < ${DB_ENTRY}/.pipes-old
158
159 #remove old list
160 rm -f ${DB_ENTRY}/.pipes-old
161
162 #very important: unsetting the fieldseperator
163 unset IFS
164 else
165 fatal_error .pipes
166 fi
167 #recreate if .pipes was zero
168 if [ ! -e ${DB_ENTRY}/.pipes ]
169 then
170 touch ${DB_ENTRY}/.pipes
171 fi
172 echo "done"
173
174
175 echo -n "Updating ${PKGNAME}/.char ... "
176 #updating .char db entries
177 if [ -e ${DB_ENTRY}/.char ]
178 then
179 #make backup
180 mv ${DB_ENTRY}/.char \
181 ${DB_ENTRY}/.char-old
182
183 #sets fieldseperator to "$OLD_IFS" instead of " "
184 IFS=${OLD_IFS}
185
186 #update
187 while read pathto posix
188 do
189 echo "${pathto}${NEW_IFS}${posix}" \
190 >> ${DB_ENTRY}/.char
191 done < ${DB_ENTRY}/.char-old
192
193 #remove old list
194 rm -f ${DB_ENTRY}/.char-old
195
196 #very important: unsetting the fieldseperator
197 unset IFS
198 else
199 fatal_error .char
200 fi
201 #recreate if .char was zero
202 if [ ! -e ${DB_ENTRY}/.char ]
203 then
204 touch ${DB_ENTRY}/.char
205 fi
206 echo "done"
207
208 echo -n "Rebuilding Package ... "
209 cd ${BUILDDIR}
210 tar cjf ${PKGNAME}.tar.bz2 ./${PKGNAME}
211 install -d ${PKGDIR}
212 mv ${PKGNAME}.tar.bz2 ${PKGDIR}/${PKGNAME}.mpk
213 echo "done"
214 echo

Properties

Name Value
svn:executable *