Annotation of /branches/mage-next/usr/lib/mage/pkgbuild_dir.sh
Parent Directory | Revision Log
Revision 312 -
(hide annotations)
(download)
(as text)
Sun Jan 1 23:15:54 2006 UTC (18 years, 8 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/pkgbuild_dir.sh
File MIME type: application/x-sh
File size: 4275 byte(s)
Sun Jan 1 23:15:54 2006 UTC (18 years, 8 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/pkgbuild_dir.sh
File MIME type: application/x-sh
File size: 4275 byte(s)
fixed installation of char-devices
1 | niro | 24 | #!/bin/bash |
2 | |||
3 | # | ||
4 | # builds packages from given dir | ||
5 | # | ||
6 | |||
7 | niro | 312 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/pkgbuild_dir.sh,v 1.10 2006-01-01 23:15:54 niro Exp $ |
8 | niro | 24 | |
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 | niro | 169 | # export default C locale |
19 | export LC_ALL=C | ||
20 | |||
21 | niro | 272 | [[ -z $1 ]] && echo "No package name given. Aborting." && exit 1 |
22 | [[ -z $2 ]] && echo "No source dir given. Aborting." && exit 1 | ||
23 | niro | 24 | |
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 | niro | 272 | source ${MLIBDIR}/mage4.functions.sh |
32 | niro | 24 | |
33 | niro | 312 | # 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 | niro | 272 | build_preinstall() |
42 | { | ||
43 | niro | 24 | 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 | niro | 272 | build_postinstall() |
57 | { | ||
58 | niro | 24 | echo |
59 | echo "Fetching files for package '${PKGNAME}' ..." | ||
60 | |||
61 | niro | 272 | # 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 | niro | 24 | M_MTIME=$(stat -c %Y ${BINDIR}) |
66 | niro | 272 | |
67 | # install mtime to package (needed for later checks) | ||
68 | niro | 24 | echo "${M_MTIME}" > ${BUILDDIR}/${PKGNAME}/.mtime |
69 | |||
70 | niro | 272 | # !! we use § as field seperator !! |
71 | niro | 24 | # doing so prevent us to get errors by filenames with spaces |
72 | BUILD_TODELFILES=$(find ${SEARCHDIRS} -printf %p§) | ||
73 | niro | 272 | |
74 | # sets fieldseperator to "§" instead of " " | ||
75 | niro | 24 | 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 | niro | 272 | [[ ${FILEOWNER} = UNKNOWN ]] && FILEOWNER="root" |
89 | [[ ${FILEGROUP} = UNKNOWN ]] && FILEGROUP="root" | ||
90 | niro | 24 | |
91 | case "${FILETYPE}" in | ||
92 | "directory") | ||
93 | niro | 272 | if [[ $I != ${SEARCHDIRS} ]] |
94 | niro | 24 | then |
95 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.dirs | ||
96 | fi | ||
97 | ;; | ||
98 | niro | 272 | |
99 | niro | 24 | "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 | niro | 272 | |
123 | niro | 24 | "block special file") |
124 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.pipes | ||
125 | ;; | ||
126 | |||
127 | "character special file") | ||
128 | niro | 312 | local CHAR_MAJOR="$(stat -c %t $I)" |
129 | local CHAR_MINOR="$(stat -c %T $I)" | ||
130 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${CHAR_MAJOR}§${CHAR_MINOR}" >> ${BUILDDIR}/${PKGNAME}/.char | ||
131 | niro | 24 | ;; |
132 | niro | 272 | |
133 | niro | 24 | *) |
134 | echo "What I am ? -- $I" | ||
135 | echo "$0 paused ... Press Enter" | ||
136 | read | ||
137 | ;; | ||
138 | esac | ||
139 | fi | ||
140 | done | ||
141 | niro | 272 | |
142 | # very important: unsetting the '§' fieldseperator | ||
143 | niro | 24 | unset IFS |
144 | niro | 272 | |
145 | # forcing mtime to same value | ||
146 | niro | 24 | echo -n "Forcing mtime to the same value ..." |
147 | find ${BUILDDIR}/${PKGNAME}/binfiles \ | ||
148 | -exec touch -m -r ${BUILDDIR}/${PKGNAME}/.mtime '{}' ';' \ | ||
149 | && echo done || echo false | ||
150 | } | ||
151 | |||
152 | niro | 272 | build_rmtimestamp() |
153 | { | ||
154 | niro | 24 | rm /var/tmp/timestamp |
155 | } | ||
156 | |||
157 | niro | 272 | build_package() |
158 | { | ||
159 | niro | 24 | echo "Building Package ..." |
160 | cd ${BUILDDIR} | ||
161 | tar cvjf ${PKGNAME}.tar.bz2 ./${PKGNAME} | ||
162 | install -d ${PKGDIR} | ||
163 | mv ${PKGNAME}.tar.bz2 ${PKGDIR}/${PKGNAME}.${PKGSUFFIX} | ||
164 | } | ||
165 | |||
166 | build_preinstall | ||
167 | build_postinstall | ||
168 | build_package |
Properties
Name | Value |
---|---|
svn:executable | * |