Magellan Linux

Contents of /branches/mage-next/usr/lib/mage/generate_meta_data.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1642 - (show annotations) (download) (as text)
Fri Jan 13 18:37:52 2012 UTC (12 years, 4 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/generate_meta_data.sh
File MIME type: application/x-sh
File size: 3733 byte(s)
-honor the PCATEGORIE deprecation and make the scripts work with the latest changes to smage/mage
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 "${MAGE_TARGETS}" >> ${DEST}/meta
38 echo "${INHERITS}" >> ${DEST}/meta
39
40 # arch specific meta data
41 [[ -f ${PKGDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}.${PKGSUFFIX} ]] &&
42 MD5=$(md5sum ${PKGDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}.${PKGSUFFIX} | cut -d' ' -f1)
43 [[ -e ${BUILDDIR}/builded ]] &&
44 SIZE="$(du -hDs ${BUILDDIR}/builded | cut -d $'\t' -f1)"
45 [[ -f ${BUILDDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}/.mtime ]] &&
46 MTIME="$(< ${BUILDDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}/.mtime)"
47 echo "${MD5}" > ${DEST}/${ARCH}/desc
48 echo "${SIZE}" >> ${DEST}/${ARCH}/desc
49 echo "${MTIME}" >> ${DEST}/${ARCH}/desc
50
51 # depends
52 echo "${DEPEND}" > ${DEST}/${ARCH}/depend
53
54 # sdepends
55 echo "${SDEPEND}" > ${DEST}/${ARCH}/sdepend
56
57 # provides
58 echo "${PROVIDES}" > ${DEST}/${ARCH}/provides
59
60 # content
61 # char
62 # dirs
63 # files
64 # pipes
65 # symlinks
66 for i in char dirs files pipes symlinks
67 do
68 SRC="${BUILDDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}/.${i}"
69 [[ -f ${SRC} ]] && cat ${SRC} | bzip2 -9 > ${DEST}/${ARCH}/${i}.bz2
70 done
71
72 # preinstall etc
73 # routines.sh
74
75 do_preinst=0
76 do_postinst=0
77 do_prerm=0
78 do_postrm=0
79 do_script=0
80
81 [[ -n $(typeset -f preinstall) ]] && touch ${DEST}/preinstall && do_preinst=1 && do_script=1
82 [[ -n $(typeset -f postinstall) ]] && touch ${DEST}/postinstall && do_postinst=1 && do_script=1
83 [[ -n $(typeset -f preremove) ]] && touch ${DEST}/preremove && do_prerm=1 && do_script=1
84 [[ -n $(typeset -f postremove) ]] && touch ${DEST}/postremove && do_postrm=1 && do_script=1
85
86 # create it only if do_script=1
87 if [[ ${do_script} = 1 ]]
88 then
89 # create a routines script
90 routines="${DEST}/routines.sh"
91
92 echo "#!/bin/sh" > ${routines}
93 echo "# routines.sh script for ${PNAME}-${PVER}-${PBUILD}" >> ${routines}
94 echo >> ${routines}
95
96 # special functions and variables
97 if [[ -n ${SPECIAL_VARS} ]]
98 then
99 for i in ${SPECIAL_VARS}
100 do
101 # being tricky here :)
102 echo "${i}=\"$(eval echo \$${i})\"" >> ${routines}
103 done
104 echo >> ${routines}
105 fi
106
107 # add special functions
108 if [[ -n ${SPECIAL_FUNCTIONS} ]]
109 then
110 for i in ${SPECIAL_FUNCTIONS}
111 do
112 # add to mage (quotes needed !)
113 typeset -f "${i}" >> ${routines}
114 echo >> ${routines}
115 # unset to be safe (quotes needed !)
116 unset "${i}"
117 done
118 echo >> ${routines}
119 fi
120
121 # postinstall and co
122 for i in preinstall postinstall preremove postremove
123 do
124 if [[ -n $(typeset -f "${i}") ]]
125 then
126 typeset -f "${i}" >> ${routines}
127 echo >> ${routines}
128 fi
129 done
130
131 # create start logic
132 echo >> ${routines}
133 echo 'case $1 in' >> ${routines}
134 [[ ${do_preinst} = 1 ]] && echo ' preinstall) preinstall ;;' >> ${routines}
135 [[ ${do_postinst} = 1 ]] && echo ' postinstall) postinstall ;;' >> ${routines}
136 [[ ${do_prerm} = 1 ]] && echo ' preremove) preremove ;;' >> ${routines}
137 [[ ${do_postrm} = 1 ]] && echo ' postremove) postremove ;;' >> ${routines}
138 echo ' *) echo "error unkown option \"$1\" ..." ;;' >> ${routines}
139 echo 'esac' >> ${routines}
140 echo >> ${routines}
141 fi

Properties

Name Value
svn:executable *