summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c52
1 files changed, 46 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index 08be875..4a672b2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -36,16 +36,28 @@
extern const char *PACKAGE_VERSION_GIT;
-const char *_optstring = "c:f:F:lLhV";
+const char *_optstring = "bc:d:f:F:lLhV";
#ifdef HAVE_GETOPT_LONG
struct option _longopts[] = {
{
+ .name = "build",
+ .has_arg = 0,
+ .flag = NULL,
+ .val = 'b',
+ },
+ {
.name = "control-dir",
.has_arg = 1,
.flag = NULL,
.val = 'c',
},
{
+ .name = "data-dir",
+ .has_arg = 1,
+ .flag = NULL,
+ .val = 'd',
+ },
+ {
.name = "control-file",
.has_arg = 1,
.flag = NULL,
@@ -89,9 +101,17 @@ _help(const char *program_name)
{
printf(_("Usage: %s [-c CONTROL-DIR] [-f CONTROL-FILE] [-F DATA-FILE] "
"[-l] [-L] PACKAGE\n"), program_name);
+ printf(_(" or: %s -b -c CONTROL-DIR -d DATA-DIR PACKAGE\n"),
+ program_name);
#ifdef HAVE_GETOPT_LONG
puts(_("Options:\n"
-" -c, --control-dir=CONTROL-DIR Extract control files into CONTROL-DIR.\n"
+" -b, --build Create a package from the specified\n"
+" CONTROL-DIR and DATA-DIR.\n"
+" -c, --control-dir=CONTROL-DIR In build mode, read control files from\n"
+" CONTROL-DIR. Otherwise, extract control\n"
+" files into CONTROL-DIR.\n"
+" -d, --data-dir=DATA-DIR In build mode, read data files from "
+ "DATA-DIR\n"
" -f, --control-file=CONTROL-FILE Print the contents of the named control "
"file.\n"
" If this option is given multiple times, the"
@@ -121,6 +141,11 @@ _help(const char *program_name)
" -V, --version Show version information and exit."));
#else
puts(_("Options:\n"
+" -b Create a package from the specified CONTROL-DIR and DATA-DIR.\n"
+" -c In build mode, read control files from CONTROL-DIR. Otherwise, extract"
+ "\n"
+" control files into CONTROL-DIR.\n"
+" -d In build mode, read data files from DATA-DIR\n"
" -f Print the contents of the named control file. If this option is given\n"
" multiple times, the named control files will be printed in the order "
"they\n"
@@ -182,6 +207,7 @@ main(int argc, char *argv[])
{
const char *program_name;
struct opkg_opk_opk *opk;
+ int build;
int opt_f;
int opt_F;
int opt_l;
@@ -206,6 +232,7 @@ main(int argc, char *argv[])
}
opterr = 0;
+ build = 0;
opt_f = 0;
opt_F = 0;
opt_l = 0;
@@ -217,9 +244,15 @@ main(int argc, char *argv[])
while ((opt = getopt(argc, argv, _optstring)) != -1) {
#endif
switch(opt) {
+ case 'b':
+ build = 1;
+ break;
case 'c':
opkg_opk_opk_control_dir(opk, optarg);
break;
+ case 'd':
+ opkg_opk_opk_data_dir(opk, optarg);
+ break;
case 'f':
if (opt_l > 0) {
_opt_mutex(program_name, 'f', 'l');
@@ -298,10 +331,17 @@ main(int argc, char *argv[])
return EXIT_FAILURE;
}
- /* Read package. */
- if (opkg_opk_opk_read(opk, argv[0]) != OPKG_OPK_OK) {
- opkg_opk_opk_free(opk);
- return EXIT_FAILURE;
+ /* Read or build package. */
+ if (build == 1) {
+ if (opkg_opk_opk_write(opk, argv[0]) != OPKG_OPK_OK) {
+ opkg_opk_opk_free(opk);
+ return EXIT_FAILURE;
+ }
+ } else {
+ if (opkg_opk_opk_read(opk, argv[0]) != OPKG_OPK_OK) {
+ opkg_opk_opk_free(opk);
+ return EXIT_FAILURE;
+ }
}
opkg_opk_opk_free(opk);