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.
 
 
 

100 lines
2.4 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:
  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 file, 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(\&processfile, $dir);
  46. sub processfile {
  47. my $file=$_; # File::Find craziness.
  48. $file eq 'po' && -d $file && ($File::Find::prune = 1);
  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)) {
  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. }
  82. }
  83. }
  84. }
  85. foreach (qw{task section relevance description key}) {
  86. print OUT ucfirst($_).": ".$fields{$_}."\n" if length $fields{$_};
  87. }
  88. print OUT "\n";
  89. }
  90. close OUT;