This leaves in isys.c: a call to sync(), a call to settimeofday(), a function that returns the version from some CFLAGS, and a SIGSEGV handler. The first can be removed when we move to Python 3.
David Shea (4): Convert isys.isIsoImage to python code Remove isys.isPseudoTTY Added a note about when and how to remove isys.sync Remove a bunch of unused includes and tests for headers
configure.ac | 50 ++--------------------------- pyanaconda/isys/Makefile.am | 16 ++-------- pyanaconda/isys/__init__.py | 17 +++++++--- pyanaconda/isys/isofs.c | 57 --------------------------------- pyanaconda/isys/isys.c | 77 +-------------------------------------------- pyanaconda/isys/isys.h | 31 ------------------ widgets/configure.ac | 2 +- 7 files changed, 20 insertions(+), 230 deletions(-) delete mode 100644 pyanaconda/isys/isofs.c delete mode 100644 pyanaconda/isys/isys.h
This removes the need for isys.h and brings the _isys module down to a single C file. --- pyanaconda/isys/Makefile.am | 10 +------- pyanaconda/isys/__init__.py | 13 ++++++++++- pyanaconda/isys/isofs.c | 57 --------------------------------------------- pyanaconda/isys/isys.c | 17 -------------- pyanaconda/isys/isys.h | 31 ------------------------ 5 files changed, 13 insertions(+), 115 deletions(-) delete mode 100644 pyanaconda/isys/isofs.c delete mode 100644 pyanaconda/isys/isys.h
diff --git a/pyanaconda/isys/Makefile.am b/pyanaconda/isys/Makefile.am index 8a26aa7..0253491 100644 --- a/pyanaconda/isys/Makefile.am +++ b/pyanaconda/isys/Makefile.am @@ -19,8 +19,6 @@
pkgpyexecdir = $(pyexecdir)/py$(PACKAGE_NAME)
-ISYS_SRCS = isofs.c - dist_noinst_HEADERS = $(srcdir)/*.h
ISYS_CFLAGS = -DVERSION_RELEASE='"$(PACKAGE_VERSION)-$(PACKAGE_RELEASE)"' \ @@ -34,13 +32,7 @@ pkgpyexec_LTLIBRARIES = _isys.la _isys_la_CFLAGS = $(PYTHON_CFLAGS) $(ISYS_CFLAGS) _isys_la_LDFLAGS = -module -avoid-version _isys_la_LIBADD = $(PYTHON_LIBS) $(ISYS_LIBS) -_isys_la_SOURCES = isys.c $(ISYS_SRCS) - -noinst_LTLIBRARIES = libisys.la -libisys_la_CFLAGS = $(ISYS_CFLAGS) -libisys_la_LDFLAGS = -static -libisys_la_LIBADD = $(ISYS_LIBS) -libisys_la_SOURCES = $(ISYS_SRCS) +_isys_la_SOURCES = isys.c
auditddir = $(libexecdir)/$(PACKAGE_NAME) auditd_PROGRAMS = auditd diff --git a/pyanaconda/isys/__init__.py b/pyanaconda/isys/__init__.py index 5fb29f4..a1c7998 100644 --- a/pyanaconda/isys/__init__.py +++ b/pyanaconda/isys/__init__.py @@ -62,11 +62,22 @@ def isPseudoTTY (fd): def sync (): return _isys.sync ()
+ISO_BLOCK_SIZE = 2048 + ## Determine if a file is an ISO image or not. # @param file The full path to a file to check. # @return True if ISO image, False otherwise. def isIsoImage(path): - return _isys.isisoimage(path) + try: + with open(path, "rb") as isoFile: + for blockNum in range(16, 100): + isoFile.seek(blockNum * ISO_BLOCK_SIZE + 1) + if isoFile.read(5) == "CD001": + return True + except IOError: + pass + + return False
isPAE = None def isPaeAvailable(): diff --git a/pyanaconda/isys/isofs.c b/pyanaconda/isys/isofs.c deleted file mode 100644 index f144114..0000000 --- a/pyanaconda/isys/isofs.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * isofs.c - * - * Copyright (C) 2007 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#include "config.h" - -#include <fcntl.h> -#include <string.h> -#include <unistd.h> - -#define BLOCK_SIZE 2048 - -/* returns 1 if file is an ISO, 0 otherwise */ -int fileIsIso(const char * file) { - int blkNum; - char magic[5]; - int fd; - - fd = open(file, O_RDONLY); - if (fd < 0) - return 0; - - for (blkNum = 16; blkNum < 100; blkNum++) { - if (lseek(fd, blkNum * BLOCK_SIZE + 1, SEEK_SET) < 0) { - close(fd); - return 0; - } - - if (read(fd, magic, sizeof(magic)) != sizeof(magic)) { - close(fd); - return 0; - } - - if (!strncmp(magic, "CD001", 5)) { - close(fd); - return 1; - } - } - - close(fd); - return 0; -} diff --git a/pyanaconda/isys/isys.c b/pyanaconda/isys/isys.c index 103967b..2a00471 100644 --- a/pyanaconda/isys/isys.c +++ b/pyanaconda/isys/isys.c @@ -67,15 +67,12 @@ #include <sys/sysmacros.h> #endif
-#include "isys.h" - #ifndef CDROMEJECT #define CDROMEJECT 0x5309 #endif
static PyObject * doisPseudoTTY(PyObject * s, PyObject * args); static PyObject * doSync(PyObject * s, PyObject * args); -static PyObject * doisIsoImage(PyObject * s, PyObject * args); static PyObject * doSegvHandler(PyObject *s, PyObject *args); static PyObject * doGetAnacondaVersion(PyObject * s, PyObject * args); static PyObject * doSetSystemTime(PyObject *s, PyObject *args); @@ -83,7 +80,6 @@ static PyObject * doSetSystemTime(PyObject *s, PyObject *args); static PyMethodDef isysModuleMethods[] = { { "isPseudoTTY", (PyCFunction) doisPseudoTTY, METH_VARARGS, NULL}, { "sync", (PyCFunction) doSync, METH_VARARGS, NULL}, - { "isisoimage", (PyCFunction) doisIsoImage, METH_VARARGS, NULL}, { "handleSegv", (PyCFunction) doSegvHandler, METH_VARARGS, NULL }, { "getAnacondaVersion", (PyCFunction) doGetAnacondaVersion, METH_VARARGS, NULL }, { "set_system_time", (PyCFunction) doSetSystemTime, METH_VARARGS, NULL}, @@ -119,19 +115,6 @@ static PyObject * doSync(PyObject * s, PyObject * args) { return Py_None; }
-int fileIsIso(const char * file); - -static PyObject * doisIsoImage(PyObject * s, PyObject * args) { - char * fn; - int rc; - - if (!PyArg_ParseTuple(args, "s", &fn)) return NULL; - - rc = fileIsIso(fn); - - return Py_BuildValue("i", rc); -} - static PyObject * doSegvHandler(PyObject *s, PyObject *args) { void *array[20]; size_t size; diff --git a/pyanaconda/isys/isys.h b/pyanaconda/isys/isys.h deleted file mode 100644 index ad31f7b..0000000 --- a/pyanaconda/isys/isys.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * isys.h - * - * Copyright (C) 2007 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#ifndef H_ISYS -#define H_ISYS - -#define OUTPUT_TERMINAL "/dev/tty5" - -int insmod(char * modName, char * path, char ** args); -int rmmod(char * modName); - -/* returns 0 for true, !0 for false */ -int fileIsIso(const char * file); - -#endif
This function isn't used anywhere anymore --- pyanaconda/isys/__init__.py | 3 --- pyanaconda/isys/isys.c | 13 ------------- 2 files changed, 16 deletions(-)
diff --git a/pyanaconda/isys/__init__.py b/pyanaconda/isys/__init__.py index a1c7998..b1f16c6 100644 --- a/pyanaconda/isys/__init__.py +++ b/pyanaconda/isys/__init__.py @@ -55,9 +55,6 @@ else: MIN_GUI_RAM = MIN_RAM + GUI_INSTALL_EXTRA_RAM EARLY_SWAP_RAM = 896 * 1024
-def isPseudoTTY (fd): - return _isys.isPseudoTTY (fd) - ## Flush filesystem buffers. def sync (): return _isys.sync () diff --git a/pyanaconda/isys/isys.c b/pyanaconda/isys/isys.c index 2a00471..f20a064 100644 --- a/pyanaconda/isys/isys.c +++ b/pyanaconda/isys/isys.c @@ -71,14 +71,12 @@ #define CDROMEJECT 0x5309 #endif
-static PyObject * doisPseudoTTY(PyObject * s, PyObject * args); static PyObject * doSync(PyObject * s, PyObject * args); static PyObject * doSegvHandler(PyObject *s, PyObject *args); static PyObject * doGetAnacondaVersion(PyObject * s, PyObject * args); static PyObject * doSetSystemTime(PyObject *s, PyObject *args);
static PyMethodDef isysModuleMethods[] = { - { "isPseudoTTY", (PyCFunction) doisPseudoTTY, METH_VARARGS, NULL}, { "sync", (PyCFunction) doSync, METH_VARARGS, NULL}, { "handleSegv", (PyCFunction) doSegvHandler, METH_VARARGS, NULL }, { "getAnacondaVersion", (PyCFunction) doGetAnacondaVersion, METH_VARARGS, NULL }, @@ -94,17 +92,6 @@ void init_isys(void) { Py_InitModule("_isys", isysModuleMethods); }
-static PyObject * doisPseudoTTY(PyObject * s, PyObject * args) { - int fd; - struct stat sb; - - if (!PyArg_ParseTuple(args, "i", &fd)) return NULL; - fstat(fd, &sb); - - /* XXX close enough for now */ - return Py_BuildValue("i", ((major(sb.st_rdev) >= 136) && (major(sb.st_rdev) <= 143))); -} - static PyObject * doSync(PyObject * s, PyObject * args) { int fd;
--- pyanaconda/isys/__init__.py | 1 + 1 file changed, 1 insertion(+)
diff --git a/pyanaconda/isys/__init__.py b/pyanaconda/isys/__init__.py index b1f16c6..c216428 100644 --- a/pyanaconda/isys/__init__.py +++ b/pyanaconda/isys/__init__.py @@ -57,6 +57,7 @@ EARLY_SWAP_RAM = 896 * 1024
## Flush filesystem buffers. def sync (): + # TODO: This can be replaced with os.sync in Python 3.3 return _isys.sync ()
ISO_BLOCK_SIZE = 2048
On Mon, 2014-02-24 at 09:27 -0500, David Shea wrote:
pyanaconda/isys/__init__.py | 1 + 1 file changed, 1 insertion(+)
diff --git a/pyanaconda/isys/__init__.py b/pyanaconda/isys/__init__.py index b1f16c6..c216428 100644 --- a/pyanaconda/isys/__init__.py +++ b/pyanaconda/isys/__init__.py @@ -57,6 +57,7 @@ EARLY_SWAP_RAM = 896 * 1024
## Flush filesystem buffers. def sync ():
- # TODO: This can be replaced with os.sync in Python 3.3 return _isys.sync ()
We could just call it from libc:
# TODO: replace this with os.sync() in Python 3.3 import ctypes libc = ctypes.CDLL("libc.so.6") libc.sync()
and then we don't have to wait for Python 3.3! Whee!
-w
Most of isys.c is no longer relevant, and a fair amount of the autoconf tests are for things that used to be in isys or loader or other code that is no longer with us. Also anaconda barely links to anything through C, so there's no need to pull in a bunch of CFLAGS and LDFLAGS for various packages. Moved the one actual bit of information from all that--the required Gtk version--to widgets, where the newer Gtk functionality is actually used. --- configure.ac | 50 ++------------------------------------------- pyanaconda/isys/Makefile.am | 6 ++---- pyanaconda/isys/isys.c | 47 +----------------------------------------- widgets/configure.ac | 2 +- 4 files changed, 6 insertions(+), 99 deletions(-)
diff --git a/configure.ac b/configure.ac index dd7efd6..97b78cc 100644 --- a/configure.ac +++ b/configure.ac @@ -68,62 +68,23 @@ AM_GNU_GETTEXT([external]) # Also update in gettextver in anaconda.spec.in AM_GNU_GETTEXT_VERSION([0.18.3])
-# Checks for libraries. -AC_CHECK_LIB([X11], [XGetWindowAttributes], - [AC_SUBST(X11_LIBS, [-lX11])], - [AC_MSG_FAILURE([*** libX11 not usable.])]) - -AC_CHECK_LIB([audit], [audit_open], - [AC_SUBST(AUDIT_LIBS, [-laudit])], - [AC_MSG_FAILURE([*** libaudit not usable.])]) - -AC_CHECK_LIB([z], [zlibVersion], - [AC_SUBST(ZLIB_LIBS, [-lz])], - [AC_MSG_FAILURE([*** libz not usable.])]) - # Checks for header files. AC_PATH_X -AC_FUNC_ALLOCA -AC_HEADER_RESOLV -AC_HEADER_MAJOR -AC_CHECK_HEADERS([argz.h arpa/inet.h fcntl.h inttypes.h libintl.h limits.h \ - malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h \ - string.h strings.h sys/ioctl.h sys/mount.h sys/param.h \ - sys/socket.h sys/time.h sys/vfs.h syslog.h termios.h \ - unistd.h utime.h wchar.h], +AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h], [], [AC_MSG_FAILURE([*** Header file $ac_header not found.])], [])
# Checks for typedefs, structures, and compiler characteristics. -AC_TYPE_UID_T -AC_C_INLINE -AC_TYPE_INT32_T -AC_TYPE_MODE_T -AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_SSIZE_T -AC_CHECK_MEMBERS([struct stat.st_rdev]) -AC_TYPE_UINT16_T AC_TYPE_UINT32_T -AC_TYPE_UINT64_T -AC_TYPE_UINT8_T AC_TYPE_INT64_T
# Checks for library functions. -AC_FUNC_CHOWN -AC_FUNC_ERROR_AT_LINE AC_FUNC_FORK -AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK -AC_FUNC_MALLOC -AC_FUNC_MMAP -AC_FUNC_REALLOC -AC_CHECK_FUNCS([dup2 fdatasync ftruncate getcwd gethostbyname gettimeofday \ - lchown memmove memset mkdir mkfifo munmap realpath select \ - setenv sethostname socket strcasecmp strchr strcspn strdup \ - strerror strncasecmp strndup strrchr strstr strtol strtoul \ - strverscmp uname utime wcwidth], +AC_CHECK_FUNCS([getcwd memset mkdir strchr strdup], [], [AC_MSG_FAILURE([*** Required function $ac_func not found.])])
@@ -144,13 +105,6 @@ PKG_CHECK_MODULES([PYTHON], [python], [
# Check for libraries we need that provide pkg-config scripts PKG_PROG_PKG_CONFIG([0.23]) -PKG_CHECK_MODULES([X11], [x11 >= 1.3]) -PKG_CHECK_MODULES([XCOMPOSITE], [xcomposite >= 0.4.1]) -PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.16.1]) -PKG_CHECK_MODULES([GTK_X11], [gtk+-x11-3.0 >= 3.11.3]) -PKG_CHECK_MODULES([GDK], [gdk-3.0]) -PKG_CHECK_MODULES([NETWORKMANAGER], [NetworkManager >= 0.7.1]) -PKG_CHECK_MODULES([LIBNM_GLIB], [libnm-glib >= 0.7.1 libnm-util >= 0.7.1]) PKG_CHECK_MODULES([RPM], [rpm >= 4.10.0]) PKG_CHECK_MODULES([LIBARCHIVE], [libarchive >= 3.0.4])
diff --git a/pyanaconda/isys/Makefile.am b/pyanaconda/isys/Makefile.am index 0253491..bd3e36f 100644 --- a/pyanaconda/isys/Makefile.am +++ b/pyanaconda/isys/Makefile.am @@ -21,9 +21,7 @@ pkgpyexecdir = $(pyexecdir)/py$(PACKAGE_NAME)
dist_noinst_HEADERS = $(srcdir)/*.h
-ISYS_CFLAGS = -DVERSION_RELEASE='"$(PACKAGE_VERSION)-$(PACKAGE_RELEASE)"' \ - $(LIBNL_CFLAGS) $(GLIB_CFLAGS) -ISYS_LIBS = $(DEVMAPPER_LIBS) $(LIBNL_LIBS) $(GLIB_LIBS) +ISYS_CFLAGS = -DVERSION_RELEASE='"$(PACKAGE_VERSION)-$(PACKAGE_RELEASE)"'
isysdir = $(pkgpyexecdir)/isys isys_PYTHON = $(srcdir)/*.py @@ -31,7 +29,7 @@ isys_PYTHON = $(srcdir)/*.py pkgpyexec_LTLIBRARIES = _isys.la _isys_la_CFLAGS = $(PYTHON_CFLAGS) $(ISYS_CFLAGS) _isys_la_LDFLAGS = -module -avoid-version -_isys_la_LIBADD = $(PYTHON_LIBS) $(ISYS_LIBS) +_isys_la_LIBADD = $(PYTHON_LIBS) _isys_la_SOURCES = isys.c
auditddir = $(libexecdir)/$(PACKAGE_NAME) diff --git a/pyanaconda/isys/isys.c b/pyanaconda/isys/isys.c index f20a064..c9a7ff5 100644 --- a/pyanaconda/isys/isys.c +++ b/pyanaconda/isys/isys.c @@ -22,54 +22,12 @@ #include <Python.h>
#include <stdio.h> -#include <dirent.h> -#include <errno.h> -#define u32 __u32 -#include <fcntl.h> -/* Need to tell loop.h what the actual dev_t type is. */ -#undef dev_t -#if defined(__alpha) -#define dev_t unsigned int -#else -#if defined(__x86_64__) -#define dev_t unsigned long -#else -#define dev_t unsigned short -#endif -#endif -#include <linux/loop.h> -#undef dev_t -#define dev_t dev_t -#include <sys/ioctl.h> -#include <sys/stat.h> -#include <sys/sysmacros.h> #include <sys/time.h> -#include <sys/utsname.h> -#include <sys/vfs.h> #include <unistd.h> -#include <sys/vt.h> #include <sys/types.h> -#include <sys/socket.h> -#include <arpa/inet.h> -#include <linux/fb.h> -#include <libintl.h> -#include <libgen.h> -#include <linux/cdrom.h> -#include <linux/major.h> #include <signal.h> #include <execinfo.h> - -#ifdef MAJOR_IN_MKDEV -#include <sys/mkdev.h> -#endif - -#ifdef MAJOR_IN_SYSMACROS -#include <sys/sysmacros.h> -#endif - -#ifndef CDROMEJECT -#define CDROMEJECT 0x5309 -#endif +#include <stdlib.h>
static PyObject * doSync(PyObject * s, PyObject * args); static PyObject * doSegvHandler(PyObject *s, PyObject *args); @@ -84,9 +42,6 @@ static PyMethodDef isysModuleMethods[] = { { NULL, NULL, 0, NULL } } ;
-#define BOOT_SIGNATURE 0xaa55 /* boot signature */ -#define BOOT_SIG_OFFSET 510 /* boot signature offset */ - /* cppcheck-suppress unusedFunction */ void init_isys(void) { Py_InitModule("_isys", isysModuleMethods); diff --git a/widgets/configure.ac b/widgets/configure.ac index 87ae7fe..d24f8eb 100644 --- a/widgets/configure.ac +++ b/widgets/configure.ac @@ -53,7 +53,7 @@ m4_pattern_forbid([GTK_DOC_CHECK])dnl GTK_DOC_CHECK([1.14], [--flavour no-tmpl])
PKG_CHECK_MODULES([GLADEUI], [gladeui-2.0 >= 3.10]) -PKG_CHECK_MODULES([GTK], [gtk+-x11-3.0 >= 3.0]) +PKG_CHECK_MODULES([GTK], [gtk+-x11-3.0 >= 3.11.3]) PKG_CHECK_MODULES([GLIB], [glib-2.0]) PKG_CHECK_MODULES([LIBXKLAVIER], [libxklavier >= 5.2.1]) PKG_CHECK_EXISTS([gobject-introspection-1.0 >= 1.30])
On Mon, 2014-02-24 at 09:27 -0500, David Shea wrote:
This leaves in isys.c: a call to sync(), a call to settimeofday(), a function that returns the version from some CFLAGS, and a SIGSEGV handler. The first can be removed when we move to Python 3.
David Shea (4): Convert isys.isIsoImage to python code Remove isys.isPseudoTTY Added a note about when and how to remove isys.sync Remove a bunch of unused includes and tests for headers
configure.ac | 50 ++--------------------------- pyanaconda/isys/Makefile.am | 16 ++-------- pyanaconda/isys/__init__.py | 17 +++++++--- pyanaconda/isys/isofs.c | 57 --------------------------------- pyanaconda/isys/isys.c | 77 +-------------------------------------------- pyanaconda/isys/isys.h | 31 ------------------ widgets/configure.ac | 2 +- 7 files changed, 20 insertions(+), 230 deletions(-) delete mode 100644 pyanaconda/isys/isofs.c delete mode 100644 pyanaconda/isys/isys.h
These all look fine. ACK!
-w
(An aside: we could probably replace the CFLAGS stuff with a little autoconf junk somewhere else and use ctypes to call settimeofday()..
Not really sure about that SIGSEGV handler though. But surely we can do that in Python these days?)
anaconda-patches@lists.fedorahosted.org