Add ENABLE_COMPLEX_DEPS flag
[platform/upstream/libsolv.git] / tools / conda2solv.c
1 /*
2  * Copyright (c) 2019, SUSE LLC
3  *
4  * This program is licensed under the BSD license, read LICENSE.BSD
5  * for further information
6  */
7
8 /*
9  * conda2solv.c
10  *
11  * parse a conda repository file
12  *
13  * reads from stdin
14  * writes to stdout
15  */
16
17 #include <sys/types.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <unistd.h>
22
23 #include "pool.h"
24 #include "repo.h"
25 #include "repo_conda.h"
26 #include "solv_xfopen.h"
27 #include "common_write.h"
28
29
30 static void
31 usage(int status)
32 {
33   fprintf(stderr, "\nUsage:\n"
34           "conda2solv\n"
35           "  reads a conda repository from <stdin> and writes a .solv file to <stdout>\n"
36           "  -S : include signature data\n"
37           "  -h : print help & exit\n"
38          );
39    exit(status);
40 }
41
42 int
43 main(int argc, char **argv)
44 {
45   Pool *pool;
46   Repo *repo;
47   int c;
48   int flags = 0;
49
50   while ((c = getopt(argc, argv, "hS")) >= 0)
51     {
52       switch(c)
53         {
54         case 'h':
55           usage(0);
56           break;
57         case 'S':
58           flags |= CONDA_ADD_WITH_SIGNATUREDATA;
59           break;
60         default:
61           usage(1);
62           break;
63         }
64     }
65   pool = pool_create();
66   repo = repo_create(pool, "<stdin>");
67   if (repo_add_conda(repo, stdin, flags))
68     {
69       fprintf(stderr, "conda2solv: %s\n", pool_errstr(pool));
70       exit(1);
71     }
72   repo_internalize(repo);
73   tool_write(repo, stdout);
74   pool_free(pool);
75   exit(0);
76 }