diff options
Diffstat (limited to 'src/apk.c')
-rw-r--r-- | src/apk.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -17,7 +17,9 @@ #include <stdlib.h> #include <string.h> #include <getopt.h> +#include <unistd.h> #include <sys/stat.h> +#include <sys/ioctl.h> #include <openssl/crypto.h> #ifndef OPENSSL_NO_ENGINE @@ -31,6 +33,7 @@ #include "apk_print.h" char **apk_argv; +int apk_screen_width; static struct apk_option generic_options[] = { { 'h', "help", "Show generic help or applet specific help" }, @@ -45,6 +48,7 @@ static struct apk_option generic_options[] = { { 'f', "force", "Do what was asked even if it looks dangerous" }, { 'U', "update-cache", "Update the repository cache" }, { 0x101, "progress", "Show a progress bar" }, + { 0x110, "no-progress", "Disable progress bar even for TTYs" }, { 0x102, "clean-protected", "Do not create .apk-new files to " "configuration dirs" }, { 0x106, "purge", "Delete also modified configuration files on " @@ -62,6 +66,8 @@ static struct apk_option generic_options[] = { required_argument, "REPOFILE" }, { 0x109, "no-network", "Do not use network (cache is still used)" }, { 0x111, "overlay-from-stdin", "Read list of overlay files from stdin" }, + { 0x112, "arch", "Use architecture with --root", + required_argument, "ARCH" }, }; static int version(void) @@ -236,6 +242,20 @@ static void init_openssl(void) #endif } +static void setup_terminal(void) +{ + struct winsize w; + + setvbuf(stderr, NULL, _IOLBF, BUFSIZ); + if (ioctl(STDERR_FILENO,TIOCGWINSZ, &w) == 0) + apk_screen_width = w.ws_col; + else + apk_screen_width = 70; + if (isatty(STDOUT_FILENO) && isatty(STDERR_FILENO) && isatty(STDIN_FILENO)) + apk_flags |= APK_PROGRESS; + +} + int main(int argc, char **argv) { struct apk_applet *applet; @@ -255,6 +275,7 @@ int main(int argc, char **argv) list_init(&dbopts.repository_list); apk_atom_init(); umask(0); + setup_terminal(); applet = deduce_applet(argc, argv); num_options = ARRAY_SIZE(generic_options) + 1; @@ -326,6 +347,9 @@ int main(int argc, char **argv) case 0x101: apk_flags |= APK_PROGRESS; break; + case 0x110: + apk_flags &= ~APK_PROGRESS; + break; case 0x102: apk_flags |= APK_CLEAN_PROTECTED; break; @@ -347,6 +371,9 @@ int main(int argc, char **argv) case 0x111: apk_flags |= APK_OVERLAY_FROM_STDIN; break; + case 0x112: + dbopts.arch = optarg; + break; default: if (applet == NULL || applet->parse == NULL || applet->parse(ctx, &dbopts, r, |