2 * Copyright (c) 2012, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
9 * archpkgs2solv - create a solv file from multiple arch packages
13 #include <sys/types.h>
22 #include "repo_arch.h"
23 #include "repo_solv.h"
24 #include "common_write.h"
27 fgets0(char *s, int size, FILE *stream)
50 main(int argc, char **argv)
52 const char **pkgs = 0;
55 int i, c, res, npkgs = 0;
56 Pool *pool = pool_create();
60 const char *basefile = 0;
63 while ((c = getopt(argc, argv, "0b:m:i")) >= 0)
77 flags |= ARCH_ADD_WITH_PKGID;
85 if (!strcmp(manifest, "-"))
87 else if ((fp = fopen(manifest, "r")) == 0)
96 if (!fgets0(buf, sizeof(buf), fp))
101 if (!fgets(buf, sizeof(buf), fp))
103 if ((p = strchr(buf, '\n')) != 0)
106 pkgs = solv_extend(pkgs, npkgs, 1, sizeof(char *), 15);
107 pkgs[npkgs++] = strdup(buf);
112 while (optind < argc)
114 pkgs = solv_extend(pkgs, npkgs, 1, sizeof(char *), 15);
115 pkgs[npkgs++] = solv_strdup(argv[optind++]);
117 repo = repo_create(pool, "archpkgs2solv");
118 repo_add_repodata(repo, 0);
120 for (i = 0; i < npkgs; i++)
121 if (repo_add_arch_pkg(repo, pkgs[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE|flags) == 0)
123 fprintf(stderr, "archpkgs2solv: %s\n", pool_errstr(pool));
126 repo_internalize(repo);
127 tool_write(repo, basefile, 0);
129 for (c = 0; c < npkgs; c++)
130 solv_free((char *)pkgs[c]);