Contents of /trunk/mage/usr/lib/mage/pkgbuild_dir.sh
Parent Directory | Revision Log
Revision 169 -
(show annotations)
(download)
(as text)
Sun Jul 31 11:57:05 2005 UTC (19 years, 1 month ago) by niro
File MIME type: application/x-sh
File size: 4031 byte(s)
Sun Jul 31 11:57:05 2005 UTC (19 years, 1 month ago) by niro
File MIME type: application/x-sh
File size: 4031 byte(s)
fixed locale issue; pkgs get not build or installed if the default system local ist another than LC_ALL=C
1 | #!/bin/bash |
2 | |
3 | # |
4 | # builds packages from given dir |
5 | # |
6 | |
7 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/pkgbuild_dir.sh,v 1.8 2005-07-31 11:56:55 niro Exp $ |
8 | |
9 | PKGSUFFIX="mpk" |
10 | PKGNAME="$1" |
11 | SEARCHDIRS="$2" |
12 | MLIBDIR=/usr/lib/mage |
13 | |
14 | COLRED="\033[1;6m\033[31m" |
15 | COLGREEN="\033[1;6m\033[32m" |
16 | COLDEFAULT="\033[0m" |
17 | |
18 | # export default C locale |
19 | export LC_ALL=C |
20 | |
21 | if [ -z "$1" ] |
22 | then |
23 | echo "No package name given. Aborting." |
24 | fi |
25 | |
26 | if [ -z "$2" ] |
27 | then |
28 | echo "No source dir given. Aborting." |
29 | fi |
30 | |
31 | if [ -f /etc/mage.rc ] |
32 | then |
33 | source /etc/mage.rc |
34 | else |
35 | echo "Your /etc/mage.rc is missing. Aborting." |
36 | exit 1 |
37 | fi |
38 | source ${MLIBDIR}/mage3.functions.sh |
39 | |
40 | build_preinstall() { |
41 | if [ -d ${BUILDDIR}/${PKGNAME} ] |
42 | then |
43 | rm -rf ${BUILDDIR}/${PKGNAME} |
44 | fi |
45 | |
46 | install -d ${BUILDDIR}/${PKGNAME}/binfiles |
47 | touch ${BUILDDIR}/${PKGNAME}/.dirs |
48 | touch ${BUILDDIR}/${PKGNAME}/.symlinks |
49 | touch ${BUILDDIR}/${PKGNAME}/.files |
50 | touch ${BUILDDIR}/${PKGNAME}/.pipes |
51 | touch ${BUILDDIR}/${PKGNAME}/.char |
52 | } |
53 | |
54 | build_postinstall() { |
55 | |
56 | echo |
57 | echo "Fetching files for package '${PKGNAME}' ..." |
58 | |
59 | #md5sums will only be generated for files: $M_MD5SUM |
60 | |
61 | #sets mtime to same value of the $BINDIR: $M_MTIME |
62 | #only needed for files and symlinks |
63 | M_MTIME=$(stat -c %Y ${BINDIR}) |
64 | |
65 | #install mtime to package (needed for later checks) |
66 | echo "${M_MTIME}" > ${BUILDDIR}/${PKGNAME}/.mtime |
67 | |
68 | #!! we use § as field seperator !! |
69 | # doing so prevent us to get errors by filenames with spaces |
70 | BUILD_TODELFILES=$(find ${SEARCHDIRS} -printf %p§) |
71 | |
72 | #sets fieldseperator to "§" instead of " " |
73 | IFS=§ |
74 | |
75 | for I in $BUILD_TODELFILES |
76 | do |
77 | CHECK_SRCDIR="$(echo ${I#${SEARCHDIRS}*}|grep $BUILDDIR)" |
78 | |
79 | if [ -z "$CHECK_SRCDIR" ] |
80 | then |
81 | FILETYPE="$(stat -c %F $I)" |
82 | FILEPOSIX="$(stat -c %a $I)" |
83 | FILEOWNER="$(stat -c %U $I)" |
84 | FILEGROUP="$(stat -c %G $I)" |
85 | |
86 | if [ "${FILEOWNER}" == "UNKNOWN" ] |
87 | then |
88 | FILEOWNER="root" |
89 | fi |
90 | |
91 | if [ "${FILEGROUP}" == "UNKNOWN" ] |
92 | then |
93 | FILEGROUP="root" |
94 | fi |
95 | |
96 | case "${FILETYPE}" in |
97 | "directory") |
98 | if [ "$I" != "${SEARCHDIRS}" ] |
99 | then |
100 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.dirs |
101 | fi |
102 | ;; |
103 | |
104 | "symbolic link") |
105 | LNKDEST="$(readlink $I)" |
106 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${LNKDEST#${SEARCHDIRS}*}§${M_MTIME}" >> ${BUILDDIR}/${PKGNAME}/.symlinks |
107 | ;; |
108 | |
109 | |
110 | "regular empty file") |
111 | FILEDIR="$(dirname $I)" |
112 | FILEDIR="${FILEDIR#${SEARCHDIRS}*}" |
113 | M_MD5SUM="$(md5sum ${I}|cut -d' ' -f1)" |
114 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}§${M_MTIME}§${M_MD5SUM}" >> ${BUILDDIR}/${PKGNAME}/.files |
115 | install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR} |
116 | cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR} |
117 | ;; |
118 | |
119 | "regular file" ) |
120 | FILEDIR="$(dirname $I)" |
121 | FILEDIR="${FILEDIR#${SEARCHDIRS}*}" |
122 | M_MD5SUM="$(md5sum ${I}|cut -d' ' -f1)" |
123 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}§${M_MTIME}§${M_MD5SUM}" >> ${BUILDDIR}/${PKGNAME}/.files |
124 | install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR} |
125 | cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR} |
126 | ;; |
127 | |
128 | "block special file") |
129 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.pipes |
130 | ;; |
131 | |
132 | "character special file") |
133 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.char |
134 | ;; |
135 | |
136 | *) |
137 | echo "What I am ? -- $I" |
138 | echo "$0 paused ... Press Enter" |
139 | read |
140 | ;; |
141 | esac |
142 | fi |
143 | done |
144 | |
145 | #very important: unsetting the '§' fieldseperator |
146 | unset IFS |
147 | |
148 | #forcing mtime to same value |
149 | echo -n "Forcing mtime to the same value ..." |
150 | find ${BUILDDIR}/${PKGNAME}/binfiles \ |
151 | -exec touch -m -r ${BUILDDIR}/${PKGNAME}/.mtime '{}' ';' \ |
152 | && echo done || echo false |
153 | |
154 | } |
155 | |
156 | build_rmtimestamp() { |
157 | rm /var/tmp/timestamp |
158 | } |
159 | |
160 | |
161 | build_package() { |
162 | echo "Building Package ..." |
163 | cd ${BUILDDIR} |
164 | tar cvjf ${PKGNAME}.tar.bz2 ./${PKGNAME} |
165 | install -d ${PKGDIR} |
166 | mv ${PKGNAME}.tar.bz2 ${PKGDIR}/${PKGNAME}.${PKGSUFFIX} |
167 | } |
168 | |
169 | |
170 | build_preinstall |
171 | build_postinstall |
172 | build_package |
Properties
Name | Value |
---|---|
svn:executable | * |