src/scripts/find-prerequires \
src/scripts/find-provides \
src/scripts/find-requires \
+ src/scripts/mkimage \
src/scripts/perl.prov \
src/scripts/perl.req \
src/scripts/strip
return ret;
}
+static PyObject* Pakfire_mkimage(PakfireObject* self, PyObject* args, PyObject* kwargs) {
+ char* kwlist[] = {
+ "type",
+ "path",
+ NULL,
+ };
+ struct pakfire_build* build = NULL;
+ const char* type = NULL;
+ const char* path = NULL;
+ int r;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss", kwlist, &type, &path))
+ return NULL;
+
+ // Create a new build environment
+ r = pakfire_build_create(&build, self->pakfire, NULL, 0);
+ if (r) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ goto ERROR;
+ }
+
+ Py_BEGIN_ALLOW_THREADS
+
+ // Run mkimage
+ r = pakfire_build_mkimage(build, type, path);
+ if (r) {
+ Py_BLOCK_THREADS;
+
+ if (r < 0)
+ PyErr_SetFromErrno(PyExc_OSError);
+
+ goto ERROR;
+ }
+
+ Py_END_ALLOW_THREADS
+
+ERROR:
+ if (build)
+ pakfire_build_unref(build);
+ if (r)
+ return NULL;
+
+ Py_RETURN_NONE;
+}
+
static struct PyMethodDef Pakfire_methods[] = {
{
"build",
METH_VARARGS|METH_KEYWORDS,
NULL,
},
+ {
+ "mkimage",
+ (PyCFunction)Pakfire_mkimage,
+ METH_VARARGS|METH_KEYWORDS,
+ NULL
+ },
{
"open",
(PyCFunction)Pakfire_open,
return r;
}
+PAKFIRE_EXPORT int pakfire_build_mkimage(struct pakfire_build* build,
+ const char* type, const char* filename) {
+ int r;
+
+ // Check inputs
+ if (!type || !filename) {
+ errno = EINVAL;
+ return 1;
+ }
+
+ // Initialize the build environment
+ r = pakfire_build_init(build);
+ if (r)
+ goto ERROR;
+
+ // XXX Allocate a temporary file
+
+ const char* args[] = {
+ type,
+ // XXX tempfile
+ NULL,
+ };
+
+ // Run the mkimage script
+ r = pakfire_build_run_script(build, "mkimage", args, NULL, NULL, NULL);
+ if (r)
+ goto ERROR;
+
+ERROR:
+ // XXX remove the tempfile
+
+ return r;
+}
+
int pakfire_build_clean(struct pakfire* pakfire, int flags) {
struct pakfire_repo* local = NULL;
int r = 0;
int pakfire_build_exec(struct pakfire_build* build, const char* path);
+int pakfire_build_mkimage(struct pakfire_build* build,
+ const char* type, const char* filename);
+
int pakfire_build_clean(struct pakfire* pakfire, int flags);
int pakfire_shell(struct pakfire* pakfire, const char** packages, int flags);
# build
pakfire_build_create;
pakfire_build_exec;
+ pakfire_build_mkimage;
pakfire_build_ref;
pakfire_build_set_ccache_path;
pakfire_build_set_target;
--- /dev/null
+#!/bin/bash
+###############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2021 Pakfire development team #
+# #
+# 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 3 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/>. #
+# #
+###############################################################################
+
+mkimage_installer_iso() {
+ echo "TODO"
+}
+
+main() {
+ local type="${1}"
+ local path="${2}"
+
+ case "${type}" in
+ installer-iso)
+ "mkimage_${type//-/_}" "${path}" || return $?
+ ;;
+
+ *)
+ echo "Unknown image type: ${type}" >&2
+ return 2
+ ;;
+ esac
+
+ return 0
+}
+
+main "$@" || exit $?
extract.add_argument("--path", help=_("Extract the archive into this path"))
extract.set_defaults(func=self._extract)
+ # image
+ image = subparsers.add_parser("image", help=_("Commands to manipulate images"))
+ image_subparsers = image.add_subparsers()
+
+ # image create
+ image_create = image_subparsers.add_parser("create", help=_("Create a new image"))
+ image_create.set_defaults(func=self._image_create)
+ image_create.add_argument("type", help=_("Image Type"))
+ image_create.add_argument("path", help=_("Image Path"))
+
# info
info = subparsers.add_parser("info",
help=_("Print some information about the given package(s)"))
except pakfire.errors.CommandExecutionError as e:
return e.args[0]
+ # Images
+
+ def _image_create(self, ns):
+ """
+ Creates a new image
+ """
+ # Setup Pakfire
+ p = self.pakfire(ns)
+
+ # Run mkimage()
+ p.mkimage(type=ns.type, path=ns.path)
+
if __name__ == "__main__":
c = Cli()