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