1 | #!/usr/bin/perl -w |
---|
2 | |
---|
3 | # Libraries |
---|
4 | use strict; |
---|
5 | use Number::Bytes::Human qw(format_bytes); |
---|
6 | use Parse::DebianChangelog; |
---|
7 | |
---|
8 | # My values |
---|
9 | my $data_file=""; |
---|
10 | my @lines; |
---|
11 | my @line; |
---|
12 | my $line; |
---|
13 | my $desktop; |
---|
14 | my $action; |
---|
15 | my $package; |
---|
16 | my $version; |
---|
17 | my $newversion; |
---|
18 | my $source; |
---|
19 | my $component; |
---|
20 | my $size; |
---|
21 | my $workingdirectory; |
---|
22 | # Main |
---|
23 | |
---|
24 | # Data file is the first argument |
---|
25 | $data_file=$ARGV[0]; |
---|
26 | |
---|
27 | # Create a directory as a working-area and store in a simple variable |
---|
28 | $workingdirectory=`mktemp -d /tmp/lliurex-up-working-area.XXXXX`; |
---|
29 | chomp($workingdirectory); |
---|
30 | |
---|
31 | # Open the file |
---|
32 | open(DAT, $data_file) || die("Could not open file!"); |
---|
33 | @lines = <DAT>; |
---|
34 | |
---|
35 | # Foreach line in file it will be processed to extract the values that are needed |
---|
36 | # to make the list. |
---|
37 | # The format of the line is : |
---|
38 | # |
---|
39 | #Inst libreoffice-l10n-es [1:3.5.0-2ubuntu1~lucid1] (1:3.5.1-1ubuntu1~lucid1 LibreOffice PPA:10.04/lucid) |
---|
40 | # |
---|
41 | # Action , package, version installed, new version, Source of package and component |
---|
42 | # Now for each line extract and print the data on standar |
---|
43 | foreach $line(@lines) |
---|
44 | { |
---|
45 | chomp($line); |
---|
46 | ($action,$package,$version,$newversion,$source,$component) = split(" ",$line); |
---|
47 | if ( $action eq "Inst" ) { |
---|
48 | |
---|
49 | $desktop=""; |
---|
50 | # Print package name |
---|
51 | print "$package"; |
---|
52 | print ";"; |
---|
53 | |
---|
54 | # Print new version of the package |
---|
55 | $newversion =~ s/\(//; |
---|
56 | print "$newversion"; |
---|
57 | print ";"; |
---|
58 | |
---|
59 | # Print size of package |
---|
60 | $size = format_bytes(1024*`apt-cache show $package |grep "Installed-Size:" |cut -d" " -f2 |head -1`); |
---|
61 | print $size; |
---|
62 | print ";"; |
---|
63 | |
---|
64 | # Print desktop file |
---|
65 | print($desktop); |
---|
66 | $desktop = `dpkg -L $package| grep ".desktop\$" | head -1`; |
---|
67 | chomp($desktop); |
---|
68 | if ( $desktop ne "") |
---|
69 | { |
---|
70 | print "$desktop"; |
---|
71 | } |
---|
72 | print ";"; |
---|
73 | |
---|
74 | |
---|
75 | # Print changelog |
---|
76 | my $filechglog = `dpkg -L $package| grep "angelog.gz\$" | head -1`; |
---|
77 | chomp($filechglog); |
---|
78 | if ($filechglog ne "") { |
---|
79 | |
---|
80 | my $result=`zcat $filechglog| head -n 100`; |
---|
81 | |
---|
82 | open (TEMPORALFILE, ">>$workingdirectory/$package.llog"); |
---|
83 | print TEMPORALFILE $result; |
---|
84 | close (TEMPORALFILE); |
---|
85 | |
---|
86 | print "$workingdirectory/$package.llog"; |
---|
87 | } |
---|
88 | print ";"; |
---|
89 | # Print new line |
---|
90 | print "\n"; |
---|
91 | } |
---|
92 | } |
---|
93 | |
---|