You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

105 lines
2.6 KiB

  1. #!/usr/bin/perl
  2. #
  3. # makedesc directory file
  4. #
  5. # Scan the directory for files, and use the files to generate a task
  6. # description file. The format of the task description file is described in
  7. # data.c. The format of the input files is:
  8. #
  9. # Task: desktop
  10. # Section: user
  11. # Description: Provide a basic GUI system
  12. # This task provides functionality for a basic desktop; whether Gnome
  13. # based, KDE based or customised. With this task, your system will boot
  14. # into a graphical login screen, at which point you can choose which of
  15. # these desktops you wish to use on a per-user basis. You can further
  16. # customise your desktop once installed.
  17. # Packages-list:
  18. # kdebase
  19. # gdm
  20. # ...
  21. #
  22. # Hash-comments are allowed in the files, but must be on their own lines.
  23. my $dir=shift or die "no directory specified\n";
  24. my $file=shift or die "no file specified\n";
  25. my %package;
  26. my %notmain;
  27. my $dolint=1;
  28. {
  29. local $/="\n\n";
  30. if (! open (AVAIL, "apt-cache dumpavail |")) {
  31. warn "cannot real available info, so disabling lint check\n";
  32. $dolint=0;
  33. }
  34. while (<AVAIL>) {
  35. my ($package)=/Package:\s*(.*?)\n/;
  36. $package{$package}=1;
  37. if (/Section:\s*(contrib|non-free)/) {
  38. $notmain{$package}=$1;
  39. }
  40. }
  41. close AVAIL;
  42. }
  43. open (OUT, ">$file") or die ">$file: $!";
  44. use File::Find;
  45. find({ wanted => \&processfile, preprocess => sub { return sort @_}}, $dir);
  46. sub processfile {
  47. my $file=$_; # File::Find craziness.
  48. $file eq 'po' && -d $file && ($File::Find::prune = 1);
  49. return if $File::Find::dir=~/\.svn/;
  50. return unless $file =~ /^[-+_.a-z0-9]+$/ and -f $file;
  51. open (IN, $file) or die "$file: $!";
  52. my %fields;
  53. my $field="";
  54. while (<IN>) {
  55. chomp;
  56. next if /^\s*#/;
  57. s/#.*//;
  58. if (/^\s/) {
  59. $fields{$field}.="\n$_";
  60. }
  61. else {
  62. ($field, my $value)=split(/:\s*/, $_, 2);
  63. $field=lc($field);
  64. $fields{$field}=$value;
  65. }
  66. }
  67. close IN;
  68. # Basic lint of the listed packages.
  69. # TODO: a better lint would incloude checks for conflicting
  70. # packages. Hard tho.
  71. if ($dolint) {
  72. foreach my $field (qw(key packages-list)) {
  73. foreach (split ' ', $fields{$field}) {
  74. if (! $package{$_}) {
  75. print STDERR "$file: $_ is not a valid package.\n";
  76. if ($field eq 'key') {
  77. print STDERR "MISSING KEY PACKAGE, TASK BROKEN\n";
  78. }
  79. }
  80. if ($notmain{$_}) {
  81. print STDERR "$file: $_ is in $notmain{$_}.\n";
  82. if ($field eq 'key') {
  83. print STDERR "MISSING KEY PACKAGE, TASK BROKEN\n";
  84. }
  85. }
  86. }
  87. }
  88. }
  89. foreach (qw{task section relevance description key depends packages},
  90. grep(/^test-(.*)/, keys %fields)) {
  91. print OUT ucfirst($_).": ".$fields{$_}."\n" if length $fields{$_};
  92. }
  93. print OUT "\n";
  94. }
  95. close OUT;