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 1117 by niro, Sat Jul 17 10:39:06 2010 UTC revision 1118 by niro, Thu Jul 22 07:19:48 2010 UTC
# Line 356  EOF Line 356  EOF
356   local do_script=0   local do_script=0
357   local script=""   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   [[ -n $(typeset -f preinstall) ]] && do_preinst=1 && do_script=1   [[ -n $(typeset -f preinstall) ]] && do_preinst=1 && do_script=1
367   [[ -n $(typeset -f postinstall) ]] && do_postinst=1 && do_script=1   [[ -n $(typeset -f postinstall) ]] && do_postinst=1 && do_script=1
368   [[ -n $(typeset -f preremove) ]] && do_prerm=1 && do_script=1   [[ -n $(typeset -f preremove) ]] && do_prerm=1 && do_script=1
369   [[ -n $(typeset -f postremove) ]] && do_postrm=1 && do_script=1   [[ -n $(typeset -f postremove) ]] && do_postrm=1 && do_script=1
370    
371   [[ ${do_script} = 1 ]] && script="$(basename ${DBFILE} .sql).routines/${pkgid}/routines.sh"   [[ ${do_script} = 1 ]] && script="$(basename ${DBFILE} .sql).data/${PCATEGORIE}/${PNAME}-${PVER}-${PBUILD}/routines.sh"
372    
373   sql "insert into packages_routines(pkg_id,   sql "insert into packages_routines(pkg_id,
374   mincludes,   mincludes,
# Line 378  EOF Line 385  EOF
385   '${do_postrm}',   '${do_postrm}',
386   '${script}')"   '${script}')"
387    
388    # # # create it only if do_script=1
389    # # if [[ ${do_script} = 1 ]]
390    # # then
391    # # # create a routines script
392    # # local routines=$(dirname ${DBFILE})/${script}
393    # # install -d $(dirname ${routines})
394    # #
395    # # echo '#!/bin/sh' > ${routines}
396    # # echo "# routines.sh script for ${pkgid}, ${PNAME}-${PVER}-${PBUILD}" >> ${routines}
397    # # echo >> ${routines}
398    # #
399    # #
400    # # # special functions and variables
401    # # if [[ -n ${SPECIAL_VARS} ]]
402    # # then
403    # # local i
404    # # for i in ${SPECIAL_VARS}
405    # # do
406    # # # being tricky here :)
407    # # echo "${i}=\"$(eval echo \$${i})\"" >> ${routines}
408    # # done
409    # # echo  >> ${routines}
410    # # fi
411    # #
412    # # # add special functions
413    # # if [[ -n ${SPECIAL_FUNCTIONS} ]]
414    # # then
415    # # local i
416    # # for i in ${SPECIAL_FUNCTIONS}
417    # # do
418    # # # add to mage (quotes needed !)
419    # # typeset -f "${i}" >> ${routines}
420    # # echo >> ${routines}
421    # # # unset to be safe (quotes needed !)
422    # # unset "${i}"
423    # # done
424    # # echo  >> ${routines}
425    # # fi
426    # #
427    # # # postinstall and co
428    # # for i in preinstall postinstall preremove postremove
429    # # do
430    # # if [[ -n $(typeset -f "${i}") ]]
431    # # then
432    # # typeset -f "${i}" >> ${routines}
433    # # echo >> ${routines}
434    # # fi
435    # # done
436    # #
437    # # # create start logic
438    # # echo >> ${routines}
439    # # echo 'case $1 in' >> ${routines}
440    # # echo ' preinstall) preinstall ;;' >> ${routines}
441    # # echo ' postinstall) postinstall ;;' >> ${routines}
442    # # echo ' preremove) preremove ;;' >> ${routines}
443    # # echo ' postremove) postremove ;;' >> ${routines}
444    # # echo 'esac' >> ${routines}
445    # # echo >> ${routines}
446    # # fi
447    
448  # create it only if do_script=1  # create it only if do_script=1
449  if [[ ${do_script} = 1 ]]  if [[ ${do_script} = 1 ]]
450  then  then
# Line 386  then Line 453  then
453   install -d $(dirname ${routines})   install -d $(dirname ${routines})
454    
455   echo '#!/bin/sh' > ${routines}   echo '#!/bin/sh' > ${routines}
456   echo "# routines.sh script for ${pkgid}, ${PNAME}-${PVER}-${PBUILD}" >> ${routines}   echo "# routines.sh script for ${PCATEGORIE}/${PNAME}-${PVER}-${PBUILD}" >> ${routines}
457   echo >> ${routines}   echo >> ${routines}
458    
459    
# Line 424  then Line 491  then
491   then   then
492   typeset -f "${i}" >> ${routines}   typeset -f "${i}" >> ${routines}
493   echo >> ${routines}   echo >> ${routines}
494     else
495     echo "${i} () { return 0; }" >> ${routines}
496   fi   fi
497   done   done
498    
# Line 624  convert_install_db() Line 693  convert_install_db()
693   include|profiles) continue;;   include|profiles) continue;;
694   esac   esac
695    
696   sql "insert into categories (pcat) values('${pcat}')"   # "upsert"
697     if [[ -z $(sql "select pcat from categories where pcat='${pcat}'") ]]
698     then
699     sql "insert into categories (pcat) values('${pcat}')"
700     fi
701   done   done
702    
703   # create packages   # create packages
# Line 728  EOF Line 801  EOF
801   '$(typeset -f preremove | sed s:\':\'\':g)',   '$(typeset -f preremove | sed s:\':\'\':g)',
802   '$(typeset -f postremove | sed s:\':\'\':g)')"   '$(typeset -f postremove | sed s:\':\'\':g)')"
803    
804   ####           ####  # # ####           ####
805   # record contents #  # # # record contents #
806   ####           ####  # # ####           ####
807   pkginfoid=$(sql "select id from packages_info where pkg_id='${pkgid}' and arch='${ARCH}'")  # # pkginfoid=$(sql "select id from packages_info where pkg_id='${pkgid}' and arch='${ARCH}'")
808   entrydir="$(dirname ${magefile})"  # # entrydir="$(dirname ${magefile})"
809   sql "insert into packages_content(pkginfo_id,  # # sql "insert into packages_content(pkginfo_id,
810   char,  # # char,
811   dirs,  # # dirs,
812   files,  # # files,
813   pipes,  # # pipes,
814   symlinks)  # # symlinks)
815   values('${pkginfoid}',  # # values('${pkginfoid}',
816   '$(basename ${DBFILE} .sql).records/${pkginfoid}/char.bz2',  # # '$(basename ${DBFILE} .sql).records/${pkginfoid}/char.bz2',
817   '$(basename ${DBFILE} .sql).records/${pkginfoid}/dirs.bz2',  # # '$(basename ${DBFILE} .sql).records/${pkginfoid}/dirs.bz2',
818   '$(basename ${DBFILE} .sql).records/${pkginfoid}/files.bz2',  # # '$(basename ${DBFILE} .sql).records/${pkginfoid}/files.bz2',
819   '$(basename ${DBFILE} .sql).records/${pkginfoid}/pipes.bz2',  # # '$(basename ${DBFILE} .sql).records/${pkginfoid}/pipes.bz2',
820   '$(basename ${DBFILE} .sql).records/${pkginfoid}/symlinks.bz2')"  # # '$(basename ${DBFILE} .sql).records/${pkginfoid}/symlinks.bz2')"
821   # create compressed content files  # # # create compressed content files
822   local entryfile  # # local entryfile
823   for entryfile in char dirs files pipes symlinks  # # for entryfile in char dirs files pipes symlinks
824   do  # # do
825   install -d $(dirname ${DBFILE})/$(basename ${DBFILE} .sql).records/${pkginfoid}  # # install -d $(dirname ${DBFILE})/$(basename ${DBFILE} .sql).records/${pkginfoid}
826   cat ${entrydir}/.${entryfile} | bzip2 -9 >> $(dirname ${DBFILE})/$(basename ${DBFILE} .sql).records/${pkginfoid}/${entryfile}.bz2  # # cat ${entrydir}/.${entryfile} | bzip2 -9 >> $(dirname ${DBFILE})/$(basename ${DBFILE} .sql).records/${pkginfoid}/${entryfile}.bz2
827   done  # # done
828    
829   unset PKGNAME   unset PKGNAME
830   unset DEPEND   unset DEPEND

Legend:
Removed from v.1117  
changed lines
  Added in v.1118