Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
apk-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hassan Albahri
apk-tools
Commits
f16b671e
Commit
f16b671e
authored
16 years ago
by
Natanael Copa
Browse files
Options
Downloads
Patches
Plain Diff
info: implement -R/--depends to show dependencies
parent
c0166798
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/info.c
+42
-1
42 additions, 1 deletion
src/info.c
with
42 additions
and
1 deletion
src/info.c
+
42
−
1
View file @
f16b671e
...
...
@@ -112,7 +112,7 @@ static int info_contents(struct apk_database *db, int argc, char **argv)
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
name
=
apk_db_query_name
(
db
,
APK_BLOB_STR
(
argv
[
i
]));
if
(
name
==
NULL
)
{
if
(
name
==
NULL
)
{
apk_error
(
"Not found: %s"
,
name
);
return
1
;
}
...
...
@@ -128,6 +128,43 @@ static int info_contents(struct apk_database *db, int argc, char **argv)
return
0
;
}
static
void
info_print_depends
(
struct
apk_package
*
pkg
)
{
int
i
;
char
*
separator
=
apk_verbosity
>
1
?
" "
:
"
\n
"
;
if
(
apk_verbosity
==
1
)
printf
(
"%s-%s depends on:
\n
"
,
pkg
->
name
->
name
,
pkg
->
version
);
if
(
pkg
->
depends
==
NULL
)
return
;
if
(
apk_verbosity
>
1
)
printf
(
"%s: "
,
pkg
->
name
->
name
);
for
(
i
=
0
;
i
<
pkg
->
depends
->
num
;
i
++
)
{
printf
(
"%s%s"
,
pkg
->
depends
->
item
[
i
].
name
->
name
,
separator
);
}
puts
(
""
);
}
static
int
info_depends
(
struct
apk_database
*
db
,
int
argc
,
char
**
argv
)
{
struct
apk_name
*
name
;
int
i
,
j
;
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
name
=
apk_db_query_name
(
db
,
APK_BLOB_STR
(
argv
[
i
]));
if
(
name
==
NULL
)
{
apk_error
(
"Not found: %s"
,
argv
[
i
]);
return
1
;
}
for
(
j
=
0
;
j
<
name
->
pkgs
->
num
;
j
++
)
{
struct
apk_package
*
pkg
=
name
->
pkgs
->
item
[
j
];
if
(
apk_pkg_get_state
(
pkg
)
==
APK_STATE_INSTALL
)
info_print_depends
(
pkg
);
}
}
return
0
;
}
static
int
info_parse
(
void
*
ctx
,
int
optch
,
int
optindex
,
const
char
*
optarg
)
{
struct
info_ctx
*
ictx
=
(
struct
info_ctx
*
)
ctx
;
...
...
@@ -142,6 +179,9 @@ static int info_parse(void *ctx, int optch, int optindex, const char *optarg)
case
'L'
:
ictx
->
action
=
info_contents
;
break
;
case
'R'
:
ictx
->
action
=
info_depends
;
break
;
default:
return
-
1
;
}
...
...
@@ -170,6 +210,7 @@ static struct option info_options[] = {
{
"contents"
,
no_argument
,
NULL
,
'L'
},
{
"installed"
,
no_argument
,
NULL
,
'e'
},
{
"who-owns"
,
no_argument
,
NULL
,
'W'
},
{
"depends"
,
no_argument
,
NULL
,
'R'
},
};
static
struct
apk_applet
apk_info
=
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment