Magellan Linux

Diff of /branches/mage-sql/usr/lib/mage/convert_databases_smage.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1112 by niro, Wed Jul 14 17:38:51 2010 UTC revision 1113 by niro, Sat Jul 17 10:39:06 2010 UTC
# Line 5  source /etc/mage.rc Line 5  source /etc/mage.rc
5    
6    
7  #### fixups ####  #### fixups ####
8  MLIBDIR=/home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage  MLIBDIR=/home/tjoke/svn/magellan-source/branches/mage-sql/usr/lib/mage
9  INSTALLDB=/var/db/mage  INSTALLDB=/var/db/mage
10  #################  #################
11    
# Line 29  ${sqlcmd}; Line 29  ${sqlcmd};
29  EOF  EOF
30  }  }
31    
32    split_save_variables()
33    {
34     export SAVED_PNAME="${PNAME}"
35     export SAVED_PVER="${PVER}"
36     export SAVED_PBUILD="${PBUILD}"
37     export SAVED_PCATEGORIE="${PCATEGORIE}"
38     export SAVED_DESCRIPTION="${DESCRIPTION}"
39     export SAVED_HOMEPAGE="${HOMEPAGE}"
40     export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"
41     export SAVED_STATE="${STATE}"
42     export SAVED_PKGTYPE="${PKGTYPE}"
43     export SAVED_INHERITS="${INHERITS}"
44     export SAVED_DEPEND="${DEPEND}"
45     export SAVED_SDEPEND="${SDEPEND}"
46     export SAVED_PROVIDE="${PROVIDE}"
47     export SAVED_NOPKGBUILD="${NOPKGBUILD}"
48    
49     # bindir too
50     export SAVED_BINDIR="${BINDIR}"
51    
52     # export the SPLIT_PACKAGE_BASE
53     export SPLIT_PACKAGE_BASE="${SAVED_PNAME}"
54    
55     # functions
56     if [[ ! -z $(typeset -f preinstall) ]]
57     then
58     # rename the old one
59     local saved_preinstall
60     saved_preinstall=SAVED_$(typeset -f preinstall)
61     eval "${saved_preinstall}"
62     export -f SAVED_preinstall
63     fi
64    
65     if [[ ! -z $(typeset -f postinstall) ]]
66     then
67     # rename the old one
68     local saved_postinstall
69     saved_postinstall=SAVED_$(typeset -f postinstall)
70     eval "${saved_postinstall}"
71     export -f SAVED_postinstall
72     fi
73    
74     if [[ ! -z $(typeset -f preremove) ]]
75     then
76     # rename the old one
77     local saved_preremove
78     saved_preremove=SAVED_$(typeset -f preremove)
79     eval "${saved_preremove}"
80     export -f SAVED_preremove
81     fi
82    
83     if [[ ! -z $(typeset -f postremove) ]]
84     then
85     # rename the old one
86     local saved_postremove
87     saved_postremove=SAVED_$(typeset -f postremove)
88     eval "${saved_postremove}"
89     export -f SAVED_postremove
90     fi
91    }
92    
93    split_restore_variables()
94    {
95     export PNAME="${SAVED_PNAME}"
96     export PVER="${SAVED_PVER}"
97     export PBUILD="${SAVED_PBUILD}"
98     export PCATEGORIE="${SAVED_PCATEGORIE}"
99     export DESCRIPTION="${SAVED_DESCRIPTION}"
100     export HOMEPAGE="${SAVED_HOMEPAGE}"
101     export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
102     export STATE="${SAVED_STATE}"
103     export PKGTYPE="${SAVED_PKGTYPE}"
104     export INHERITS="${SAVED_INHERITS}"
105     export DEPEND="${SAVED_DEPEND}"
106     export SDEPEND="${SAVED_SDEPEND}"
107     export PROVIDE="${SAVED_PROVIDE}"
108     export NOPKGBUILD="${SAVED_NOPKGBUILD}"
109    
110     # bindir too
111     export BINDIR="${SAVED_BINDIR}"
112    
113     # functions
114     if [[ ! -z $(typeset -f SAVED_preinstall) ]]
115     then
116     # rename the old one
117     local saved_preinstall
118     saved_preinstall=$(typeset -f SAVED_preinstall)
119     eval "${saved_preinstall/SAVED_/}"
120     export -f preinstall
121     fi
122    
123     if [[ ! -z $(typeset -f SAVED_postinstall) ]]
124     then
125     # rename the old one
126     local saved_postinstall
127     saved_postinstall=$(typeset -f SAVED_postinstall)
128     eval "${saved_postinstall/SAVED_/}"
129     export -f postinstall
130     fi
131    
132     if [[ ! -z $(typeset -f SAVED_preremove) ]]
133     then
134     # rename the old one
135     local saved_preremove
136     saved_preremove=$(typeset -f SAVED_preremove)
137     eval "${saved_preremove/SAVED_/}"
138     export -f preremove
139     fi
140    
141     if [[ ! -z $(typeset -f SAVED_postremove) ]]
142     then
143     # rename the old one
144     local saved_postremove
145     saved_postremove=$(typeset -f SAVED_postremove)
146     eval "${saved_postremove/SAVED_/}"
147     export -f postremove
148     fi
149    }
150    
151    split_unset_variables()
152    {
153     # unset saved vars; not needed anymore
154     unset SAVED_PNAME
155     unset SAVED_PVER
156     unset SAVED_PBUILD
157     unset SAVED_PCATEGORIE
158     unset SAVED_DESCRIPTION
159     unset SAVED_HOMEPAGE
160     unset SAVED_SPECIAL_VARS
161     unset SAVED_STATE
162     unset SAVED_PKGTYPE
163     unset SAVED_INHERITS
164     unset SAVED_DEPEND
165     unset SAVED_SDEPEND
166     unset SAVED_PROVIDE
167     unset SAVED_BINDIR
168     unset SAVED_NOPKGBUILD
169     unset SPLIT_PACKAGE_BASE
170     unset -f SAVED_preinstall
171     unset -f SAVED_postinstall
172     unset -f SAVED_preremove
173     unset -f SAVED_postremove
174    }
175    
176  create_database_layout()  create_database_layout()
177  {  {
178   sql "create table categories(id integer primary key, pcat text unique)"   sql "create table categories(id integer primary key, pcat text unique)"
# Line 65  create_database_layout() Line 209  create_database_layout()
209   script text)"   script text)"
210  }  }
211    
212  convert_smage_db()  smage2sqlite()
213  {  {
214   local i   local i
  local smagefile  
  local PCATEGORIE  
  local PNAME  
  local PVER  
  local PBUILD  
215   local pcatid   local pcatid
  local STATE  
216   local pkgid   local pkgid
217   local dep   local dep
  local PKGNAME  
  local DESCRIPTION  
  local HOMEPAGE  
  local DEPEND  
  local SDEPEND  
  local PROVIDE  
  local PKGTYPE  
  local preinstall  
  local postinstall  
  local preremove  
  local postremove  
218   local sym   local sym
219   local depname   local depname
220   local depver   local depver
# Line 97  convert_smage_db() Line 224  convert_smage_db()
224   local md5file   local md5file
225   local md5sum   local md5sum
226    
227   # create categories   pcatid=$(sql "select id from categories where pcat='${PCATEGORIE}'")
  cat ${SMAGESCRIPTSDIR}/.known_categories | while read pcat  
  do  
  case ${pcat} in  
  include|profiles) continue;;  
  esac  
228    
229   sql "insert into categories (pcat) values('${pcat}')"   sql "insert into packages(
230   done   pname,
231     pver,
232     pbuild,
233     pcat_id,
234     state,
235     provide,
236     pkgtype
237     )
238     values(
239     '${PNAME}',
240     '${PVER}',
241     '${PBUILD}',
242     '${pcatid}',
243     '${STATE}',
244     '${PROVIDE}',
245     '${PKGTYPE}'
246     )"
247    
248   # create packages   pkgid=$(sql "select id from packages where pname='${PNAME}' and pver='${PVER}' and pbuild='${PBUILD}'")
249   for smagefile in $(find ${SMAGESCRIPTSDIR}/glibc-nptl -type f -name '*'.smage2 | sort)  
250     # depends
251     while read sym dep
252   do   do
253   case ${DEBUG} in   # ignore scripts atm -FIXME!!!
254   1|true) echo "converting ${smagefile}" ;;   case ${sym} in
255     \$\(*) continue ;;
256   esac   esac
257    
258   source ${smagefile}   [[ -z ${dep} ]] && continue
259     depcat="$(dep2pcat ${dep})"
260     depcatid=$(sql "select id from categories where pcat='${depcat}'")
261     depname="$(dep2pname ${dep})"
262     depver="$(dep2pver ${dep})"
263    
264   # substitute r from pbuild   if [[ -z ${depcatid} ]]
265   PBUILD="${PBUILD/r/}"   then
266     die "Error: '${PNAME}' -> depcat '${depcat}' has no depcatid, it does no exist in database!"
267     fi
268    
269   pcatid=$(sql "select id from categories where pcat='${PCATEGORIE}'")   sql "insert into depends(pkg_id,
270   sql "insert into packages(   relation,
271     pcat_id,
272   pname,   pname,
273   pver,   pver,
274   pbuild,   pbuild)
275   pcat_id,   values('${pkgid}',
276   state,   '${sym}',
277   provide,   '${depcatid}',
278   pkgtype   '${depname}',
279   )   '${depver}',
280   values(   '${depbuild}')"
281   '${PNAME}',   done << EOF
  '${PVER}',  
  '${PBUILD}',  
  '${pcatid}',  
  '${STATE}',  
  '${PROVIDE}',  
  '${PKGTYPE}'  
  )"  
   
  pkgid=$(sql "select id from packages where pname='${PNAME}' and pver='${PVER}' and pbuild='${PBUILD}'")  
  # depends  
  while read sym dep  
  do  
  [[ -z ${dep} ]] && continue  
  depcat="$(dep2pcat ${dep})"  
  depcatid=$(sql "select id from categories where pcat='${depcat}'")  
  depname="$(dep2pname ${dep})"  
  depver="$(dep2pver ${dep})"  
  sql "insert into depends(pkg_id,  
  relation,  
  pcat_id,  
  pname,  
  pver,  
  pbuild)  
  values('${pkgid}',  
  '${sym}',  
  '${depcatid}',  
  '${depname}',  
  '${depver}',  
  '${depbuild}')"  
  done << EOF  
282  ${DEPEND}  ${DEPEND}
283  EOF  EOF
284   # sdepends   # sdepends
285   while read sym dep   while read sym dep
286   do   do
287   [[ -z ${dep} ]] && continue   [[ -z ${dep} ]] && continue
288   depcat="$(dep2pcat ${dep})"   depcat="$(dep2pcat ${dep})"
289   depcatid=$(sql "select id from categories where pcat='${depcat}'")   depcatid=$(sql "select id from categories where pcat='${depcat}'")
290   depname="$(dep2pname ${dep})"   depname="$(dep2pname ${dep})"
291   depver="$(dep2pver ${dep})"   depver="$(dep2pver ${dep})"
292   sql "insert into sdepends(pkg_id,   sql "insert into sdepends(pkg_id,
293   relation,   relation,
294   pcat_id,   pcat_id,
295   pname,   pname,
296   pver,   pver,
297   pbuild)   pbuild)
298   values('${pkgid}',   values('${pkgid}',
299   '${sym}',   '${sym}',
300   '${depcatid}',   '${depcatid}',
301   '${depname}',   '${depname}',
302   '${depver}',   '${depver}',
303   '${depbuild}')"   '${depbuild}')"
304   done << EOF   done << EOF
305  ${SDEPEND}  ${SDEPEND}
306  EOF  EOF
307    
308   for arch in i686 x86_64   for arch in i686 x86_64
309   do   do
310   md5file="${MAGEDIR}/${PCATEGORIE}/${PNAME}/md5/${PNAME}-${PVER}-${arch}-r${PBUILD}.md5"   md5file="${MAGEDIR}/${PCATEGORIE}/${PNAME}/md5/${PNAME}-${PVER}-${arch}-r${PBUILD}.md5"
311   [[ -f ${md5file} ]] && md5sum="$(cat ${md5file} | cut -d' ' -f1)"   [[ -f ${md5file} ]] && md5sum="$(cat ${md5file} | cut -d' ' -f1)"
   
  # fix descriptions  
  DESCRIPTION="$(echo ${DESCRIPTION} | sed s:\':\'\':g)"  
312    
313   sql "insert into packages_info(pkg_id, arch, md5, description, homepage)   # fix descriptions
314   values('${pkgid}','${arch}','${md5sum}','${DESCRIPTION}','${HOMEPAGE}')"   DESCRIPTION="$(echo ${DESCRIPTION} | sed s:\':\'\':g)"
  done  
315    
316   # using $INHERITS directly   sql "insert into packages_info(pkg_id, arch, md5, description, homepage)
317   #mincludes="$(grep -r 'minclude ' ${magefile} | cut -d: -f2 | sed s:minclude\ ::)"   values('${pkgid}','${arch}','${md5sum}','${DESCRIPTION}','${HOMEPAGE}')"
318     done
319    
320  # # #   # using $INHERITS directly
321  # # # install routines & includes   #mincludes="$(grep -r 'minclude ' ${magefile} | cut -d: -f2 | sed s:minclude\ ::)"
 # # #  
 # # # needs special magic: the last line of typeset has no ';'  
 # # # but to eval the function we must append it  
 # # # so this sed deletes the last line of the typeset output  
 # # # and replaces it with an ;} and a newline between  
 # # #  
 # # # but we will not add this fun when no postinstall etc are given  
 # # # -> [[ -n $(typeset -f postinstall ]] &&  
 # # #  
 # # # also the character ' is a problem while importing to sql  
 # # # because we use ' as escape char. so we replace it with ''  
 # # #  
 # # # $([[ -n $(typeset -f postinstall) ]] && echo -e "$(typeset -f postinstall | sed s:\':\'\':g | sed '$d');\n}")  
 # # #  
 # # sql "insert into packages_routines(pkg_id,  
 # # mincludes,  
 # # postinstall,  
 # # preinstall,  
 # # preremove,  
 # # postremove)  
 # # values('${pkgid}',  
 # # '${mincludes}',  
 # # '$([[ -n $(typeset -f postinstall) ]] && echo -e "$(typeset -f postinstall | sed s:\':\'\':g | sed '$d');\n}")',  
 # # '$([[ -n $(typeset -f preinstall) ]] && echo -e "$(typeset -f preinstall | sed s:\':\'\':g | sed '$d');\n}")',  
 # # '$([[ -n $(typeset -f preremove) ]] && echo -e "$(typeset -f preremove | sed s:\':\'\':g | sed '$d');\n}")',  
 # # '$([[ -n $(typeset -f postremove) ]] && echo -e "$(typeset -f postremove | sed s:\':\'\':g | sed '$d');\n}")')"  
   
  local do_preinst=0  
  local do_postinst=0  
  local do_prerm=0  
  local do_postrm=0  
  local do_script=0  
  local script=""  
   
  [[ -n $(typeset -f preinstall) ]] && do_preinst=1 && do_script=1  
  [[ -n $(typeset -f postinstall) ]] && do_postinst=1 && do_script=1  
  [[ -n $(typeset -f preremove) ]] && do_prerm=1 && do_script=1  
  [[ -n $(typeset -f postremove) ]] && do_postrm=1 && do_script=1  
322    
323   [[ ${do_script} = 1 ]] && script="$(basename ${DBFILE} .sql).routines/${pkgid}/routines.sh"  # # #
324    # # # install routines & includes
325   sql "insert into packages_routines(pkg_id,  # # #
326   mincludes,  # # # needs special magic: the last line of typeset has no ';'
327   postinstall,  # # # but to eval the function we must append it
328   preinstall,  # # # so this sed deletes the last line of the typeset output
329   preremove,  # # # and replaces it with an ;} and a newline between
330   postremove,  # # #
331   script)  # # # but we will not add this fun when no postinstall etc are given
332   values('${pkgid}',  # # # -> [[ -n $(typeset -f postinstall ]] &&
333   '${INHERITS}',  # # #
334   '${do_postinst}',  # # # also the character ' is a problem while importing to sql
335   '${do_pretinst}',  # # # because we use ' as escape char. so we replace it with ''
336   '${do_prerm}',  # # #
337   '${do_postrm}',  # # # $([[ -n $(typeset -f postinstall) ]] && echo -e "$(typeset -f postinstall | sed s:\':\'\':g | sed '$d');\n}")
338   '${script}')"  # # #
339    # # sql "insert into packages_routines(pkg_id,
340    # # mincludes,
341    # # postinstall,
342    # # preinstall,
343    # # preremove,
344    # # postremove)
345    # # values('${pkgid}',
346    # # '${mincludes}',
347    # # '$([[ -n $(typeset -f postinstall) ]] && echo -e "$(typeset -f postinstall | sed s:\':\'\':g | sed '$d');\n}")',
348    # # '$([[ -n $(typeset -f preinstall) ]] && echo -e "$(typeset -f preinstall | sed s:\':\'\':g | sed '$d');\n}")',
349    # # '$([[ -n $(typeset -f preremove) ]] && echo -e "$(typeset -f preremove | sed s:\':\'\':g | sed '$d');\n}")',
350    # # '$([[ -n $(typeset -f postremove) ]] && echo -e "$(typeset -f postremove | sed s:\':\'\':g | sed '$d');\n}")')"
351    
352     local do_preinst=0
353     local do_postinst=0
354     local do_prerm=0
355     local do_postrm=0
356     local do_script=0
357     local script=""
358    
359     [[ -n $(typeset -f preinstall) ]] && do_preinst=1 && do_script=1
360     [[ -n $(typeset -f postinstall) ]] && do_postinst=1 && do_script=1
361     [[ -n $(typeset -f preremove) ]] && do_prerm=1 && do_script=1
362     [[ -n $(typeset -f postremove) ]] && do_postrm=1 && do_script=1
363    
364     [[ ${do_script} = 1 ]] && script="$(basename ${DBFILE} .sql).routines/${pkgid}/routines.sh"
365    
366     sql "insert into packages_routines(pkg_id,
367     mincludes,
368     postinstall,
369     preinstall,
370     preremove,
371     postremove,
372     script)
373     values('${pkgid}',
374     '${INHERITS}',
375     '${do_postinst}',
376     '${do_pretinst}',
377     '${do_prerm}',
378     '${do_postrm}',
379     '${script}')"
380    
381  # create it only if do_script=1  # create it only if do_script=1
382  if [[ ${do_script} = 1 ]]  if [[ ${do_script} = 1 ]]
383  then  then
384   # create a routines script   # create a routines script
385   local routines=$(dirname ${DBFILE})/${script}   local routines=$(dirname ${DBFILE})/${script}
386   install -d $(dirname ${routines})   install -d $(dirname ${routines})
387    
388     echo '#!/bin/sh' > ${routines}
389     echo "# routines.sh script for ${pkgid}, ${PNAME}-${PVER}-${PBUILD}" >> ${routines}
390     echo >> ${routines}
391    
392    
393   echo "#!/bin/sh" > ${routines}   # special functions and variables
394   echo "# routines.sh script for #${pkgid}, ${PNAME}-${PVER}-${PBUILD}" >> ${routines}   if [[ -n ${SPECIAL_VARS} ]]
395   echo >> ${routines}   then
396     local i
397     for i in ${SPECIAL_VARS}
398     do
399     # being tricky here :)
400     echo "${i}=\"$(eval echo \$${i})\"" >> ${routines}
401     done
402     echo  >> ${routines}
403     fi
404    
405     # add special functions
406     if [[ -n ${SPECIAL_FUNCTIONS} ]]
407     then
408     local i
409     for i in ${SPECIAL_FUNCTIONS}
410     do
411     # add to mage (quotes needed !)
412     typeset -f "${i}" >> ${routines}
413     echo >> ${routines}
414     # unset to be safe (quotes needed !)
415     unset "${i}"
416     done
417     echo  >> ${routines}
418     fi
419    
420   # special functions and variables   # postinstall and co
421   if [[ -n ${SPECIAL_VARS} ]]   for i in preinstall postinstall preremove postremove
422     do
423     if [[ -n $(typeset -f "${i}") ]]
424   then   then
425   local i   typeset -f "${i}" >> ${routines}
426   for i in ${SPECIAL_VARS}   echo >> ${routines}
427   do   fi
428   # being tricky here :)   done
429   echo "${i}=\"$(eval echo \$${i})\"" >> ${routines}  
430   done   # create start logic
431   echo  >> ${routines}   echo >> ${routines}
432     echo 'case $1 in' >> ${routines}
433     echo ' preinstall) preinstall ;;' >> ${routines}
434     echo ' postinstall) postinstall ;;' >> ${routines}
435     echo ' preremove) preremove ;;' >> ${routines}
436     echo ' postremove) postremove ;;' >> ${routines}
437     echo 'esac' >> ${routines}
438     echo >> ${routines}
439    fi
440    
441     unset PCATEGORIE
442     unset PNAME
443     unset PVER
444     unset PBUILD
445     unset STATE
446     unset DESCRIPTION
447     unset HOMEPAGE
448     unset PKGTYPE
449     unset PKGNAME
450     unset DEPEND
451     unset SDEPEND
452     unset PROVIDE
453     unset SPECIAL_VARS
454     unset SPECIAL_FUNCTIONS
455     unset INHERITS
456     unset SPLIT_PACKAGES
457    
458     # unset these functions
459     unset -f preinstall
460     unset -f postinstall
461     unset -f preremove
462     unset -f postremove
463    }
464    
465    categories2sqlite()
466    {
467     local file="$1"
468    
469     if [[ ! -f ${file} ]]
470     then
471     echo "${file} does not exist, ignoring..."
472     return 0
473     fi
474    
475     echo "using categories from ${file}..."
476     # create categories
477     cat ${file} | while read pcat
478     do
479     case ${pcat} in
480     include|profiles) continue;;
481     \#*|"") continue ;;
482     esac
483    
484     # "upsert"
485     if [[ -z $(sql "select pcat from categories where pcat='${pcat}'") ]]
486     then
487     sql "insert into categories (pcat) values('${pcat}')"
488   fi   fi
489     done
490    }
491    
492    convert_smage_db()
493    {
494     local smagefile
495    
496   # add special functions   local PCATEGORIE
497   if [[ -n ${SPECIAL_FUNCTIONS} ]]   local PNAME
498     local PVER
499     local PBUILD
500     local STATE
501     local PKGNAME
502     local DESCRIPTION
503     local HOMEPAGE
504     local DEPEND
505     local SDEPEND
506     local PROVIDE
507     local PKGTYPE
508     local SPLIT_PACKAGES
509     local preinstall
510     local postinstall
511     local preremove
512     local postremove
513    
514     # create categories - global
515     categories2sqlite "${SMAGESCRIPTSDIR}/.known_categories"
516    
517     # create categories - repo specific
518     categories2sqlite "${SMAGESCRIPTSDIR}/${REPO}/.known_categories"
519    
520     # create packages
521     for smagefile in $(find ${SMAGESCRIPTSDIR}/${REPO} -type f -name \*.smage2 | sort)
522     do
523     case ${DEBUG} in
524     1|true) echo "converting ${smagefile}" ;;
525     esac
526    
527     source ${smagefile}
528    
529     # build several subpackages
530     if [[ -n ${SPLIT_PACKAGES} ]]
531   then   then
532   local i   split_save_variables
533   for i in ${SPECIAL_FUNCTIONS}   for subpackage in ${SPLIT_PACKAGES}
534   do   do
535   # add to mage (quotes needed !)   echo "Running for subpackage '${subpackage}'..."
  typeset -f "${i}" >> ${routines}  
  echo >> ${routines}  
  # unset to be safe (quotes needed !)  
  unset "${i}"  
  done  
  echo  >> ${routines}  
  fi  
536    
537   # postinstall and co   # get the right variables for the split
538   for i in preinstall postinstall preremove postremove   export PNAME="${subpackage}"
539   do   split_info_${subpackage}
  if [[ -n $(typeset -f "${i}") ]]  
  then  
  typeset -f "${i}" >> ${routines}  
  echo >> ${routines}  
  fi  
  done  
540    
541   # create start logic   smage2sqlite
  echo >> ${routines}  
  echo 'case $1 in' >> ${routines}  
  echo ' preinstall) preinstall ;;' >> ${routines}  
  echo ' postinstall) postinstall ;;' >> ${routines}  
  echo ' preremove) preremove ;;' >> ${routines}  
  echo ' postremove) postremove ;;' >> ${routines}  
  echo 'esac' >> ${routines}  
  echo >> ${routines}  
 fi  
542    
543     # restore smage environment
544     split_restore_variables
545     done
546     # unset all saved smage variables
547     split_unset_variables
548     else
549     smage2sqlite
550     fi
551    
552   unset PCATEGORIE   unset PCATEGORIE
553   unset PNAME   unset PNAME
# Line 336  fi Line 564  fi
564   unset SPECIAL_VARS   unset SPECIAL_VARS
565   unset SPECIAL_FUNCTIONS   unset SPECIAL_FUNCTIONS
566   unset INHERITS   unset INHERITS
567     unset SPLIT_PACKAGES
568    
569   # unset these functions   # unset these functions
570   unset -f preinstall   unset -f preinstall
# Line 384  convert_install_db() Line 613  convert_install_db()
613   local pkginfoid   local pkginfoid
614   local entrydir   local entrydir
615    
616     # first of all add virtual categorie
617     sql "insert into categories(pcat) values('virtual')"
618    
619   # create categories   # create categories
620   for i in virtual ${INSTALLDB}/*   for i in virtual ${INSTALLDB}/*
621   do   do
# Line 406  convert_install_db() Line 638  convert_install_db()
638   pname="$(magename2pname ${magefile})"   pname="$(magename2pname ${magefile})"
639   pver="$(magename2pver ${magefile})"   pver="$(magename2pver ${magefile})"
640   pbuild="$(magename2pbuild ${magefile})"   pbuild="$(magename2pbuild ${magefile})"
  # substitute r from pbuild  
  pbuild="${pbuild/r/}"  
641    
642   source ${magefile}   source ${magefile}
643    
# Line 562  convert_virtual_defaults() Line 792  convert_virtual_defaults()
792    
793  METHOD="$1"  METHOD="$1"
794  DBFILE="$2"  DBFILE="$2"
795    REPO="$3"
796    
797  [[ -z ${METHOD} ]] && die "No method given. Use --install, --packages or --virtual for your appropiate task"  [[ -z ${METHOD} ]] && die "No method given. Use --install, --packages or --virtual for your appropiate task"
798  [[ -z ${DBFILE} ]] && die "No database given."  [[ -z ${DBFILE} ]] && die "No database given."
799    [[ -z ${REPO} ]] && die "No repository given."
800    
801  case $1 in  case $1 in
802   --install|-i)   --install|-i)
# Line 572  case $1 in Line 804  case $1 in
804   convert_install_db   convert_install_db
805   ;;   ;;
806   --packages|-p)   --packages|-p)
807     convert_virtual_defaults
808   create_database_layout   create_database_layout
809   convert_smage_db   convert_smage_db
810   ;;   ;;
811   --virtuals|-v)  # --virtuals|-v)
812   convert_virtual_defaults  # convert_virtual_defaults
813   ;;  # ;;
814   *) die "Unkown method." ;;   *) die "Unkown method." ;;
815  esac  esac

Legend:
Removed from v.1112  
changed lines
  Added in v.1113