Commits

Michał Górny  committed ccb129d

Initialize the codebase.

  • Participants

Comments (0)

Files changed (4)

+/build/
+Copyright (c) 2012, Michał Górny
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+   this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.

File pymountboot.cxx

+#include <Python.h>
+
+typedef struct {
+	PyObject_HEAD
+} BootMountpoint;
+
+static void BootMountpoint_dealloc(PyObject *o);
+static PyObject *BootMountpoint_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
+
+static PyTypeObject BootMountpointType = {
+	PyObject_HEAD_INIT(NULL)
+	0, /* ob_size */
+	"pymountboot.BootMountpoint", /* tp_name */
+	sizeof(BootMountpoint), /* tp_basicsize */
+	0, /* tp_itemsize */
+	BootMountpoint_dealloc, /* tp_dealloc */
+	0, /* tp_print */
+	0, /* tp_getattr */
+	0, /* tp_setattr */
+	0, /* tp_compare */
+	0, /* tp_repr */
+	0, /* tp_as_number */
+	0, /* tp_as_sequence */
+	0, /* tp_as_mapping */
+	0, /* tp_hash  */
+	0, /* tp_call */
+	0, /* tp_str */
+	0, /* tp_getattro */
+	0, /* tp_setattro */
+	0, /* tp_as_buffer */
+	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+	"/boot mount point", /* tp_doc */
+	0, /* tp_traverse */
+	0, /* tp_clear */
+	0, /* tp_richcompare */
+	0, /* tp_weaklistoffset */
+	0, /* tp_iter */
+	0, /* tp_iternext */
+	0, /* tp_methods */
+	0, /* tp_members */
+	0, /* tp_getset */
+	0, /* tp_base */
+	0, /* tp_dict */
+	0, /* tp_descr_get */
+	0, /* tp_descr_set */
+	0, /* tp_dictoffset */
+	0, /* tp_init */
+	0, /* tp_alloc */
+	BootMountpoint_new /* tp_new */
+};
+
+static PyMethodDef pymountboot_methods[] = {
+	{ NULL }
+};
+
+#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
+#	define PyMODINIT_FUNC void
+#endif
+
+extern "C" {
+	PyMODINIT_FUNC initpymountboot(void);
+};
+
+PyMODINIT_FUNC initpymountboot(void) {
+	PyObject *m;
+
+	if (PyType_Ready(&BootMountpointType) < 0)
+		return;
+
+	m = Py_InitModule3("pymountboot", pymountboot_methods,
+		"Module used to handle /boot auto(re)mounting.");
+
+	Py_INCREF(&BootMountpointType);
+	PyModule_AddObject(m, "BootMountpoint", (PyObject *)&BootMountpointType);
+}
+
+static void BootMountpoint_dealloc(PyObject *o) {
+	BootMountpoint *b = reinterpret_cast<BootMountpoint*>(o);
+}
+
+static PyObject *BootMountpoint_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
+	PyObject *self;
+
+	self = type->tp_alloc(type, 0);
+
+	if (self != NULL) {
+		BootMountpoint *b = reinterpret_cast<BootMountpoint*>(self);
+	}
+
+	return self;
+}
+#!/usr/bin/python
+#	vim:fileencoding=utf-8
+# (c) 2012 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+from distutils.core import setup, Extension
+
+import subprocess
+
+def pkgconfig_get(*args):
+	output = subprocess.check_output(('pkg-config',) + args)
+	return output.decode('utf8').strip().split()
+
+cflags, libs = [pkgconfig_get(x, 'mount') for x in ('--cflags', '--libs')]
+
+setup(
+		name = 'pyremountboot',
+		version = '0',
+		author = 'Michał Górny',
+		author_email = 'mgorny@gentoo.org',
+		url = 'http://github.com/mgorny/pyremountboot',
+
+		ext_modules = [
+			Extension('pymountboot',
+				extra_compile_args = cflags,
+				extra_link_args = libs,
+				sources = ['pymountboot.cxx'])
+		],
+
+		classifiers = [
+			'Development Status :: 3 - Alpha',
+			'Environment :: Console',
+			'Intended Audience :: System Administrators',
+			'License :: OSI Approved :: BSD License',
+			'Operating System :: POSIX :: Linux',
+			'Programming Language :: C++',
+			'Topic :: System :: Filesystems'
+		]
+)