ALT Linux Sisyphus discussions
 help / color / mirror / Atom feed
From: Alexey Tourbin <at@altlinux.ru>
To: sisyphus@altlinux.ru
Subject: [sisyphus] Re: sisyphus-daily?
Date: Wed, 19 Nov 2003 22:01:14 +0300
Message-ID: <20031119190114.GV1860@julia.office.altlinux.ru> (raw)
In-Reply-To: <20031119202148.01a53601.sssku@online.ru>


[-- Attachment #1.1: Type: text/plain, Size: 467 bytes --]

On Wed, Nov 19, 2003 at 08:21:48PM +0300, Sergey S. Skulachenko wrote:
> Я тут же подпишусь. Процесс обновления будет более осмысленным и
> интересным.

Скрипт, который делает это "почти совсем правильно", я уже сделал. :)
Теперь только такой вопрос: кому интересно смотреть диффы от полностью
развернутых исходников, а кому нет.  Мне интересно.  Если наберется
критическое число тех, кому также интересно, то...

Но они могут быть большими, порядка 100 кб на пакет.

[-- Attachment #1.2: rpmcmp.pl --]
[-- Type: text/plain, Size: 2315 bytes --]

#!/usr/bin/perl

use Cwd qw(realpath);
use File::Temp qw(tempdir);
use Getopt::Long qw(GetOptions);
use strict;

GetOptions "deep" => \my $opt_deep;

sub tmp_unpack($) {
	my $rpm = shift;
	my $dir = tempdir(CLEANUP => 1);
	chdir $dir;
	system "rpm2cpio $rpm | cpio -idm 2>/dev/null";
	return $dir;
}

sub uncompress($) {
	my $dir = shift;
	chdir $dir;
	system "gunzip *.gz &>/dev/null";
	system "bunzip *.bz2 &>/dev/null";
	system "tar xf *.tar &>/dev/null && rm -f *.tar";
}

sub cmp_rm($$) {
	my ($f1, $f2) = @_;
	my $rv;
	if (-e $f1 && -e $f2) {
		$rv = `LC_ALL=C TZ=UTC0 diff -abBdpruw $f1 $f2`;
		system "rm -rf $f1 $f2";
	}
	return $rv;
}

sub _cmp_eq($$) {
	return $_[0] eq $_[1];
}

sub _cmp_az($$) {
	(my $az1 = $_[0]) =~ s/[^a-z]//g;
	(my $az2 = $_[1]) =~ s/[^a-z]//g;
	return $az1 eq $az2;
}

sub same_type($$) {
	my ($f1, $f2) = @_;
	return "f" if -f $f1 && -f $f2;
	return "d" if -d $f1 && -d $f2 && $opt_deep;
	return;
}

sub supercmp($$$) {
	my ($dir1, $dir2, $glob) = @_;
	my $diff;
try:	while (1) {
		foreach my $cmp_func (\&_cmp_eq, \&_cmp_az) {
			chdir $dir1; my @f1 = <*>;
			foreach my $f1 (@f1) {
				chdir $dir2; my @f2 = <*>;
				foreach my $f2 (@f2) {
					if ($cmp_func->($f1, $f2) && same_type("$dir1/$f1", "$dir2/$f2")) {
						$diff .= cmp_rm "$dir1/$f1", "$dir2/$f2";
						next try;
					}
				}
			}
		}
		last;
	}
	return $diff;
}

sub rpmcmp ($$) {
	my ($rpm1, $rpm2) = map { realpath($_) } @_;
	my ($name1, $name2) = map { /.*\/(.+?)\.src\.rpm/ } ($rpm1, $rpm2);
	-f $rpm1 or die "$rpm1: $!\n";
	-f $rpm2 or die "$rpm2: $!\n";

	my $dir1 = tmp_unpack $rpm1; uncompress $dir1;
	my $dir2 = tmp_unpack $rpm2; uncompress $dir2;

	my $diff = supercmp($dir1, $dir2, "*.spec");
	$diff .= supercmp($dir1, $dir2, "*.patch");
	$diff .= supercmp($dir1, $dir2, "*");

# see the rest
	$diff .= "End of diff\n";
	my $rest1 = `/bin/ls -AF $dir1`;
	$diff .= "\nFiles not compared in $dir1\:\n$rest1\n" if $rest1 =~ /\S/;
	my $rest2 = `/bin/ls -AF $dir2`;
	$diff .= "\nFiles not compared in $dir2\:\n$rest2\n" if $rest2 =~ /\S/;

# filter out temporary dirs
	$diff =~ s/\Q$dir1/$name1/g;
	$diff =~ s/\Q$dir2/$name2/g;
	return $diff;
}

@ARGV == 2 and -f $ARGV[0] and -f $ARGV[1] or print <<EOF and exit 1;
usage:
$0 [--deep] package1.src.rpm package2.src.rpm
EOF
print rpmcmp $ARGV[0], $ARGV[1];

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2003-11-19 19:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-19 15:23 [sisyphus] sisyphus-daily? Alexey Tourbin
2003-11-19 15:33 ` Sergey Vlasov
2003-11-19 15:37   ` [sisyphus] sisyphus-daily? Alexey Tourbin
2003-11-19 17:21 ` [sisyphus] sisyphus-daily? Sergey S. Skulachenko
2003-11-19 19:01   ` Alexey Tourbin [this message]
2003-11-19 19:09     ` [sisyphus] sisyphus-daily? Michael Shigorin
2003-11-19 19:18       ` Alexey Tourbin
2003-11-19 19:25         ` Michael Shigorin
2003-11-19 19:37           ` Alexey Tourbin
2003-11-19 20:17             ` Michael Shigorin
2003-11-19 19:29         ` Alexey Tourbin
2003-11-20  1:20         ` Alexey Morozov
2003-11-19 23:17     ` Andrey Rahmatullin
2003-11-20  7:58 ` [sisyphus] sisyphus-daily? Alexey Gladkov
2003-11-20  8:18   ` Alexey I. Froloff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031119190114.GV1860@julia.office.altlinux.ru \
    --to=at@altlinux.ru \
    --cc=sisyphus@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Sisyphus discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \
		sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru
	public-inbox-index sisyphus

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.sisyphus


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git