Magellan Linux

Annotation of /tags/mage-0_4_23/usr/lib/mage/pkgbuild_dir.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 272 - (hide annotations) (download) (as text)
Fri Oct 21 14:23:59 2005 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: 3976 byte(s)
fixed includes; fixed whitespaces

1 niro 24 #!/bin/bash
2    
3     #
4     # builds packages from given dir
5     #
6    
7 niro 272 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/pkgbuild_dir.sh,v 1.9 2005-10-21 14:23:59 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 272 build_preinstall()
34     {
35 niro 24 if [ -d ${BUILDDIR}/${PKGNAME} ]
36     then
37     rm -rf ${BUILDDIR}/${PKGNAME}
38     fi
39    
40     install -d ${BUILDDIR}/${PKGNAME}/binfiles
41     touch ${BUILDDIR}/${PKGNAME}/.dirs
42     touch ${BUILDDIR}/${PKGNAME}/.symlinks
43     touch ${BUILDDIR}/${PKGNAME}/.files
44     touch ${BUILDDIR}/${PKGNAME}/.pipes
45     touch ${BUILDDIR}/${PKGNAME}/.char
46     }
47    
48 niro 272 build_postinstall()
49     {
50 niro 24 echo
51     echo "Fetching files for package '${PKGNAME}' ..."
52    
53 niro 272 # md5sums will only be generated for files: $M_MD5SUM
54    
55     # sets mtime to same value of the $BINDIR: $M_MTIME
56     # only needed for files and symlinks
57 niro 24 M_MTIME=$(stat -c %Y ${BINDIR})
58 niro 272
59     # install mtime to package (needed for later checks)
60 niro 24 echo "${M_MTIME}" > ${BUILDDIR}/${PKGNAME}/.mtime
61    
62 niro 272 # !! we use § as field seperator !!
63 niro 24 # doing so prevent us to get errors by filenames with spaces
64     BUILD_TODELFILES=$(find ${SEARCHDIRS} -printf %p§)
65 niro 272
66     # sets fieldseperator to "§" instead of " "
67 niro 24 IFS=§
68    
69     for I in $BUILD_TODELFILES
70     do
71     CHECK_SRCDIR="$(echo ${I#${SEARCHDIRS}*}|grep $BUILDDIR)"
72    
73     if [ -z "$CHECK_SRCDIR" ]
74     then
75     FILETYPE="$(stat -c %F $I)"
76     FILEPOSIX="$(stat -c %a $I)"
77     FILEOWNER="$(stat -c %U $I)"
78     FILEGROUP="$(stat -c %G $I)"
79    
80 niro 272 [[ ${FILEOWNER} = UNKNOWN ]] && FILEOWNER="root"
81     [[ ${FILEGROUP} = UNKNOWN ]] && FILEGROUP="root"
82 niro 24
83     case "${FILETYPE}" in
84     "directory")
85 niro 272 if [[ $I != ${SEARCHDIRS} ]]
86 niro 24 then
87     echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.dirs
88     fi
89     ;;
90 niro 272
91 niro 24 "symbolic link")
92     LNKDEST="$(readlink $I)"
93     echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${LNKDEST#${SEARCHDIRS}*}§${M_MTIME}" >> ${BUILDDIR}/${PKGNAME}/.symlinks
94     ;;
95    
96    
97     "regular empty file")
98     FILEDIR="$(dirname $I)"
99     FILEDIR="${FILEDIR#${SEARCHDIRS}*}"
100     M_MD5SUM="$(md5sum ${I}|cut -d' ' -f1)"
101     echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}§${M_MTIME}§${M_MD5SUM}" >> ${BUILDDIR}/${PKGNAME}/.files
102     install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}
103     cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}
104     ;;
105    
106     "regular file" )
107     FILEDIR="$(dirname $I)"
108     FILEDIR="${FILEDIR#${SEARCHDIRS}*}"
109     M_MD5SUM="$(md5sum ${I}|cut -d' ' -f1)"
110     echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}§${M_MTIME}§${M_MD5SUM}" >> ${BUILDDIR}/${PKGNAME}/.files
111     install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}
112     cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}
113     ;;
114 niro 272
115 niro 24 "block special file")
116     echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.pipes
117     ;;
118    
119     "character special file")
120     echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.char
121     ;;
122 niro 272
123 niro 24 *)
124     echo "What I am ? -- $I"
125     echo "$0 paused ... Press Enter"
126     read
127     ;;
128     esac
129     fi
130     done
131 niro 272
132     # very important: unsetting the '§' fieldseperator
133 niro 24 unset IFS
134 niro 272
135     # forcing mtime to same value
136 niro 24 echo -n "Forcing mtime to the same value ..."
137     find ${BUILDDIR}/${PKGNAME}/binfiles \
138     -exec touch -m -r ${BUILDDIR}/${PKGNAME}/.mtime '{}' ';' \
139     && echo done || echo false
140     }
141    
142 niro 272 build_rmtimestamp()
143     {
144 niro 24 rm /var/tmp/timestamp
145     }
146    
147 niro 272 build_package()
148     {
149 niro 24 echo "Building Package ..."
150     cd ${BUILDDIR}
151     tar cvjf ${PKGNAME}.tar.bz2 ./${PKGNAME}
152     install -d ${PKGDIR}
153     mv ${PKGNAME}.tar.bz2 ${PKGDIR}/${PKGNAME}.${PKGSUFFIX}
154     }
155    
156     build_preinstall
157     build_postinstall
158     build_package

Properties

Name Value
svn:executable *