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