1 /*#############################################################################
3 # Pakfire - The IPFire package management system #
4 # Copyright (C) 2023 Pakfire development team #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 #############################################################################*/
27 #include <pakfire/build.h>
28 #include <pakfire/pakfire.h>
30 #define MAX_PACKAGES 128
36 const char* packages
[MAX_PACKAGES
];
37 unsigned int num_packages
;
40 static const char* doc
=
41 "Creates a build environment and launches an interactive shell in it";
44 OPT_DISABLE_SNAPSHOT
= 1,
48 static struct argp_option options
[] = {
49 { "disable-snapshot", OPT_DISABLE_SNAPSHOT
, NULL
, 0, "Do not use the snapshot", 0 },
50 { "install", OPT_INSTALL
, "PACKAGE", 0, "Install this package", 0 },
54 static error_t
parse(int key
, char* arg
, struct argp_state
* state
, void* data
) {
55 struct config
* config
= data
;
58 case OPT_DISABLE_SNAPSHOT
:
59 config
->flags
|= PAKFIRE_BUILD_DISABLE_SNAPSHOT
;
63 if (config
->num_packages
>= MAX_PACKAGES
)
66 config
->packages
[config
->num_packages
++] = arg
;
70 return ARGP_ERR_UNKNOWN
;
76 int cli_shell(void* data
, int argc
, char* argv
[]) {
77 struct pakfire
* pakfire
= NULL
;
80 struct cli_config
* cli_config
= data
;
82 struct config config
= {
88 // Parse the command line
89 r
= cli_parse(options
, NULL
, NULL
, doc
, parse
, 0, argc
, argv
, &config
);
94 r
= cli_setup_pakfire(&pakfire
, cli_config
);
99 r
= pakfire_shell(pakfire
, config
.packages
, config
.flags
);
105 pakfire_unref(pakfire
);