[Yaird-devel] Bug#337279: Patch for #337279 (/boot != /tmp)
Anthony DeRobertis
anthony at derobert.net
Wed Mar 22 20:03:06 UTC 2006
Package: yaird
Version: 0.0.12-8asd5
Followup-For: Bug #337279
The attached patch, suitable for inclusion in debian/patches, tests if
there are less than 1024 free inodes on the target and, if so, switches
to using /tmp to build the initrd instead.
An additional dependency on libfilesys-statvfs-perl needs to be added to
debian/control.
PS: Honestly, despite writing this patch, I suggest that you just change
it to always use /tmp.
[The asd5 is my local rebuild including this patch ]
-- System Information:
Debian Release: 3.1
APT prefers stable
APT policy: (500, 'stable'), (100, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-686-smp
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Versions of packages yaird depends on:
ii cpio 2.5-1.3 GNU cpio -- a program to manage ar
ii dash 0.5.2-5 The Debian Almquist Shell
ii libc6 2.3.2.ds1-22 GNU C Library: Shared libraries an
ii libhtml-template-perl 2.6-2 HTML::Template : A module for usin
ii libparse-recdescent-perl 1.94-4 Generates recursive-descent parser
ii perl 5.8.4-8sarge3 Larry Wall's Practical Extraction
yaird recommends no packages.
-- no debconf information
-------------- next part --------------
Index: yaird-0.0.12/perl/Pack.pm
===================================================================
--- yaird-0.0.12.orig/perl/Pack.pm 2006-03-22 14:45:44.000000000 -0500
+++ yaird-0.0.12/perl/Pack.pm 2006-03-22 14:53:29.000000000 -0500
@@ -33,6 +33,8 @@
use strict;
use warnings;
use File::Temp;
+use Filesys::Statvfs ();
+use File::Basename ();
use Base;
use Image;
@@ -60,11 +62,12 @@
Base::fatal ("there were errors in this run, aborting now without output");
}
- #
- # Temp based on destination,to increase likelyhood
- # of rename being atomic.
- #
- my $template = "$destination.XXXXXXXXXXXXXXXX";
+ # If there are enough free inodes on the destination file system
+ # (we'll assume 1024 to be enough), use the destination file system
+ # to facilitate atomic moves. Otherwise, use /tmp.
+ my $dest_dir = File::Basename::dirname($destination);
+ my $template = ((Filesys::Statvfs::statvfs($dest_dir))[7] < 1024)
+ ? "/tmp/yaird.XXXXXXXXXXXXXXXX" : "$destination.XXXXXXXXXXXXXXXX";
my $tempdir = File::Temp::tempdir ($template, CLEANUP => 1);
$image->buildHere ($tempdir);
More information about the Yaird-devel
mailing list