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
60
Issues
60
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
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
6542d4ca
Commit
6542d4ca
authored
Feb 27, 2017
by
Timo Teräs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db: allow overriding cache location
parent
c0f2d88f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
7 deletions
+13
-7
src/apk.c
src/apk.c
+5
-0
src/apk_database.h
src/apk_database.h
+1
-0
src/database.c
src/database.c
+7
-7
No files found.
src/apk.c
View file @
6542d4ca
...
...
@@ -130,6 +130,9 @@ static int option_parse_global(void *ctx, struct apk_db_options *dbopts, int opt
case
0x115
:
apk_flags
|=
APK_NO_CACHE
;
break
;
case
0x116
:
dbopts
->
cache_dir
=
optarg
;
break
;
case
0x112
:
dbopts
->
arch
=
optarg
;
break
;
...
...
@@ -180,6 +183,8 @@ static const struct apk_option options_global[] = {
required_argument
,
"REPOFILE"
},
{
0x109
,
"no-network"
,
"Do not use network (cache is still used)"
},
{
0x115
,
"no-cache"
,
"Read uncached index from network"
},
{
0x116
,
"cache-dir"
,
"Override cache directory"
,
required_argument
,
"CACHEDIR"
},
{
0x112
,
"arch"
,
"Use architecture with --root"
,
required_argument
,
"ARCH"
},
{
0x114
,
"print-arch"
,
"Print default arch and exit"
},
...
...
src/apk_database.h
View file @
6542d4ca
...
...
@@ -125,6 +125,7 @@ struct apk_db_options {
const
char
*
root
;
const
char
*
arch
;
const
char
*
keys_dir
;
const
char
*
cache_dir
;
const
char
*
repositories_file
;
struct
list_head
repository_list
;
};
...
...
src/database.c
View file @
6542d4ca
...
...
@@ -53,7 +53,6 @@ static apk_blob_t tmpprefix = { .len=8, .ptr = ".apknew." };
static
const
char
*
const
apkindex_tar_gz
=
"APKINDEX.tar.gz"
;
static
const
char
*
const
apk_static_cache_dir
=
"var/cache/apk"
;
static
const
char
*
const
apk_linked_cache_dir
=
"etc/apk/cache"
;
static
const
char
*
const
apk_world_file
=
"etc/apk/world"
;
static
const
char
*
const
apk_world_file_tmp
=
"etc/apk/world.new"
;
...
...
@@ -598,7 +597,7 @@ int apk_repo_format_real_url(struct apk_database *db, struct apk_repository *rep
int
apk_repo_format_item
(
struct
apk_database
*
db
,
struct
apk_repository
*
repo
,
struct
apk_package
*
pkg
,
int
*
fd
,
char
*
buf
,
size_t
len
)
{
if
(
repo
->
url
==
apk_linked_cache_dir
)
{
if
(
repo
->
url
==
db
->
repos
[
APK_REPOSITORY_CACHED
].
url
)
{
*
fd
=
db
->
cache_fd
;
return
apk_pkg_format_cache_pkg
(
APK_BLOB_PTR_LEN
(
buf
,
len
),
pkg
);
}
else
{
...
...
@@ -1403,10 +1402,10 @@ static int add_repos_from_file(void *ctx, int dirfd, const char *file)
return
0
;
}
static
void
apk_db_setup_repositories
(
struct
apk_database
*
db
)
static
void
apk_db_setup_repositories
(
struct
apk_database
*
db
,
const
char
*
cache_dir
)
{
db
->
repos
[
APK_REPOSITORY_CACHED
]
=
(
struct
apk_repository
)
{
.
url
=
apk_linked_
cache_dir
,
.
url
=
cache_dir
,
.
csum
.
data
=
{
0xb0
,
0x35
,
0x92
,
0x80
,
0x6e
,
0xfa
,
0xbf
,
0xee
,
0xb7
,
0x09
,
0xf5
,
0xa7
,
0x0a
,
0x7c
,
0x17
,
0x26
,
0x69
,
0xb0
,
0x05
,
0x38
},
...
...
@@ -1494,6 +1493,7 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
r
=
-
1
;
goto
ret_r
;
}
if
(
!
dbopts
->
cache_dir
)
dbopts
->
cache_dir
=
"etc/apk/cache"
;
apk_hash_init
(
&
db
->
available
.
names
,
&
pkg_name_hash_ops
,
20000
);
apk_hash_init
(
&
db
->
available
.
packages
,
&
pkg_info_hash_ops
,
10000
);
...
...
@@ -1505,7 +1505,7 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
apk_protected_path_array_init
(
&
db
->
protected_paths
);
db
->
permanent
=
1
;
apk_db_setup_repositories
(
db
);
apk_db_setup_repositories
(
db
,
dbopts
->
cache_dir
);
db
->
root
=
strdup
(
dbopts
->
root
?:
"/"
);
db
->
root_fd
=
openat
(
AT_FDCWD
,
db
->
root
,
O_RDONLY
|
O_CLOEXEC
);
...
...
@@ -1592,9 +1592,9 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
add_protected_paths_from_file
,
db
);
/* figure out where to have the cache */
fd
=
openat
(
db
->
root_fd
,
apk_linked_
cache_dir
,
O_RDONLY
|
O_CLOEXEC
);
fd
=
openat
(
db
->
root_fd
,
dbopts
->
cache_dir
,
O_RDONLY
|
O_CLOEXEC
);
if
(
fd
>=
0
)
{
db
->
cache_dir
=
apk_linked_
cache_dir
;
db
->
cache_dir
=
dbopts
->
cache_dir
;
db
->
cache_fd
=
fd
;
db
->
cache_remount_flags
=
map_statfs_flags
(
stfs
.
f_flags
);
if
((
dbopts
->
open_flags
&
(
APK_OPENF_WRITE
|
APK_OPENF_CACHE_WRITE
))
&&
...
...
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