1*b1cdbd2cSJim Jagielski: # -*- perl -*- 2*b1cdbd2cSJim Jagielski# ************************************************************* 3*b1cdbd2cSJim Jagielski# 4*b1cdbd2cSJim Jagielski# Licensed to the Apache Software Foundation (ASF) under one 5*b1cdbd2cSJim Jagielski# or more contributor license agreements. See the NOTICE file 6*b1cdbd2cSJim Jagielski# distributed with this work for additional information 7*b1cdbd2cSJim Jagielski# regarding copyright ownership. The ASF licenses this file 8*b1cdbd2cSJim Jagielski# to you under the Apache License, Version 2.0 (the 9*b1cdbd2cSJim Jagielski# "License"); you may not use this file except in compliance 10*b1cdbd2cSJim Jagielski# with the License. You may obtain a copy of the License at 11*b1cdbd2cSJim Jagielski# 12*b1cdbd2cSJim Jagielski# http://www.apache.org/licenses/LICENSE-2.0 13*b1cdbd2cSJim Jagielski# 14*b1cdbd2cSJim Jagielski# Unless required by applicable law or agreed to in writing, 15*b1cdbd2cSJim Jagielski# software distributed under the License is distributed on an 16*b1cdbd2cSJim Jagielski# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17*b1cdbd2cSJim Jagielski# KIND, either express or implied. See the License for the 18*b1cdbd2cSJim Jagielski# specific language governing permissions and limitations 19*b1cdbd2cSJim Jagielski# under the License. 20*b1cdbd2cSJim Jagielski# 21*b1cdbd2cSJim Jagielski# ************************************************************* 22*b1cdbd2cSJim Jagielskieval 'exec perl -wS $0 ${1+"$@"}' 23*b1cdbd2cSJim Jagielski if 0; 24*b1cdbd2cSJim Jagielski 25*b1cdbd2cSJim Jagielskiuse File::Temp qw/ tempdir /; 26*b1cdbd2cSJim Jagielskiuse File::Basename; 27*b1cdbd2cSJim Jagielskiuse Cwd; 28*b1cdbd2cSJim Jagielski 29*b1cdbd2cSJim Jagielski$tempdir = tempdir(); 30*b1cdbd2cSJim Jagielski$dir = cwd(); 31*b1cdbd2cSJim Jagielski 32*b1cdbd2cSJim Jagielskisub unpack_rpm 33*b1cdbd2cSJim Jagielski{ 34*b1cdbd2cSJim Jagielski my ($package) = @_; 35*b1cdbd2cSJim Jagielski 36*b1cdbd2cSJim Jagielski system << "EOF" 37*b1cdbd2cSJim Jagielskirpm --query --queryformat "[trigger%{TRIGGERTYPE} script (through %{TRIGGERSCRIPTPROG}) -- %{TRIGGERNAME} %{TRIGGERVERSION}\n%{TRIGGERSCRIPTS}\n]" --package $package > triggers 38*b1cdbd2cSJim Jagielskirpm --query --queryformat "%{PREIN}\n" --package $package > prein 39*b1cdbd2cSJim Jagielskirpm --query --queryformat "%{POSTIN}\n" --package $package > postin 40*b1cdbd2cSJim Jagielskirpm --query --queryformat "%{PREUN}\n" --package $package > preun 41*b1cdbd2cSJim Jagielskirpm --query --queryformat "%{POSTUN}\n" --package $package > postun 42*b1cdbd2cSJim Jagielskirpm --query --queryformat "[%{FILEMODES:perms} %{FILEUSERNAME}/%{FILEGROUPNAME} .%{FILENAMES} -> %{FILELINKTOS}\n]" --package $package | sed 's/ -> \$//' | sort --key=3 -o filelist 43*b1cdbd2cSJim Jagielski 44*b1cdbd2cSJim Jagielskirpm2cpio $package | cpio --extract --make-directories 45*b1cdbd2cSJim Jagielski 46*b1cdbd2cSJim Jagielskirm --force `sed --silent 's|^lrw.r..r..-* root/root \\./\\(.*\\) -> .*|\\1 |p' filelist | tr -d "\\012"` 47*b1cdbd2cSJim JagielskiEOF 48*b1cdbd2cSJim Jagielski 49*b1cdbd2cSJim Jagielski# the last step removes all symbolic links from the extracted file tree as they 50*b1cdbd2cSJim Jagielski# are handled by diffing the filelist 51*b1cdbd2cSJim Jagielski} 52*b1cdbd2cSJim Jagielski 53*b1cdbd2cSJim Jagielskisub unpack_deb 54*b1cdbd2cSJim Jagielski{ 55*b1cdbd2cSJim Jagielski my ($package) = @_; 56*b1cdbd2cSJim Jagielski 57*b1cdbd2cSJim Jagielski system << "EOF" 58*b1cdbd2cSJim Jagielskiar x $package control.tar.gz data.tar.gz 59*b1cdbd2cSJim Jagielskitar --extract --ungzip --file=control.tar.gz 60*b1cdbd2cSJim Jagielskirm --force control control.tar.gz 61*b1cdbd2cSJim Jagielskitar --extract --ungzip --file=data.tar.gz 62*b1cdbd2cSJim Jagielskitar --list --verbose --ungzip --file=data.tar.gz | sed -e 's| root/root .* \./|- root/root ./|' -e 's|^d\\(.*\\)/\$|d\\1|' | sort --key=3 -o filelist 63*b1cdbd2cSJim Jagielskirm --force data.tar.gz 64*b1cdbd2cSJim Jagielski 65*b1cdbd2cSJim Jagielskirm --force `sed --silent 's|^lrw.r..r..- root/root \\./\\(.*\\) -> .*|\\1 |p' filelist | tr -d "\\012"` 66*b1cdbd2cSJim JagielskiEOF 67*b1cdbd2cSJim Jagielski 68*b1cdbd2cSJim Jagielski# the last step removes all symbolic links from the extracted file tree as they 69*b1cdbd2cSJim Jagielski# are handled by diffing the filelist 70*b1cdbd2cSJim Jagielski} 71*b1cdbd2cSJim Jagielski 72*b1cdbd2cSJim Jagielskisub unpack_solpkg 73*b1cdbd2cSJim Jagielski{ 74*b1cdbd2cSJim Jagielski my ($package) = @_; 75*b1cdbd2cSJim Jagielski 76*b1cdbd2cSJim Jagielski system << "EOF" 77*b1cdbd2cSJim Jagielskised -e '1 d' -e 's/[0-9][0-9]* [0-9][0-9]* [0-9]\\{10\\}\$//' $package/pkgmap > filelist 78*b1cdbd2cSJim Jagielskigrep -v "^PSTAMP=" $package/pkginfo > pkginfo 79*b1cdbd2cSJim Jagielskicp $package/install/* . 80*b1cdbd2cSJim Jagielskiif [ -f $package/archive/none.bz2 ]; then 81*b1cdbd2cSJim Jagielski bzcat $package/archive/none.bz2 | cpio -i -d 82*b1cdbd2cSJim Jagielskielse 83*b1cdbd2cSJim Jagielski cp -pr $package/reloc/* . 84*b1cdbd2cSJim Jagielskifi 85*b1cdbd2cSJim JagielskiEOF 86*b1cdbd2cSJim Jagielski} 87*b1cdbd2cSJim Jagielski 88*b1cdbd2cSJim Jagielskisub unpack_tgz { 89*b1cdbd2cSJim Jagielski my ($package) = @_; 90*b1cdbd2cSJim Jagielski 91*b1cdbd2cSJim Jagielski system << "EOF" 92*b1cdbd2cSJim Jagielskicat $package | gunzip | tar -xf - 93*b1cdbd2cSJim JagielskiEOF 94*b1cdbd2cSJim Jagielski} 95*b1cdbd2cSJim Jagielski 96*b1cdbd2cSJim Jagielskimy $script = basename($0); 97*b1cdbd2cSJim Jagielski 98*b1cdbd2cSJim Jagielskidie "Usage: $script <package 1> <package 2>\n" unless $#ARGV == 1; 99*b1cdbd2cSJim Jagielski 100*b1cdbd2cSJim Jagielskimy @pkgroot = (); 101*b1cdbd2cSJim Jagielski 102*b1cdbd2cSJim Jagielskiwhile ( $#ARGV >= 0 ) 103*b1cdbd2cSJim Jagielski{ 104*b1cdbd2cSJim Jagielski my $package = shift; 105*b1cdbd2cSJim Jagielski 106*b1cdbd2cSJim Jagielski # make package paths absolute if necessary 107*b1cdbd2cSJim Jagielski $package = $dir . "/" . $package unless $package =~ /^\//; 108*b1cdbd2cSJim Jagielski 109*b1cdbd2cSJim Jagielski my $basename = basename($package); 110*b1cdbd2cSJim Jagielski 111*b1cdbd2cSJim Jagielski # when comparing identically named packages, append a "-2" 112*b1cdbd2cSJim Jagielski unless ( mkdir "$tempdir/$basename", 0777 ) { 113*b1cdbd2cSJim Jagielski $basename = $basename . "-2"; 114*b1cdbd2cSJim Jagielski mkdir "$tempdir/$basename", 0777; 115*b1cdbd2cSJim Jagielski } 116*b1cdbd2cSJim Jagielski 117*b1cdbd2cSJim Jagielski # change working directory, unpack the package and change back .. 118*b1cdbd2cSJim Jagielski die "Unable to change to unpack directory $tempdir/$basename: $!\n" unless chdir "$tempdir/$basename"; 119*b1cdbd2cSJim Jagielski 120*b1cdbd2cSJim Jagielski if ( $package =~ /\.rpm$/ ) { unpack_rpm( $package ); } 121*b1cdbd2cSJim Jagielski elsif( $package =~ /\.deb$/ ) { unpack_deb( $package ); } 122*b1cdbd2cSJim Jagielski elsif( -f "$package/pkgmap" ) { unpack_solpkg( $package ); } 123*b1cdbd2cSJim Jagielski elsif( $package =~ /\.tgz$/ ) { unpack_tgz( $package ); } 124*b1cdbd2cSJim Jagielski 125*b1cdbd2cSJim Jagielski push @pkgroot, $basename; 126*b1cdbd2cSJim Jagielski chdir $dir; 127*b1cdbd2cSJim Jagielski} 128*b1cdbd2cSJim Jagielski 129*b1cdbd2cSJim Jagielski# print "$0\n"; 130*b1cdbd2cSJim Jagielski 131*b1cdbd2cSJim Jagielskidie "Unable to change to working directory $tempdir: $!\n" unless chdir $tempdir; 132*b1cdbd2cSJim Jagielski 133*b1cdbd2cSJim Jagielskisystem "diff -ru @pkgroot[0] @pkgroot[1]"; 134*b1cdbd2cSJim Jagielskisystem "rm -rf *"; 135*b1cdbd2cSJim Jagielski 136*b1cdbd2cSJim Jagielskichdir $dir; 137*b1cdbd2cSJim Jagielskirmdir $tempdir; 138*b1cdbd2cSJim Jagielski#print STDERR "rm -rf $tempdir\n"; 139*b1cdbd2cSJim Jagielski 140