Annotation of /trunk/mage/usr/lib/mage/pkgbuild_dir.sh
Parent Directory | Revision Log
Revision 43 -
(hide annotations)
(download)
(as text)
Mon Jan 10 01:59:03 2005 UTC (19 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 3890 byte(s)
Mon Jan 10 01:59:03 2005 UTC (19 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 3890 byte(s)
updated revision tags
1 | niro | 24 | #!/bin/bash |
2 | |||
3 | # | ||
4 | # builds packages from given dir | ||
5 | # | ||
6 | |||
7 | niro | 43 | # version: 0.3.6-r11 |
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 | if [ -z "$1" ] | ||
19 | then | ||
20 | echo "No package name given. Aborting." | ||
21 | fi | ||
22 | |||
23 | if [ -z "$2" ] | ||
24 | then | ||
25 | echo "No source dir given. Aborting." | ||
26 | fi | ||
27 | |||
28 | if [ -f /etc/mage.rc ] | ||
29 | then | ||
30 | source /etc/mage.rc | ||
31 | else | ||
32 | echo "Your /etc/mage.rc is missing. Aborting." | ||
33 | exit 1 | ||
34 | fi | ||
35 | source ${MLIBDIR}/mage3.functions.sh | ||
36 | |||
37 | build_preinstall() { | ||
38 | if [ -d ${BUILDDIR}/${PKGNAME} ] | ||
39 | then | ||
40 | rm -rf ${BUILDDIR}/${PKGNAME} | ||
41 | fi | ||
42 | |||
43 | install -d ${BUILDDIR}/${PKGNAME}/binfiles | ||
44 | touch ${BUILDDIR}/${PKGNAME}/.dirs | ||
45 | touch ${BUILDDIR}/${PKGNAME}/.symlinks | ||
46 | touch ${BUILDDIR}/${PKGNAME}/.files | ||
47 | touch ${BUILDDIR}/${PKGNAME}/.pipes | ||
48 | touch ${BUILDDIR}/${PKGNAME}/.char | ||
49 | } | ||
50 | |||
51 | build_postinstall() { | ||
52 | |||
53 | echo | ||
54 | echo "Fetching files for package '${PKGNAME}' ..." | ||
55 | |||
56 | #md5sums will only be generated for files: $M_MD5SUM | ||
57 | |||
58 | #sets mtime to same value of the $BINDIR: $M_MTIME | ||
59 | #only needed for files and symlinks | ||
60 | M_MTIME=$(stat -c %Y ${BINDIR}) | ||
61 | |||
62 | #install mtime to package (needed for later checks) | ||
63 | echo "${M_MTIME}" > ${BUILDDIR}/${PKGNAME}/.mtime | ||
64 | |||
65 | #!! we use § as field seperator !! | ||
66 | # doing so prevent us to get errors by filenames with spaces | ||
67 | BUILD_TODELFILES=$(find ${SEARCHDIRS} -printf %p§) | ||
68 | |||
69 | #sets fieldseperator to "§" instead of " " | ||
70 | IFS=§ | ||
71 | |||
72 | for I in $BUILD_TODELFILES | ||
73 | do | ||
74 | CHECK_SRCDIR="$(echo ${I#${SEARCHDIRS}*}|grep $BUILDDIR)" | ||
75 | |||
76 | if [ -z "$CHECK_SRCDIR" ] | ||
77 | then | ||
78 | FILETYPE="$(stat -c %F $I)" | ||
79 | FILEPOSIX="$(stat -c %a $I)" | ||
80 | FILEOWNER="$(stat -c %U $I)" | ||
81 | FILEGROUP="$(stat -c %G $I)" | ||
82 | |||
83 | if [ "${FILEOWNER}" == "UNKNOWN" ] | ||
84 | then | ||
85 | FILEOWNER="root" | ||
86 | fi | ||
87 | |||
88 | if [ "${FILEGROUP}" == "UNKNOWN" ] | ||
89 | then | ||
90 | FILEGROUP="root" | ||
91 | fi | ||
92 | |||
93 | case "${FILETYPE}" in | ||
94 | "directory") | ||
95 | if [ "$I" != "${SEARCHDIRS}" ] | ||
96 | then | ||
97 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.dirs | ||
98 | fi | ||
99 | ;; | ||
100 | |||
101 | "symbolic link") | ||
102 | LNKDEST="$(readlink $I)" | ||
103 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${LNKDEST#${SEARCHDIRS}*}§${M_MTIME}" >> ${BUILDDIR}/${PKGNAME}/.symlinks | ||
104 | ;; | ||
105 | |||
106 | |||
107 | "regular empty file") | ||
108 | FILEDIR="$(dirname $I)" | ||
109 | FILEDIR="${FILEDIR#${SEARCHDIRS}*}" | ||
110 | M_MD5SUM="$(md5sum ${I}|cut -d' ' -f1)" | ||
111 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}§${M_MTIME}§${M_MD5SUM}" >> ${BUILDDIR}/${PKGNAME}/.files | ||
112 | install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR} | ||
113 | cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR} | ||
114 | ;; | ||
115 | |||
116 | "regular file" ) | ||
117 | FILEDIR="$(dirname $I)" | ||
118 | FILEDIR="${FILEDIR#${SEARCHDIRS}*}" | ||
119 | M_MD5SUM="$(md5sum ${I}|cut -d' ' -f1)" | ||
120 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}§${M_MTIME}§${M_MD5SUM}" >> ${BUILDDIR}/${PKGNAME}/.files | ||
121 | install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR} | ||
122 | cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR} | ||
123 | ;; | ||
124 | |||
125 | "block special file") | ||
126 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.pipes | ||
127 | ;; | ||
128 | |||
129 | "character special file") | ||
130 | echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.char | ||
131 | ;; | ||
132 | |||
133 | *) | ||
134 | echo "What I am ? -- $I" | ||
135 | echo "$0 paused ... Press Enter" | ||
136 | read | ||
137 | ;; | ||
138 | esac | ||
139 | fi | ||
140 | done | ||
141 | |||
142 | #very important: unsetting the '§' fieldseperator | ||
143 | unset IFS | ||
144 | |||
145 | #forcing mtime to same value | ||
146 | 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 | |||
153 | build_rmtimestamp() { | ||
154 | rm /var/tmp/timestamp | ||
155 | } | ||
156 | |||
157 | |||
158 | build_package() { | ||
159 | 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 | |||
167 | build_preinstall | ||
168 | build_postinstall | ||
169 | build_package |
Properties
Name | Value |
---|---|
svn:executable | * |