Magellan Linux

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

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

revision 1564 by niro, Wed Dec 28 10:05:49 2011 UTC revision 2280 by niro, Wed Nov 20 12:20:12 2013 UTC
# Line 27  usage() Line 27  usage()
27   echo "Usage: $(basename $0) [command] [arg] ..."   echo "Usage: $(basename $0) [command] [arg] ..."
28   echo   echo
29   echo "  -h     --help          shows this help"   echo "  -h     --help          shows this help"
30   echo "  -c     --pcat          categorie of the package"   echo "  -c     --pcat          category of the package"
31   echo "  -n     --pname         name of the package"   echo "  -n     --pname         name of the package"
32   echo "  -v     --pver          version number of the package"   echo "  -v     --pver          version number of the package"
33   echo "  -b     --pbuild        build number of the package"   echo "  -b     --pbuild        build number of the package"
34   echo "  -m     --method        which calc method should be used:"   echo "  -m     --method        which calc method should be used:"
35   echo "                         install, srcinstall, depend, srcdepend"   echo "                         install, srcinstall, depend, srcdepend"
36   echo "                         upgrade, srcupgrade"   echo "                         upgrade, srcupgrade,"
37     echo "                         install-build-prerequisites,"
38     echo "                         pretend-build-prerequisites"
39     echo "  -d     --debug         enable debug mode"
40   echo   echo
41   echo "method, name, version and build must be given !"   echo "method, category, name, version and build must be given !"
42   echo   echo
43   exit 1   exit 1
44  }  }
45    
46    # always default debug=0
47    DEBUG=0
48    
49  # very basic getops  # very basic getops
50  for i in $*  for i in $*
51  do  do
# Line 49  do Line 55  do
55   --pver|-v) shift; PVER="$1" ;;   --pver|-v) shift; PVER="$1" ;;
56   --pbuild|-b) shift; PBUILD="$1" ;;   --pbuild|-b) shift; PBUILD="$1" ;;
57   --method|-m) shift; METHOD="$1" ;;   --method|-m) shift; METHOD="$1" ;;
58     --debug|-d) shift; DEBUG=1 ;;
59   --help|-h) usage ;;   --help|-h) usage ;;
60   esac   esac
61   shift   shift
# Line 151  depwalking() Line 158  depwalking()
158   fi   fi
159   fi   fi
160    
161     if [[ ${METHOD} = install-build-prerequisites ]] || \
162     [[ ${METHOD} = pretend-build-prerequisites ]]
163     then
164     # only one time
165     if [[ ${LOOP_COUNTER} -lt 1 ]]
166     then
167     # only if SDEPEND is not zero
168     if [ -n "${SDEPEND}" ]
169     then
170     # crlf is substantly needed !!
171     if [ -n "${MY_DEPEND}" ]
172     then
173     MY_DEPEND="${MY_DEPEND}
174     ${SDEPEND}"
175     else
176     MY_DEPEND="${SDEPEND}"
177     fi
178     fi
179     fi
180     LOOP_COUNTER=${LOOP_COUNTER}+1
181     fi
182    
183   unset DEPEND   unset DEPEND
184   unset SDEPEND   unset SDEPEND
185    
# Line 161  depwalking() Line 190  depwalking()
190    
191   while read SYM DEPNAME   while read SYM DEPNAME
192   do   do
193     if [[ ${DEBUG} = 1 ]]
194     then
195     echo "DEBUG: DEPNAME='${DEPNAME}'" >&2
196     fi
197    
198   # exclude empty depnames   # exclude empty depnames
199   [[ -z ${DEPNAME} ]] && continue   [[ -z ${DEPNAME} ]] && continue
200    
# Line 179  depwalking() Line 213  depwalking()
213   fi   fi
214    
215   HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")   HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")
216     if [[ -z ${HIGHEST_DEPFILE} ]]
217     then
218     INVALID_DEPS+=" ${DEPNAME}:${DFILE}"
219     continue
220     fi
221    
222   PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"   PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"
223   PNAME="$(magename2pname ${HIGHEST_DEPFILE})"   PNAME="$(magename2pname ${HIGHEST_DEPFILE})"
# Line 207  EOF Line 246  EOF
246  [[ ${METHOD} = pretend ]] || \  [[ ${METHOD} = pretend ]] || \
247   [[ ${METHOD} = srcpretend ]] || \   [[ ${METHOD} = srcpretend ]] || \
248   [[ ${METHOD} = uppretend ]] || \   [[ ${METHOD} = uppretend ]] || \
249   [[ ${METHOD} = srcuppretend ]] && \   [[ ${METHOD} = srcuppretend ]] || \
250     [[ ${METHOD} = pretend-build-prerequisites ]] && \
251   echo -n "Calculating dependencies ... "   echo -n "Calculating dependencies ... "
252    
253    
# Line 245  then Line 285  then
285    
286   # now add the package itself to the dependencies   # now add the package itself to the dependencies
287   # (if not exists already)   # (if not exists already)
  #if [ -z "$(echo ${ALLDEPS} | fgrep "${MAGEFILE}")" ]  
288   if checklist_alldeps "${MAGEFILE}"   if checklist_alldeps "${MAGEFILE}"
289   then   then
290   ALLDEPS="${ALLDEPS} ${MAGEFILE}"   ALLDEPS="${ALLDEPS} ${MAGEFILE}"
# Line 253  then Line 292  then
292   fi   fi
293   done   done
294  else  else
295     LOOP_COUNTER=0
296   # get all dependencies of the package   # get all dependencies of the package
297   depwalking ${MAGEFILE}   depwalking ${MAGEFILE}
298    fi
299    
300    if [[ ${METHOD} != install-build-prerequisites ]] &&
301     [[ ${METHOD} != pretend-build-prerequisites ]] &&
302     [[ ${METHOD} != upgrade ]] &&
303     [[ ${METHOD} != uppretend ]] &&
304     [[ ${METHOD} != srcupgrade ]] &&
305     [[ ${METHOD} != srcuppretend ]]
306    then
307   # now add the package itself to the dependencies   # now add the package itself to the dependencies
308   ALLDEPS="${ALLDEPS} ${MAGEFILE}"   # (if not exists already)
309     if checklist_alldeps "${MAGEFILE}"
310     then
311     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
312     fi
313  fi  fi
314    
315  [[ ${METHOD} = pretend ]] || \  [[ ${METHOD} = pretend ]] || \
316   [[ ${METHOD} = srcpretend ]] || \   [[ ${METHOD} = srcpretend ]] || \
317   [[ ${METHOD} = uppretend ]] || \   [[ ${METHOD} = uppretend ]] || \
318   [[ ${METHOD} = srcuppretend ]] && \   [[ ${METHOD} = srcuppretend ]] || \
319     [[ ${METHOD} = pretend-build-prerequisites ]] && \
320   echo "done"   echo "done"
321    
322    
# Line 271  fi Line 324  fi
324  if [[ ${METHOD} = pretend ]] || \  if [[ ${METHOD} = pretend ]] || \
325   [[ ${METHOD} = srcpretend ]] || \   [[ ${METHOD} = srcpretend ]] || \
326   [[ ${METHOD} = uppretend ]] || \   [[ ${METHOD} = uppretend ]] || \
327   [[ ${METHOD} = srcuppretend ]]   [[ ${METHOD} = srcuppretend ]] || \
328     [[ ${METHOD} = pretend-build-prerequisites ]]
329  then  then
330   # this is a little bit faster   # this is a little bit faster
331   declare -i x=0   declare -i x=0
# Line 288  then Line 342  then
342   PBUILD="$(magename2pbuild ${i})"   PBUILD="$(magename2pbuild ${i})"
343   if [ -z "${list}" ]   if [ -z "${list}" ]
344   then   then
345   list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"   list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
346   else   else
347   list="${list}   list="${list}
348  \t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"  \t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
# Line 299  then Line 353  then
353   echo -e "${list}"   echo -e "${list}"
354   echo   echo
355    
356     if [[ ! -z ${INVALID_DEPS} ]]
357     then
358     echo -e "${COLRED}Invalid dependencies found:${COLDEFAULT}"
359     for i in ${INVALID_DEPS}
360     do
361     _dep="${i%%:*}"
362     _mage="${i##*:}"
363     echo -e "${COLRED} '${_dep}' -> '${_mage}'${COLDEFAULT}"
364     done
365     echo
366     fi
367    
368   if [[ ! -z ${NO_UPGRADE_CANDIDATE} ]]   if [[ ! -z ${NO_UPGRADE_CANDIDATE} ]]
369   then   then
370   echo -e "${COLRED}Currently no candidates found for:${COLDEFAULT}"   echo -e "${COLRED}Currently no candidates found for:${COLDEFAULT}"
# Line 318  fi Line 384  fi
384  [[ ${METHOD} = install ]] || \  [[ ${METHOD} = install ]] || \
385   [[ ${METHOD} = srcinstall ]] || \   [[ ${METHOD} = srcinstall ]] || \
386   [[ ${METHOD} = upgrade ]] || \   [[ ${METHOD} = upgrade ]] || \
387   [[ ${METHOD} = srcupgrade ]] && \   [[ ${METHOD} = srcupgrade ]] || \
388     [[ ${METHOD} = install-build-prerequisites ]] && \
389   echo "${ALLDEPS}"   echo "${ALLDEPS}"

Legend:
Removed from v.1564  
changed lines
  Added in v.2280