Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sysui / desktop / util / pkgdiff.pl
blobc3435202d0cfbc5892ac28e19476f93d07ba6772
1 : # -*- perl -*-
2 eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
6 # This file is part of the LibreOffice project.
8 # This Source Code Form is subject to the terms of the Mozilla Public
9 # License, v. 2.0. If a copy of the MPL was not distributed with this
10 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 # This file incorporates work covered by the following license notice:
14 # Licensed to the Apache Software Foundation (ASF) under one or more
15 # contributor license agreements. See the NOTICE file distributed
16 # with this work for additional information regarding copyright
17 # ownership. The ASF licenses this file to you under the Apache
18 # License, Version 2.0 (the "License"); you may not use this file
19 # except in compliance with the License. You may obtain a copy of
20 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 use File::Temp qw/ tempdir /;
24 use File::Basename;
25 use Cwd;
27 $tempdir = tempdir();
28 $dir = cwd();
30 sub unpack_rpm
32 my ($package) = @_;
34 system << "EOF"
35 rpm --query --queryformat "[trigger%{TRIGGERTYPE} script (through %{TRIGGERSCRIPTPROG}) -- %{TRIGGERNAME} %{TRIGGERVERSION}\n%{TRIGGERSCRIPTS}\n]" --package $package > triggers
36 rpm --query --queryformat "%{PREIN}\n" --package $package > prein
37 rpm --query --queryformat "%{POSTIN}\n" --package $package > postin
38 rpm --query --queryformat "%{PREUN}\n" --package $package > preun
39 rpm --query --queryformat "%{POSTUN}\n" --package $package > postun
40 rpm --query --queryformat "[%{FILEMODES:perms} %{FILEUSERNAME}/%{FILEGROUPNAME} .%{FILENAMES} -> %{FILELINKTOS}\n]" --package $package | sed 's/ -> \$//' | sort --key=3 -o filelist
42 rpm2cpio $package | cpio --extract --make-directories
44 rm --force `sed --silent 's|^lrw.r..r..-* root/root \\./\\(.*\\) -> .*|\\1 |p' filelist | tr -d "\\012"`
45 EOF
47 # the last step removes all symbolic links from the extracted file tree as they
48 # are handled by diffing the filelist
51 sub unpack_deb
53 my ($package) = @_;
55 system << "EOF"
56 ar x $package control.tar.gz data.tar.gz
57 tar --extract --ungzip --file=control.tar.gz
58 rm --force control control.tar.gz
59 tar --extract --ungzip --file=data.tar.gz
60 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
61 rm --force data.tar.gz
63 rm --force `sed --silent 's|^lrw.r..r..- root/root \\./\\(.*\\) -> .*|\\1 |p' filelist | tr -d "\\012"`
64 EOF
66 # the last step removes all symbolic links from the extracted file tree as they
67 # are handled by diffing the filelist
70 sub unpack_solpkg
72 my ($package) = @_;
74 system << "EOF"
75 sed -e '1 d' -e 's/[0-9][0-9]* [0-9][0-9]* [0-9]\\{10\\}\$//' $package/pkgmap > filelist
76 grep -v "^PSTAMP=" $package/pkginfo > pkginfo
77 cp $package/install/* .
78 if [ -f $package/archive/none.bz2 ]; then
79 bzcat $package/archive/none.bz2 | cpio -i -d
80 else
81 cp -pr $package/reloc/* .
83 EOF
86 sub unpack_tgz {
87 my ($package) = @_;
89 system << "EOF"
90 cat $package | gunzip | tar -xf -
91 EOF
94 my $script = basename($0);
96 die "Usage: $script <package 1> <package 2>\n" unless $#ARGV == 1;
98 my @pkgroot = ();
100 while ( $#ARGV >= 0 )
102 my $package = shift;
104 # make package paths absolute if necessary
105 $package = $dir . "/" . $package unless $package =~ /^\//;
107 my $basename = basename($package);
109 # when comparing identically named packages, append a "-2"
110 unless ( mkdir "$tempdir/$basename", 0777 ) {
111 $basename = $basename . "-2";
112 mkdir "$tempdir/$basename", 0777;
115 # change working directory, unpack the package and change back ..
116 die "Unable to change to unpack directory $tempdir/$basename: $!\n" unless chdir "$tempdir/$basename";
118 if ( $package =~ /\.rpm$/ ) { unpack_rpm( $package ); }
119 elsif( $package =~ /\.deb$/ ) { unpack_deb( $package ); }
120 elsif( -f "$package/pkgmap" ) { unpack_solpkg( $package ); }
121 elsif( $package =~ /\.tgz$/ ) { unpack_tgz( $package ); }
123 push @pkgroot, $basename;
124 chdir $dir;
127 # print "$0\n";
129 die "Unable to change to working directory $tempdir: $!\n" unless chdir $tempdir;
131 system "diff -ru @pkgroot[0] @pkgroot[1]";
132 system "rm -rf *";
134 chdir $dir;
135 rmdir $tempdir;
136 #print STDERR "rm -rf $tempdir\n";