Magellan Linux

Diff of /trunk/mage/usr/lib/mage/pkgbuild_dir.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 440 by niro, Mon Mar 19 19:10:07 2007 UTC revision 1292 by niro, Fri May 27 12:55:43 2011 UTC
# Line 4  Line 4 
4  # builds packages from given dir  # builds packages from given dir
5  #  #
6    
7  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/pkgbuild_dir.sh,v 1.14 2007-03-19 19:10:07 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/pkgbuild_dir.sh,v 1.15 2007-03-19 19:24:46 niro Exp $
8    
9  # set default user mage.rc  # set default user mage.rc
10  : ${MAGERC="/etc/mage.rc"}  : ${MAGERC="/etc/mage.rc"}
# Line 14  PKGNAME="$1" Line 14  PKGNAME="$1"
14  SEARCHDIRS="$2"  SEARCHDIRS="$2"
15  MLIBDIR=/usr/lib/mage  MLIBDIR=/usr/lib/mage
16    
17    ## only for tests -> normally in /etc/rc.d/init.d/functions
18  COLRED="\033[1;6m\033[31m"  COLRED="\033[1;6m\033[31m"
19  COLGREEN="\033[1;6m\033[32m"  COLGREEN="\033[1;6m\033[32m"
20    COLYELLOW="\033[1;6m\033[33m"
21    COLBLUE="\033[1;6m\033[34m"
22    COLMAGENTA="\033[1;6m\033[35m"
23    COLWHITE="\033[1;6m\033[37m"
24    COLGRAY="\033[0;6m\033[37m"
25    COLBOLD="\033[1m"
26  COLDEFAULT="\033[0m"  COLDEFAULT="\033[0m"
27    
28    if [[ ${NOCOLORS} = true ]]
29    then
30     COLRED=""
31     COLGREEN=""
32     COLYELLOW=""
33     COLBLUE=""
34     COLMAGENTA=""
35     COLWHITE=""
36     COLGRAY=""
37     COLBOLD=""
38     COLDEFAULT=""
39    fi
40    
41  # export default C locale  # export default C locale
42  export LC_ALL=C  export LC_ALL=C
43    
# Line 25  export LC_ALL=C Line 45  export LC_ALL=C
45  [[ -z $2 ]] && echo "No source dir given. Aborting." && exit 1  [[ -z $2 ]] && echo "No source dir given. Aborting." && exit 1
46    
47  source /etc/mage.rc.global  source /etc/mage.rc.global
48  if [ -f ${MAGERC} ]  [[ -f ${MAGERC} ]] && source ${MAGERC}
 then  
  source ${MAGERC}  
 else  
  echo "Your ${MAGERC} is missing. Aborting."  
  exit 1  
 fi  
49  source ${MLIBDIR}/mage4.functions.sh  source ${MLIBDIR}/mage4.functions.sh
50    
51  # set PKGDIR and BUILDDIR and BINDIR to MROOT  # set PKGDIR and BUILDDIR and BINDIR to MROOT
# Line 55  build_preinstall() Line 69  build_preinstall()
69   touch ${BUILDDIR}/${PKGNAME}/.files   touch ${BUILDDIR}/${PKGNAME}/.files
70   touch ${BUILDDIR}/${PKGNAME}/.pipes   touch ${BUILDDIR}/${PKGNAME}/.pipes
71   touch ${BUILDDIR}/${PKGNAME}/.char   touch ${BUILDDIR}/${PKGNAME}/.char
72     touch ${BUILDDIR}/${PKGNAME}/.fifo
73  }  }
74    
75  build_postinstall()  build_postinstall()
76  {  {
77     local m_mtime
78     local m_md5sum
79     local filelist
80     local item
81     local check_srcdir
82     local filetype
83     local fileposix
84     local fileowner
85     local filegroup
86     local lnkdest
87     local filedir
88     local char_major
89     local char_minor
90    
91   echo -e "${COLBLUE}===${COLGREEN} fetching files for package '${PKGNAME}' ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} fetching files for package '${PKGNAME}' ...${COLDEFAULT}"
92    
93   # md5sums will only be generated for files: $M_MD5SUM   # md5sums will only be generated for files: $m_md5sum
94    
95   # sets mtime to same value of the $BINDIR: $M_MTIME   # sets mtime to same value of the $BINDIR: $m_mtime
96   # only needed for files and symlinks   # only needed for files and symlinks
97   M_MTIME=$(stat -c %Y ${BINDIR})   m_mtime=$(stat -c %Y ${BINDIR})
98    
99   # install mtime to package (needed for later checks)   # install mtime to package (needed for later checks)
100   echo "${M_MTIME}" > ${BUILDDIR}/${PKGNAME}/.mtime   echo "${m_mtime}" > ${BUILDDIR}/${PKGNAME}/.mtime
101    
102   # !! we use § as field seperator !!   # !! we use § as field seperator !!
103   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
104   BUILD_TODELFILES=$(find ${SEARCHDIRS} -printf %p§)   filelist=$(find ${SEARCHDIRS} -printf %p§)
105    
106   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
107   IFS=§   IFS=§
108    
109   for I in $BUILD_TODELFILES   for item in ${filelist}
110   do   do
111   CHECK_SRCDIR="$(echo ${I#${SEARCHDIRS}*}|grep $BUILDDIR)"   check_srcdir="$(echo ${item#${SEARCHDIRS}*}|grep ${BUILDDIR})"
112    
113   if [ -z "$CHECK_SRCDIR" ]   if [[ -z ${check_srcdir} ]]
114   then   then
115   FILETYPE="$(stat -c %F $I)"   filetype="$(stat -c %F ${item})"
116   FILEPOSIX="$(stat -c %a $I)"   fileposix="$(stat -c %a ${item})"
117   FILEOWNER="$(stat -c %U $I)"   fileowner="$(stat -c %U ${item})"
118   FILEGROUP="$(stat -c %G $I)"   filegroup="$(stat -c %G ${item})"
119    
120   [[ ${FILEOWNER} = UNKNOWN ]] && FILEOWNER="root"   [[ ${fileowner} = UNKNOWN ]] && fileowner="root"
121   [[ ${FILEGROUP} = UNKNOWN ]] && FILEGROUP="root"   [[ ${filegroup} = UNKNOWN ]] && filegroup="root"
122    
123   case "${FILETYPE}" in   case "${filetype}" in
124   "directory")   "directory")
125   if [[ $I != ${SEARCHDIRS} ]]   if [[ ${item} != ${SEARCHDIRS} ]]
126   then   then
127   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.dirs   echo "${item#${SEARCHDIRS}*}§${fileposix}§${fileowner}§${filegroup}" >> ${BUILDDIR}/${PKGNAME}/.dirs
128   fi   fi
129   ;;   ;;
130    
131   "symbolic link")   "symbolic link")
132   LNKDEST="$(readlink $I)"   lnkdest="$(readlink ${item})"
133   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${LNKDEST#${SEARCHDIRS}*}§${M_MTIME}" >> ${BUILDDIR}/${PKGNAME}/.symlinks   echo "${item#${SEARCHDIRS}*}§${fileposix}§${lnkdest#${SEARCHDIRS}*}§${m_mtime}" >> ${BUILDDIR}/${PKGNAME}/.symlinks
134   ;;   ;;
   
135    
136   "regular empty file")   "regular empty file")
137   FILEDIR="$(dirname $I)"   filedir="$(dirname ${item})"
138   FILEDIR="${FILEDIR#${SEARCHDIRS}*}"   filedir="${filedir#${SEARCHDIRS}*}"
139   M_MD5SUM="$(md5sum ${I}|cut -d' ' -f1)"   m_md5sum="$(md5sum ${item}|cut -d' ' -f1)"
140   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}§${M_MTIME}§${M_MD5SUM}" >> ${BUILDDIR}/${PKGNAME}/.files   echo "${item#${SEARCHDIRS}*}§${fileposix}§${fileowner}§${filegroup}§${m_mtime}§${m_md5sum}" >> ${BUILDDIR}/${PKGNAME}/.files
141   install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}   install -d ${BUILDDIR}/${PKGNAME}/binfiles/${filedir}
142   cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}   cp ${item} ${BUILDDIR}/${PKGNAME}/binfiles/${filedir}
143   ;;   ;;
144    
145   "regular file" )   "regular file" )
146   FILEDIR="$(dirname $I)"   filedir="$(dirname ${item})"
147   FILEDIR="${FILEDIR#${SEARCHDIRS}*}"   filedir="${filedir#${SEARCHDIRS}*}"
148   M_MD5SUM="$(md5sum ${I}|cut -d' ' -f1)"   m_md5sum="$(md5sum ${item}|cut -d' ' -f1)"
149   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}§${M_MTIME}§${M_MD5SUM}" >> ${BUILDDIR}/${PKGNAME}/.files   echo "${item#${SEARCHDIRS}*}§${fileposix}§${fileowner}§${filegroup}§${m_time}§${m_md5sum}" >> ${BUILDDIR}/${PKGNAME}/.files
150   install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}   install -d ${BUILDDIR}/${PKGNAME}/binfiles/${filedir}
151   cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}   cp ${item} ${BUILDDIR}/${PKGNAME}/binfiles/${filedir}
152   ;;   ;;
153    
154   "block special file")   "block special file")
155   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.pipes   # convert hex2dec
156     #  printf '%d' 0x12 -> 18
157     char_major="$(printf 0x$(stat -c %t ${item}))"
158     char_minor="$(printf 0x$(stat -c %T ${item}))"
159     echo "${item#${SEARCHDIRS}*}§${fileposix}§${char_major}§${char_minor}§${fileowner}§${filegroup}" >> ${BUILDDIR}/${PKGNAME}/.pipes
160   ;;   ;;
161    
162   "character special file")   "character special file")
163   # convert hex2dec   # convert hex2dec
164   #  printf '%d' 0x12 -> 18   #  printf '%d' 0x12 -> 18
165   local CHAR_MAJOR="$(printf 0x$(stat -c %t $I))"   char_major="$(printf 0x$(stat -c %t ${item}))"
166   local CHAR_MINOR="$(printf 0x$(stat -c %T $I))"   char_minor="$(printf 0x$(stat -c %T ${item}))"
167   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${CHAR_MAJOR}§${CHAR_MINOR}" >> ${BUILDDIR}/${PKGNAME}/.char   echo "${item#${SEARCHDIRS}*}§${fileposix}§${char_major}§${char_minor}§${fileowner}§${filegroup}" >> ${BUILDDIR}/${PKGNAME}/.char
168     ;;
169    
170     "fifo")
171     echo "${item#${SEARCHDIRS}*}§${fileposix}§${fileowner}§${filegroup}" >> ${BUILDDIR}/${PKGNAME}/.fifo
172   ;;   ;;
173    
174   *)   *)

Legend:
Removed from v.440  
changed lines
  Added in v.1292