# ex:ts=8 sw=4:
-# $OpenBSD: Installed.pm,v 1.29 2014/06/15 23:49:51 afresh1 Exp $
+# $OpenBSD: Installed.pm,v 1.30 2015/04/16 09:32:23 espie Exp $
#
# Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org>
#
package OpenBSD::PackageRepositoryBase;
+my ($version, $current);
+
+sub expand_locations
+{
+ my ($class, $string, $state) = @_;
+ if ($string eq '%a') {
+ require OpenBSD::PackingElement;
+ return OpenBSD::PackingElement::Arch::arch();
+ } else {
+ if (!defined $version) {
+ require OpenBSD::Paths;
+ open my $cmd, '-|',
+ OpenBSD::Paths->sysctl, '-n', 'kern.version';
+ my $line = <$cmd>;
+ close($cmd);
+ if ($line =~ m/^OpenBSD (\d\.\d)(\S*)\s/) {
+ $version = $1;
+ if ($2 eq '-current') {
+ $current = 'snapshots';
+ } else {
+ $current = $version;
+ }
+ } else {
+ $state->fatal("Can't figure out version");
+ }
+ }
+ if ($string eq '%c') {
+ return $current;
+ } else {
+ return $version;
+ }
+ }
+}
+
sub parse_url
{
my ($class, $r, $state) = @_;
$$r = '';
}
+ $path =~ s/\%[vac]/$class->expand_locations($&, $state)/ge;
$path .= '/' unless $path =~ m/\/$/;
bless { path => $path, state => $state }, $class;
}
# ex:ts=8 sw=4:
-# $OpenBSD: PackingElement.pm,v 1.239 2015/02/25 16:37:15 sthen Exp $
+# $OpenBSD: PackingElement.pm,v 1.240 2015/04/16 09:32:23 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
my ($machine_arch, $arch);
+sub arch
+{
+ if (!defined $arch) {
+ my $cmd = OpenBSD::Paths->uname." -m";
+ chomp($arch = `$cmd`);
+ }
+ return $arch;
+}
+
sub check
{
my ($self, $forced_arch) = @_;
chomp($machine_arch = `$cmd`);
}
return 1 if $ok eq $machine_arch;
- if (!defined $arch) {
- my $cmd = OpenBSD::Paths->uname." -m";
- chomp($arch = `$cmd`);
- }
- return 1 if $ok eq $arch;
+ return 1 if $ok eq arch();
}
return;
}