File: conda2solv.c

package info (click to toggle)
libsolv 0.7.36-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,804 kB
  • sloc: ansic: 73,124; python: 871; perl: 742; tcl: 730; ruby: 705; sh: 263; cpp: 204; makefile: 42
file content (76 lines) | stat: -rw-r--r-- 1,329 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * Copyright (c) 2019, SUSE LLC
 *
 * This program is licensed under the BSD license, read LICENSE.BSD
 * for further information
 */

/*
 * conda2solv.c
 *
 * parse a conda repository file
 *
 * reads from stdin
 * writes to stdout
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include "pool.h"
#include "repo.h"
#include "repo_conda.h"
#include "solv_xfopen.h"
#include "common_write.h"


static void
usage(int status)
{
  fprintf(stderr, "\nUsage:\n"
          "conda2solv\n"
          "  reads a conda repository from <stdin> and writes a .solv file to <stdout>\n"
          "  -S : include signature data\n"
          "  -h : print help & exit\n"
         );
   exit(status);
}

int
main(int argc, char **argv)
{
  Pool *pool;
  Repo *repo;
  int c;
  int flags = 0;

  while ((c = getopt(argc, argv, "hS")) >= 0)
    {
      switch(c)
	{
	case 'h':
	  usage(0);
	  break;
	case 'S':
	  flags |= CONDA_ADD_WITH_SIGNATUREDATA;
	  break;
	default:
	  usage(1);
	  break;
	}
    }
  pool = pool_create();
  repo = repo_create(pool, "<stdin>");
  if (repo_add_conda(repo, stdin, flags))
    {
      fprintf(stderr, "conda2solv: %s\n", pool_errstr(pool));
      exit(1);
    }
  repo_internalize(repo);
  tool_write(repo, stdout);
  pool_free(pool);
  exit(0);
}