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.
 
 
 

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