Guest User

Untitled

a guest
Dec 9th, 2012
136
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. deduplicate () {
  2. packages="$1"
  3. outdir="/tmp/net-retriever-$$-deduplicate"
  4.  
  5. mkdir -p "$outdir"
  6.  
  7. while [ -s "$packages" ]; do
  8. entry="$(sed '/^$/q' "$packages")"
  9. package="$(echo "$entry" | sed -n 's/Package:[[:space:]][[:space:]]*//pI' | head -n 1)"
  10. case $package in
  11. ''|*/*)
  12. continue
  13. ;;
  14. *)
  15. if [ -f "$outdir/$package" ]; then
  16. newver="$(echo "$entry" | sed -n 's/Version:[[:space:]][[:space:]]*//pI' | head -n 1)"
  17. [ "$newver" ] || continue
  18. oldver="$(sed -n 's/Version:[[:space:]][[:space:]]*//pI' "$outdir/$package" | head -n 1)"
  19. if /usr/lib/net-retriever/vergt "$newver" "$oldver"; then
  20. echo "$entry" > "$outdir/$package"
  21. echo >> "$outdir/$package"
  22. fi
  23. else
  24. echo "$entry" > "$outdir/$package"
  25. echo >> "$outdir/$package"
  26. fi
  27. ;;
  28. esac
  29. sed -n '/^$/,$p' "$packages" | tail -n +2 > "$packages.new"
  30. mv "$packages.new" "$packages"
  31. done
  32.  
  33. cat "$outdir"/* > "$packages.new"
  34. mv "$packages.new" "$packages"
  35. rm -rf "$outdir"
  36. }
RAW Paste Data