Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
alpine
apk-tools
Commits
20775276
Commit
20775276
authored
Mar 16, 2011
by
Timo Teräs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apk: show progress bar by default for tty controlled runs
and make the progress bar disappear on regular runs too.
parent
5d64bc5d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
src/apk.c
src/apk.c
+8
-0
src/state.c
src/state.c
+4
-7
No files found.
src/apk.c
View file @
20775276
...
...
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include <sys/stat.h>
#include <openssl/crypto.h>
...
...
@@ -45,6 +46,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 "
...
...
@@ -256,6 +258,9 @@ int main(int argc, char **argv)
apk_atom_init
();
umask
(
0
);
if
(
isatty
(
STDOUT_FILENO
)
&&
isatty
(
STDERR_FILENO
)
&&
isatty
(
STDIN_FILENO
))
apk_flags
|=
APK_PROGRESS
;
applet
=
deduce_applet
(
argc
,
argv
);
num_options
=
ARRAY_SIZE
(
generic_options
)
+
1
;
if
(
applet
!=
NULL
)
...
...
@@ -326,6 +331,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
;
...
...
src/state.c
View file @
20775276
...
...
@@ -655,7 +655,7 @@ static void apk_count_change(struct apk_change *change, struct apk_stats *stats)
stats
->
packages
++
;
}
static
inline
void
apk_draw_progress
(
int
percent
,
int
last
)
static
inline
void
apk_draw_progress
(
int
percent
)
{
char
tmp
[
128
];
char
reset
[
128
];
...
...
@@ -666,10 +666,7 @@ static inline void apk_draw_progress(int percent, int last)
tmp
[
2
+
i
]
=
'#'
;
memset
(
reset
,
'\b'
,
strlen
(
tmp
));
fwrite
(
tmp
,
strlen
(
tmp
),
1
,
stderr
);
if
(
!
last
)
fwrite
(
reset
,
strlen
(
tmp
),
1
,
stderr
);
else
if
(
apk_verbosity
>
0
)
fwrite
(
"
\n
"
,
1
,
1
,
stderr
);
fflush
(
stderr
);
}
...
...
@@ -692,7 +689,7 @@ static void progress_cb(void *ctx, size_t progress)
prog
->
total
.
bytes
+
prog
->
total
.
packages
);
if
(
prog
->
count
!=
count
)
apk_draw_progress
(
count
,
0
);
apk_draw_progress
(
count
);
prog
->
count
=
count
;
}
...
...
@@ -961,7 +958,7 @@ int apk_state_commit(struct apk_state *state,
apk_count_change
(
change
,
&
prog
.
done
);
}
if
(
apk_flags
&
APK_PROGRESS
)
apk_draw_progress
(
100
,
1
);
apk_draw_progress
(
100
);
update_state:
apk_db_run_triggers
(
db
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment