Magellan Linux

Contents of /branches/mage-next/src/sql/generate_meta_data.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2578 - (show annotations) (download) (as text)
Wed Jan 29 13:45:34 2014 UTC (10 years, 2 months ago) by niro
File MIME type: application/x-sh
File size: 3694 byte(s)
-temporarily moved sql stuff to src/sql
1 #!/bin/bash
2 # generate metadata files for packages - called after smage2 has done packaging
3
4 : ${MAGERC="/etc/mage.rc"}
5
6 source /etc/mage.rc.global
7 source ${MAGERC}
8 source ${MLIBDIR}/mage4.functions.sh
9 source ${MLIBDIR}/smage2.functions.sh
10
11 die()
12 {
13 echo -e "Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."
14 echo -e "$@"
15 exit 1
16 }
17
18 SMAGEFILE="$1"
19 METADIR=/var/cache/mage/meta
20
21 smagesource ${SMAGEFILE}
22
23 DEST="${METADIR}/${PNAME}/${PNAME}-${PVER}-${PBUILD}"
24
25 install -d ${DEST} || die
26 install -d ${DEST}/${ARCH} || die
27
28 # basic meta data
29 echo "${PNAME}" > ${DEST}/meta
30 echo "${PCAT}" >> ${DEST}/meta
31 echo "${PVER}" >> ${DEST}/meta
32 echo "${PBUILD/r/}" >> ${DEST}/meta
33 echo "${STATE}" >> ${DEST}/meta
34 echo "${DESCRIPTION}" >> ${DEST}/meta
35 echo "${HOMEPAGE}" >> ${DEST}/meta
36 echo "${PKGTYPE}" >> ${DEST}/meta
37 echo "${INHERITS}" >> ${DEST}/meta
38
39 # arch specific meta data
40 [[ -f ${PKGDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}.${PKGSUFFIX} ]] &&
41 MD5=$(md5sum ${PKGDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}.${PKGSUFFIX} | cut -d' ' -f1)
42 [[ -e ${BUILDDIR}/builded ]] &&
43 SIZE="$(du -hDs ${BUILDDIR}/builded | cut -d $'\t' -f1)"
44 [[ -f ${BUILDDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}/.mtime ]] &&
45 MTIME="$(< ${BUILDDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}/.mtime)"
46 echo "${MD5}" > ${DEST}/${ARCH}/desc
47 echo "${SIZE}" >> ${DEST}/${ARCH}/desc
48 echo "${MTIME}" >> ${DEST}/${ARCH}/desc
49
50 # depends
51 echo "${DEPEND}" > ${DEST}/${ARCH}/depend
52
53 # sdepends
54 echo "${SDEPEND}" > ${DEST}/${ARCH}/sdepend
55
56 # provides
57 echo "${PROVIDES}" > ${DEST}/${ARCH}/provides
58
59 # content
60 # char
61 # dirs
62 # files
63 # pipes
64 # symlinks
65 for i in char dirs files pipes symlinks
66 do
67 SRC="${BUILDDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}/.${i}"
68 [[ -f ${SRC} ]] && cat ${SRC} | bzip2 -9 > ${DEST}/${ARCH}/${i}.bz2
69 done
70
71 # preinstall etc
72 # routines.sh
73
74 do_preinst=0
75 do_postinst=0
76 do_prerm=0
77 do_postrm=0
78 do_script=0
79
80 [[ -n $(typeset -f preinstall) ]] && touch ${DEST}/preinstall && do_preinst=1 && do_script=1
81 [[ -n $(typeset -f postinstall) ]] && touch ${DEST}/postinstall && do_postinst=1 && do_script=1
82 [[ -n $(typeset -f preremove) ]] && touch ${DEST}/preremove && do_prerm=1 && do_script=1
83 [[ -n $(typeset -f postremove) ]] && touch ${DEST}/postremove && do_postrm=1 && do_script=1
84
85 # create it only if do_script=1
86 if [[ ${do_script} = 1 ]]
87 then
88 # create a routines script
89 routines="${DEST}/routines.sh"
90
91 echo "#!/bin/sh" > ${routines}
92 echo "# routines.sh script for ${PNAME}-${PVER}-${PBUILD}" >> ${routines}
93 echo >> ${routines}
94
95 # special functions and variables
96 if [[ -n ${SPECIAL_VARS} ]]
97 then
98 for i in ${SPECIAL_VARS}
99 do
100 # being tricky here :)
101 echo "${i}=\"$(eval echo \$${i})\"" >> ${routines}
102 done
103 echo >> ${routines}
104 fi
105
106 # add special functions
107 if [[ -n ${SPECIAL_FUNCTIONS} ]]
108 then
109 for i in ${SPECIAL_FUNCTIONS}
110 do
111 # add to mage (quotes needed !)
112 typeset -f "${i}" >> ${routines}
113 echo >> ${routines}
114 # unset to be safe (quotes needed !)
115 unset "${i}"
116 done
117 echo >> ${routines}
118 fi
119
120 # postinstall and co
121 for i in preinstall postinstall preremove postremove
122 do
123 if [[ -n $(typeset -f "${i}") ]]
124 then
125 typeset -f "${i}" >> ${routines}
126 echo >> ${routines}
127 fi
128 done
129
130 # create start logic
131 echo >> ${routines}
132 echo 'case $1 in' >> ${routines}
133 [[ ${do_preinst} = 1 ]] && echo ' preinstall) preinstall ;;' >> ${routines}
134 [[ ${do_postinst} = 1 ]] && echo ' postinstall) postinstall ;;' >> ${routines}
135 [[ ${do_prerm} = 1 ]] && echo ' preremove) preremove ;;' >> ${routines}
136 [[ ${do_postrm} = 1 ]] && echo ' postremove) postremove ;;' >> ${routines}
137 echo ' *) echo "error unkown option \"$1\" ..." ;;' >> ${routines}
138 echo 'esac' >> ${routines}
139 echo >> ${routines}
140 fi

Properties

Name Value
svn:executable *