Magellan Linux

Annotation of /trunk/mage/usr/lib/mage/generate_meta_data.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 489 - (hide annotations) (download) (as text)
Wed May 2 06:12:04 2007 UTC (17 years ago) by niro
File MIME type: application/x-sh
File size: 3684 byte(s)
-new meta data conversion scripts

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     local i
97     for i in ${SPECIAL_VARS}
98     do
99     # being tricky here :)
100     echo "${i}=\"$(eval echo \$${i})\"" >> ${routines}
101     done
102     echo >> ${routines}
103     fi
104    
105     # add special functions
106     if [[ -n ${SPECIAL_FUNCTIONS} ]]
107     then
108     local i
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 *