Magellan Linux

Annotation of /trunk/mage/usr/lib/mage/meta-generator.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2290 - (hide annotations) (download) (as text)
Fri Dec 6 09:29:41 2013 UTC (10 years, 5 months ago) by niro
File MIME type: application/x-sh
File size: 4439 byte(s)
-pull in smage2 functions
1 niro 2287 #!/bin/bash
2     # meta generator
3    
4     # metafile matrix
5    
6     # Common infos -> meta
7     # ----------------------------
8     # lineno description example
9     # 01 PNAME glibc-nptl
10     # 02 PCATEGORIE sys-libs
11     # 03 PVER 2.5.0
12     # 04 PBUILD 7
13     # 05 STATE unstable
14     # 06 DESCRIPTION GNU libc6 (also called glibc2) C library with NPTL Threads.
15     # 07 HOMEPAGE http://www.gnu.org/software/libc/libc.html
16     # 08 PKGTYPE
17     # 09 SPLIT_PACKAGE_BASE
18     # 10 INHERITS mtools
19     #
20     # # Arch specific -> ${arch}/desc
21     # ----------------------------
22     # lineno description example
23     # 1 MD5 7ba206976e312a456dc29cea4bb283ea
24     # 2 SIZE
25     # 3 MTIME 1187714117
26     #
27     # Dependencies
28     # ---------------------------------
29     # DEPEND -> ${ARCH}/depend
30     # SDEPEND -> ${ARCH}/sdepend
31     # PROVIDE -> ${ARCH}/provide
32     #
33     # # Content
34     # ---------------------------------
35     # CHAR -> ${ARCH}/char
36     # DIRS -> ${ARCH}/dirs
37     # FILES -> ${ARCH}/files
38     # PIPES -> ${ARCH}/pipes
39     # SYMLINKS -> ${ARCH}/symlinks
40    
41     # --extract -> extract info from given package
42     # no params given/smage2, it uses the current build environment
43    
44    
45     # default die function
46     die()
47     {
48     echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT}
49     echo -e ${COLRED}"$@"${COLDEFAULT}
50     exit 1
51     }
52    
53     add2meta()
54     {
55     local var="$1"
56     local value="$2"
57    
58     echo "${var}=\"${value}\"" >> ${METAFILE}
59     }
60    
61     ## only for tests -> normally in /etc/rc.d/init.d/functions
62     COLRED="\033[1;6m\033[31m"
63     COLGREEN="\033[1;6m\033[32m"
64     COLYELLOW="\033[1;6m\033[33m"
65     COLBLUE="\033[1;6m\033[34m"
66     COLMAGENTA="\033[1;6m\033[35m"
67     COLWHITE="\033[1;6m\033[37m"
68     COLGRAY="\033[0;6m\033[37m"
69     COLBOLD="\033[1m"
70     COLDEFAULT="\033[0m"
71    
72     # get mage environment
73     [ -f /etc/mage.rc.global ] && source /etc/mage.rc.global || die "/etc/mage.rc.global missing"
74     [ -f ${MAGERC} ] && source ${MAGERC} || die "Your ${MAGERC} is missing. Aborting."
75     [ -f ${MLIBDIR}/mage4.functions.sh ] && source ${MLIBDIR}/mage4.functions.sh || die "mage functions missing"
76 niro 2290 [ -f ${MLIBDIR}/smage2.functions.sh ] && source ${MLIBDIR}/smage2.functions.sh || die "mage functions missing"
77 niro 2287
78     # default variables
79     PKGTARBALL=""
80     SMAGEFILE=""
81     METADIR="${PKGDIR}/meta"
82     METASUFFIX="meta"
83     METAFILE=""
84    
85     # very basic getops
86     for i in $*
87     do
88     case $1 in
89     --extract|-c) shift; PKGTARBALL="$1" ;;
90     esac
91     # shift
92     done
93    
94     SMAGEFILE="$1"
95 niro 2288 [ -z ${SMAGEFILE} ] && die "No smage file given."
96     [ -e ${SMAGEFILE} ] || die "Smage file '${SMAGEFILE}' does not exist."
97 niro 2287
98     if [[ -n ${PKGTARBALL} ]]
99     then
100     # abort if given file is not a pkg
101     [[ ${PKGTARBALL##*.} != ${PKGSUFFIX} ]] && die "${PKGTARBALL} is not a valid pkg file."
102    
103     [[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR}
104    
105     # unpack srctarball
106     [[ ! -f ${PKGTARBALL} ]] && die "Error: ${PKGTARBALL} does not exist. Aborting."
107    
108     # set correct SMAGENAME; use the one that the src_pkg provide
109     # /path/to/SOURCEDIR/PNAME/SMAGENAME
110     SMAGEFILE="${SOURCEDIR}/$(basename ${PKGTARBALL%-*-*})/$(basename ${PKGTARBALL} .${PKGSUFFIX}).${SMAGESUFFIX}"
111    
112     tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die "Error unpackung src-tarball ${SRCPKGTARBALL}"
113     fi
114    
115     # get generic package information from smage file
116 niro 2289 smagesource ${SMAGEFILE}
117 niro 2287
118     # set the right meta-location
119     [[ ! -d ${METADIR} ]] && install -d ${METADIR}
120     METAFILE="${METADIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}.${METASUFFIX}"
121    
122     # create a clean metafile
123     :> ${METAFILE}
124    
125     # basic packages information
126     add2meta PNAME "${PNAME}"
127     add2meta PCATEGORIE "${PCATEGORIE}"
128     add2meta PVER "${PVER}"
129     add2meta PBUILD "${PBUILD}"
130     #add2meta STATE "${STATE}"
131     add2meta DESCRIPTION "${DESCRIPTION}"
132     add2meta HOMEPAGE "${HOMEPAGE}"
133     add2meta PKGTYPE "${PKGTYPE}"
134     #add2meta SPLIT_PACKAGE_BASE "${SPLIT_PACKAGE_BASE}"
135     #add2meta INHERITS "${INHERITS}"
136    
137     # arch specific
138     add2meta ARCH "${ARCH}"
139     add2meta SIZE "$(du -Ds ${BUILDDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}/binfiles | sed 's/^\(.*\)\t.*/\1/')"
140     add2meta MTIME "$(< ${BUILDDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}/.mtime)"
141    
142     # provided binfiles
143     SEARCH_DIRS="bin,sbin,usr/bin,usr/sbin"
144     SEARCH_DIRS+=",usr/*/bin,usr/*/sbin"
145     SEARCH_DIRS+=",opt/bin,opt/*/bin,opt/*/sbin"
146     SEARCH_DIRS+=",opt/*/jre/bin"
147     # at last add braces
148     SEARCH_DIRS="{${SEARCH_DIRS}}"
149     # search them
150     add2meta PROVIDED_BINARIES "$(find $(eval echo ${BUILDDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}/binfiles/${SEARCH_DIRS}) -type f -printf '%f ' 2> /dev/null)"
151    
152     # generate MD5SUM (get it with tail -n1)
153     echo >> ${METAFILE}
154     echo '# MD5 CHECKSUM:' >> ${METAFILE}
155     ( cd ${PKGDIR}; md5sum ${PNAME}-${PVER}-${ARCH}-${PBUILD}.${PKGSUFFIX} >> ${METAFILE} )