Magellan Linux

Annotation of /trunk/pkgtools/add2alx-060

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2115 - (hide annotations) (download)
Mon May 13 11:45:19 2013 UTC (11 years, 5 months ago) by niro
File size: 8281 byte(s)
-support split-packages, do not autostart services and fixed hardcored chroot path
1 niro 1330 #!/bin/bash
2    
3     source /usr/lib/mage/mage4.functions.sh
4    
5     SMAGEFILE="$1"
6     if [[ -z ${SMAGEFILE} ]]
7     then
8     echo "No smagefile given."
9     exit 1
10     fi
11     [[ -n $2 ]] && [[ $2 != -st ]] && SVN_COMMIT="$2"
12     if [[ $3 = -st ]] || [[ $2 = -st ]]
13     then
14     echo "Using SRCTARBALL ..."
15     USE_SRCTARBALL=true
16     fi
17    
18     CURARCH=i486
19    
20     if [[ -z ${CURARCH} ]]
21     then
22     echo "Environment variable \${CURARCH} not given. Aborted."
23     exit 1
24     fi
25    
26     BUILDROOT="/mnt/alx-0.6.0-toolchain/chroot"
27    
28     SMAGEDIR=$(dirname ${SMAGEFILE})
29     MD5DIR=${SMAGEDIR}/md5
30     MD5NAME=$(basename $1 .smage2).md5
31     SMAGENAME=$(basename $1)
32     CURPNAME=$(magename2pname $1)
33     CURPVER=$(magename2pver $1)
34     CURPBUILD=$(magename2pbuild $(basename $1 .smage2))
35     PKGNAME=${CURPNAME}-${CURPVER}-${CURARCH}-${CURPBUILD}.mpk
36     SRCPKGNAME=${CURPNAME}-${CURPVER}-${CURPBUILD}.mpks
37     #REPO="$(echo ${SMAGEFILE#*trunk/} | cut -d'/' -f1)"
38     REPO="$(echo ${SMAGEFILE#*branches/alx-0_6_0/} | cut -d'/' -f1)"
39     SSHLOGIN="tjoke@magellan-linux.de:/var/www/htdocs/magellan/alx-0.6.0/unstable/packages"
40     SRCTARBALL_URI="http://magellan-linux.de/magellan/alx-0.6.0/unstable/packages/src"
41    
42     # abort if the package is already installed in BUILDROOT
43     get_value_from_file()
44     {
45     local var="$1"
46     local file="$2"
47     local value
48    
49     # source /etc/mage.rc to get the includes right
50     source /etc/mage.rc.global
51     source /etc/mage.rc
52    
53     # evaluate the value
54     source ${file} $> /dev/null
55     eval value=\$$(echo ${var})
56     echo "${value}"
57     }
58    
59     get_function_from_file()
60     {
61     local function="$1"
62     local file="$2"
63    
64     # source /etc/mage.rc to get the includes right
65     source /etc/mage.rc.global
66     source /etc/mage.rc
67    
68     # evaluate the value
69     source ${file} $> /dev/null
70     export -f ${function}
71     }
72    
73     CURPCATEGORIE=$(get_value_from_file PCATEGORIE ${SMAGEFILE})
74     INSTALLDB_BUILDROOT=$(get_value_from_file INSTALLDB ${BUILDROOT}/etc/mage.rc)
75     CURSPLITPACKAGES="$(get_value_from_file SPLIT_PACKAGES ${SMAGEFILE})"
76    
77 niro 2115 # abort if the package is already installed in BUILDROOT
78     if [[ -z ${CURSPLITPACKAGES} ]]
79 niro 1330 then
80 niro 2115 if [[ -d ${BUILDROOT}/${INSTALLDB_BUILDROOT}/${CURPCATEGORIE}/${CURPNAME}-${CURPVER}-${CURPBUILD} ]]
81     then
82     echo "Package '${CURPCATEGORIE}/${CURPNAME}-${CURPVER}-${CURPBUILD}' already installed in ${BUILDROOT}. Aborting!"
83     exit 1
84     fi
85     else
86     for i in ${CURSPLITPACKAGES}
87     do
88     if [[ -d ${BUILDROOT}/${INSTALLDB_BUILDROOT}/${CURPCATEGORIE}/${i}-${CURPVER}-${CURPBUILD} ]]
89     then
90     SPLITINSTALLED+=" ${CURPCATEGORIE}/${i}-${CURPVER}-${CURPBUILD}"
91     fi
92     done
93     if [[ ! -z ${SPLITINSTALLED} ]]
94     then
95     echo "Following SPLIT-Packages are installled from ${CURPCATEGORIE}/${CURPNAME}-${CURPVER}-${CURPBUILD} in ${BUILDROOT}:"
96     for i in ${SPLITINSTALLED}
97     do
98     echo " ${i}"
99     done
100     echo "Aborted."
101     exit 1
102     fi
103 niro 1330 fi
104    
105     # delete md5 if exist
106     [[ -f ${MD5DIR}/${MD5NAME} ]] && rm ${MD5DIR}/${MD5NAME}
107    
108     if [[ ${USE_SRCTARBALL} != true ]]
109     then
110     /sbin/smage2 download ${SMAGEFILE}
111     /sbin/smage2 calcmd5 ${SMAGEFILE} ${MD5DIR}
112     pushd ${SMAGEDIR}/../
113     svn add ${CURPNAME}
114     pushd ${SMAGEDIR}
115     svn add md5
116     svn add ${SMAGENAME} md5/${MD5NAME}
117     [[ -d mcore ]] && svn add mcore
118     [[ -d mcore/files ]] && svn add mcore/files
119    
120     [[ -z ${SVN_COMMIT} ]] && SVN_COMMIT="auto added: ver bump to ${CURPVER}-${CURPBUILD}"
121     svn commit -m "${SVN_COMMIT}" ../${CURPNAME} ${SMAGENAME} md5 md5/${MD5NAME}
122     popd
123     fi
124    
125     # update target repo
126     #sudo svn update ${BUILDROOT}/var/cache/mage/smage/trunk/include
127     sudo svn update ${BUILDROOT}/var/cache/mage/smage/branches/alx-0_6_0/include
128     #sudo svn update ${BUILDROOT}/var/cache/mage/smage/trunk/${REPO}
129     #sudo svn update ${BUILDROOT}/var/cache/mage/smage/trunk/${REPO}/include
130     sudo svn update ${BUILDROOT}/var/cache/mage/smage/branches/alx-0_6_0/${REPO}/include
131     #sudo svn update ${BUILDROOT}/var/cache/mage/smage/trunk/${REPO}/${CURPNAME}
132     sudo svn update ${BUILDROOT}/var/cache/mage/smage/branches/alx-0_6_0/${REPO}/${CURPNAME}
133    
134     sudo -s << EOF
135     :> ${BUILDROOT}/.installrc
136    
137     echo "export LC_ALL=C" >> ${BUILDROOT}/.installrc
138 niro 2115 # do not start any services, set mage bootstrap flag
139     echo "export MAGE_BOOTSTRAP=true" >> ${BUILDROOT}/.installrc
140 niro 1330 echo "REPO=${REPO}" >> ${BUILDROOT}/.installrc
141     echo "CURPNAME=${CURPNAME}" >> ${BUILDROOT}/.installrc
142     echo "CURPVER=${CURPVER}" >> ${BUILDROOT}/.installrc
143     echo "CURPBUILD=${CURPBUILD}" >> ${BUILDROOT}/.installrc
144     echo "CURARCH=${CURARCH}" >> ${BUILDROOT}/.installrc
145     echo "CURSPLITPACKAGES=\"${CURSPLITPACKAGES}\"" >> ${BUILDROOT}/.installrc
146     echo "SMAGENAME=${SMAGENAME}" >> ${BUILDROOT}/.installrc
147     echo "MD5NAME=${MD5NAME}" >> ${BUILDROOT}/.installrc
148     echo "PKGNAME=${PKGNAME}" >> ${BUILDROOT}/.installrc
149     echo "SPKGNAME=${SPKGNAME}" >> ${BUILDROOT}/.installrc
150     echo '/usr/bin/whoami' >> ${BUILDROOT}/.installrc
151     echo 'source /etc/profile' >> ${BUILDROOT}/.installrc
152     #echo 'echo PATH=\${PATH};read' >> ${BUILDROOT}/.installrc
153     #echo 'cd /var/cache/mage/smage/trunk/${REPO}' >> ${BUILDROOT}/.installrc
154     echo 'cd /var/cache/mage/smage/branches/alx-0_6_0/${REPO}' >> ${BUILDROOT}/.installrc
155     #echo 'svn update include' >> ${BUILDROOT}/.installrc
156     #echo 'svn update ../include' >> ${BUILDROOT}/.installrc
157     #echo 'svn update ${CURPNAME}' >> ${BUILDROOT}/.installrc
158     echo 'USE_SRCTARBALL=${USE_SRCTARBALL}' >> ${BUILDROOT}/.installrc
159     echo 'if [[ \${USE_SRCTARBALL} != true ]];then ' >> ${BUILDROOT}/.installrc
160     #echo '/sbin/smage2 /var/cache/mage/smage/trunk/${REPO}/${CURPNAME}/${SMAGENAME} || exit 1' >> ${BUILDROOT}/.installrc
161     echo '/sbin/smage2 /var/cache/mage/smage/branches/alx-0_6_0/${REPO}/${CURPNAME}/${SMAGENAME} || exit 1' >> ${BUILDROOT}/.installrc
162     echo 'else' >> ${BUILDROOT}/.installrc
163     echo 'echo "Fetching SRC_TARBALL"' >> ${BUILDROOT}/.installrc
164     echo 'pushd /var/tmp/magebuild > /dev/null' >> ${BUILDROOT}/.installrc
165     echo "SRCTARBALL=${CURPNAME}-${CURPVER}-${CURPBUILD}.mpks" >> ${BUILDROOT}/.installrc
166     echo "SRCTARBALL_URI=${SRCTARBALL_URI}" >> ${BUILDROOT}/.installrc
167     echo '/usr/bin/wget -c \${SRCTARBALL_URI}/\${SRCTARBALL}' >> ${BUILDROOT}/.installrc
168     echo '/sbin/smage2 -st \${SRCTARBALL}' >> ${BUILDROOT}/.installrc
169     echo '[[ -f \${SRCTARBALL} ]] && rm \${SRCTARBALL}' >> ${BUILDROOT}/.installrc
170     echo 'popd > /dev/null' >> ${BUILDROOT}/.installrc
171     echo 'fi' >> ${BUILDROOT}/.installrc
172     echo 'if [[ ! -z \${CURSPLITPACKAGES} ]]' >> ${BUILDROOT}/.installrc
173     echo 'then' >> ${BUILDROOT}/.installrc
174     echo 'for package in \${CURSPLITPACKAGES}' >> ${BUILDROOT}/.installrc
175     echo 'do' >> ${BUILDROOT}/.installrc
176     echo '/sbin/mage install \${package} || exit 1' >> ${BUILDROOT}/.installrc
177     echo 'mv /var/cache/mage/packages/\${package}-${CURPVER}-${CURARCH}-${CURPBUILD}.mpk /BUILDED' >> ${BUILDROOT}/.installrc
178     echo 'done' >> ${BUILDROOT}/.installrc
179     echo 'else' >> ${BUILDROOT}/.installrc
180     echo '/sbin/mage install ${CURPNAME} || exit 1' >> ${BUILDROOT}/.installrc
181     echo 'mv /var/cache/mage/packages/${PKGNAME} /BUILDED' >> ${BUILDROOT}/.installrc
182     echo 'fi' >> ${BUILDROOT}/.installrc
183     echo 'mv /var/cache/mage/packages/sources/${SRCPKGNAME} /BUILDED/sources' >> ${BUILDROOT}/.installrc
184     echo 'rm -rf /var/cache/mage/sources/${CURPNAME}' >> ${BUILDROOT}/.installrc
185     EOF
186    
187 niro 2115 sudo -H chroot ${BUILDROOT} /bin/bash /.installrc
188 niro 1330 sudo rm ${BUILDROOT}/.installrc
189    
190     if [[ ! -z ${CURSPLITPACKAGES} ]]
191     then
192     for package in ${CURSPLITPACKAGES}
193     do
194     # get pkgtyp
195     get_function_from_file split_info_${package} ${SMAGEFILE}
196     split_info_${package}
197     if [[ ${PKGTYPE} = virtual ]]
198     then
199     unset PKGTYPE
200     continue
201     fi
202     if [[ ${NOPKGBUILD} = true ]]
203     then
204     unset NOPKGBUILD
205     continue
206     fi
207    
208     pkgname="${package}-${CURPVER}-${CURARCH}-${CURPBUILD}.mpk"
209    
210     if [[ -f ${BUILDROOT}/BUILDED/${pkgname} ]]
211     then
212     scp ${BUILDROOT}/BUILDED/${pkgname} ${SSHLOGIN}/${CURARCH}/
213     else
214     echo "Error: ${BUILDROOT}/BUILDED/${pkgname} missing!"
215     exit 1
216     fi
217     done
218     else
219     if [[ -f ${BUILDROOT}/BUILDED/${PKGNAME} ]]
220     then
221     scp ${BUILDROOT}/BUILDED/${PKGNAME} ${SSHLOGIN}/${CURARCH}/
222     else
223     echo "Error: ${BUILDROOT}/BUILDED/${PKGNAME} missing!"
224     exit 1
225     fi
226     fi
227    
228     if [[ -f ${BUILDROOT}/BUILDED/sources/${SRCPKGNAME} ]]
229     then
230     scp ${BUILDROOT}/BUILDED/sources/${SRCPKGNAME} ${SSHLOGIN}/src/
231     else
232     echo "Error: ${BUILDROOT}/BUILDED/${SRCPKGNAME} missing!"
233     # exit 1
234     fi
235    
236     [[ -d /var/cache/mage/sources/${CURPNAME} ]] && rm -rf /var/cache/mage/sources/${CURPNAME}
237    
238    
239     # if we don't break before; all things are right - regardless if $? is not zero
240     # because some things like src-pkg creation may be disabled
241     exit 0
242    

Properties

Name Value
svn:executable *