blob: 3a38fd1cd79dd6ebba3352b4cfc4073146f8c90a (
plain)
- #!/bin/sh
- set -e
- #set -x
- ORIGIN="Jones"
- LABEL="Jones"
- DISTS="etch lenny sid"
- ARCHS="i386 powerpc amd64"
- SRCBASE=~/public_debian
- PUBBASE=~/public_websites/debian.jones.dk
- #PUBTOSRC=../../public_debian
- archsfrompaths() {
- find "$@" -type l -exec find '{}'/ -type f -name '*.deb' ';' \
- | sed 's/^.*_\([a-z0-9-]\+\)\.deb$/\1/' \
- | sort -u
- }
- distsfrompaths() {
- find "$@" -mindepth 1 -maxdepth 1 -type d -printf '%f\n'
- }
- pathsfromsections() {
- case "$@" in
- all)
- sections_re=""
- ;;
- "")
- echo 1>&2 "ERROR: At least one section (or the magic \"all\") is needed."
- exit 1
- ;;
- *)
- sections_re="\b\($(echo "$@" | sed 's/[[:space:]]\+/\\|/g')\)\b"
- ;;
- esac
- find $SRCBASE -type f -name HINTS -exec grep -q "^Sections:.*$sections_re" '{}' ';' -printf '%h\n' \
- | sed "s,^$SRCBASE/,,"
- }
- sectionsfrompaths() {
- case "$@" in
- all)
- fullpaths="$SRCBASE"
- ;;
- *)
- fullpaths=
- for path in "$@"; do
- # TODO: rewrite to support spaces in directory names
- fullpaths="$fullpaths $SRCBASE/$path"
- done
- ;;
- esac
- find $fullpaths -type f -name HINTS -exec cat '{}' ';' \
- | grep '^Sections:' \
- | sed 's/^Sections://; s/[[:space:]]\+/ /g; s/^ //; s/ $//' \
- | tr ' ' '\n' \
- | sort -u
- }
- genlist() {
- dist="$1"
- arch="$2"
- srcdir="$3"
- basedir="$4"
- case "$arch" in
- source)
- destdir="$basedir/source";
- cmd="dpkg-scansources";
- file="Sources";
- ;;
- *)
- destdir="$basedir/binary-$arch";
- cmd="dpkg-scanpackages";
- file="Packages";
- ;;
- esac
- mkdir -p "$destdir"
- ( cd "$srcdir" && $cmd $dist /dev/null pools/ ) > "$destdir/$file"
- gzip -c "$destdir/$file" > "$destdir/$file.gz"
- bzip2 -c "$destdir/$file" > "$destdir/$file.bz2"
- cat <<EOF > "$destdir/Release"
- Archive: $dist
- Component: $section
- Origin: $ORIGIN
- Label: $LABEL
- Architecture: $arch
- EOF
- }
- genlistsfromsection() {
- section="$1"
- case "$section" in
- all)
- srcdir="$SRCBASE/sections"
- ;;
- "")
- echo 1>&2 "ERROR: At least one section (or the magic \"all\") is needed."
- exit 1
- ;;
- *)
- srcdir="$SRCBASE/sections/$section"
- ;;
- esac
- dists="$(distsfrompaths "$srcdir")"
- archs="$(archsfrompaths "$srcdir")"
- for dist in $DISTS; do
- do_dist=
- for dist_found in $dists; do
- if [ "$dist_found" = "$dist" ]; then
- do_dist=1
- continue
- fi
- done
- [ -n "$do_dist" ] || continue
- archlist=
- for arch in $ARCHS; do
- do_arch=
- for arch_found in $archs; do
- case $arch_found in
- $arch|all)
- do_arch=1
- archlist="$archlist $arch"
- continue
- ;;
- esac
- done
- [ -n "$do_arch" ] || continue
- genlist "$dist" "$arch" "$srcdir" "$PUBBASE/dists/$dist/$section"
- done
- genlist "$dist" "source" "$srcdir" "$PUBBASE/dists/$dist/$section"
- case "$dist" in
- etch) suite="stable";;
- lenny) suite="testing";;
- sid) suite="unstable";;
- esac
- # TODO: Enable the below when running magic section "all"
- # (needs all sections fed in here instead of each single section)
- # cat <<EOF > "$PUBBASE/dists/$dist/Release"
- #Origin: $ORIGIN
- #Label: $LABEL
- #Suite: $suite
- #Codename: $dist
- #Architectures:$archlist
- #Components: $sections
- #EOF
- done
- }
- sections="$@"
- paths="$(pathsfromsections "$sections")"
- #echo $paths; exit 0
- #sectionsfrompaths all; exit 0
- for path in $paths; do
- package="$(basename "$path")"
- pool="$(echo $(dirname "$path") | sed 's,.*/pool-\([^/]\+\)/\?.*,\1,; s,-all$,,')"
- buildhost="$(echo $(dirname "$path") | sed 's,^\([^/]\+\)/pool-.*,\1,')"
- symlink_dir="$pool/$package"
- mkdir -p "$PUBBASE/pools/$symlink_dir"
- # ln -sf -T "../../../$PUBTOSRC/$path" "$PUBBASE/pools/$symlink_dir/$buildhost"
- ln -sf -T "$SRCBASE/$path" "$PUBBASE/pools/$symlink_dir/$buildhost"
- for section in $(sectionsfrompaths "$path"); do
- mkdir -p "$SRCBASE/sections/$section/$symlink_dir"
- ln -sf -T "../../../../$path" "$SRCBASE/sections/$section/$symlink_dir/$buildhost"
- done
- done
- for section in $sections; do
- genlistsfromsection $section
- done
- exit 0
|