Magellan Linux

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

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

revision 2195 by niro, Thu Oct 10 11:05:34 2013 UTC revision 2359 by niro, Mon Jan 6 12:35:42 2014 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, pretend, srcpretend"
44   echo "                         upgrade, srcupgrade"   echo "                         upgrade, srcupgrade,"
45     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 49  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 120  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 132  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 156  depwalking() Line 177  depwalking()
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 201  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 212  EOF Line 238  EOF
238  [[ ${METHOD} = pretend ]] || \  [[ ${METHOD} = pretend ]] || \
239   [[ ${METHOD} = srcpretend ]] || \   [[ ${METHOD} = srcpretend ]] || \
240   [[ ${METHOD} = uppretend ]] || \   [[ ${METHOD} = uppretend ]] || \
241   [[ ${METHOD} = srcuppretend ]] && \   [[ ${METHOD} = srcuppretend ]] || \
242     [[ ${METHOD} = pretend-build-prerequisites ]] && \
243   echo -n "Calculating dependencies ... "   echo -n "Calculating dependencies ... "
244    
245    
# Line 230  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 242  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
304     LOOP_COUNTER=0
305   # get all dependencies of the package   # get all dependencies of the package
306   depwalking ${MAGEFILE}   depwalking ${MAGEFILE}
307  fi  fi
308    
309  # now add the package itself to the dependencies  if [[ ${METHOD} != install-build-prerequisites ]] &&
310  # (if not exists already)   [[ ${METHOD} != pretend-build-prerequisites ]] &&
311  if checklist_alldeps "${MAGEFILE}"   [[ ${METHOD} != upgrade ]] &&
312     [[ ${METHOD} != uppretend ]] &&
313     [[ ${METHOD} != srcupgrade ]] &&
314     [[ ${METHOD} != srcuppretend ]]
315  then  then
316   ALLDEPS="${ALLDEPS} ${MAGEFILE}"   # now add the package itself to the dependencies
317     # (if not exists already)
318     if checklist_alldeps "${MAGEFILE}"
319     then
320     decho "added '${MAGEFILE}' to ALLDEPS"
321     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
322     fi
323  fi  fi
324    
325  [[ ${METHOD} = pretend ]] || \  [[ ${METHOD} = pretend ]] || \
326   [[ ${METHOD} = srcpretend ]] || \   [[ ${METHOD} = srcpretend ]] || \
327   [[ ${METHOD} = uppretend ]] || \   [[ ${METHOD} = uppretend ]] || \
328   [[ ${METHOD} = srcuppretend ]] && \   [[ ${METHOD} = srcuppretend ]] || \
329     [[ ${METHOD} = pretend-build-prerequisites ]] && \
330   echo "done"   echo "done"
331    
332    
# Line 272  fi Line 334  fi
334  if [[ ${METHOD} = pretend ]] || \  if [[ ${METHOD} = pretend ]] || \
335   [[ ${METHOD} = srcpretend ]] || \   [[ ${METHOD} = srcpretend ]] || \
336   [[ ${METHOD} = uppretend ]] || \   [[ ${METHOD} = uppretend ]] || \
337   [[ ${METHOD} = srcuppretend ]]   [[ ${METHOD} = srcuppretend ]] || \
338     [[ ${METHOD} = pretend-build-prerequisites ]]
339  then  then
340   # this is a little bit faster   # this is a little bit faster
341   declare -i x=0   declare -i x=0
# Line 289  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}"
# Line 331  fi Line 394  fi
394  [[ ${METHOD} = install ]] || \  [[ ${METHOD} = install ]] || \
395   [[ ${METHOD} = srcinstall ]] || \   [[ ${METHOD} = srcinstall ]] || \
396   [[ ${METHOD} = upgrade ]] || \   [[ ${METHOD} = upgrade ]] || \
397   [[ ${METHOD} = srcupgrade ]] && \   [[ ${METHOD} = srcupgrade ]] || \
398     [[ ${METHOD} = install-build-prerequisites ]] && \
399   echo "${ALLDEPS}"   echo "${ALLDEPS}"

Legend:
Removed from v.2195  
changed lines
  Added in v.2359