Magellan Linux

Diff of /branches/mage-next/src/pkgbuild_dir.in

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

trunk/mage/usr/lib/mage/pkgbuild_dir.sh revision 419 by niro, Mon Jan 22 00:24:14 2007 UTC branches/mage-next/src/pkgbuild_dir.in revision 2570 by niro, Wed Jan 29 12:22:49 2014 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    # $Id$
3    
4  #  #
5  # builds packages from given dir  # builds packages from given dir
6  #  #
7    
8  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/pkgbuild_dir.sh,v 1.13 2007-01-22 00:24:14 niro Exp $  # export default C locale
9    export LC_ALL=C
 # set default user mage.rc  
 : ${MAGERC="/etc/mage.rc"}  
10    
 PKGSUFFIX="mpk"  
11  PKGNAME="$1"  PKGNAME="$1"
12  SEARCHDIRS="$2"  SEARCHDIRS="$2"
 MLIBDIR=/usr/lib/mage  
13    
14  COLRED="\033[1;6m\033[31m"  [[ -z ${PKGNAME} ]] && echo "No package name given. Aborting." && exit 1
15  COLGREEN="\033[1;6m\033[32m"  [[ -z ${SEARCHDIRS} ]] && echo "No source dir given. Aborting." && exit 1
 COLDEFAULT="\033[0m"  
16    
17  # export default C locale  source /etc/mage.rc.global
18  export LC_ALL=C  [[ -f ${MAGERC} ]] && source ${MAGERC}
   
 [[ -z $1 ]] && echo "No package name given. Aborting." && exit 1  
 [[ -z $2 ]] && echo "No source dir given. Aborting." && exit 1  
   
 if [ -f ${MAGERC} ]  
 then  
  source ${MAGERC}  
 else  
  echo "Your ${MAGERC} is missing. Aborting."  
  exit 1  
 fi  
19  source ${MLIBDIR}/mage4.functions.sh  source ${MLIBDIR}/mage4.functions.sh
20    
21  # set PKGDIR and BUILDDIR and BINDIR to MROOT  # set PKGDIR and BUILDDIR and BINDIR to MROOT
# Line 54  build_preinstall() Line 39  build_preinstall()
39   touch ${BUILDDIR}/${PKGNAME}/.files   touch ${BUILDDIR}/${PKGNAME}/.files
40   touch ${BUILDDIR}/${PKGNAME}/.pipes   touch ${BUILDDIR}/${PKGNAME}/.pipes
41   touch ${BUILDDIR}/${PKGNAME}/.char   touch ${BUILDDIR}/${PKGNAME}/.char
42     touch ${BUILDDIR}/${PKGNAME}/.fifo
43  }  }
44    
45  build_postinstall()  build_postinstall()
46  {  {
47   echo   local m_mtime
48   echo "Fetching files for package '${PKGNAME}' ..."   local m_md5sum
49     local filelist
50     local item
51     local check_srcdir
52     local filetype
53     local fileposix
54     local fileowner
55     local filegroup
56     local lnkdest
57     local filedir
58     local char_major
59     local char_minor
60    
61   # md5sums will only be generated for files: $M_MD5SUM   echo -e "${COLBLUE}===${COLGREEN} fetching files for package '${PKGNAME}' ...${COLDEFAULT}"
62    
63   # sets mtime to same value of the $BINDIR: $M_MTIME   # md5sums will only be generated for files: $m_md5sum
64    
65     # sets mtime to same value of the $BINDIR: $m_mtime
66   # only needed for files and symlinks   # only needed for files and symlinks
67   M_MTIME=$(stat -c %Y ${BINDIR})   m_mtime=$(stat -c %Y ${BINDIR})
68    
69   # install mtime to package (needed for later checks)   # install mtime to package (needed for later checks)
70   echo "${M_MTIME}" > ${BUILDDIR}/${PKGNAME}/.mtime   echo "${m_mtime}" > ${BUILDDIR}/${PKGNAME}/.mtime
71    
72   # !! we use § as field seperator !!   # !! we use § as field seperator !!
73   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
74   BUILD_TODELFILES=$(find ${SEARCHDIRS} -printf %p§)   filelist=$(find ${SEARCHDIRS} -printf %p§)
75    
76   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
77   IFS=§   IFS=§
78    
79   for I in $BUILD_TODELFILES   for item in ${filelist}
80   do   do
81   CHECK_SRCDIR="$(echo ${I#${SEARCHDIRS}*}|grep $BUILDDIR)"   check_srcdir="$(echo ${item#${SEARCHDIRS}*}|grep ${BUILDDIR})"
82    
83   if [ -z "$CHECK_SRCDIR" ]   if [[ -z ${check_srcdir} ]]
84   then   then
85   FILETYPE="$(stat -c %F $I)"   filetype="$(stat -c %F ${item})"
86   FILEPOSIX="$(stat -c %a $I)"   fileposix="$(stat -c %a ${item})"
87   FILEOWNER="$(stat -c %U $I)"   fileowner="$(stat -c %U ${item})"
88   FILEGROUP="$(stat -c %G $I)"   filegroup="$(stat -c %G ${item})"
89    
90   [[ ${FILEOWNER} = UNKNOWN ]] && FILEOWNER="root"   [[ ${fileowner} = UNKNOWN ]] && fileowner="root"
91   [[ ${FILEGROUP} = UNKNOWN ]] && FILEGROUP="root"   [[ ${filegroup} = UNKNOWN ]] && filegroup="root"
92    
93   case "${FILETYPE}" in   case "${filetype}" in
94   "directory")   "directory")
95   if [[ $I != ${SEARCHDIRS} ]]   if [[ ${item} != ${SEARCHDIRS} ]]
96   then   then
97   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.dirs   echo "${item#${SEARCHDIRS}*}§${fileposix}§${fileowner}§${filegroup}" >> ${BUILDDIR}/${PKGNAME}/.dirs
98   fi   fi
99   ;;   ;;
100    
101   "symbolic link")   "symbolic link")
102   LNKDEST="$(readlink $I)"   lnkdest="$(readlink ${item})"
103   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${LNKDEST#${SEARCHDIRS}*}§${M_MTIME}" >> ${BUILDDIR}/${PKGNAME}/.symlinks   echo "${item#${SEARCHDIRS}*}§${fileposix}§${lnkdest#${SEARCHDIRS}*}§${m_mtime}" >> ${BUILDDIR}/${PKGNAME}/.symlinks
104   ;;   ;;
   
105    
106   "regular empty file")   "regular empty file")
107   FILEDIR="$(dirname $I)"   filedir="$(dirname ${item})"
108   FILEDIR="${FILEDIR#${SEARCHDIRS}*}"   filedir="${filedir#${SEARCHDIRS}*}"
109   M_MD5SUM="$(md5sum ${I}|cut -d' ' -f1)"   m_md5sum="$(md5sum ${item}|cut -d' ' -f1)"
110   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
111   install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}   install -d ${BUILDDIR}/${PKGNAME}/binfiles/${filedir}
112   cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}   cp ${item} ${BUILDDIR}/${PKGNAME}/binfiles/${filedir}
113   ;;   ;;
114    
115   "regular file" )   "regular file" )
116   FILEDIR="$(dirname $I)"   filedir="$(dirname ${item})"
117   FILEDIR="${FILEDIR#${SEARCHDIRS}*}"   filedir="${filedir#${SEARCHDIRS}*}"
118   M_MD5SUM="$(md5sum ${I}|cut -d' ' -f1)"   m_md5sum="$(md5sum ${item}|cut -d' ' -f1)"
119   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
120   install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}   install -d ${BUILDDIR}/${PKGNAME}/binfiles/${filedir}
121   cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}   cp ${item} ${BUILDDIR}/${PKGNAME}/binfiles/${filedir}
122   ;;   ;;
123    
124   "block special file")   "block special file")
125   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.pipes   # convert hex2dec
126     #  printf '%d' 0x12 -> 18
127     char_major="$(printf 0x$(stat -c %t ${item}))"
128     char_minor="$(printf 0x$(stat -c %T ${item}))"
129     echo "${item#${SEARCHDIRS}*}§${fileposix}§${char_major}§${char_minor}§${fileowner}§${filegroup}" >> ${BUILDDIR}/${PKGNAME}/.pipes
130   ;;   ;;
131    
132   "character special file")   "character special file")
133   # convert hex2dec   # convert hex2dec
134   #  printf '%d' 0x12 -> 18   #  printf '%d' 0x12 -> 18
135   local CHAR_MAJOR="$(printf 0x$(stat -c %t $I))"   char_major="$(printf 0x$(stat -c %t ${item}))"
136   local CHAR_MINOR="$(printf 0x$(stat -c %T $I))"   char_minor="$(printf 0x$(stat -c %T ${item}))"
137   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${CHAR_MAJOR}§${CHAR_MINOR}" >> ${BUILDDIR}/${PKGNAME}/.char   echo "${item#${SEARCHDIRS}*}§${fileposix}§${char_major}§${char_minor}§${fileowner}§${filegroup}" >> ${BUILDDIR}/${PKGNAME}/.char
138     ;;
139    
140     "fifo")
141     echo "${item#${SEARCHDIRS}*}§${fileposix}§${fileowner}§${filegroup}" >> ${BUILDDIR}/${PKGNAME}/.fifo
142   ;;   ;;
143    
144   *)   *)
# Line 148  build_postinstall() Line 154  build_postinstall()
154   unset IFS   unset IFS
155    
156   # forcing mtime to same value   # forcing mtime to same value
157   echo -n "Forcing mtime to the same value ..."   echo -e "${COLBLUE}===${COLGREEN} forcing mtime to the same value ...${COLDEFAULT}"
158   find ${BUILDDIR}/${PKGNAME}/binfiles \   find ${BUILDDIR}/${PKGNAME}/binfiles -exec touch -m -r ${BUILDDIR}/${PKGNAME}/.mtime '{}' ';'
  -exec touch -m -r ${BUILDDIR}/${PKGNAME}/.mtime '{}' ';' \  
  && echo done || echo false  
 }  
   
 build_rmtimestamp()  
 {  
  rm /var/tmp/timestamp  
159  }  }
160    
161  build_package()  build_package()
162  {  {
163   echo "Building Package ..."   echo -e "${COLBLUE}===${COLGREEN} building package tarball ...${COLDEFAULT}"
164   cd ${BUILDDIR}   cd ${BUILDDIR}
165   tar cvjf ${PKGNAME}.tar.bz2 ./${PKGNAME}   tar cvjf ${PKGNAME}.tar.bz2 ./${PKGNAME}
166   install -d ${PKGDIR}   install -d ${PKGDIR}

Legend:
Removed from v.419  
changed lines
  Added in v.2570