static int pakfire_dist_add_sources(struct pakfire* pakfire, struct pakfire_packager* packager,
struct pakfire_package* pkg, struct pakfire_parser* makefile) {
+ char* sources = NULL;
+ char* p = NULL;
+ int r;
+
// Fetch sources
- char** sources = pakfire_parser_get_split(makefile, NULL, "sources", ' ');
+ sources = pakfire_parser_get(makefile, NULL, "sources");
// Nothing to do if this variable is empty
if (!sources)
- return 1;
+ return 0;
struct pakfire_downloader* downloader = NULL;
struct pakfire_mirrorlist* mirrorlist = NULL;
goto ERROR;
// Add all files one by one
- for (char** source = sources; *source; source++) {
- DEBUG(pakfire, "Adding source file %s\n", *source);
+ // Add all mirrors
+ const char* source = strtok_r(sources, " ", &p);
+ while (source) {
+ DEBUG(pakfire, "Adding source file %s\n", source);
- r = pakfire_dist_add_source(pakfire, packager, pkg, downloader, mirrorlist, *source);
+ r = pakfire_dist_add_source(pakfire, packager, pkg, downloader, mirrorlist, source);
if (r) {
- ERROR(pakfire, "Could not add '%s' to package: %m\n", *source);
+ ERROR(pakfire, "Could not add '%s' to package: %m\n", source);
goto ERROR;
}
+
+ source = strtok_r(NULL, " ", &p);
}
// Success
pakfire_downloader_unref(downloader);
if (mirrorlist)
pakfire_mirrorlist_unref(mirrorlist);
-
- if (sources) {
- for (char** source = sources; *source; source++)
- free(*source);
+ if (sources)
free(sources);
- }
return r;
}