Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2477/perlmod/Fink

Modified Files:
        ChangeLog Config.pm Engine.pm Package.pm PkgVersion.pm 
        Scanpackages.pm Status.pm Validation.pm VirtPackage.pm 
Log Message:
Store Architecture and Debarch strings in $config object instead of
hard-coded and as a Config global variable. Now we can lie about our
arch! But prohibit compiling and other alterations of local system if
we are not using the native arch.


Index: PkgVersion.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/PkgVersion.pm,v
retrieving revision 1.547
retrieving revision 1.548
diff -u -d -r1.547 -r1.548
--- PkgVersion.pm       4 Apr 2006 22:24:36 -0000       1.547
+++ PkgVersion.pm       4 Apr 2006 22:45:44 -0000       1.548
@@ -35,7 +35,7 @@
 use Fink::CLI qw(&print_breaking &print_breaking_stderr &rejoin_text
                                 &prompt_boolean &prompt_selection
                                 &should_skip_prompt &die_breaking);
-use Fink::Config qw($config $basepath $libpath $debarch $buildpath
+use Fink::Config qw($config $basepath $libpath $buildpath
                                        $dbpath $ignore_errors);
 use Fink::NetAccess qw(&fetch_url_to_file);
 use Fink::Mirror;
@@ -364,7 +364,7 @@
                # always call pkglist(architecture) even if no_exclusions so
                # that we get error-checking on the field
                if (not $options{no_exclusions}) {
-                       my $sys_arch = &get_arch;
+                       my $sys_arch = $config->param('Architecture');
                        if (defined $pkg_arch and $pkg_arch !~ 
/(\A|,)\s*$sys_arch\s*(,|\Z)/) {
                                # Discard the whole thing if local arch not 
listed
                                return ();
@@ -488,7 +488,6 @@
        my ($depspec, $deplist, $dep, $expand, $destdir);
        my ($parentpkgname, $parentdestdir, $parentinvname);
        my ($i, $path, @parts, $finkinfo_index, $section, @splitofffields);
-       my $arch = get_arch();
 
        $self->SUPER::initialize();
        
@@ -566,7 +565,7 @@
                                $section .= join("/", 
@parts[$finkinfo_index+1..$#parts])."/";
                        }
                        $self->{_section} = substr($section,0,-1);       # cut 
last /
-                       $parts[$finkinfo_index] = "binary-$debarch";
+                       $parts[$finkinfo_index] = 'binary-' . 
$config->param('Debarch');
                        $self->{_debpath} = join("/", @parts);
                        $self->{_debpaths} = [];
                        for ($i = $#parts; $i >= $finkinfo_index; $i--) {
@@ -610,7 +609,7 @@
                                'r' => $revision,
                                'f' => $fullname,
                                'p' => $basepath,
-                               'm' => $arch,
+                               'm' => $config->param('Architecture'),
 
                                'N' => $parentpkgname,
                                'Ni'=> $parentinvname,
@@ -1289,7 +1288,7 @@
                $self->get_name(),
                $self->get_version(),
                $self->get_revision(),
-               $debarch;
+               $config->param('Debarch');
        return $self->{_debname};
 }
 
@@ -2164,7 +2163,7 @@
                        $epoch ? $epoch.'%3a' : '',
                        $self->get_version(),
                        $self->get_revision(),
-                       $debarch;
+                       $config->param('Debarch');
                if (-f $fn) {
                        return $fn;
                }
@@ -2945,6 +2944,8 @@
        my ($renamefield, @renamefiles, $renamefile, $renamelist, $expand);
        my ($tarcommand, $tarflags, $cat, $gzip, $bzip2, $unzip);
 
+       $config->mixed_arch(msg=>'build a package', fatal=>1);
+
        if ($self->is_type('bundle') || $self->is_type('dummy')) {
                return;
        }
@@ -3145,6 +3146,8 @@
        my $self = shift;
        my ($dir, $patch_script, $cmd, $patch, $subdir);
 
+       $config->mixed_arch(msg=>'build a package', fatal=>1);
+
        if ($self->is_type('bundle') || $self->is_type('dummy')) {
                return;
        }
@@ -3247,6 +3250,8 @@
        my $self = shift;
        my ($dir, $compile_script, $cmd);
        
+       $config->mixed_arch(msg=>'build a package', fatal=>1);
+
        # Fix repair permissions bug on Tiger
        Fink::Services::fix_gcc_repairperms();
        
@@ -3289,6 +3294,8 @@
        my $do_splitoff = shift || 0;
        my ($dir, $install_script, $cmd, $bdir);
 
+       $config->mixed_arch(msg=>'build a package', fatal=>1);
+
        my $notifier = Fink::Notify->new();
 
        if ($self->is_type('dummy')) {
@@ -3523,6 +3530,8 @@
        my ($daemonicname, $daemonicfile);
        my ($cmd);
 
+       $config->mixed_arch(msg=>'build a package', fatal=>1);
+
        my $notifier = Fink::Notify->new();
 
        if ($self->is_type('dummy')) {
@@ -3568,6 +3577,7 @@
        $prio = $self->get_priority();
        
        $instsize = $self->get_instsize("$destdir$basepath");   # kilobytes!
+       my $debarch = $config->param('Debarch');
        $control = <<EOF;
 Package: $pkgname
 Source: $parentpkgname
@@ -4147,6 +4157,8 @@
                %opts = (no_clean_bl => 1);
        }
 
+       $config->mixed_arch(msg=>'install a package', fatal=>1);
+
        my (@installable);
 
        my $notifier = Fink::Notify->new();
@@ -4635,8 +4647,6 @@
        my $no_expand = shift || 0;
        my $nonroot_okay = shift || 0;
 
-       my $arch = get_arch();
-
        # Expand percent shortcuts
        $script = &expand_percent($script, $self->{_expand}, 
$self->get_info_filename." $phase script") unless $no_expand;
 
@@ -4657,7 +4667,7 @@
                                "or fink-beginners mailing lists.  As a last 
resort, you can try e-mailing\n".
                                "the maintainer directly:\n\n".
                                "\t" . $self->param('maintainer') . "\n\n";
-                       if ($arch eq "i386") {
+                       if (get_arch() eq 'i386' or 
$config->param('Architecture') eq 'i386') {
 $error .= "Note that many fink package maintainers do not (yet) have access to 
OS X on\n" .
        "Intel hardware, so you may have better luck on the mailing lists.\n\n";
 }

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.1315
retrieving revision 1.1316
diff -u -d -r1.1315 -r1.1316
--- ChangeLog   30 Mar 2006 08:04:05 -0000      1.1315
+++ ChangeLog   4 Apr 2006 22:45:43 -0000       1.1316
@@ -1,5 +1,23 @@
 2006-03-28  Daniel Macks  <[EMAIL PROTECTED]>
 
+       * Config.pm: Store architecture and debarch in $config object
+       ("Architecture" and "Debarch", not written to fink.conf) and
+       remove exported $debarch. New method mixed_arch checks whether
+       local machine matches $config arch.
+
+       * Status.pm: Disable local dpkg when forging arch.
+
+       * Package.pm: Disable saved pdb when forging arch.
+
+       * VirtPackage.pm: Consider all virtuals "uninstalled" when forging
+       arch.
+       
+       * all: Use $config data instead of $Fink::Config::debarch. Call
+       mixed_arch to prevent compiling or doing any other local .deb
+       actions if arch is forged.
+
+2006-03-28  Daniel Macks  <[EMAIL PROTECTED]>
+
        * Engine.pm: Weaken .info validator settings for dependencies
        and only check each .info file once in -m mode.
 

Index: Status.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Status.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- Status.pm   2 Mar 2006 02:43:25 -0000       1.23
+++ Status.pm   4 Apr 2006 22:45:44 -0000       1.24
@@ -76,7 +76,7 @@
        $file = $basepath."/var/lib/dpkg/status";
        $hash = {};
 
-       if (not $config->want_magic_tree('status')) {
+       if ($config->mixed_arch() or not $config->want_magic_tree('status')) {
                return;
        }
 

Index: Package.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Package.pm,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -d -r1.171 -r1.172
--- Package.pm  19 Mar 2006 09:27:48 -0000      1.171
+++ Package.pm  4 Apr 2006 22:45:43 -0000       1.172
@@ -28,7 +28,7 @@
                      &expand_percent &lock_wait &store_rename);
 use Fink::CLI qw(&get_term_width &print_breaking &print_breaking_stderr
                                 &rejoin_text);
-use Fink::Config qw($config $basepath $dbpath $debarch);
+use Fink::Config qw($config $basepath $dbpath);
 use Fink::Command qw(&touch &mkdir_p &rm_rf &rm_f);
 use Fink::PkgVersion;
 use Fink::FinkVersion;
@@ -616,7 +616,7 @@
        return 1 if -M $dbfile > -M "$basepath/etc/fink.conf";
 
        # Using find is much faster than doing it in Perl
-       my $prune_bin = "\\( -name 'binary-$debarch' -prune \\)";
+       my $prune_bin = "\\( -name 'binary-" . $config->param("Debarch") . "' 
-prune \\)";
        my $file_test = "\\( \\( -type f -o -type l \\) -name '*.info' \\)";
        my $cmd = "/usr/bin/find -L $path \\! $prune_bin \\( $file_test -o 
-type d \\) "
                . " -newer $dbfile";
@@ -715,6 +715,11 @@
 
 sub can_read_write_db {
        my $class = shift;
+
+       # do not use disk cache if we are using a forged architecture
+       if ($config->mixed_arch()) {
+               return (0,0);
+       }
        
        my ($read, $write) = (1, 0);
        

Index: Scanpackages.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Scanpackages.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- Scanpackages.pm     29 Mar 2006 23:00:45 -0000      1.10
+++ Scanpackages.pm     4 Apr 2006 22:45:44 -0000       1.11
@@ -293,17 +293,20 @@
        $self = $self->new(%$options) unless ref $self;
        
        $self->_ensure_fink;
-       
+
+       my $config = $Fink::Config::config;  # stupid use() spaghetti!
+       return 0 if $config->mixed_arch(message=>'scan local binaries');
+
        # Get the tree list
-       @trees = $Fink::Config::config->get_treelist unless @trees;
-       my @dists = map { "dists/$_/binary-$Fink::Config::debarch" } @trees;
+       @trees = $config->get_treelist unless @trees;
+       my @dists = map { "dists/$_/binary-".$config->param('Debarch') } @trees;
        
        # Get some more params
        my $basedir = $Fink::Config::basepath . "/fink";
        my %release = (
                Origin  => 'Fink',
                Label   => 'Fink',
-               Architecture => $Fink::Config::debarch,
+               Architecture => $config->param('Debarch'),
        );
        
        # Always use a DB 

Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.372
retrieving revision 1.373
diff -u -d -r1.372 -r1.373
--- Engine.pm   30 Mar 2006 08:04:05 -0000      1.372
+++ Engine.pm   4 Apr 2006 22:45:43 -0000       1.373
@@ -26,7 +26,7 @@
 use Fink::Services qw(&latest_version &sort_versions
                                          &pkglist2lol &cleanup_lol
                                          &execute &expand_percent
-                                         &count_files &get_arch
+                                         &count_files
                                          &call_queue_clear &call_queue_add
                                          &dpkg_lockwait &aptget_lockwait 
&store_rename &get_options
                                          $VALIDATE_HELP &apt_available);
@@ -39,7 +39,7 @@
 use Fink::Finally::BuildConflicts;
 use Fink::Package;
 use Fink::PkgVersion;
-use Fink::Config qw($config $basepath $debarch $dbpath);
+use Fink::Config qw($config $basepath $dbpath);
 use File::Find;
 use Fink::Status;
 use Fink::Command qw(mkdir_p rm_f);
@@ -237,8 +237,8 @@
 
        # Warn about Spotlight
        if (&spotlight_warning()) {
-               $config->save;
-               $config->initialize;
+               $self->{config}->save;
+               $self->{config}->initialize;
        }
        
        # read package descriptions if needed
@@ -1179,6 +1179,9 @@
 
 sub cleanup_debs {
        my %opts = (dryrun => 0, @_);
+
+       return if $config->mixed_arch(message=>'cleanup .deb archives');
+
        Fink::Package->require_packages();
 
        my $file_count;
@@ -1725,6 +1728,10 @@
        # if we were really in fetch or dry-run modes, stop here
        return if $fetch_only || $dryrun;
 
+       # cross-building is not supported yet because we don't have a
+       # generic way to pass the arch info to the compiler
+       $config->mixed_arch(message=>'build or install/remove binary packages', 
fatal=>1);
+
        # install in correct order...
        while (1) {
                $all_installed = 1;

Index: Config.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Config.pm,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- Config.pm   29 Mar 2006 17:30:50 -0000      1.79
+++ Config.pm   4 Apr 2006 22:45:43 -0000       1.80
@@ -33,23 +33,23 @@
 require Exporter;
 
 our @ISA        = qw(Exporter Fink::Base);
-our @EXPORT_OK  = qw($config $basepath $libpath $debarch $buildpath $dbpath
+our @EXPORT_OK  = qw($config $basepath $libpath $buildpath $dbpath
                       $distribution $ignore_errors
                       get_option set_options
                      );
 our $VERSION    = 1.00;
 
 
-our ($config, $basepath, $libpath, $dbpath, $distribution, $buildpath, 
$ignore_errors, $debarch);
+our ($config, $basepath, $libpath, $dbpath, $distribution, $buildpath, 
$ignore_errors, $native_debarch);
 
-# determine the dpkg Architecture string
+# determine the dpkg Architecture string for the local machine
 #
 # We can't use `dpkg --print-installation-architecture` (although we
 # have to match it) because dpkg runs fink-virtual-pkgs, which loads
 # Config.pm.
 {
        my $_arch = &get_arch();
-       $debarch = "darwin-$_arch";
+       $native_debarch = "darwin-$_arch";
 }
 
 my %options = ();
@@ -186,6 +186,14 @@
                die "Distribution not set in config file 
\"".$self->{_path}."\"!\n";
        }
 
+       # The Architecture config field is used for .info Architecture
+       # control and %m expansion, and can be set to simulate the engine
+       # and indexer on non-local architectures.
+       if (not $self->has_param('Architecture')) {
+               $self->set_param('Architecture', get_arch());
+       }
+       $self->set_param('Debarch', 'darwin-' . $self->param('Architecture'));
+
        $self->{_queue} = [];
 }
 
@@ -976,6 +984,50 @@
        $self->set_param('Flags', join(' ', keys %{$self->{_flags}}));
 }
 
+=item mixed_arch
+
+       my $not_mixed = $config->mixed_arch(%opts);
+
+Make sure that the local architecture matches the one for which fink
+is configured. If not a message can be printed on stderr, a fatal
+error can be generated, and/or a boolean value can be returned. The
+following %opts are known:
+
+=over 4
+
+=item message (optional)
+
+If a non-null string, a message including this string is printed on
+stderr.
+
+=item fatal (optional)
+
+If true, we die. If not, we just return a boolean indicating if there
+is a mismatch.
+
+=back
+
+=cut
+
+sub mixed_arch {
+       my $self = shift;
+       my %opts = @_;
+
+       if ($native_debarch ne $self->param("Debarch")) {
+               if (defined (my $msg = $opts{message})) {
+                       if ($opts{fatal}) {
+                               die $msg;
+                       } else {
+                               warn $msg;
+                       }
+               } elsif ($opts{fatal}) {
+                       die "\n";
+               }
+               return 1;
+       }
+       return 0;
+}
+
 =back
 
 =head2 Exported Variables
@@ -1001,12 +1053,6 @@
 
 The last Fink::Config object created.
 
-=item $debarch
-
-Debian-style name of the current architecture.  
-
-Typically C<darwin-powerpc> or C<darwin-i386>.
-
 =item $distribution
 
 Fink package distribution being used.

Index: Validation.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Validation.pm,v
retrieving revision 1.219
retrieving revision 1.220
diff -u -d -r1.219 -r1.220
--- Validation.pm       21 Mar 2006 05:02:14 -0000      1.219
+++ Validation.pm       4 Apr 2006 22:45:44 -0000       1.220
@@ -23,7 +23,7 @@
 
 package Fink::Validation;
 
-use Fink::Services qw(&read_properties &read_properties_var &expand_percent 
&get_arch &file_MD5_checksum &pkglist2lol &version_cmp);
+use Fink::Services qw(&read_properties &read_properties_var &expand_percent 
&file_MD5_checksum &pkglist2lol &version_cmp);
 use Fink::Config qw($config);
 use Cwd qw(getcwd);
 use File::Find qw(find);
@@ -343,7 +343,6 @@
        my $expand = {};
        my $looks_good = 1;
        my $error_found = 0;
-       my $arch = get_arch();
 
        my $full_filename = $filename;  # we munge $filename later
 
@@ -700,7 +699,7 @@
                                'i' => $pkgdestdir.$basepath,
                                'a' => $pkgpatchpath,
                                'b' => '.',
-                               'm' => $arch,
+                               'm' => $config->param('Architecture'),
                                %{$expand},
                                'ni' => $pkginvarname,
                                'Ni' => $pkginvarname

Index: VirtPackage.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/VirtPackage.pm,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- VirtPackage.pm      22 Mar 2006 23:25:24 -0000      1.104
+++ VirtPackage.pm      4 Apr 2006 22:45:44 -0000       1.105
@@ -1254,7 +1254,7 @@
                }
        }
 
-       if (exists $self->{$pkgname} and exists $self->{$pkgname}->{status}) {
+       if (exists $self->{$pkgname} and exists $self->{$pkgname}->{status} and 
not $config->mixed_arch()) {
                my ($purge, $ok, $installstat) = split(/\s+/, 
$self->{$pkgname}->{status});
                return $self->{$pkgname}->{version} if ($installstat eq 
"installed" and exists $self->{$pkgname}->{version});
        }
@@ -1302,6 +1302,7 @@
                                $newhash->{$field} = $hash->{$field};
                        }
                }
+               $newhash->{status} = STATUS_ABSENT if $config->mixed_arch();
                $list->{$pkgname} = $newhash;
        }
 



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Fink-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to