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