}
// Add all files to the package
- for (unsigned int i = 0; i < length; i++) {
- struct pakfire_file* file = pakfire_filelist_get(filelist, i);
-
- // Add the file to the package
- r = pakfire_packager_add_file(packager, file);
- if (r) {
- pakfire_file_unref(file);
- goto ERROR;
- }
-
- // Remove the file after it was packaged
- r = pakfire_file_cleanup(file);
- if (r) {
- pakfire_file_unref(file);
- goto ERROR;
- }
-
- pakfire_file_unref(file);
- }
+ r = pakfire_packager_add_files(packager, filelist, 1);
+ if (r)
+ goto ERROR;
ERROR:
if (filelist)
#ifdef PAKFIRE_PRIVATE
#include <pakfire/file.h>
+#include <pakfire/filelist.h>
#include <pakfire/package.h>
#include <pakfire/scriptlet.h>
int pakfire_packager_add_file(
struct pakfire_packager* packager, struct pakfire_file* file);
+int pakfire_packager_add_files(struct pakfire_packager* packager,
+ struct pakfire_filelist* filelist, int cleanup);
int pakfire_packager_add(struct pakfire_packager* packager,
const char* sourcepath, const char* path);
return r;
}
+int pakfire_packager_add_files(struct pakfire_packager* packager,
+ struct pakfire_filelist* filelist, int cleanup) {
+ struct pakfire_file* file = NULL;
+ int r;
+
+ // Fetch length of the filelist
+ const size_t length = pakfire_filelist_size(filelist);
+
+ // Add all files to the package
+ for (unsigned int i = 0; i < length; i++) {
+ file = pakfire_filelist_get(filelist, i);
+
+ // Add the file to the package
+ r = pakfire_packager_add_file(packager, file);
+ if (r) {
+ pakfire_file_unref(file);
+ goto ERROR;
+ }
+
+ // Remove the file after it was packaged
+ if (cleanup) {
+ r = pakfire_file_cleanup(file);
+ if (r) {
+ pakfire_file_unref(file);
+ goto ERROR;
+ }
+ }
+
+ pakfire_file_unref(file);
+ }
+
+ERROR:
+ return r;
+}
+
int pakfire_packager_add_scriptlet(struct pakfire_packager* packager,
struct pakfire_scriptlet* scriptlet) {
if (!scriptlet) {