rpms/olpc-utils/OLPC-3 diskspace.patch, NONE, 1.1 olpc-utils.spec, 1.20, 1.21
C. Scott Ananian
cscott at fedoraproject.org
Mon Sep 29 13:08:16 UTC 2008
- Previous message (by thread): rpms/tclx/devel tclx.spec,1.22,1.23
- Next message (by thread): rpms/workrave/devel .cvsignore, 1.6, 1.7 sources, 1.6, 1.7 workrave.spec, 1.16, 1.17 workrave-1.8.5-gcc43.patch, 1.1, NONE workrave-1.8.5-lock.patch, 1.1, NONE workrave-1.8.5-sigc.patch, 1.2, NONE workrave.desktop, 1.2, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: cscott
Update of /cvs/pkgs/rpms/olpc-utils/OLPC-3
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv945
Modified Files:
olpc-utils.spec
Added Files:
diskspace.patch
Log Message:
dlo#7932: Fix failsafe script in the presence of pretty-boot.
diskspace.patch:
--- NEW FILE diskspace.patch ---
commit fc768d34a543ca40cd4d84e38da522bcccf9ebe3
Author: Chris Ball <cjb at laptop.org>
Date: Sat Sep 27 20:50:43 2008 -0400
dlo#7932: Fix failsafe script in the presence of pretty-boot.
This is more complicated than I'd hoped. In the presence of pretty-boot
we're started with input coming in on tty2 but output happening on tty1.
The resolution is to have one script that checks to see whether we're
in pretty-boot and switches to VT2 if we are, and to move the script
that actually does input/output to "diskspacerecover". On ugly-boot
it'll run on tty1 as normal, on pretty-boot it'll run on tty2.
A long-term fix is to have /etc/init.d/z-boot-anim-stop return us to
a more sane environment than this; it should set the controlling
terminal back to tty1 and chvt 1, but I wasn't able to make this work.
diff --git a/etc/rc.d/init.d/diskspacecheck b/etc/rc.d/init.d/diskspacecheck
index c4411a5..7095fa2 100755
--- a/etc/rc.d/init.d/diskspacecheck
+++ b/etc/rc.d/init.d/diskspacecheck
@@ -2,110 +2,38 @@
# -*- coding: utf-8 -*-
#
# chkconfig: 345 02 02
-# description: If the NAND doesn't have enough free space, delete datastore\
-# objects until it does. This doesn't modify the datastore's\
-# index.
+# description: If the NAND doesn't have enough free space, set up a VT for\
+# diskspacerecover.
# processname: diskspacecheck
# Author: Chris Ball <cjb at laptop.org>
-import os, sys, statvfs, subprocess, shutil
+import os, sys, statvfs, pyvt, time
THRESHOLD = 1024 * 20 # 20MB
DATASTORE_PATH = "/home/olpc/.sugar/default/datastore/store/*-*"
ACTIVITY_PATH = "/home/olpc/Activities/*"
-def main():
- # First, check to see whether we have enough free space.
- if find_freespace() < THRESHOLD:
- print "Not enough disk space."
-
- # Per Trac #5637, delete orphaned leaks in .sugar/default/data.
- # This is safe on any build.
- try:
- shutil.rmtree("/home/olpc/.sugar/default/data")
- except OSError:
- pass
-
- if find_freespace() >= THRESHOLD:
- # The above gained enough free space.
- return
-
- # Okay, we'll have to delete some real data.
- # Add datastore files to filelist string
- lines = os.popen("du -s %s" % DATASTORE_PATH).readlines()
-
- # Add activities to filelist
- lines += (os.popen("du -s %s" % ACTIVITY_PATH).readlines())
-
- filesizes = [line.split('\t') for line in lines]
- for file in filesizes:
- file[0] = int(file[0]) # size
- file[1] = file[1].rstrip() # path
- filesizes.sort()
- filelist = [file[1] for file in filesizes]
-
- # Unfreeze the DCON, print a message.
- unfreeze_dcon()
-
- # The below string is in latin-1, because Unicode isn't present
- # in the environment when this script runs.
- string = u"""
-Your disk is nearly full. The system cannot operate with a full disk.
-To create free space, some of the entries in your Journal will now be
-deleted. If you wish to avoid having items deleted, power down your
-XO and bring it to an expert for backup and recovery.
-
-Error code: DISKFULL
-
-Press the return key to delete some Journal entries, or the 'c' key
-and then return key to attempt to boot anyway.
-
-
-Su disco está casi lleno. El sistema no puede funcionar si el disco
-está lleno. Para liberar espacio, se deben borrar algunas entradas de
-su Diario ahora. Si prefiere no tener que borrar datos, apague su XO y
-llévelo a un experto para que haga una copia de seguridad y
-recuperación de datos.
-
-Código del error: DISKFULL
-
-Pulse retorno tecla para borrar algunas entradas del Diario, o presiona
-'c' y retorno para iniciar de cualquier manera.
-"""
-
- key = raw_input(string.encode('utf-8'))
-
- if key is 'c':
- return
-
- # Now, delete files/directories one at a time.
- while find_freespace() < THRESHOLD and len(filelist) > 0:
- delete_entry(filelist.pop())
-
-def find_freespace():
- # Determine free space on /.
- stat = os.statvfs("/")
- freebytes = stat[statvfs.F_BSIZE] * stat[statvfs.F_BAVAIL]
- freekbytes = freebytes / 1024
- return freekbytes
-
-def delete_entry(entry):
- # Delete a single file from the datastore, or an activity directory
- print "Deleting " + entry
- try:
- if os.path.isdir(entry):
- shutil.rmtree(entry)
- else:
- os.remove(entry)
- except OSError:
- print "Couldn't delete " + entry
-
-def unfreeze_dcon():
- # Don't think there's anything useful I can do if this write fails.
- dcon = open('/sys/class/backlight/dcon-bl/device/freeze', 'w')
- dcon.write('0')
- dcon.close()
- os.system("/sbin/setsysfont")
- os.system("/bin/unicode_start sun12x22")
-main()
+# Determine free space on /.
+stat = os.statvfs("/")
+freebytes = stat[statvfs.F_BSIZE] * stat[statvfs.F_BAVAIL]
+freekbytes = freebytes / 1024
+
+# If we have enough disk space, exit.
+if freekbytes > THRESHOLD:
+ exit
+
+# Disable pretty-boot.
+if os.system("ps awux | grep 0-boot-anim-start | grep -v grep") == 0:
+ # Pretty-boot is running. Kill it, and set up a new VT for the next script.
+ os.system("/etc/init.d/z-boot-anim-stop start")
+ pyvt.chcon("/dev/tty1")
+ pyvt.chcon("/dev/console")
+ pyvt.chvt(2)
+
+# Don't think there's anything useful I can do if this write fails.
+dcon = open('/sys/class/backlight/dcon-bl/device/freeze', 'w')
+dcon.write('0')
+dcon.close()
+os.system("/sbin/setsysfont")
+os.system("/bin/unicode_start sun12x22")
diff --git a/etc/rc.d/init.d/diskspacerecover b/etc/rc.d/init.d/diskspacerecover
new file mode 100755
index 0000000..050a051
--- /dev/null
+++ b/etc/rc.d/init.d/diskspacerecover
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# chkconfig: 345 03 03
+# description: If the NAND doesn't have enough free space, delete datastore\
+# objects until it does. This doesn't modify the datastore's\
+# index.
+# processname: diskspacerecover
+
+# Author: Chris Ball <cjb at laptop.org>
+
+import os, sys, statvfs, subprocess, shutil, fcntl
+
+THRESHOLD = 1024 * 600 # 20MB
+DATASTORE_PATH = "/home/olpc/.sugar/default/datastore/store/*-*"
+ACTIVITY_PATH = "/home/olpc/Activities/*"
+
+def main():
+ # First, check to see whether we have enough free space.
+ if find_freespace() < THRESHOLD:
+ print "Not enough disk space."
+
+ # Per Trac #5637, delete orphaned leaks in .sugar/default/data.
+ # This is safe on any build.
+ try:
+ shutil.rmtree("/home/olpc/.sugar/default/data")
+ except OSError:
+ pass
+
+ if find_freespace() >= THRESHOLD:
+ # The above gained enough free space.
+ return
+
+ # Okay, we'll have to delete some real data.
+ # Add datastore files to filelist string
+ lines = os.popen("du -s %s" % DATASTORE_PATH).readlines()
+
+ # Add activities to filelist
+ lines += (os.popen("du -s %s" % ACTIVITY_PATH).readlines())
+
+ filesizes = [line.split('\t') for line in lines]
+ for file in filesizes:
+ file[0] = int(file[0]) # size
+ file[1] = file[1].rstrip() # path
+ filesizes.sort()
+ filelist = [file[1] for file in filesizes]
+
+ # The below string is in latin-1, because Unicode isn't present
+ # in the environment when this script runs.
+ string = u"""
+Your disk is nearly full. The system cannot operate with a full disk.
+To create free space, some of the entries in your Journal will now be
+deleted. If you wish to avoid having items deleted, power down your
+XO and bring it to an expert for backup and recovery.
+
+Error code: DISKFULL
+
+Press the return key to delete some Journal entries, or the 'c' key
+and then return key to attempt to boot anyway.
+
+
+Su disco está casi lleno. El sistema no puede funcionar si el disco
+está lleno. Para liberar espacio, se deben borrar algunas entradas de
+su Diario ahora. Si prefiere no tener que borrar datos, apague su XO y
+llévelo a un experto para que haga una copia de seguridad y
+recuperación de datos.
+
+Código del error: DISKFULL
+
+Pulse retorno tecla para borrar algunas entradas del Diario, o presiona
+'c' y retorno para iniciar de cualquier manera.
+"""
+
+ key = raw_input(string.encode('utf-8'))
+
+ if key is 'c':
+ return
+
+ # Now, delete files/directories one at a time.
+ while find_freespace() < THRESHOLD and len(filelist) > 0:
+ delete_entry(filelist.pop())
+
+def find_freespace():
+ # Determine free space on /.
+ stat = os.statvfs("/")
+ freebytes = stat[statvfs.F_BSIZE] * stat[statvfs.F_BAVAIL]
+ freekbytes = freebytes / 1024
+ return freekbytes
+
+def delete_entry(entry):
+ # Delete a single file from the datastore, or an activity directory
+ print "Deleting " + entry
+ try:
+ if os.path.isdir(entry):
+ shutil.rmtree(entry)
+ else:
+ os.remove(entry)
+ except OSError:
+ print "Couldn't delete " + entry
+
+main()
Index: olpc-utils.spec
===================================================================
RCS file: /cvs/pkgs/rpms/olpc-utils/OLPC-3/olpc-utils.spec,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- olpc-utils.spec 23 Sep 2008 20:22:47 -0000 1.20
+++ olpc-utils.spec 29 Sep 2008 13:07:46 -0000 1.21
@@ -1,6 +1,6 @@
Name: olpc-utils
Version: 0.87
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: OLPC utilities
URL: http://dev.laptop.org/git?p=projects/olpc-utils;a=summary
Group: System Environment/Base
@@ -8,6 +8,8 @@
Source0: %{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+Patch0: diskspace.patch
+
# for olpc-dm
BuildRequires: pam-devel
Requires: pam
@@ -28,7 +30,7 @@
%prep
%setup -q
-
+%patch0 -p1
%build
make -f Makefile.build %{?_smp_mflags}
@@ -42,12 +44,14 @@
%post
/sbin/chkconfig --add olpc-configure
/sbin/chkconfig --add diskspacecheck
+/sbin/chkconfig --add diskspacerecover
%preun
if [ $1 = 0 ]; then
/sbin/chkconfig --del olpc-configure
/sbin/chkconfig --del diskspacecheck
+ /sbin/chkconfig --del diskspacerecover
fi
@@ -73,6 +77,7 @@
%{_sysconfdir}/cron.d/olpc-pwr-prof.cron
%{_sysconfdir}/rc.d/init.d/olpc-configure
%{_sysconfdir}/rc.d/init.d/diskspacecheck
+%{_sysconfdir}/rc.d/init.d/diskspacerecover
%config(noreplace) %{_sysconfdir}/hal/fdi/policy/x11-input.fdi
%config(noreplace) %{_sysconfdir}/motd.olpc
%config(noreplace) %{_sysconfdir}/X11/xorg-dcon.conf
@@ -85,6 +90,10 @@
%config(noreplace) %{_sysconfdir}/ConsoleKit/run-session.d/pam-foreground-compat.ck
%changelog
+* Mon Sep 29 2008 C. Scott Ananian <cscott at laptop.org> 0.87-2
+- Chris Ball (1):
+ dlo#7932: Fix failsafe script in the presence of pretty-boot.
+
* Tue Sep 23 2008 Michael Stone <michael at laptop.org> 0.87-1
- Chris Ball (1):
dlo#7932: Set up utf8 environment, and display a UTF-8 string.
- Previous message (by thread): rpms/tclx/devel tclx.spec,1.22,1.23
- Next message (by thread): rpms/workrave/devel .cvsignore, 1.6, 1.7 sources, 1.6, 1.7 workrave.spec, 1.16, 1.17 workrave-1.8.5-gcc43.patch, 1.1, NONE workrave-1.8.5-lock.patch, 1.1, NONE workrave-1.8.5-sigc.patch, 1.2, NONE workrave.desktop, 1.2, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-extras-commits
mailing list