summaryrefslogtreecommitdiff
path: root/localdebpool
blob: b184ee6bdffe7d95e4bbc47e8d2b403f96a319f8 (plain)
  1. #!/bin/sh
  2. set -e
  3. #set -x
  4. ARCHS="i386 powerpc amd64"
  5. DISTS="etch lenny sid"
  6. SRCBASE=~/public_debian
  7. PUBBASE=~/public_websites/debian.jones.dk
  8. #PUBTOSRC=../../public_debian
  9. archsfrompaths() {
  10. find "$@" -type l -exec find '{}'/ -type f -name '*.deb' ';' \
  11. | sed 's/^.*_\([a-z0-9-]\+\)\.deb$/\1/' \
  12. | sort -u
  13. }
  14. distsfrompaths() {
  15. find "$@" -mindepth 1 -maxdepth 1 -type d -printf '%f\n'
  16. }
  17. pathsfromsections() {
  18. case "$@" in
  19. all)
  20. sections_re=""
  21. ;;
  22. "")
  23. echo 1>&2 "ERROR: At least one section (or the magic \"all\") is needed."
  24. exit 1
  25. ;;
  26. *)
  27. sections_re="\b\($(echo "$@" | sed 's/[[:space:]]\+/\\|/g')\)\b"
  28. ;;
  29. esac
  30. find $SRCBASE -type f -name HINTS -exec grep -q "^Sections:.*$sections_re" '{}' ';' -printf '%h\n' \
  31. | sed "s,^$SRCBASE/,,"
  32. }
  33. sectionsfrompaths() {
  34. case "$@" in
  35. all)
  36. fullpaths="$SRCBASE"
  37. ;;
  38. *)
  39. fullpaths=
  40. for path in "$@"; do
  41. # TODO: rewrite to support spaces in directory names
  42. fullpaths="$fullpaths $SRCBASE/$path"
  43. done
  44. ;;
  45. esac
  46. find $fullpaths -type f -name HINTS -exec cat '{}' ';' \
  47. | grep '^Sections:' \
  48. | sed 's/^Sections://; s/[[:space:]]\+/ /g; s/^ //; s/ $//' \
  49. | tr ' ' '\n' \
  50. | sort -u
  51. }
  52. genlist() {
  53. dist="$1"
  54. arch="$2"
  55. srcdir="$3"
  56. basedir="$4"
  57. case "$arch" in
  58. source)
  59. destdir="$basedir/source";
  60. cmd="dpkg-scansources";
  61. file="Sources";
  62. ;;
  63. *)
  64. destdir="$basedir/binary-$arch";
  65. cmd="dpkg-scanpackages";
  66. file="Packages";
  67. ;;
  68. esac
  69. mkdir -p "$destdir"
  70. ( cd "$srcdir" && $cmd $dist /dev/null pools/ ) > "$destdir/$file"
  71. gzip -c "$destdir/$file" > "$destdir/$file.gz"
  72. bzip2 -c "$destdir/$file" > "$destdir/$file.bz2"
  73. }
  74. genlistsfromsection() {
  75. section="$1"
  76. case "$section" in
  77. all)
  78. srcdir="$SRCBASE/sections"
  79. ;;
  80. "")
  81. echo 1>&2 "ERROR: At least one section (or the magic \"all\") is needed."
  82. exit 1
  83. ;;
  84. *)
  85. srcdir="$SRCBASE/sections/$section"
  86. ;;
  87. esac
  88. dists="$(distsfrompaths "$srcdir")"
  89. archs="$(archsfrompaths "$srcdir")"
  90. for dist in $DISTS; do
  91. do_dist=
  92. for dist_found in $dists; do
  93. if [ "$dist_found" = "$dist" ]; then
  94. do_dist=1
  95. continue
  96. fi
  97. done
  98. [ -n "$do_dist" ] || continue
  99. for arch in $ARCHS; do
  100. do_arch=
  101. for arch_found in $archs; do
  102. case $arch_found in
  103. $arch|all)
  104. do_arch=1
  105. continue
  106. esac
  107. done
  108. [ -n "$do_arch" ] || continue
  109. echo genlist "$section" "$dist" "$arch" "$srcdir" "$PUBBASE/dists/$dist/$section"
  110. done
  111. echo genlist "$section" "$dist" "source" "$srcdir" "$PUBBASE/dists/$dist/$section"
  112. done
  113. }
  114. sections="$@"
  115. paths="$(pathsfromsections "$sections")"
  116. #echo $paths; exit 0
  117. #sectionsfrompaths all; exit 0
  118. for path in $paths; do
  119. package="$(basename "$path")"
  120. pool="$(echo $(dirname "$path") | sed 's,.*/pool-\([^/]\+\)/\?.*,\1,; s,-all$,,')"
  121. buildhost="$(echo $(dirname "$path") | sed 's,^\([^/]\+\)/pool-.*,\1,')"
  122. symlink_dir="$pool/$package"
  123. mkdir -p "$PUBBASE/pools/$symlink_dir"
  124. # ln -sf -T "../../../$PUBTOSRC/$path" "$PUBBASE/pools/$symlink_dir/$buildhost"
  125. ln -sf -T "$SRCBASE/$path" "$PUBBASE/pools/$symlink_dir/$buildhost"
  126. for section in $(sectionsfrompaths "$path"); do
  127. mkdir -p "$SRCBASE/sections/$section/$symlink_dir"
  128. ln -sf -T "../../../../$path" "$SRCBASE/sections/$section/$symlink_dir/$buildhost"
  129. done
  130. done
  131. for section in $sections; do
  132. genlistsfromsection $section
  133. done
  134. exit 0