summaryrefslogtreecommitdiff
path: root/apt/preferences.d/local-multimedia
blob: 34afddcf6f81b73049d921945083129c7f525dae (plain)
  1. Package: libav-tools /libav(codec|device|filter|format|resample|util)/ libswscale*
  2. Pin: release o=Debian,a=experimental
  3. Pin-Priority: 500
  4. Package: mplayer mplayer2
  5. Pin: release o=Debian,a=experimental
  6. Pin-Priority: 500
  7. Package: melt libmlt* python-mlt*
  8. Pin: release o=Debian,a=experimental
  9. Pin-Priority: 500
  10. Package: vainfo libva1 libva-* *-va-driver
  11. Pin: release o=Debian,a=experimental
  12. Pin-Priority: 500
  13. Package: libopencv-*
  14. Pin: release o=Debian,a=experimental
  15. Pin-Priority: 500
  16. Package: x264 libx264-*
  17. Pin: release o=Debian,a=experimental
  18. Pin-Priority: 500
  19. Package: jackd2 jackd2-firewire libjack-jackd2-*
  20. Pin: release o=Debian,a=experimental
  21. Pin-Priority: 500
  22. Package: pulseaudio* libpulse*
  23. Pin: release o=Debian,a=experimental
  24. Pin-Priority: 500
"hl opt">;
  • }
  • };
  • sub import { #{{{
  • hook(type => "getopt", id => "amazon_s3", call => \&getopt);
  • hook(type => "checkconfig", id => "amazon_s3", call => \&checkconfig);
  • } # }}}
  • sub getopt () { #{{{
  • eval q{use Getopt::Long};
  • error($@) if $@;
  • Getopt::Long::Configure('pass_through');
  • GetOptions("delete-bucket" => sub {
  • my $bucket=getbucket();
  • debug(gettext("deleting bucket.."));
  • my $resp = $bucket->list_all or die $bucket->err . ": " . $bucket->errstr;
  • foreach my $key (@{$resp->{keys}}) {
  • debug("\t".$key->{key});
  • $bucket->delete_key($key->{key}) or die $bucket->err . ": " . $bucket->errstr;
  • }
  • $bucket->delete_bucket or die $bucket->err . ": " . $bucket->errstr;
  • debug(gettext("done"));
  • exit(0);
  • });
  • } #}}}
  • sub checkconfig { #{{{
  • foreach my $field (qw{amazon_s3_key_id amazon_s3_key_file
  • amazon_s3_bucket}) {
  • if (! exists $config{$field} || ! defined $config{$field}) {
  • error(sprintf(gettext("Must specify %s"), $field));
  • }
  • }
  • if (! exists $config{amazon_s3_prefix} ||
  • ! defined $config{amazon_s3_prefix}) {
  • $config{amazon_s3_prefix}="wiki/";
  • }
  • } #}}}
  • {
  • my $bucket;
  • sub getbucket { #{{{
  • return $bucket if defined $bucket;
  • open(IN, "<", $config{amazon_s3_key_file}) || error($config{amazon_s3_key_file}.": ".$!);
  • my $key=<IN>;
  • chomp $key;
  • close IN;
  • my $s3=Net::Amazon::S3->new({
  • aws_access_key_id => $config{amazon_s3_key_id},
  • aws_secret_access_key => $key,
  • retry => 1,
  • });
  • # make sure the bucket exists
  • if (exists $config{amazon_s3_location}) {
  • $bucket=$s3->add_bucket({
  • bucket => $config{amazon_s3_bucket},
  • location_constraint => $config{amazon_s3_location},
  • });
  • }
  • else {
  • $bucket=$s3->add_bucket({
  • bucket => $config{amazon_s3_bucket},
  • });
  • }
  • if (! $bucket) {
  • error(gettext("Failed to create bucket in S3: ").
  • $s3->err.": ".$s3->errstr."\n");
  • }
  • return $bucket;
  • } #}}}
  • }
  • # Given a file, return any S3 keys associated with it.
  • sub file2keys ($) { #{{{
  • my $file=shift;
  • my @keys;
  • if ($file =~ /^\Q$config{destdir}\/\E(.*)/) {
  • push @keys, $config{amazon_s3_prefix}.$1;
  • # Munge foo/index.html to foo/
  • if ($keys[0]=~/(^|.*\/)index.$config{htmlext}$/) {
  • # A duplicate might need to be stored under the
  • # unmunged name too.
  • if (!$config{usedirs} || $config{amazon_s3_dupindex}) {
  • push @keys, $1;
  • }
  • else {
  • @keys=($1);
  • }
  • }
  • }
  • return @keys;
  • } #}}}
  • package IkiWiki;
  • use File::MimeInfo;
  • use Encode;
  • # This is a wrapper around the real writefile.
  • sub writefile ($$$;$$) { #{{{
  • my $file=shift;
  • my $destdir=shift;
  • my $content=shift;
  • my $binary=shift;
  • my $writer=shift;
  • # First, write the file to disk.
  • my $ret=$IkiWiki::Plugin::amazon_s3::subs{'IkiWiki::writefile'}->($file, $destdir, $content, $binary, $writer);
  • my @keys=IkiWiki::Plugin::amazon_s3::file2keys("$destdir/$file");
  • # Store the data in S3.
  • if (@keys) {
  • my $bucket=IkiWiki::Plugin::amazon_s3::getbucket();
  • # The http layer tries to downgrade utf-8
  • # content, but that can fail (see
  • # http://rt.cpan.org/Ticket/Display.html?id=35710),
  • # so force convert it to bytes.
  • $content=encode_utf8($content) if defined $content;
  • my %opts=(
  • acl_short => 'public-read',
  • content_type => mimetype("$destdir/$file"),
  • );
  • # If there are multiple keys to write, data is sent
  • # multiple times.
  • # TODO: investigate using the new copy operation.
  • # (It may not be robust enough.)
  • foreach my $key (@keys) {
  • my $res;
  • if (! $writer) {
  • $res=$bucket->add_key($key, $content, \%opts);
  • }
  • else {
  • # This test for empty files is a workaround
  • # for this bug:
  • # http://rt.cpan.org//Ticket/Display.html?id=35731
  • if (-z "$destdir/$file") {
  • $res=$bucket->add_key($key, "", \%opts);
  • }
  • else {
  • # read back in the file that the writer emitted
  • $res=$bucket->add_key_filename($key, "$destdir/$file", \%opts);
  • }