From 4f3da0a2bdae631d72752996fc185c9e9b4b5d07 Mon Sep 17 00:00:00 2001 From: Raphael Hertzog Date: Sun, 16 Mar 2008 19:17:03 +0100 Subject: [PATCH] Update indentation and coding style to be coherent with the other modules * scripts/Dpkg/Source/Package/V3_0/bzr.pm: Use 4 spaces everywhere for indentation. Put spaces around " = ". * scripts/Dpkg/Source/Package/V3_0/git.pm: Same here. --- scripts/Dpkg/Source/Package/V3_0/bzr.pm | 276 ++++++++++++------------ scripts/Dpkg/Source/Package/V3_0/git.pm | 102 ++++----- 2 files changed, 189 insertions(+), 189 deletions(-) diff --git a/scripts/Dpkg/Source/Package/V3_0/bzr.pm b/scripts/Dpkg/Source/Package/V3_0/bzr.pm index 3e6bf1fe..617678ce 100644 --- a/scripts/Dpkg/Source/Package/V3_0/bzr.pm +++ b/scripts/Dpkg/Source/Package/V3_0/bzr.pm @@ -42,166 +42,166 @@ use Dpkg::Exit; use Dpkg::Source::Functions qw(erasedir); sub import { - foreach my $dir (split(/:/, $ENV{PATH})) { - if (-x "$dir/bzr") { - return 1; - } - } - error(_g("This source package can only be manipulated using bzr, which is not in the PATH.")); + foreach my $dir (split(/:/, $ENV{PATH})) { + if (-x "$dir/bzr") { + return 1; + } + } + error(_g("This source package can only be manipulated using bzr, which is not in the PATH.")); } sub sanity_check { - my $srcdir=shift; - - if (! -d "$srcdir/.bzr") { - error(_g("source directory is not the top directory of a bzr repository (%s/.bzr not present), but Format bzr was specified"), - $srcdir); - } - - # Symlinks from .bzr to outside could cause unpack failures, or - # point to files they shouldn't, so check for and don't allow. - if (-l "$srcdir/.bzr") { - error(_g("%s is a symlink"), "$srcdir/.bzr"); - } - my $abs_srcdir=Cwd::abs_path($srcdir); - find(sub { - if (-l $_) { - if (Cwd::abs_path(readlink($_)) !~ /^\Q$abs_srcdir\E(\/|$)/) { - error(_g("%s is a symlink to outside %s"), - $File::Find::name, $srcdir); - } - } - }, "$srcdir/.bzr"); - - return 1; + my $srcdir = shift; + + if (! -d "$srcdir/.bzr") { + error(_g("source directory is not the top directory of a bzr repository (%s/.bzr not present), but Format bzr was specified"), + $srcdir); + } + + # Symlinks from .bzr to outside could cause unpack failures, or + # point to files they shouldn't, so check for and don't allow. + if (-l "$srcdir/.bzr") { + error(_g("%s is a symlink"), "$srcdir/.bzr"); + } + my $abs_srcdir = Cwd::abs_path($srcdir); + find(sub { + if (-l $_) { + if (Cwd::abs_path(readlink($_)) !~ /^\Q$abs_srcdir\E(\/|$)/) { + error(_g("%s is a symlink to outside %s"), + $File::Find::name, $srcdir); + } + } + }, "$srcdir/.bzr"); + + return 1; } sub can_build { - my ($self, $dir) = @_; - return (-d "$dir/.bzr", _g("doesn't contain a bzr repository")); + my ($self, $dir) = @_; + return (-d "$dir/.bzr", _g("doesn't contain a bzr repository")); } sub do_build { - my ($self, $dir) = @_; - my @argv = @{$self->{'options'}{'ARGV'}}; - # TODO: warn here? - #my @tar_ignore = map { "--exclude=$_" } @{$self->{'options'}{'tar_ignore'}}; - my $diff_ignore_regexp = $self->{'options'}{'diff_ignore_regexp'}; - - $dir =~ s{/+$}{}; # Strip trailing / - my ($dirname, $updir) = fileparse($dir); - - if (scalar(@argv)) { - usageerr(_g("-b takes only one parameter with format `%s'"), - $self->{'fields'}{'Format'}); - } - - my $sourcepackage = $self->{'fields'}{'Source'}; - my $basenamerev = $self->get_basename(1); - my $basename = $self->get_basename(); - my $basedirname = $basename; - $basedirname =~ s/_/-/; - - sanity_check($dir); - - my $old_cwd=getcwd(); - chdir($dir) || - syserr(_g("unable to chdir to `%s'"), $dir); - - # Check for uncommitted files. - # To support dpkg-source -i, remove any ignored files from the - # output of bzr status. - open(BZR_STATUS, '-|', "bzr", "status") || - subprocerr("bzr status"); - my @files; - while () { - chomp; - next unless s/^ +//; - if (! length $diff_ignore_regexp || - ! m/$diff_ignore_regexp/o) { - push @files, $_; - } - } - close(BZR_STATUS) || syserr(_g("bzr status exited nonzero")); - if (@files) { - error(sprintf(_g("uncommitted, not-ignored changes in working directory: %s"), - join(" ", @files))); - } - - chdir($old_cwd) || - syserr(_g("unable to chdir to `%s'"), $old_cwd); - - my $tmp = tempdir("$dirname.bzr.XXXXXX", DIR => $updir); - push @Dpkg::Exit::handlers, sub { erasedir($tmp) }; - my $tardir = "$tmp/$dirname"; - - system("bzr", "branch", $dir, $tardir); - $? && subprocerr("bzr branch $dir $tardir"); - - # Remove the working tree. - system("bzr", "remove-tree", $tardir); - - # Some branch metadata files are unhelpful. - unlink("$tardir/.bzr/branch/branch-name", - "$tardir/.bzr/branch/parent"); - - # Create the tar file - my $debianfile = "$basenamerev.bzr.tar." . $self->{'options'}{'comp_ext'}; - info(_g("building %s in %s"), - $sourcepackage, $debianfile); - my $tar = Dpkg::Source::Archive->new(filename => $debianfile, - compression => $self->{'options'}{'compression'}, - compression_level => $self->{'options'}{'comp_level'}); - $tar->create('chdir' => $tmp); - $tar->add_directory($dirname); - $tar->finish(); - - erasedir($tmp); - pop @Dpkg::Exit::handlers; - - $self->add_file($debianfile); + my ($self, $dir) = @_; + my @argv = @{$self->{'options'}{'ARGV'}}; + # TODO: warn here? + #my @tar_ignore = map { "--exclude=$_" } @{$self->{'options'}{'tar_ignore'}}; + my $diff_ignore_regexp = $self->{'options'}{'diff_ignore_regexp'}; + + $dir =~ s{/+$}{}; # Strip trailing / + my ($dirname, $updir) = fileparse($dir); + + if (scalar(@argv)) { + usageerr(_g("-b takes only one parameter with format `%s'"), + $self->{'fields'}{'Format'}); + } + + my $sourcepackage = $self->{'fields'}{'Source'}; + my $basenamerev = $self->get_basename(1); + my $basename = $self->get_basename(); + my $basedirname = $basename; + $basedirname =~ s/_/-/; + + sanity_check($dir); + + my $old_cwd = getcwd(); + chdir($dir) || + syserr(_g("unable to chdir to `%s'"), $dir); + + # Check for uncommitted files. + # To support dpkg-source -i, remove any ignored files from the + # output of bzr status. + open(BZR_STATUS, '-|', "bzr", "status") || + subprocerr("bzr status"); + my @files; + while () { + chomp; + next unless s/^ +//; + if (! length $diff_ignore_regexp || + ! m/$diff_ignore_regexp/o) { + push @files, $_; + } + } + close(BZR_STATUS) || syserr(_g("bzr status exited nonzero")); + if (@files) { + error(_g("uncommitted, not-ignored changes in working directory: %s"), + join(" ", @files)); + } + + chdir($old_cwd) || + syserr(_g("unable to chdir to `%s'"), $old_cwd); + + my $tmp = tempdir("$dirname.bzr.XXXXXX", DIR => $updir); + push @Dpkg::Exit::handlers, sub { erasedir($tmp) }; + my $tardir = "$tmp/$dirname"; + + system("bzr", "branch", $dir, $tardir); + $? && subprocerr("bzr branch $dir $tardir"); + + # Remove the working tree. + system("bzr", "remove-tree", $tardir); + + # Some branch metadata files are unhelpful. + unlink("$tardir/.bzr/branch/branch-name", + "$tardir/.bzr/branch/parent"); + + # Create the tar file + my $debianfile = "$basenamerev.bzr.tar." . $self->{'options'}{'comp_ext'}; + info(_g("building %s in %s"), + $sourcepackage, $debianfile); + my $tar = Dpkg::Source::Archive->new(filename => $debianfile, + compression => $self->{'options'}{'compression'}, + compression_level => $self->{'options'}{'comp_level'}); + $tar->create('chdir' => $tmp); + $tar->add_directory($dirname); + $tar->finish(); + + erasedir($tmp); + pop @Dpkg::Exit::handlers; + + $self->add_file($debianfile); } # Called after a tarball is unpacked, to check out the working copy. sub do_extract { - my ($self, $newdirectory) = @_; - my $fields = $self->{'fields'}; + my ($self, $newdirectory) = @_; + my $fields = $self->{'fields'}; - my $dscdir = $self->{'basedir'}; + my $dscdir = $self->{'basedir'}; - check_version($fields->{'Version'}); + check_version($fields->{'Version'}); - my $basename = $self->get_basename(); - my $basenamerev = $self->get_basename(1); + my $basename = $self->get_basename(); + my $basenamerev = $self->get_basename(1); - my @files = $self->get_files(); - if (@files > 1) { - error(_g("format v3.0 uses only one source file")); - } - my $tarfile = $files[0]; - if ($tarfile !~ /^\Q$basenamerev\E\.bzr\.tar\.$comp_regex$/) { - error(_g("expected %s, got %s"), - "$basenamerev.bzr.tar.$comp_regex", $tarfile); - } + my @files = $self->get_files(); + if (@files > 1) { + error(_g("format v3.0 uses only one source file")); + } + my $tarfile = $files[0]; + if ($tarfile !~ /^\Q$basenamerev\E\.bzr\.tar\.$comp_regex$/) { + error(_g("expected %s, got %s"), + "$basenamerev.bzr.tar.$comp_regex", $tarfile); + } - erasedir($newdirectory); + erasedir($newdirectory); - # Extract main tarball - info(_g("unpacking %s"), $tarfile); - my $tar = Dpkg::Source::Archive->new(filename => "$dscdir$tarfile"); - $tar->extract($newdirectory); + # Extract main tarball + info(_g("unpacking %s"), $tarfile); + my $tar = Dpkg::Source::Archive->new(filename => "$dscdir$tarfile"); + $tar->extract($newdirectory); - sanity_check($newdirectory); + sanity_check($newdirectory); - my $old_cwd=getcwd(); - chdir($newdirectory) || - syserr(_g("unable to chdir to `%s'"), $newdirectory); + my $old_cwd = getcwd(); + chdir($newdirectory) || + syserr(_g("unable to chdir to `%s'"), $newdirectory); - # Reconstitute the working tree. - system("bzr", "checkout"); + # Reconstitute the working tree. + system("bzr", "checkout"); - chdir($old_cwd) || - syserr(_g("unable to chdir to `%s'"), $old_cwd); + chdir($old_cwd) || + syserr(_g("unable to chdir to `%s'"), $old_cwd); } -1 +1; diff --git a/scripts/Dpkg/Source/Package/V3_0/git.pm b/scripts/Dpkg/Source/Package/V3_0/git.pm index 4839dcc3..8b134fc2 100644 --- a/scripts/Dpkg/Source/Package/V3_0/git.pm +++ b/scripts/Dpkg/Source/Package/V3_0/git.pm @@ -48,60 +48,60 @@ delete $ENV{GIT_ALTERNATE_OBJECT_DIRECTORIES}; delete $ENV{GIT_WORK_TREE}; sub import { - foreach my $dir (split(/:/, $ENV{PATH})) { - if (-x "$dir/git") { - return 1; - } - } - error(_g("This source package can only be manipulated using git, which is not in the PATH.")); + foreach my $dir (split(/:/, $ENV{PATH})) { + if (-x "$dir/git") { + return 1; + } + } + error(_g("This source package can only be manipulated using git, which is not in the PATH.")); } sub sanity_check { - my $srcdir=shift; + my $srcdir = shift; - if (! -d "$srcdir/.git") { - error(_g("source directory is not the top directory of a git repository (%s/.git not present), but Format git was specified"), - $srcdir); - } - if (-s "$srcdir/.gitmodules") { - error(_g("git repository %s uses submodules. This is not yet supported."), - $srcdir); - } - - # Symlinks from .git to outside could cause unpack failures, or - # point to files they shouldn't, so check for and don't allow. - if (-l "$srcdir/.git") { - error(_g("%s is a symlink"), "$srcdir/.git"); - } - my $abs_srcdir=Cwd::abs_path($srcdir); - find(sub { - if (-l $_) { - if (Cwd::abs_path(readlink($_)) !~ /^\Q$abs_srcdir\E(\/|$)/) { - error(_g("%s is a symlink to outside %s"), - $File::Find::name, $srcdir); - } - } - }, "$srcdir/.git"); + if (! -d "$srcdir/.git") { + error(_g("source directory is not the top directory of a git repository (%s/.git not present), but Format git was specified"), + $srcdir); + } + if (-s "$srcdir/.gitmodules") { + error(_g("git repository %s uses submodules. This is not yet supported."), + $srcdir); + } - return 1; + # Symlinks from .git to outside could cause unpack failures, or + # point to files they shouldn't, so check for and don't allow. + if (-l "$srcdir/.git") { + error(_g("%s is a symlink"), "$srcdir/.git"); + } + my $abs_srcdir = Cwd::abs_path($srcdir); + find(sub { + if (-l $_) { + if (Cwd::abs_path(readlink($_)) !~ /^\Q$abs_srcdir\E(\/|$)/) { + error(_g("%s is a symlink to outside %s"), + $File::Find::name, $srcdir); + } + } + }, "$srcdir/.git"); + + return 1; } # Returns a hash of arrays of git config values. sub read_git_config { - my $file=shift; - - my %ret; - open(GIT_CONFIG, '-|', "git", "config", "--file", $file, "--null", "-l") || - subprocerr("git config"); - local $/ = "\0"; - while () { - chomp; - my ($key, $value) = split(/\n/, $_, 2); - push @{$ret{$key}}, $value; - } - close(GIT_CONFIG) || syserr(_g("git config exited nonzero")); + my $file = shift; + + my %ret; + open(GIT_CONFIG, '-|', "git", "config", "--file", $file, "--null", "-l") || + subprocerr("git config"); + local $/ = "\0"; + while () { + chomp; + my ($key, $value) = split(/\n/, $_, 2); + push @{$ret{$key}}, $value; + } + close(GIT_CONFIG) || syserr(_g("git config exited nonzero")); - return \%ret; + return \%ret; } sub can_build { @@ -132,7 +132,7 @@ sub do_build { sanity_check($dir); - my $old_cwd=getcwd(); + my $old_cwd = getcwd(); chdir($dir) || syserr(_g("unable to chdir to `%s'"), $dir); @@ -140,8 +140,8 @@ sub do_build { # To support dpkg-source -i, get a list of files # equivalent to the ones git status finds, and remove any # ignored files from it. - my @ignores="--exclude-per-directory=.gitignore"; - my $core_excludesfile=`git config --get core.excludesfile`; + my @ignores = "--exclude-per-directory=.gitignore"; + my $core_excludesfile = `git config --get core.excludesfile`; chomp $core_excludesfile; if (length $core_excludesfile && -e $core_excludesfile) { push @ignores, "--exclude-from='$core_excludesfile'"; @@ -257,7 +257,7 @@ sub do_extract { sanity_check($newdirectory); - my $old_cwd=getcwd(); + my $old_cwd = getcwd(); chdir($newdirectory) || syserr(_g("unable to chdir to `%s'"), $newdirectory); @@ -281,7 +281,7 @@ sub do_extract { # Comment out potentially probamatic or annoying stuff in # .git/config. - my $safe_fields=qr/^( + my $safe_fields = qr/^( core\.autocrlf | branch\..* | remote\..* | @@ -290,7 +290,7 @@ sub do_extract { core\.logallrefupdates | core\.bare )$/x; - my %config=%{read_git_config(".git/config")}; + my %config = %{read_git_config(".git/config")}; foreach my $field (keys %config) { if ($field =~ /$safe_fields/) { delete $config{$field}; @@ -332,4 +332,4 @@ sub do_extract { syserr(_g("unable to chdir to `%s'"), $old_cwd); } -1 +1; -- 2.39.5