Magellan Linux

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

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

revision 24 by niro, Wed Jan 5 05:08:01 2005 UTC revision 419 by niro, Mon Jan 22 00:24:14 2007 UTC
# Line 4  Line 4 
4  # builds packages from given dir  # builds packages from given dir
5  #  #
6    
7  # version: 0.3.6-r8  # $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 $
8    
9    # set default user mage.rc
10    : ${MAGERC="/etc/mage.rc"}
11    
12  PKGSUFFIX="mpk"  PKGSUFFIX="mpk"
13  PKGNAME="$1"  PKGNAME="$1"
# Line 15  COLRED="\033[1;6m\033[31m" Line 18  COLRED="\033[1;6m\033[31m"
18  COLGREEN="\033[1;6m\033[32m"  COLGREEN="\033[1;6m\033[32m"
19  COLDEFAULT="\033[0m"  COLDEFAULT="\033[0m"
20    
21  if [ -z "$1" ]  # export default C locale
22  then  export LC_ALL=C
  echo "No package name given. Aborting."  
 fi  
23    
24  if [ -z "$2" ]  [[ -z $1 ]] && echo "No package name given. Aborting." && exit 1
25  then  [[ -z $2 ]] && echo "No source dir given. Aborting." && exit 1
  echo "No source dir given. Aborting."  
 fi  
26    
27  if [ -f /etc/mage.rc ]  if [ -f ${MAGERC} ]
28  then  then
29   source /etc/mage.rc   source ${MAGERC}
30  else  else
31   echo "Your /etc/mage.rc is missing. Aborting."   echo "Your ${MAGERC} is missing. Aborting."
32   exit 1   exit 1
33  fi  fi
34  source ${MLIBDIR}/mage3.functions.sh  source ${MLIBDIR}/mage4.functions.sh
35    
36  build_preinstall() {  # set PKGDIR and BUILDDIR and BINDIR to MROOT
37    if [[ -n ${MROOT} ]]
38    then
39     export PKGDIR=${MROOT}/${PKGDIR}
40     export BUILDDIR=${MROOT}/${BUILDDIR}
41     export BINDIR=${MROOT}/${BINDIR}
42    fi
43    
44    build_preinstall()
45    {
46   if [ -d ${BUILDDIR}/${PKGNAME} ]   if [ -d ${BUILDDIR}/${PKGNAME} ]
47   then   then
48   rm -rf ${BUILDDIR}/${PKGNAME}   rm -rf ${BUILDDIR}/${PKGNAME}
# Line 48  build_preinstall() { Line 56  build_preinstall() {
56   touch ${BUILDDIR}/${PKGNAME}/.char   touch ${BUILDDIR}/${PKGNAME}/.char
57  }  }
58    
59  build_postinstall() {  build_postinstall()
60    {
61   echo   echo
62   echo "Fetching files for package '${PKGNAME}' ..."   echo "Fetching files for package '${PKGNAME}' ..."
63    
64   #md5sums will only be generated for files: $M_MD5SUM   # md5sums will only be generated for files: $M_MD5SUM
65    
66   #sets mtime to same value of the $BINDIR: $M_MTIME   # sets mtime to same value of the $BINDIR: $M_MTIME
67   #only needed for files and symlinks   # only needed for files and symlinks
68   M_MTIME=$(stat -c %Y ${BINDIR})   M_MTIME=$(stat -c %Y ${BINDIR})
69    
70   #install mtime to package (needed for later checks)   # install mtime to package (needed for later checks)
71   echo "${M_MTIME}" > ${BUILDDIR}/${PKGNAME}/.mtime   echo "${M_MTIME}" > ${BUILDDIR}/${PKGNAME}/.mtime
72    
73   #!! we use § as field seperator !!   # !! we use § as field seperator !!
74   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
75   BUILD_TODELFILES=$(find ${SEARCHDIRS} -printf %p§)   BUILD_TODELFILES=$(find ${SEARCHDIRS} -printf %p§)
76    
77   #sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
78   IFS=§   IFS=§
79    
80   for I in $BUILD_TODELFILES   for I in $BUILD_TODELFILES
# Line 80  build_postinstall() { Line 88  build_postinstall() {
88   FILEOWNER="$(stat -c %U $I)"   FILEOWNER="$(stat -c %U $I)"
89   FILEGROUP="$(stat -c %G $I)"   FILEGROUP="$(stat -c %G $I)"
90    
91   if [ "${FILEOWNER}" == "UNKNOWN" ]   [[ ${FILEOWNER} = UNKNOWN ]] && FILEOWNER="root"
92   then   [[ ${FILEGROUP} = UNKNOWN ]] && FILEGROUP="root"
  FILEOWNER="root"  
  fi  
   
  if [ "${FILEGROUP}" == "UNKNOWN" ]  
  then  
  FILEGROUP="root"  
  fi  
93    
94   case "${FILETYPE}" in   case "${FILETYPE}" in
95   "directory")   "directory")
96   if [ "$I" != "${SEARCHDIRS}" ]   if [[ $I != ${SEARCHDIRS} ]]
97   then   then
98   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.dirs   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.dirs
99   fi   fi
100   ;;   ;;
101    
102   "symbolic link")   "symbolic link")
103   LNKDEST="$(readlink $I)"   LNKDEST="$(readlink $I)"
104   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${LNKDEST#${SEARCHDIRS}*}§${M_MTIME}" >> ${BUILDDIR}/${PKGNAME}/.symlinks   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${LNKDEST#${SEARCHDIRS}*}§${M_MTIME}" >> ${BUILDDIR}/${PKGNAME}/.symlinks
# Line 121  build_postinstall() { Line 122  build_postinstall() {
122   install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}   install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}
123   cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}   cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}
124   ;;   ;;
125    
126   "block special file")   "block special file")
127   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.pipes   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.pipes
128   ;;   ;;
129    
130   "character special file")   "character special file")
131   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.char   # convert hex2dec
132     #  printf '%d' 0x12 -> 18
133     local CHAR_MAJOR="$(printf 0x$(stat -c %t $I))"
134     local CHAR_MINOR="$(printf 0x$(stat -c %T $I))"
135     echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${CHAR_MAJOR}§${CHAR_MINOR}" >> ${BUILDDIR}/${PKGNAME}/.char
136   ;;   ;;
137    
138   *)   *)
139   echo "What I am ? -- $I"   echo "What I am ? -- $I"
140   echo "$0 paused ... Press Enter"   echo "$0 paused ... Press Enter"
# Line 138  build_postinstall() { Line 143  build_postinstall() {
143   esac   esac
144   fi   fi
145   done   done
146    
147   #very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
148   unset IFS   unset IFS
149    
150   #forcing mtime to same value   # forcing mtime to same value
151   echo -n "Forcing mtime to the same value ..."   echo -n "Forcing mtime to the same value ..."
152   find ${BUILDDIR}/${PKGNAME}/binfiles \   find ${BUILDDIR}/${PKGNAME}/binfiles \
153   -exec touch -m -r ${BUILDDIR}/${PKGNAME}/.mtime '{}' ';' \   -exec touch -m -r ${BUILDDIR}/${PKGNAME}/.mtime '{}' ';' \
154   && echo done || echo false   && echo done || echo false
   
155  }  }
156    
157  build_rmtimestamp() {  build_rmtimestamp()
158    {
159   rm /var/tmp/timestamp   rm /var/tmp/timestamp
160  }  }
161    
162    build_package()
163  build_package() {  {
164   echo "Building Package ..."   echo "Building Package ..."
165   cd ${BUILDDIR}   cd ${BUILDDIR}
166   tar cvjf ${PKGNAME}.tar.bz2 ./${PKGNAME}   tar cvjf ${PKGNAME}.tar.bz2 ./${PKGNAME}
# Line 163  build_package() { Line 168  build_package() {
168   mv ${PKGNAME}.tar.bz2 ${PKGDIR}/${PKGNAME}.${PKGSUFFIX}   mv ${PKGNAME}.tar.bz2 ${PKGDIR}/${PKGNAME}.${PKGSUFFIX}
169  }  }
170    
   
171  build_preinstall  build_preinstall
172  build_postinstall  build_postinstall
173  build_package  build_package

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