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

Legend:
Removed from v.60  
changed lines
  Added in v.315