[Debtags-commits] [svn] r2133 - autodebtag/trunk/ad-plugins
Enrico Zini
enrico at alioth.debian.org
Mon Nov 20 16:24:25 CET 2006
Author: enrico
Date: Mon Nov 20 16:24:24 2006
New Revision: 2133
Modified:
autodebtag/trunk/ad-plugins/subtags
Log:
Revamped subtags
Modified: autodebtag/trunk/ad-plugins/subtags
==============================================================================
--- autodebtag/trunk/ad-plugins/subtags (original)
+++ autodebtag/trunk/ad-plugins/subtags Mon Nov 20 16:24:24 2006
@@ -1,32 +1,47 @@
-#!/bin/bash -ue
+#!/usr/bin/perl -w
-exit 0
+use strict;
+use warnings;
-OUT=${1:?"Usage: $0 outfile"}
+# Parent tags to avoid
+my %blacklist = map { $_ => 1 } (
+ 'devel::lang',
+ 'made-of::data',
+);
-##
-## Auto-add parent tags when their subtags are present
-##
-
-for base in \
- 'works-with::text' \
- 'game::rpg' \
- 'hardware::modem' \
- 'hardware::power' \
- 'hardware::storage' \
- 'special::not-yet-tagged' \
- 'works-with::3dmodel' \
- 'works-with::archive' \
- 'works-with::audio' \
- 'works-with::db' \
- 'works-with::image' \
- 'works-with::video' \
- 'works-with::xml'
-do
- for pkg in `debtags grep "$base:*" | tagcoll copy -i`
- do
- echo "$pkg: +$base" >> $OUT
- done
-done
+# Get the parent tags for the given tag list
+sub expand (@)
+{
+ my @res;
+ for my $t (@_)
+ {
+ next if $t =~ /:special/;
+ while ($t =~ /^(.+[^:]):[^:]/)
+ {
+ $t = $1;
+ next if exists $blacklist{$t};
+ push @res, $t
+ }
+ }
+ return @res;
+}
-exit 0
+ at ARGV or die "Usage: $0 outfile";
+
+open IN, $ENV{TAGDB} or die "Cannot open tag database at $ENV{TAGDB}: $!";
+open OUT, ">$ARGV[0]" or die "Cannot open output file at $ARGV[0]: $!";
+
+while (<IN>)
+{
+ chop;
+ my ($pkgs, $tags) = split(': ', $_);
+ my @pkgs = split(', ', $pkgs);
+ my @tags = split(', ', $tags);
+ my @patch = map "+$_", expand(@tags);
+ print OUT join(', ', @pkgs), ": ", join(', ', @patch), "\n" if @patch;
+}
+
+close IN;
+close OUT;
+
+exit 0;
More information about the Debtags-commits
mailing list