update dev300-m58
[ooovba.git] / sysui / desktop / util / pkgdiff.pl
blobac42fbc02066a9f31c605546a1c2096fc4deeb8e
1 : # -*- perl -*-
2 eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
5 use File::Temp qw/ tempdir /;
6 use File::Basename;
7 use Cwd;
9 $tempdir = tempdir();
10 $dir = cwd();
12 sub unpack_rpm
14 my ($package) = @_;
16 system << "EOF"
17 rpm --query --queryformat "[trigger%{TRIGGERTYPE} script (through %{TRIGGERSCRIPTPROG}) -- %{TRIGGERNAME} %{TRIGGERVERSION}\n%{TRIGGERSCRIPTS}\n]" --package $package > triggers
18 rpm --query --queryformat "%{PREIN}\n" --package $package > prein
19 rpm --query --queryformat "%{POSTIN}\n" --package $package > postin
20 rpm --query --queryformat "%{PREUN}\n" --package $package > preun
21 rpm --query --queryformat "%{POSTUN}\n" --package $package > postun
22 rpm --query --queryformat "[%{FILEMODES:perms} %{FILEUSERNAME}/%{FILEGROUPNAME} .%{FILENAMES} -> %{FILELINKTOS}\n]" --package $package | sed 's/ -> \$//' | sort --key=3 -o filelist
24 rpm2cpio $package | cpio --extract --make-directories
26 rm --force `sed --silent 's|^lrw.r..r..-* root/root \\./\\(.*\\) -> .*|\\1 |p' filelist | tr -d "\\012"`
27 EOF
29 # the last step removes all symbolic links from the extracted file tree as they
30 # are handled by diffing the filelist
33 sub unpack_deb
35 my ($package) = @_;
37 system << "EOF"
38 ar x $package control.tar.gz data.tar.gz
39 tar --extract --ungzip --file=control.tar.gz
40 rm --force control control.tar.gz
41 tar --extract --ungzip --file=data.tar.gz
42 tar --list --verbose --ungzip --file=data.tar.gz | sed -e 's| root/root .* \./|- root/root ./|' -e 's|^d\\(.*\\)/\$|d\\1|' | sort --key=3 -o filelist
43 rm --force data.tar.gz
45 rm --force `sed --silent 's|^lrw.r..r..- root/root \\./\\(.*\\) -> .*|\\1 |p' filelist | tr -d "\\012"`
46 EOF
48 # the last step removes all symbolic links from the extracted file tree as they
49 # are handled by diffing the filelist
52 sub unpack_solpkg
54 my ($package) = @_;
56 system << "EOF"
57 sed -e '1 d' -e 's/[0-9][0-9]* [0-9][0-9]* [0-9]\\{10\\}\$//' $package/pkgmap > filelist
58 grep -v "^PSTAMP=" $package/pkginfo > pkginfo
59 cp $package/install/* .
60 if [ -f $package/archive/none.bz2 ]; then
61 bzcat $package/archive/none.bz2 | cpio -i -d
62 else
63 cp -pr $package/reloc/* .
65 EOF
68 sub unpack_tgz {
69 my ($package) = @_;
71 system << "EOF"
72 cat $package | gunzip | tar -xf -
73 EOF
76 my $script = basename($0);
78 die "Usage: $script <package 1> <package 2>\n" unless $#ARGV == 1;
80 my @pkgroot = ();
82 while ( $#ARGV >= 0 )
84 my $package = shift;
86 # make package paths absolute if necessary
87 $package = $dir . "/" . $package unless $package =~ /^\//;
89 my $basename = basename($package);
91 # when comparing identically named packages, append a "-2"
92 unless ( mkdir "$tempdir/$basename", 0777 ) {
93 $basename = $basename . "-2";
94 mkdir "$tempdir/$basename", 0777;
97 # change working directory, unpack the package and change back ..
98 die "Unable to change to unpack directory $tempdir/$basename: $!\n" unless chdir "$tempdir/$basename";
100 if ( $package =~ /\.rpm$/ ) { unpack_rpm( $package ); }
101 elsif( $package =~ /\.deb$/ ) { unpack_deb( $package ); }
102 elsif( -f "$package/pkgmap" ) { unpack_solpkg( $package ); }
103 elsif( $package =~ /\.tgz$/ ) { unpack_tgz( $package ); }
105 push @pkgroot, $basename;
106 chdir $dir;
109 # print "$0\n";
111 die "Unable to change to working directory $tempdir: $!\n" unless chdir $tempdir;
113 system "diff -ru @pkgroot[0] @pkgroot[1]";
114 system "rm -rf *";
116 chdir $dir;
117 rmdir $tempdir;
118 #print STDERR "rm -rf $tempdir\n";