Magellan Linux

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

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

revision 2210 by niro, Mon Oct 14 13:13:46 2013 UTC revision 2286 by niro, Mon Dec 2 10:12:35 2013 UTC
# Line 9  die() Line 9  die()
9   exit 1   exit 1
10  }  }
11    
12    decho()
13    {
14     if [[ ${DEBUG} = 1 ]]
15     then
16     echo "DEBUG: $@" >&2
17     fi
18    }
19    
20  # include all needed files  # include all needed files
21  [ -f /etc/mage.rc.global ] &&  \  [ -f /etc/mage.rc.global ] &&  \
22   source /etc/mage.rc.global || \   source /etc/mage.rc.global || \
# Line 27  usage() Line 35  usage()
35   echo "Usage: $(basename $0) [command] [arg] ..."   echo "Usage: $(basename $0) [command] [arg] ..."
36   echo   echo
37   echo "  -h     --help          shows this help"   echo "  -h     --help          shows this help"
38   echo "  -c     --pcat          categorie of the package"   echo "  -c     --pcat          category of the package"
39   echo "  -n     --pname         name of the package"   echo "  -n     --pname         name of the package"
40   echo "  -v     --pver          version number of the package"   echo "  -v     --pver          version number of the package"
41   echo "  -b     --pbuild        build number of the package"   echo "  -b     --pbuild        build number of the package"
42   echo "  -m     --method        which calc method should be used:"   echo "  -m     --method        which calc method should be used:"
43   echo "                         install, srcinstall, depend, srcdepend"   echo "                         install, srcinstall, depend, srcdepend"
44   echo "                         upgrade, srcupgrade,"   echo "                         upgrade, srcupgrade,"
45   echo "                         install-build-prerequisites, pretend-build-prerequisites"   echo "                         install-build-prerequisites,"
46     echo "                         pretend-build-prerequisites"
47     echo "  -d     --debug         enable debug mode"
48   echo   echo
49   echo "method, name, version and build must be given !"   echo "method, category, name, version and build must be given !"
50   echo   echo
51   exit 1   exit 1
52  }  }
53    
54    # always default debug=0
55    DEBUG=0
56    
57  # very basic getops  # very basic getops
58  for i in $*  for i in $*
59  do  do
# Line 50  do Line 63  do
63   --pver|-v) shift; PVER="$1" ;;   --pver|-v) shift; PVER="$1" ;;
64   --pbuild|-b) shift; PBUILD="$1" ;;   --pbuild|-b) shift; PBUILD="$1" ;;
65   --method|-m) shift; METHOD="$1" ;;   --method|-m) shift; METHOD="$1" ;;
66     --debug|-d) shift; DEBUG=1 ;;
67   --help|-h) usage ;;   --help|-h) usage ;;
68   esac   esac
69   shift   shift
# Line 121  depwalking() Line 135  depwalking()
135    
136   DFILE="$1"   DFILE="$1"
137    
138     # debug info
139     decho "depwalking magefile '${DFILE}'"
140     decho
141    
142   source ${DFILE}   source ${DFILE}
143    
144   # forced nodeps   # forced nodeps
# Line 133  depwalking() Line 151  depwalking()
151   MY_DEPEND="${DEPEND}"   MY_DEPEND="${DEPEND}"
152    
153   # for srcinstall & srcdepend only; SDEPEND also needed   # for srcinstall & srcdepend only; SDEPEND also needed
154   if [[ ${METHOD} = srcinstall ]] || \   if [[ ${METHOD} = srcinstall ]] ||
155   [[ ${METHOD} = srcpretend ]] || \   [[ ${METHOD} = srcpretend ]] ||
156   [[ ${METHOD} = srcupgrade ]] || \   [[ ${METHOD} = srcupgrade ]] ||
157   [[ ${METHOD} = srcuppretend ]]   [[ ${METHOD} = srcuppretend ]] ||
158     [[ ${METHOD} = install-build-prerequisites ]] ||
159     [[ ${METHOD} = pretend-build-prerequisites ]]
160   then   then
161   # only if SDEPEND is not zero   # only if SDEPEND is not zero
162   if [ -n "${SDEPEND}" ]   if [ -n "${SDEPEND}" ]
# Line 152  depwalking() Line 172  depwalking()
172   fi   fi
173   fi   fi
174    
  if [[ ${METHOD} = install-build-prerequisites ]] || \  
  [[ ${METHOD} = pretend-build-prerequisites ]]  
  then  
  # only one time  
  if [[ ${LOOP_COUNTER} -lt 1 ]]  
  then  
  # only if SDEPEND is not zero  
  if [ -n "${SDEPEND}" ]  
  then  
  # crlf is substantly needed !!  
  if [ -n "${MY_DEPEND}" ]  
  then  
  MY_DEPEND="${MY_DEPEND}  
  ${SDEPEND}"  
  else  
  MY_DEPEND="${SDEPEND}"  
  fi  
  fi  
  fi  
  LOOP_COUNTER=${LOOP_COUNTER}+1  
  fi  
   
175   unset DEPEND   unset DEPEND
176   unset SDEPEND   unset SDEPEND
177    
178   if [ -z "${MY_DEPEND}" ]   if [ -z "${MY_DEPEND}" ]
179   then   then
180     decho "MY_DEPEND is empty; deps of '${DFILE}' ignored"
181   return 1   return 1
182   fi   fi
183    
184   while read SYM DEPNAME   while read SYM DEPNAME
185   do   do
186     # debug info
187     decho "DEPNAME='${DEPNAME}'"
188    
189   # exclude empty depnames   # exclude empty depnames
190   [[ -z ${DEPNAME} ]] && continue   [[ -z ${DEPNAME} ]] && continue
191    
# Line 224  depwalking() Line 226  depwalking()
226   then   then
227   depwalking ${HIGHEST_DEPFILE}   depwalking ${HIGHEST_DEPFILE}
228   ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}"   ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}"
229     decho "added '${HIGHEST_DEPFILE}' to ALLDEPS"
230   fi   fi
231   fi   fi
232   done << EOF   done << EOF
# Line 254  then Line 257  then
257   # get the highest mage file from mage-db   # get the highest mage file from mage-db
258   MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})"   MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})"
259    
260     # debug info
261     decho "dep='${dep}'"
262     decho "PCAT='${PCAT}'"
263     decho "PNAME='${PNAME}'"
264     decho "MAGEFILE='${MAGEFILE}'"
265    
266   # if no install candidate was found, record this   # if no install candidate was found, record this
267   # and process with the next one   # and process with the next one
268   if [[ -z ${MAGEFILE} ]]   if [[ -z ${MAGEFILE} ]]
269   then   then
270   NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}"   NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}"
271     decho "added to NO_UPGRADE_CANDIDATE"
272   continue   continue
273   fi   fi
274    
# Line 266  then Line 276  then
276   PVER="$(magename2pver ${MAGEFILE})"   PVER="$(magename2pver ${MAGEFILE})"
277   PBUILD="$(magename2pbuild ${MAGEFILE})"   PBUILD="$(magename2pbuild ${MAGEFILE})"
278    
279     # debug info
280     decho "PVER='${PVER}'"
281     decho "PBUILD='${PBUILD}'"
282    
283   # do not walk files which are installed   # do not walk files which are installed
284   if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]   if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
285   then   then
286   # get dependencies the package   # get dependencies the package
287   depwalking ${MAGEFILE}   depwalking ${MAGEFILE}
288    
289     # now add the package itself to the dependencies
290     # (if not exists already)
291     if checklist_alldeps "${MAGEFILE}"
292     then
293     decho "added '${MAGEFILE}' to ALLDEPS"
294     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
295     fi
296     else
297     # debug info
298     decho "ignored package"
299     decho
300     fi
301   fi   fi
302   done   done
303  else  else
# Line 280  else Line 307  else
307  fi  fi
308    
309  if [[ ${METHOD} != install-build-prerequisites ]] &&  if [[ ${METHOD} != install-build-prerequisites ]] &&
310   [[ ${METHOD} != pretend-build-prerequisites ]]   [[ ${METHOD} != pretend-build-prerequisites ]] &&
311     [[ ${METHOD} != upgrade ]] &&
312     [[ ${METHOD} != uppretend ]] &&
313     [[ ${METHOD} != srcupgrade ]] &&
314     [[ ${METHOD} != srcuppretend ]]
315  then  then
316   # now add the package itself to the dependencies   # now add the package itself to the dependencies
317   # (if not exists already)   # (if not exists already)
318   if checklist_alldeps "${MAGEFILE}"   if checklist_alldeps "${MAGEFILE}"
319   then   then
320     decho "added '${MAGEFILE}' to ALLDEPS"
321   ALLDEPS="${ALLDEPS} ${MAGEFILE}"   ALLDEPS="${ALLDEPS} ${MAGEFILE}"
322   fi   fi
323  fi  fi
# Line 320  then Line 352  then
352   PBUILD="$(magename2pbuild ${i})"   PBUILD="$(magename2pbuild ${i})"
353   if [ -z "${list}" ]   if [ -z "${list}" ]
354   then   then
355   list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"   list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
356   else   else
357   list="${list}   list="${list}
358  \t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"  \t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"

Legend:
Removed from v.2210  
changed lines
  Added in v.2286