blob: 3ed44ef8736b5017a0ee63915722e366e52bcb68 [file] [log] [blame]
Uwe Hermann7eb845e2008-11-02 17:01:06 +00001/*
2 * This file is part of the bayou project.
3 *
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Uwe Hermann7eb845e2008-11-02 17:01:06 +000014 */
15
16#include <stdio.h>
17#include <string.h>
18#include <getopt.h>
19#include "pbuilder.h"
20
21static void usage(void)
22{
23 printf("./pbuilder [-c config] [create|show] [LAR]\n");
24}
25
26int main(int argc, char **argv)
27{
28 char *config = NULL;
29
30 while (1) {
31 signed ch = getopt(argc, argv, "c:");
32 if (ch == -1)
33 break;
34
35 switch (ch) {
36 case 'c':
37 config = optarg;
38 break;
39 default:
40 usage();
41 return -1;
42 }
43 }
44
45 if (optind >= argc) {
46 usage();
47 return 0;
48 }
49
50 if (!strcmp(argv[optind], "create")) {
51 if (config == NULL) {
52 warn("E: No config was provided\n");
53 usage();
54 return -1;
55 }
56
57 if (optind + 1 >= argc) {
58 warn("E: No LAR name was given\n");
59 usage();
60 return -1;
61 }
62
63 create_lar_from_config((const char *)config,
64 (const char *)argv[optind + 1]);
65 } else if (!strcmp(argv[optind], "show")) {
66 if (optind + 1 >= argc) {
67 warn("E: No LAR name was given\n");
68 usage();
69 return -1;
70 }
71 pbuilder_show_lar((const char *)argv[optind + 1]);
72 } else {
73 usage();
74 return -1;
75 }
76
77 return 0;
78}