Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
apk-tools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
apk-tools
Commits
3197d0f6
Commit
3197d0f6
authored
Sep 14, 2011
by
Timo Teräs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search: implement --origin to print origin package name
fixes
#714
parent
e34d2ed5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
17 deletions
+32
-17
src/search.c
src/search.c
+32
-17
No files found.
src/search.c
View file @
3197d0f6
...
...
@@ -18,24 +18,32 @@
struct
search_ctx
{
int
(
*
match
)(
struct
apk_package
*
pkg
,
const
char
*
str
);
int
(
*
print
)(
struct
apk_package
*
pkg
);
void
(
*
print_result
)(
struct
search_ctx
*
ctx
,
struct
apk_package
*
pkg
);
void
(
*
print_package
)(
struct
search_ctx
*
ctx
,
struct
apk_package
*
pkg
);
int
argc
;
char
**
argv
;
};
static
int
print_match
(
struct
apk_package
*
pkg
)
static
void
print_package_name
(
struct
search_ctx
*
ctx
,
struct
apk_package
*
pkg
)
{
printf
(
"%s"
,
pkg
->
name
->
name
);
if
(
apk_verbosity
>
0
)
printf
(
"-"
BLOB_FMT
,
BLOB_PRINTF
(
*
pkg
->
version
));
if
(
apk_verbosity
>
1
)
printf
(
" - %s"
,
pkg
->
description
);
printf
(
"
\n
"
);
}
return
0
;
static
void
print_origin_name
(
struct
search_ctx
*
ctx
,
struct
apk_package
*
pkg
)
{
if
(
pkg
->
origin
!=
NULL
)
printf
(
BLOB_FMT
,
BLOB_PRINTF
(
*
pkg
->
origin
));
else
printf
(
"%s"
,
pkg
->
name
->
name
);
if
(
apk_verbosity
>
0
)
printf
(
"-"
BLOB_FMT
,
BLOB_PRINTF
(
*
pkg
->
version
));
}
static
int
print_rdepends
(
struct
apk_package
*
pkg
)
static
void
print_rdepends
(
struct
search_ctx
*
ctx
,
struct
apk_package
*
pkg
)
{
struct
apk_name
*
name
,
*
name0
;
struct
apk_package
*
pkg0
;
...
...
@@ -53,15 +61,12 @@ static int print_rdepends(struct apk_package *pkg)
dep
=
&
pkg0
->
depends
->
item
[
k
];
if
(
name
==
dep
->
name
&&
apk_dep_is_satisfied
(
dep
,
pkg
))
{
printf
(
" "
PKG_VER_FMT
,
PKG_VER_PRINTF
(
pkg0
)
);
printf
(
" "
);
ctx
->
print_package
(
ctx
,
pkg0
);
}
}
}
}
printf
(
"
\n
"
);
return
0
;
}
static
int
search_pkgname
(
struct
apk_package
*
pkg
,
const
char
*
str
)
...
...
@@ -85,7 +90,10 @@ static int search_parse(void *ctx, struct apk_db_options *dbopts,
ictx
->
match
=
search_desc
;
break
;
case
'r'
:
ictx
->
print
=
print_rdepends
;
ictx
->
print_result
=
print_rdepends
;
break
;
case
'o'
:
ictx
->
print_package
=
print_origin_name
;
break
;
default:
return
-
1
;
...
...
@@ -102,8 +110,10 @@ static int match_packages(apk_hash_item item, void *ctx)
for
(
i
=
0
;
i
<
ictx
->
argc
;
i
++
)
if
(
ictx
->
match
(
pkg
,
ictx
->
argv
[
i
]))
break
;
if
(
ictx
->
argc
==
0
||
i
<
ictx
->
argc
)
ictx
->
print
(
pkg
);
if
(
ictx
->
argc
==
0
||
i
<
ictx
->
argc
)
{
ictx
->
print_result
(
ictx
,
pkg
);
printf
(
"
\n
"
);
}
return
0
;
}
...
...
@@ -125,8 +135,10 @@ static int search_main(void *ctx, struct apk_database *db, int argc, char **argv
if
(
ictx
->
match
==
NULL
)
ictx
->
match
=
search_pkgname
;
if
(
ictx
->
print
==
NULL
)
ictx
->
print
=
print_match
;
if
(
ictx
->
print_package
==
NULL
)
ictx
->
print_package
=
print_package_name
;
if
(
ictx
->
print_result
==
NULL
)
ictx
->
print_result
=
ictx
->
print_package
;
else
if
(
argc
==
0
)
return
-
1
;
...
...
@@ -140,8 +152,10 @@ static int search_main(void *ctx, struct apk_database *db, int argc, char **argv
name
=
apk_db_query_name
(
db
,
APK_BLOB_STR
(
argv
[
i
]));
if
(
name
==
NULL
)
continue
;
for
(
j
=
0
;
j
<
name
->
pkgs
->
num
;
j
++
)
ictx
->
print
(
name
->
pkgs
->
item
[
j
]);
for
(
j
=
0
;
j
<
name
->
pkgs
->
num
;
j
++
)
{
ictx
->
print_result
(
ctx
,
name
->
pkgs
->
item
[
j
]);
printf
(
"
\n
"
);
}
}
}
...
...
@@ -151,6 +165,7 @@ static int search_main(void *ctx, struct apk_database *db, int argc, char **argv
static
struct
apk_option
search_options
[]
=
{
{
'd'
,
"description"
,
"Search also package descriptions"
},
{
'r'
,
"rdepends"
,
"Print reverse dependencies of package"
},
{
'o'
,
"origin"
,
"Print origin package name instead of the subpackage"
},
};
static
struct
apk_applet
apk_search
=
{
...
...
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