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 --pacman-cache, --pacman-log and --maxdepth to CLI options #123

Merged
merged 5 commits into from May 11, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions README.md
Expand Up @@ -17,11 +17,21 @@ Install via the [AUR](https://aur.archlinux.org/packages/downgrade/).
Usage: downgrade [option...] <pkg> [pkg...] [-- pacman_option...]

Options:
--pacman <command>
--pacman <command>
pacman command to use, defaults to "pacman"
--pacman-conf <file-path>
--pacman-conf <path>
pacman configuration file, defaults to "/etc/pacman.conf"
--ala-url <url>
--pacman-cache <path>
pacman cache directory or directories,
default value taken from pacman configuration file,
or otherwise defaults to "/var/cache/pacman/pkg"
--pacman-log <path>
pacman log file,
default value taken from pacman configuration file,
or otherwise defaults to "/var/log/pacman.log"
--maxdepth <integer>
maximum depth to search for cached packages, defaults to 1
--ala-url <url>
location of ALA server, defaults to "https://archive.archlinux.org"
--ala-only only use ALA server
--cached-only only use cached packages
Expand Down
9 changes: 6 additions & 3 deletions completion/zsh
Expand Up @@ -2,9 +2,12 @@

_downgrade(){
_arguments -S -C '*:packages:->pkg' \
'--pacman[Specify pacman command]' \
'--pacman-conf[Specify pacman configuration file]:config:_files' \
'--ala-url[Specify location of ALA server]' \
'--pacman[Specify pacman command]:pacman command' \
'--pacman-conf[Specify pacman configuration file]:pacman config file:_files' \
'--pacman-cache[Specify pacman cache directory or directories]:pacman cache directory:_path_files -/' \
'--pacman-log[Specify pacman log-file]:pacman log file:_files' \
'--maxdepth[Specify maximum depth for local cache find]:maximum search depth' \
'--ala-url[Specify location of ALA server]:ala url' \
'--ala-only[Option enables only ALA server search]' \
'--cached-only[Option enables only cached search]' \
'--nosudo[Option enables only su even when sudo is present]' \
Expand Down
22 changes: 14 additions & 8 deletions doc/downgrade.8.md
Expand Up @@ -60,16 +60,26 @@ The columns have the following meaning:

# OPTIONS

## DOWNGRADE OPTIONS

**\--pacman** *\<command\>*\

> Pacman command, default is *pacman*.

**\--pacman-conf** *\<file-path\>*\
**\--pacman-conf** *\<path\>*\

> Pacman configuration file, default is */etc/pacman.conf*.

**\--pacman-cache** *\<path\>*\

> Pacman cache directory or directories, default value is extracted from pacman configuration file, or otherwise defaults to */var/cache/pacman/pkg*. Multiple cache directories can be supplied as space-separated paths.

**\--pacman-log** *\<path\>*\

> Pacman log file, default value is extracted from pacman configuration file, or otherwise defaults to */var/log/pacman.log*.

**\--maxdepth** *\<int\>*\

> Maximum depth to search for cached packages, defaults to *1*.

**\--ala-url** *\<url\>*\

> Location of an ALA server, default is *https://archive.archlinux.org*.
Expand All @@ -94,16 +104,12 @@ As per the usage syntax, any options supplied after the **\--** character sequen

By default, **downgrade** will search both local caches and the ALA.

The package cache directory is read from the pacman configuration file by default, or set to */var/cache/pacman/pkg/* when not found.

The pacman log file is read from the pacman configuration file by default, or set to */var/log/pacman.log* when not found.
If only one package with its corresponding location matches, the package will be installed without further prompt from the user.

# VERSION FILTERING

**downgrade** allows the use of the following version-filtering operators: **=**, **=~**, **<=**, **>=**, **<** and **>**. Note that **=~** represents a regex match operator.

If only one package-path matches, the package will be installed without further prompt from the user.

# EXIT CODES

**downgrade** will stop further processing and exit non-zero if it encounters any of
Expand Down
58 changes: 54 additions & 4 deletions downgrade
Expand Up @@ -7,11 +7,21 @@ usage() {
$(gettext "Usage: downgrade [option...] <pkg> [pkg...] [-- pacman_option...]")

$(gettext "Options"):
--pacman <$(gettext "command")>
--pacman <$(gettext "command")>
$(gettext "pacman command to use, defaults to") "pacman"
--pacman-conf <$(gettext "file-path")>
--pacman-conf <$(gettext "path")>
$(gettext "pacman configuration file, defaults to") "/etc/pacman.conf"
--ala-url <url>
--pacman-cache <$(gettext "path")>
$(gettext "pacman cache directory or directories,")
$(gettext "default value taken from pacman configuration file,")
$(gettext "or otherwise defaults to") "/var/cache/pacman/pkg"
--pacman-log <$(gettext "path")>
$(gettext "pacman log file,")
$(gettext "default value taken from pacman configuration file,")
$(gettext "or otherwise defaults to") "/var/log/pacman.log"
--maxdepth <$(gettext "integer")>
$(gettext "maximum depth to search for cached packages, defaults to") 1
--ala-url <url>
$(gettext "location of ALA server, defaults to") "https://archive.archlinux.org"
--ala-only $(gettext "only use ALA server")
--cached-only $(gettext "only use cached packages")
Expand Down Expand Up @@ -162,7 +172,7 @@ search_packages() {
: "${PACMAN_CACHE:=/var/cache/pacman/pkg/}"

# shellcheck disable=SC2086
find $PACMAN_CACHE -maxdepth 1 -regextype posix-extended -regex ".*/$pkgfile_re"
find $PACMAN_CACHE -maxdepth "$DOWNGRADE_MAXDEPTH" -regextype posix-extended -regex ".*/$pkgfile_re"
fi
}

Expand Down Expand Up @@ -302,6 +312,7 @@ main() {
: "${DOWNGRADE_FROM_ALA:=1}"
: "${DOWNGRADE_FROM_CACHE:=1}"
: "${DOWNGRADE_NOSUDO:=0}"
: "${DOWNGRADE_MAXDEPTH:=1}"

declare -a terms
declare -a to_ignore
Expand Down Expand Up @@ -352,6 +363,45 @@ parse_options() {
exit 1
fi
;;
--pacman-cache)
if [[ -n "$2" ]]; then
shift
PACMAN_CACHE="$1"
else
{
gettext "Missing --pacman-cache argument"
echo
usage
} >&2
exit 1
fi
;;
--pacman-log)
if [[ -n "$2" ]]; then
shift
PACMAN_LOG="$1"
else
{
gettext "Missing --pacman-log argument"
echo
usage
} >&2
exit 1
fi
;;
--maxdepth)
if [[ -n "$2" ]]; then
shift
DOWNGRADE_MAXDEPTH="$1"
else
{
gettext "Missing --maxdepth argument"
echo
usage
} >&2
exit 1
fi
;;
--ala-only)
DOWNGRADE_FROM_ALA=1
DOWNGRADE_FROM_CACHE=0
Expand Down
84 changes: 59 additions & 25 deletions locale/cs.po
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: downgrade\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-11 19:36+0200\n"
"POT-Creation-Date: 2020-05-11 20:02+0200\n"
"PO-Revision-Date: 2020-04-21 21:10+0100\n"
"Last-Translator: <tom.vycital@gmail.com>, <shankar.atreya@gmail.com>\n"
"Language-Team: Czech\n"
Expand All @@ -34,93 +34,130 @@ msgstr "příkaz"
msgid "pacman command to use, defaults to"
msgstr "příkaz pacman, výchozí nastavení je"

#: downgrade:12
msgid "file-path"
#: downgrade:12 downgrade:14 downgrade:18
msgid "path"
msgstr "soubor"

#: downgrade:13
msgid "pacman configuration file, defaults to"
msgstr "konfigurační soubor pacman, výchozí nastavení"

#: downgrade:15
msgid "pacman cache directory or directories,"
msgstr "adresář nebo adresáře mezipaměti pacman,"

#: downgrade:16 downgrade:20
msgid "default value taken from pacman configuration file,"
msgstr "výchozí hodnota převzatá z konfiguračního souboru pacman,"

#: downgrade:17 downgrade:21
msgid "or otherwise defaults to"
msgstr "nebo jinak výchozí"

#: downgrade:19
msgid "pacman log file,"
msgstr "soubor protokolu pacman"

#: downgrade:22
msgid "integer"
msgstr "celé číslo"

#: downgrade:23
msgid "maximum depth to search for cached packages, defaults to"
msgstr ""
"maximální hloubka pro vyhledávání balíčků v mezipaměti, výchozí hodnota"

#: downgrade:25
msgid "location of ALA server, defaults to"
msgstr "umístění serveru ALA, výchozí nastavení je"

#: downgrade:16
#: downgrade:26
msgid "only use ALA server"
msgstr "používejte pouze server ALA"

#: downgrade:17
#: downgrade:27
msgid "only use cached packages"
msgstr "používejte pouze balíčky v mezipaměti"

#: downgrade:18
#: downgrade:28
msgid "do not use sudo even when available, use su"
msgstr "nepoužívejte sudo, i když jsou k dispozici, použijte su"

#: downgrade:19
#: downgrade:29
msgid "show help script"
msgstr "zobrazit skript nápovědy"

#: downgrade:21
#: downgrade:31
msgid "Note"
msgstr "Poznámka"

#: downgrade:22
#: downgrade:32
msgid "Options after the -- characters will be treated as pacman options."
msgstr "Možnosti za znaky -- budou považovány za možnosti pacmanu."

#: downgrade:23
#: downgrade:33
msgid "See downgrade(8) for details."
msgstr "Pro více informací vizte downgrade(8)"

#: downgrade:56
#: downgrade:66
msgid "Available packages:"
msgstr "Dostupné balíčky:"

#: downgrade:66
#: downgrade:76
msgid "select a package by number: "
msgstr "vyberte balíček číslem: "

#: downgrade:83
#: downgrade:93
#, sh-format
msgid "add $pkg to IgnorePkg? [y/n] "
msgstr "přidat $pkg mezi ignorované? [a/n]"

#: downgrade:86
#: downgrade:96
msgid "y"
msgstr "a"

#: downgrade:196
#: downgrade:206
msgid "local"
msgstr "místní"

#: downgrade:198
#: downgrade:208
msgid "remote"
msgstr "vzdálený"

#: downgrade:253
#: downgrade:263
msgid "Invalid choice"
msgstr "Neplatná volba"

#: downgrade:267
#: downgrade:277
#, sh-format
msgid "Unable to downgrade $name"
msgstr "Nelze downgradovat $name"

#: downgrade:322
#: downgrade:333
msgid "Missing --pacman argument"
msgstr "Chybí argument --pacman"

#: downgrade:335
#: downgrade:346
msgid "Missing --pacman-conf argument"
msgstr "Chybí argument --pacman-conf"

#: downgrade:348
#: downgrade:359
msgid "Missing --ala-url argument"
msgstr "Chybí argument --ala-url"

#: downgrade:384
#: downgrade:372
msgid "Missing --pacman-cache argument"
msgstr "Chybí argument --pacman-cache"

#: downgrade:385
msgid "Missing --pacman-log argument"
msgstr "Chybí argument --pacman-log"

#: downgrade:398
msgid "Missing --maxdepth argument"
msgstr "Chybí argument --maxdepth"

#: downgrade:434
msgid "No packages provided for downgrading"
msgstr "Pro downgradování nebyly poskytnuty žádné balíčky"

Expand All @@ -129,6 +166,3 @@ msgstr "Pro downgradování nebyly poskytnuty žádné balíčky"

#~ msgid "target architecture, defaults to output of"
#~ msgstr "cílová architektura, výchozí nastavení"

#~ msgid "Missing --arch argument"
#~ msgstr "Chybí argument --arch"