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