#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: FwUpdate.pm,v 1.17 2015/02/15 09:54:21 espie Exp $
+# $OpenBSD: FwUpdate.pm,v 1.18 2015/04/16 13:29:16 espie Exp $
#
# Copyright (c) 2014 Marc Espie <espie@openbsd.org>
#
sub find_path
{
my $state = shift;
- open my $cmd, '-|', OpenBSD::Paths->sysctl, '-n', 'kern.version';
- my $line = <$cmd>;
- close($cmd);
- if ($line =~ m/^OpenBSD (\d\.\d)(\S*)\s/) {
- my ($version, $tag) = ($1, $2);
- if ($tag eq '-current') {
- $version = 'snapshots';
- }
- $state->{path} = "http://firmware.openbsd.org/firmware/$version/";
+ my $dir = OpenBSD::Paths->os_directory;
+ if (defined $dir) {
+ $state->{path} = "http://firmware.openbsd.org/firmware/$dir/";
} else {
$state->fatal("Couldn't find/parse OS version");
}
# ex:ts=8 sw=4:
-# $OpenBSD: Installed.pm,v 1.30 2015/04/16 09:32:23 espie Exp $
+# $OpenBSD: Installed.pm,v 1.31 2015/04/16 13:29:16 espie Exp $
#
# Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org>
#
sub expand_locations
{
my ($class, $string, $state) = @_;
+ require OpenBSD::Paths;
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;
- }
+ return OpenBSD::Paths->architecture;
+ } elsif ($string eq '%v') {
+ return OpenBSD::Paths->os_version;
+ } elsif ($string eq '%c') {
+ return OpenBSD::Paths->os_directory;
}
}
# ex:ts=8 sw=4:
-# $OpenBSD: PackingElement.pm,v 1.240 2015/04/16 09:32:23 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.241 2015/04/16 13:29:16 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
return join(',', @{$self->{arches}});
}
-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) = @_;
next;
}
}
- if (!defined $machine_arch) {
- my $cmd = OpenBSD::Paths->arch." -s";
- chomp($machine_arch = `$cmd`);
- }
- return 1 if $ok eq $machine_arch;
- return 1 if $ok eq arch();
+ return 1 if $ok eq OpenBSD::Paths->machine_architecture;
+ return 1 if $ok eq OpenBSD::Paths->architecture;
}
return;
}
# ex:ts=8 sw=4:
-# $OpenBSD: Paths.pm,v 1.30 2014/08/26 17:47:24 jsing Exp $
+# $OpenBSD: Paths.pm,v 1.31 2015/04/16 13:29:16 espie Exp $
#
# Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org>
#
sub man_cruft() { ("whatis.db", "mandoc.db", "mandoc.index") }
sub info_cruft() { ("dir") }
+# a bit of code, OS-dependent stuff that's run-time detected and has no
+# home yet.
+
+my ($machine_arch, $arch, $osversion, $osdirectory);
+
+sub architecture
+{
+ if (!defined $arch) {
+ my $cmd = uname()." -m";
+ chomp($arch = `$cmd`);
+ }
+ return $arch;
+}
+
+sub machine_architecture
+{
+ if (!defined $machine_arch) {
+ my $cmd = arch()." -s";
+ chomp($machine_arch = `$cmd`);
+ }
+ return $machine_arch;
+}
+
+sub compute_osversion
+{
+ open my $cmd, '-|', OpenBSD::Paths->sysctl, '-n', 'kern.version';
+ my $line = <$cmd>;
+ close($cmd);
+ if ($line =~ m/^OpenBSD (\d\.\d)(\S*)\s/) {
+ $osversion = $1;
+ if ($2 eq '-current') {
+ $osdirectory = 'snapshots';
+ } else {
+ $osdirectory = $osversion;
+ }
+ }
+}
+
+sub os_version
+{
+ if (!defined $osversion) {
+ compute_osversion();
+ }
+ return $osversion;
+}
+
+sub os_directory
+{
+ if (!defined $osversion) {
+ compute_osversion();
+ }
+ return $osdirectory;
+}
+
1;