src/pakfire/mirrorlist.h \
src/pakfire/mount.c \
src/pakfire/mount.h \
+ src/pakfire/oci.c \
+ src/pakfire/oci.h \
src/pakfire/os.c \
src/pakfire/os.h \
src/pakfire/package.c \
#include <argp.h>
#include <pakfire/build.h>
+#include <pakfire/oci.h>
#include <pakfire/pakfire.h>
+#include <pakfire/string.h>
#include "command.h"
#include "image_create.h"
static const char* doc = "Creates images";
+const char* packages[] = {
+ "system-release",
+ NULL,
+};
+
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
struct cli_local_args* args = data;
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
struct pakfire_build* build = NULL;
+ struct pakfire* pakfire = NULL;
FILE* f = NULL;
int r;
goto ERROR;
}
- // Setup the build environment
- r = cli_setup_build(&build, global_args, 0);
- if (r < 0)
- goto ERROR;
-
- // Create the image
- r = pakfire_build_mkimage(build, local_args.type, f);
- if (r)
- goto ERROR;
+ // Handle OCI images separately
+ if (pakfire_string_equals(local_args.type, "oci")) {
+ // Setup Pakfire
+ r = cli_setup_pakfire(&pakfire, global_args);
+ if (r < 0)
+ goto ERROR;
+
+ // Install everything
+ r = pakfire_install(pakfire, packages);
+ if (r < 0)
+ goto ERROR;
+
+ // Create the image
+ r = pakfire_oci_mkimage(pakfire, f);
+ if (r < 0)
+ goto ERROR;
+
+ // For the rest, launch a build environment
+ } else {
+ // Setup the build environment
+ r = cli_setup_build(&build, global_args, 0);
+ if (r < 0)
+ goto ERROR;
+
+ // Create the image
+ r = pakfire_build_mkimage(build, local_args.type, f);
+ if (r)
+ goto ERROR;
+ }
ERROR:
if (build)
pakfire_build_unref(build);
+ if (pakfire)
+ pakfire_unref(pakfire);
if (f)
fclose(f);
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2025 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/>. #
+# #
+#############################################################################*/
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <pakfire/compress.h>
+#include <pakfire/filelist.h>
+#include <pakfire/i18n.h>
+#include <pakfire/logging.h>
+#include <pakfire/oci.h>
+#include <pakfire/pakfire.h>
+
+int pakfire_oci_mkimage(struct pakfire* pakfire, FILE* f) {
+ struct pakfire_filelist* filelist = NULL;
+ struct archive* archive = NULL;
+ int r;
+
+ // Fetch the pakfire root
+ const char* root = pakfire_get_path(pakfire);
+
+ // Create a new filelist
+ r = pakfire_filelist_create(&filelist, pakfire);
+ if (r < 0)
+ goto ERROR;
+
+ // Scan for all files
+ r = pakfire_filelist_scan(filelist, root, NULL, NULL, 0);
+ if (r < 0)
+ goto ERROR;
+
+ // Create a new archive
+ r = pakfire_compress_create_archive(pakfire, &archive, f, PAKFIRE_COMPRESS_GZIP, 9);
+ if (r < 0)
+ goto ERROR;
+
+ // Write all files to the image
+ r = pakfire_compress(pakfire, archive, filelist,
+ _("Creating Image"), PAKFIRE_COMPRESS_SHOW_THROUGHPUT, 0);
+ if (r < 0)
+ goto ERROR;
+
+ // Close archive
+ r = archive_write_close(archive);
+ if (r) {
+ //ERROR(pakfire, "Could not close archive: %s\n", archive_error_string(archive));
+ goto ERROR;
+ }
+
+ERROR:
+ if (filelist)
+ pakfire_filelist_unref(filelist);
+ if (archive)
+ archive_free(archive);
+
+ return r;
+}
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2025 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/>. #
+# #
+#############################################################################*/
+
+#ifndef PAKFIRE_OCI_H
+#define PAKFIRE_OCI_H
+
+#include <stdio.h>
+
+#include <pakfire/pakfire.h>
+
+int pakfire_oci_mkimage(struct pakfire* pakfire, FILE* f);
+
+#endif /* PAKFIRE_OCI_H */