Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration for file paths (fixes #722) #796

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ User ID to run makepkg if pikaur started from root.
Setting this option would override DynamicUsers settings and force changing to this UID instead of a dynamic one.


##### CachePath (default: ~/.cache)
Path to package cache location.
samuel-jimenez marked this conversation as resolved.
Show resolved Hide resolved
Will be overridden by `--xdg-cache-home` argument
or environment variable `XDG_CACHE_HOME`, if set.

##### DataPath (default: ~/.local/share)
Path to database location.
Will be overridden by `--xdg-data-home` argument
or environment variable `XDG_DATA_HOME`, if set.

#### [network]

##### AurUrl (default: https://aur.archlinux.org)
Expand Down
12 changes: 6 additions & 6 deletions pikaur/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,22 +236,22 @@ def get_pikaur_str_opts(action: str | None = None) -> ArgSchema:
(
None, "home-dir",
None,
None,
translate("alternative home directory location"),
),
(
None, "xdg-cache-home",
None,
None,
PikaurConfig().misc.CachePath.get_str(),
translate("alternative package cache directory location"),
),
(
None, "xdg-config-home",
None,
None,
translate("alternative configuration file directory location"),
),
(
None, "xdg-data-home",
None,
None,
PikaurConfig().misc.DataPath.get_str(),
translate("alternative database directory location"),
),
(
None, "preserve-env",
Expand Down
12 changes: 10 additions & 2 deletions pikaur/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def init_value(cls) -> Path:
or os.environ.get(
"XDG_CACHE_HOME",
)
or Home()() / ".cache/",
or Path(PikaurConfig().misc.CachePath.get_str()),
samuel-jimenez marked this conversation as resolved.
Show resolved Hide resolved
)


Expand Down Expand Up @@ -198,7 +198,7 @@ def init_value(cls) -> Path:
or os.environ.get(
"XDG_DATA_HOME",
)
or Home()() / ".local/share/",
or PikaurConfig().misc.DataPath.get_str(),
) / "pikaur"
)

Expand Down Expand Up @@ -456,6 +456,14 @@ class DiffPagerValues:
"option": "NewsUrl",
},
},
"CachePath": {
"data_type": STR,
"default": str(Home()() / ".cache/"),
},
"DataPath": {
"data_type": STR,
"default": str(Home()() / ".local/share/"),
},
"PacmanPath": {
"data_type": STR,
"default": "pacman",
Expand Down
3 changes: 2 additions & 1 deletion pikaur/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,11 @@ def main(*, embed: bool = False) -> None:
sys.exit(22)
check_runtime_deps()

create_dirs()
# initialize config to avoid race condition in threads:
PikaurConfig.get_config()

create_dirs()

atexit.register(restore_tty)
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
signal.signal(signal.SIGINT, create_handle_stop())
Expand Down
Loading