summaryrefslogtreecommitdiff
path: root/localdebpool
blob: 90347a695b79544ce0e31b13ddc1d376b08bd391 (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. cat <<EOF > "$destdir/Release"
  74. Archive: $dist
  75. Component: $section
  76. Origin: Jones
  77. Label: Jones
  78. Architecture: $arch
  79. EOF
  80. }
  81. genlistsfromsection() {
  82. section="$1"
  83. case "$section" in
  84. all)
  85. srcdir="$SRCBASE/sections"
  86. ;;
  87. "")
  88. echo 1>&2 "ERROR: At least one section (or the magic \"all\") is needed."
  89. exit 1
  90. ;;
  91. *)
  92. srcdir="$SRCBASE/sections/$section"
  93. ;;
  94. esac
  95. dists="$(distsfrompaths "$srcdir")"
  96. archs="$(archsfrompaths "$srcdir")"
  97. for dist in $DISTS; do
  98. do_dist=
  99. for dist_found in $dists; do
  100. if [ "$dist_found" = "$dist" ]; then
  101. do_dist=1
  102. continue
  103. fi
  104. done
  105. [ -n "$do_dist" ] || continue
  106. for arch in $ARCHS; do
  107. do_arch=
  108. for arch_found in $archs; do
  109. case $arch_found in
  110. $arch|all)
  111. do_arch=1
  112. continue
  113. esac
  114. done
  115. [ -n "$do_arch" ] || continue
  116. genlist "$section" "$dist" "$arch" "$srcdir" "$PUBBASE/dists/$dist/$section"
  117. done
  118. genlist "$section" "$dist" "source" "$srcdir" "$PUBBASE/dists/$dist/$section"
  119. done
  120. }
  121. sections="$@"
  122. paths="$(pathsfromsections "$sections")"
  123. #echo $paths; exit 0
  124. #sectionsfrompaths all; exit 0
  125. for path in $paths; do
  126. package="$(basename "$path")"
  127. pool="$(echo $(dirname "$path") | sed 's,.*/pool-\([^/]\+\)/\?.*,\1,; s,-all$,,')"
  128. buildhost="$(echo $(dirname "$path") | sed 's,^\([^/]\+\)/pool-.*,\1,')"
  129. symlink_dir="$pool/$package"
  130. mkdir -p "$PUBBASE/pools/$symlink_dir"
  131. # ln -sf -T "../../../$PUBTOSRC/$path" "$PUBBASE/pools/$symlink_dir/$buildhost"
  132. ln -sf -T "$SRCBASE/$path" "$PUBBASE/pools/$symlink_dir/$buildhost"
  133. for section in $(sectionsfrompaths "$path"); do
  134. mkdir -p "$SRCBASE/sections/$section/$symlink_dir"
  135. ln -sf -T "../../../../$path" "$SRCBASE/sections/$section/$symlink_dir/$buildhost"
  136. done
  137. done
  138. for section in $sections; do
  139. genlistsfromsection $section
  140. done
  141. exit 0