Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #!/bin/sh
  2. # Pre-populate signed Release files for an archive.
  3. set -e
  4.  
  5. archive_id="$1"
  6. sources_list="$2"
  7.  
  8. chroot=
  9. if [ "$ROOT" ]; then
  10. chroot=chroot
  11. fi
  12.  
  13. if [ "$ROOT" ] && [ "${sources_list#$ROOT/}" = "$sources_list" ]; then
  14. # Generate a new temporary file that can be accessed by APT in the
  15. # chroot.
  16. file="$($chroot $ROOT tempfile)"
  17. cat "$sources_list" > "$ROOT$file"
  18. else
  19. file="${sources_list#$ROOT}"
  20. fi
  21.  
  22. # Slightly awkward output format, e.g.:
  23. # 'http://archive.ubuntu.com/ubuntu/dists/hardy/Release' archive.ubuntu.com_ubuntu_dists_hardy_Release 0
  24. lines="$($chroot $ROOT \
  25. apt-get -o APT::Get::List-Cleanup=false \
  26. -o Dir::Etc::sourcelist="$file" update --print-uris | \
  27. grep "^'.*'")"
  28.  
  29. NEWLINE='
  30. '
  31. OLD_IFS="$IFS"
  32. IFS="$NEWLINE"
  33. for line in $lines; do
  34. IFS="$OLD_IFS"
  35. uri="$(echo "$line" | sed "s/^'//; s/'.*//")"
  36. file="$(echo "$line" | sed "s/^'[^']*' //; s/ .*//")"
  37. base="${uri##*/}"
  38. dir="${uri%/*}"
  39. codename="${dir##*/}"
  40. case $base in
  41. Release|Release.gpg)
  42. release="/usr/share/apt-setup/release-files/$archive_id/$codename/$base"
  43. if [ -f "$release" ]; then
  44. cp -a "$release" "$ROOT/var/lib/apt/lists/$file"
  45. fi
  46. ;;
  47. esac
  48. IFS="$NEWLINE"
  49. done
  50. IFS="$OLD_IFS"
  51.  
  52. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement