File: debianrules

package info (click to toggle)
kprof 1.3-8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,556 kB
  • ctags: 251
  • sloc: sh: 9,915; cpp: 2,316; perl: 1,971; python: 258; makefile: 108
file content (328 lines) | stat: -rwxr-xr-x 9,167 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#!/usr/bin/perl -w

use Shell qw(mv cp mkdir rm) ;
use File::Find;
use Cwd;

$origPwd = `pwd`;
chomp $origPwd;


if (@ARGV && $ARGV[0] eq 'update') {
  @packages = `ls -1d debian/*/DEBIAN`;
  foreach $dir (@packages) {
    chomp $dir;
    next if (! -d $dir);
    foreach $file (qw{postinst postrm preinst prerm}) {  
      next if (! -f "$dir/$file");
      $found = 0;
      open(IN, "$dir/$file");
      open(OUT, ">/tmp/kde.dpkg");
      while (<IN>) { 
	if (/^#KDEHELPER#/) {
	    $found = 1;
	    if (-d $dir . "/../usr/lib/mime/packages") {
	      if ($file eq 'postinst') {
		print OUT "# added by kderules\n";
		print OUT 'case "$1" in' . "\n";
		print OUT "  configure)\n";
		print OUT "    if [ -x /usr/sbin/update-mime ]; then\n";
		print OUT "       update-mime\n";
		print OUT "    fi\n";
		print OUT "  ;;\n";
		print OUT "esac\n";
	      } elsif ($file eq 'postrm') {
		print OUT "# added by kderules\n";
		print OUT 'case "$1" in' . "\n";
		print OUT "   remove|purge)\n";
		print OUT "    if [ -x /usr/sbin/update-mime ]; then\n";
		print OUT "       update-mime\n";
		print OUT "    fi\n";
		print OUT "  ;;\n";
		print OUT "esac\n";
	      }
	    }
	    
	    next;
	  }
	print OUT $_;
      }
      
      close IN;
      close OUT;

      if ($found == 0) {
	rm("/tmp/kde.dpkg");
      } else {
	mv("/tmp/kde.dpkg", "$dir/$file");
	chown("root.root","dir/$file");
	chmod(0755,"$dir/$file");   
      }
    }
  }
  exit;
}

if (@ARGV && $ARGV[0] eq 'cleanup') {

if (-d "debian/tmp/usr/share/config") {
	if (! -d "debian/tmp/$kde_confdir") {
	  system("mv debian/tmp/usr/share/config debian/tmp/$kde_confdir");
	}
}
system("rm -f `find debian/ -name \".anchors\"`");
system("chmod 755 debian/*preinst debian/*postinst");

exit;
}

$QTDIR="/usr/lib/qt2";
$kde_prefix="/usr";
$kde_htmldir="$kde_prefix/share/doc/kde/HTML";
$kde_icondir="$kde_prefix/share/icons";
$kde_sounddir="$kde_prefix/share/sounds";
$kde_datadir="$kde_prefix/share/apps";
$kde_locale="$kde_prefix/share/locale";
$kde_confdir="/etc/kde2";
$kde_cgidir="$kde_prefix/lib/cgi-bin";
$kde_appsdir="$kde_prefix/share/applnk";
$kde_mimedir="$kde_prefix/share/mimelnk";
$kde_wallpaperdir="$kde_prefix/share/wallpapers";
$kde_bindir="$kde_prefix/bin";
$kde_servicesdir="$kde_prefix/share/services";
$kde_servicetypesdir="$kde_prefix/share/servicetypes";
$kde_includedir="$kde_prefix/include/kde";
$kde_libdir="$kde_prefix/lib";
$mandir="$kde_prefix/share/man"; 
$infodir="$kde_prefix/share/info";
$IDL="$kde_bindir/cuteidl";
$DCOPIDL="$kde_bindir/dcopidl";
$DCOPIDL2CPP="$kde_bindir/dcopidl2cpp";
$KDB2HTML="$kde_bindir/kdb2html";
$MCOPIDL="$kde_bindir/mcopidl";
$ARTSCCONFIG="$kde_bindir/artsc-config";

if (@ARGV && $ARGV[0] eq 'echodirs') {
  print STDOUT "export kde_htmldir=$kde_htmldir\n";
  print STDOUT "export kde_appsdir=$kde_appsdir\n";
  print STDOUT "export kde_icondir=$kde_icondir\n";
  print STDOUT "export kde_sounddir=$kde_sounddir\n";
  print STDOUT "export kde_datadir=$kde_datadir\n";
  print STDOUT "export kde_cgidir=$kde_cgidir\n";
  print STDOUT "export kde_locale=$kde_locale\n";
  print STDOUT "export kde_confdir=$kde_confdir\n";
  print STDOUT "export kde_mimedir=$kde_mimedir\n";
  print STDOUT "export kde_wallpaperdir=$kde_wallpaperdir\n";
  print STDOUT "export kde_bindir=$kde_bindir\n";
  print STDOUT "export kde_servicesdir=$kde_servicesdir\n";
  print STDOUT "export kde_servicetypesdir=$kde_servicetypesdir\n";
  print STDOUT "export kde_includedir=$kde_includedir\n";
  print STDOUT "export kde_libdir=$kde_libdir\n";
  print STDOUT "export mandir=$mandir\n";
  print STDOUT "export infodir=$infodir\n";
  print STDOUT "export QTDIR=$QTDIR\n";
  print STDOUT "export kde_prefix=$kde_prefix\n";
  print STDOUT "export INSTALL_DATA=install -p -c -m 644\n";
  print STDOUT "export IDL=$IDL\n";
  print STDOUT "export DCOPIDL=$DCOPIDL\n";
  print STDOUT "export DCOPIDL2CPP=$DCOPIDL2CPP\n";
  print STDOUT "export KDB2HTML=$KDB2HTML\n";
  print STDOUT "export MCOPIDL=$MCOPIDL\n";
  print STDOUT "export ARTSCCONFIG=$ARTSCCONFIG\n";
  print STDOUT "configkde=--disable-debug --disable-rpath --prefix=\$(kde_prefix) --libexecdir=\$(kde_bindir) --with-qt-dir=\$(QTDIR) --mandir=\$(mandir) --infodir=\$(infodir)\n";
  print STDOUT "configkdevelop=--enable-docbase --enable-kdoc2 --disable-debug --disable-rpath --libdir=\$(kde_libdir) --includedir=\$(kde_includedir) --with-qt-dir=\$(QTDIR) --mandir=\$(mandir) --with-kdelibsdoc-dir=/usr/share/doc/kdelibs3-doc/html\n";
  exit
}

if (@ARGV && $ARGV[0]) {  
  $package = $ARGV[0];
} else {
  open(CHANGELOG,"debian/changelog") 
	or die "can't read debian/changelog : $!\n";
  $_ = <CHANGELOG>;
  close(CHANGELOG);
  /^(.*) \((.*)\) /;
  $package = $1;
}

# Find documentation and install it
sub docwanted {
        local $dir = $File::Find::dir;
        $dir =~ s/^$origPwd//;
	if ($dir =~ /debian/) { return 0 ; }
	if ($dir =~ /build/) { return 0 ; }
	if ( ( /debian/ ) or ( /^INSTALL$/ ) or ( /^LICENSE$/ ) 
	or ( /^ARTISTIC$/ ) or ( /^COPYING$/ ) ) { return 0 ; } 
	if ( (! /CVS/ ) 
	and ( /^[A-Z]*$/ or /^README$/ or /^ChangeLog$/ or /lsm$/ or /SWALLOW/
	or /^TODO$/ or /^kdedoc$/ or /Header/ or /Documentation/ or /Tutorial/ ) )
	{	
		if ($dir) {
		  $_ = "$dir/$_";
		  $_ =~ s/^\///;
		}
		push @docs, "$_" ;
	}
}

$pwd = './';

find(\&docwanted, $pwd);
if ($pwd =~ ?^(.*/)build_([^/]*)$?) {
  $pwd = $1 . $2;
  if (-d $pwd) {
     find(\&docwanted, $pwd);
  }
}

if (! -d "debian/tmp/usr/share/doc/$package") {
	mkdir("-p", "debian/tmp/usr/share/doc/$package") ;
}

if (@docs) {
       chdir($origPwd);
       cp( "-aP", @docs, "debian/tmp/usr/share/doc/$package") ;
       if (-f "debian/tmp/usr/share/doc/$package/ChangeLog") {
	  mv("debian/tmp/usr/share/doc/$package/ChangeLog", 
		"debian/tmp/usr/share/doc/$package/changelog");
	}
	if (-f "debian/tmp/usr/share/doc/$package/CHANGES") {
	  mv("debian/tmp/usr/share/doc/$package/CHANGES",
		"debian/tmp/usr/share/doc/$package/changelog");
	}
}

# Create doc-base file

if (-d "debian/doc-base") {
        if (! -d "debian/tmp/usr/share/doc-base") {
                  mkdir("-p", "debian/tmp/usr/share/doc-base");
        }
        while (<debian/doc-base/*>) {
                  cp( "-a", $_, "debian/tmp/usr/share/doc-base")
                    unless (-d $_);
        }
#        cp( "-a", <debian/doc-base/*>, "debian/tmp/usr/share/doc-base") ;
}


# Create debian/menu files

sub findkdelnk {
	/\.desktop$/ && push @lnkfiles, "$File::Find::dir/$_" ;
}

if (-d "debian/tmp/$kde_appsdir") {
	find(\&findkdelnk,"debian/tmp/$kde_appsdir");
}

if (-e "debian/menu.in") {
	open MENUIN, "debian/menu.in" ;
	while (<MENUIN>) {
		chop ;
		($prog,$type,$sect) = split / /;
		$type{$prog}=$type;
		$sect{$prog}=$sect;
	}
	close MENUIN;
}

open MENU, ">debian/menu" or die "can't open debian/menu : $!\n";
open MIME, ">debian/mailcap" or die "can't open debian/mailcap : $!\n";

foreach $file (@lnkfiles) {
	open KDELNK, $file;
	undef %kdelnk;
	while (<KDELNK>) {
		/^#/ && next ;
		/^\[KDE Desktop Entry\]/ && next ;
		/^\s*$/ && next ;
		chop ;
		($what,$value) = split /=/ ;
		$kdelnk{ucfirst lc $what}=$value;
	}
	close KDELNK;
	if (defined $kdelnk{"Type"}) {
		if ($kdelnk{"Type"} ne "Application" ) {
			print STDERR "Type is not Application : $file !\n" ;
			next ;
		}
	} else {
		print STDERR "has no Type= defaults to Application : $file !\n" ;
	}
	if (! defined $kdelnk{"Exec"}) {
		print STDERR "has no Exec= : $file !\n" ;
		next ;
	}

	if (defined $kdelnk{"Mimetype"} && ! $kdelnk{"Mimetype"} eq '') {

  	   $execline = $kdelnk{"Exec"};
	   $execline =~ s/%f/%s/;
	   $execline =~ s/%c/$kdelnk{"Name"}/;
	   $execline =~ s/%i//;
	   $execline =~ s/%m//;
	   $execline =~ s/%u/%s/;
	   $mimeline = $kdelnk{"Mimetype"};
	   @mimetypes = split(';', $mimeline);
	   foreach $mimetype (@mimetypes) {
	   print MIME "$mimetype; $execline;" . 'test=test "$DISPLAY" != ""; priority=7' . "\n";
	   }

	}

	($prog,)=split / /, $kdelnk{"Exec"} ;
	if (! defined($type{$prog})) {
		open MENUIN, ">>debian/menu.in" ;
		print MENUIN "$prog x11 NONE\n";
		close MENUIN;
		next ;
	}
	if ($sect{$prog} eq "NONE") { next ; }
	$icon="";
	if (not defined $kdelnk{"Name"}) {
		print STDERR "No Name : $package $kdelnk\n";
		next ;
	}
	if (defined $kdelnk{"Icon"}) {
   	        $icon=$kdelnk{"Icon"} ;
		if (! -f "debian/tmp/$kde_icondir/mini/$prog.png" ) {
                   $icon="";
	        } else {
	  	  $icon="/$kde_icondir/mini/$prog.png";
               }
	}
	($kdelnk=$file) =~ s/^.*tmp// ;
	print MENU "?package($package):\\\n" ;
	print MENU "	needs=$type{$prog}\\\n" ;
	print MENU "	section=$sect{$prog}\\\n" ;
	print MENU "	hints=\"KDE\"\\\n" ;
	print MENU "	title=\"$kdelnk{Name}\"\\\n" ;
	print MENU "	command=$prog\\\n" ;
	print MENU "	icon=\"$icon\"\n\n" ;

}

if (-e "debian/menu.add") {
	open MENUADD, "debian/menu.add" ;
	while (<MENUADD>) {
		print MENU $_ ;
	}
	close MENUADD;
}

close MENU;

if (-z "debian/menu") {
	rm("debian/menu");
}

close MIME;

if (-z "debian/mailcap") {
  rm("debian/mailcap");
} else {
  mkdir("-p", "debian/tmp/usr/lib/mime/packages");
  cp("debian/mailcap", "debian/tmp/usr/lib/mime/packages/$package");
}