]> git.decadent.org.uk Git - dak.git/blob - config/backports.org/bpo-copy-packages
Add Binary packages to new.822
[dak.git] / config / backports.org / bpo-copy-packages
1 #!/bin/bash
2
3 # Copyright (c) 2005 Peter Palfrader <peter@palfrader.org>
4
5 # WARNING: spaces in filenames/paths considered harmful.
6
7 export SCRIPTVARS=/org/backports.org/dak/config/backports.org/vars
8 . $SCRIPTVARS
9
10 cd ${configdir}
11
12 for suite in etch lenny; do
13     source="${ftpdir}/dists/${suite}-backports"
14     target="${base}/buildd/dists/${suite}-backports"
15
16     if ! [ -d "$source" ]; then
17             echo "Source '$source' does not exist or is not a directory or we can't acess it." >&2
18             exit 1;
19     fi
20     if ! [ -d "$target" ]; then
21             echo "Target '$target' does not exist or is not a directory or we can't acess it." >&2
22             exit 1;
23     fi
24
25     for file in $( cd "$source" && find . -name 'Packages.gz' -o -name 'Packages' -o -name 'Sources.gz' -o -name 'Sources' -o -name 'Release' ); do
26             basedir=$(dirname "$file")
27             basename=$(basename "$file")
28             targetdir="$target/$basedir"
29             [ -d "$targetdir" ] || mkdir -p "$targetdir"
30             if [ "$basename" = "Release" ]; then
31                     cp -a "$source/$file" "$target/$file"
32                     echo 'NotAutomatic: yes' >> "$target/$file"
33             else
34                     cp -a "$source/$file" "$target/$file"
35             fi
36     done
37
38 # postprocess top level Release file
39     if ! [ -e "$target/Release" ]; then
40             echo "Did not find $target/Release after copying stuff.  something's fishy" >&2
41             exit 1;
42     fi
43
44     cd "$target"
45
46     perl -a -p -i -e '
47         if (substr($_,0,1) eq " ") {
48                 if ($in_sha1 || $in_md5) {
49                         ($hash, $size, $file) = @F;
50                         $_="",next unless -f $file;
51
52                         (undef,undef,undef,undef,undef,undef,undef,$filesize,
53                          undef,undef,undef,undef,undef) = stat($file);
54                         if ($size != $filesize) {
55                                 if ($in_sha1) {
56                                         $hash = `sha1sum "$file" | cut -d " " -f 1`
57                                 } else {
58                                         $hash = `md5sum "$file" | cut -d " " -f 1`
59                                 };
60                                 chomp $hash;
61                                 $_ = sprintf(" %s %16d %s\n", $hash, $filesize, $file);
62                         }
63                 }
64         } else {
65                 $in_sha1 = ($F[0] eq "SHA1:") ? 1 : 0;
66                 $in_md5  = ($F[0] eq "MD5Sum:") ? 1 : 0;
67         }
68 ' Release
69
70     rm -f ${base}/buildd/dists/${suite}-backports/Release.gpg
71     gpg --no-options --batch --no-tty --secret-keyring ${base}/s3kr1t/dot-gnupg/secring.gpg --output "Release.gpg" --armor --detach-sign "Release"
72 done