Magellan Linux

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

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

revision 271 by niro, Sun Jul 31 11:57:05 2005 UTC revision 272 by niro, Fri Oct 21 14:23:59 2005 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.8 2005-07-31 11:56:55 niro Exp $  # $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    
9  PKGSUFFIX="mpk"  PKGSUFFIX="mpk"
10  PKGNAME="$1"  PKGNAME="$1"
# Line 18  COLDEFAULT="\033[0m" Line 18  COLDEFAULT="\033[0m"
18  # export default C locale  # export default C locale
19  export LC_ALL=C  export LC_ALL=C
20    
21  if [ -z "$1" ]  [[ -z $1 ]] && echo "No package name given. Aborting." && exit 1
22  then  [[ -z $2 ]] && echo "No source dir given. Aborting." && exit 1
  echo "No package name given. Aborting."  
 fi  
   
 if [ -z "$2" ]  
 then  
  echo "No source dir given. Aborting."  
 fi  
23    
24  if [ -f /etc/mage.rc ]  if [ -f /etc/mage.rc ]
25  then  then
# Line 35  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() {  build_preinstall()
34    {
35   if [ -d ${BUILDDIR}/${PKGNAME} ]   if [ -d ${BUILDDIR}/${PKGNAME} ]
36   then   then
37   rm -rf ${BUILDDIR}/${PKGNAME}   rm -rf ${BUILDDIR}/${PKGNAME}
# Line 51  build_preinstall() { Line 45  build_preinstall() {
45   touch ${BUILDDIR}/${PKGNAME}/.char   touch ${BUILDDIR}/${PKGNAME}/.char
46  }  }
47    
48  build_postinstall() {  build_postinstall()
49    {
50   echo   echo
51   echo "Fetching files for package '${PKGNAME}' ..."   echo "Fetching files for package '${PKGNAME}' ..."
52    
53   #md5sums will only be generated for files: $M_MD5SUM   # md5sums will only be generated for files: $M_MD5SUM
54    
55   #sets mtime to same value of the $BINDIR: $M_MTIME   # sets mtime to same value of the $BINDIR: $M_MTIME
56   #only needed for files and symlinks   # only needed for files and symlinks
57   M_MTIME=$(stat -c %Y ${BINDIR})   M_MTIME=$(stat -c %Y ${BINDIR})
58    
59   #install mtime to package (needed for later checks)   # install mtime to package (needed for later checks)
60   echo "${M_MTIME}" > ${BUILDDIR}/${PKGNAME}/.mtime   echo "${M_MTIME}" > ${BUILDDIR}/${PKGNAME}/.mtime
61    
62   #!! we use § as field seperator !!   # !! we use § as field seperator !!
63   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
64   BUILD_TODELFILES=$(find ${SEARCHDIRS} -printf %p§)   BUILD_TODELFILES=$(find ${SEARCHDIRS} -printf %p§)
65    
66   #sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
67   IFS=§   IFS=§
68    
69   for I in $BUILD_TODELFILES   for I in $BUILD_TODELFILES
# Line 83  build_postinstall() { Line 77  build_postinstall() {
77   FILEOWNER="$(stat -c %U $I)"   FILEOWNER="$(stat -c %U $I)"
78   FILEGROUP="$(stat -c %G $I)"   FILEGROUP="$(stat -c %G $I)"
79    
80   if [ "${FILEOWNER}" == "UNKNOWN" ]   [[ ${FILEOWNER} = UNKNOWN ]] && FILEOWNER="root"
81   then   [[ ${FILEGROUP} = UNKNOWN ]] && FILEGROUP="root"
  FILEOWNER="root"  
  fi  
   
  if [ "${FILEGROUP}" == "UNKNOWN" ]  
  then  
  FILEGROUP="root"  
  fi  
82    
83   case "${FILETYPE}" in   case "${FILETYPE}" in
84   "directory")   "directory")
85   if [ "$I" != "${SEARCHDIRS}" ]   if [[ $I != ${SEARCHDIRS} ]]
86   then   then
87   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.dirs   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.dirs
88   fi   fi
89   ;;   ;;
90    
91   "symbolic link")   "symbolic link")
92   LNKDEST="$(readlink $I)"   LNKDEST="$(readlink $I)"
93   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${LNKDEST#${SEARCHDIRS}*}§${M_MTIME}" >> ${BUILDDIR}/${PKGNAME}/.symlinks   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${LNKDEST#${SEARCHDIRS}*}§${M_MTIME}" >> ${BUILDDIR}/${PKGNAME}/.symlinks
# Line 124  build_postinstall() { Line 111  build_postinstall() {
111   install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}   install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}
112   cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}   cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR}
113   ;;   ;;
114    
115   "block special file")   "block special file")
116   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.pipes   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.pipes
117   ;;   ;;
# Line 132  build_postinstall() { Line 119  build_postinstall() {
119   "character special file")   "character special file")
120   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.char   echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}" >> ${BUILDDIR}/${PKGNAME}/.char
121   ;;   ;;
122    
123   *)   *)
124   echo "What I am ? -- $I"   echo "What I am ? -- $I"
125   echo "$0 paused ... Press Enter"   echo "$0 paused ... Press Enter"
# Line 141  build_postinstall() { Line 128  build_postinstall() {
128   esac   esac
129   fi   fi
130   done   done
131    
132   #very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
133   unset IFS   unset IFS
134    
135   #forcing mtime to same value   # forcing mtime to same value
136   echo -n "Forcing mtime to the same value ..."   echo -n "Forcing mtime to the same value ..."
137   find ${BUILDDIR}/${PKGNAME}/binfiles \   find ${BUILDDIR}/${PKGNAME}/binfiles \
138   -exec touch -m -r ${BUILDDIR}/${PKGNAME}/.mtime '{}' ';' \   -exec touch -m -r ${BUILDDIR}/${PKGNAME}/.mtime '{}' ';' \
139   && echo done || echo false   && echo done || echo false
   
140  }  }
141    
142  build_rmtimestamp() {  build_rmtimestamp()
143    {
144   rm /var/tmp/timestamp   rm /var/tmp/timestamp
145  }  }
146    
147    build_package()
148  build_package() {  {
149   echo "Building Package ..."   echo "Building Package ..."
150   cd ${BUILDDIR}   cd ${BUILDDIR}
151   tar cvjf ${PKGNAME}.tar.bz2 ./${PKGNAME}   tar cvjf ${PKGNAME}.tar.bz2 ./${PKGNAME}
# Line 166  build_package() { Line 153  build_package() {
153   mv ${PKGNAME}.tar.bz2 ${PKGDIR}/${PKGNAME}.${PKGSUFFIX}   mv ${PKGNAME}.tar.bz2 ${PKGDIR}/${PKGNAME}.${PKGSUFFIX}
154  }  }
155    
   
156  build_preinstall  build_preinstall
157  build_postinstall  build_postinstall
158  build_package  build_package

Legend:
Removed from v.271  
changed lines
  Added in v.272