Arch Linux에서 정규 표현식과 일치하는 설치된 모든 패키지를 올바르게 제거하는 방법은 무엇입니까?

Arch Linux에서 정규 표현식과 일치하는 설치된 모든 패키지를 올바르게 제거하는 방법은 무엇입니까?

다음 명령을 사용하여 TeX Live 2023을 설치했습니다.스크립트Arch Linux 저장소 대신. 그러나 다른 소프트웨어를 설치할 때 일부 TeX Live 패키지가 어쨌든 내 데스크탑으로 이동하여 문제를 일으켰습니다. 그래서 모든 패키지를 제거해 보았습니다 texlive.

texlive시스템에 설치된 패키지 목록입니다.

$ sudo pacman -Qs texlive*
local/texlive-basic 2023.66594-19 (texlive)
    TeX Live - Essential programs and files
local/texlive-bin 2023.66984-16
    TeX Live binaries
local/texlive-binextra 2023.66594-19 (texlive)
    TeX Live - TeX auxiliary programs
local/texlive-context 2023.66594-19 (texlive)
    TeX Live - ConTeXt and packages
local/texlive-fontsextra 2023.66594-19 (texlive)
    TeX Live - Additional fonts
local/texlive-fontsrecommended 2023.66594-19 (texlive)
    TeX Live - Recommended fonts
local/texlive-fontutils 2023.66594-19 (texlive)
    TeX Live - Graphics and font utilities
local/texlive-games 2023.66594-19 (texlive)
    TeX Live - Games typesetting
local/texlive-langcjk 2023.66594-19 (texlive-lang)
    TeX Live - Chinese/Japanese/Korean (base)
local/texlive-langenglish 2023.66594-19 (texlive-lang)
    TeX Live - US and UK English
local/texlive-langgreek 2023.66594-19 (texlive-lang)
    TeX Live - Greek
local/texlive-langjapanese 2023.66594-19 (texlive-lang)
    TeX Live - Japanese
local/texlive-langkorean 2023.66594-19 (texlive-lang)
    TeX Live - Korean
local/texlive-langother 2023.66594-19 (texlive-lang)
    TeX Live - Other languages
local/texlive-latex 2023.66594-19 (texlive)
    TeX Live - LaTeX fundamental packages
local/texlive-latexextra 2023.66594-19 (texlive)
    TeX Live - LaTeX additional packages
local/texlive-latexrecommended 2023.66594-19 (texlive)
    TeX Live - LaTeX recommended packages
local/texlive-luatex 2023.66594-19 (texlive)
    TeX Live - LuaTeX packages
local/texlive-mathscience 2023.66594-19 (texlive)
    TeX Live - Mathematics, natural sciences, computer science packages
local/texlive-metapost 2023.66594-19 (texlive)
    TeX Live - MetaPost and Metafont packages
local/texlive-music 2023.66594-19 (texlive)
    TeX Live - Music packages
local/texlive-pictures 2023.66594-19 (texlive)
    TeX Live - Graphics, pictures, diagrams
local/texlive-plaingeneric 2023.66594-19 (texlive)
    TeX Live - Plain (La)TeX packages
local/texlive-xetex 2023.66594-19 (texlive)
    TeX Live - XeTeX and packages

먼저 데이터 제공을 시도했지만 pacman -S모든 pacman -R패키지 texlive가 설치되지 않았기 때문에 진행하지 않았습니다.

$ sudo pacman -R $(pacman -Ssq texlive*)
error: target not found: tectonic
error: target not found: texlive-bibtexextra
error: target not found: texlive-doc
error: target not found: texlive-formatsextra
error: target not found: texlive-humanities
error: target not found: texlive-langarabic
error: target not found: texlive-langchinese
error: target not found: texlive-langcyrillic
error: target not found: texlive-langczechslovak
error: target not found: texlive-langeuropean
error: target not found: texlive-langfrench
error: target not found: texlive-langgerman
error: target not found: texlive-langitalian
error: target not found: texlive-langpolish
error: target not found: texlive-langportuguese
error: target not found: texlive-langspanish
error: target not found: texlive-meta
error: target not found: texlive-pstricks
error: target not found: texlive-publishers

그래서 어떻게든 필터링해야 합니다 pacman -Q. 제한된 지식과 매개변수 확장으로 여러 번 시도한 끝에 grep패키지 이름을 추출했습니다.

$ for i in $(sudo pacman -Qs texlive* | grep -Eo '^local/[[:alpha:]]+-[[:alpha:]]+')
do
    echo ${i:6}
done
texlive-basic
texlive-bin
texlive-binextra
texlive-context
texlive-fontsextra
texlive-fontsrecommended
texlive-fontutils
texlive-games
texlive-langcjk
texlive-langenglish
texlive-langgreek
texlive-langjapanese
texlive-langkorean
texlive-langother
texlive-latex
texlive-latexextra
texlive-latexrecommended
texlive-luatex
texlive-mathscience
texlive-metapost
texlive-music
texlive-pictures
texlive-plaingeneric
texlive-xetex

그런 다음 코드를 교체 echo하고 실행합니다.sudo pacman -R

$ for i in $(sudo pacman -Qs texlive* | grep -Eo '^local/[[:alpha:]]+-[[:alpha:]]+')
do
    sudo pacman -R ${i:6}
done
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-binextra
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-context
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-fontsextra
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-fontsrecommended
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-fontutils
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-langcjk
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-langenglish
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-langgreek
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-langother
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-latex
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-luatex
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-metapost
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-pictures
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-plaingeneric
:: removing texlive-basic breaks dependency 'texlive-basic' required by texlive-xetex
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: removing texlive-bin breaks dependency 'texlive-bin' required by dvisvgm
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-basic
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-binextra
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-context
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-fontsextra
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-fontsrecommended
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-fontutils
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-games
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-langcjk
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-langenglish
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-langgreek
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-langjapanese
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-langkorean
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-langother
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-latex
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-latexextra
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-latexrecommended
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-luatex
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-mathscience
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-metapost
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-music
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-pictures
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-plaingeneric
:: removing texlive-bin breaks dependency 'texlive-bin' required by texlive-xetex
checking dependencies...
:: python-matplotlib optionally requires texlive-binextra: usetex dependencies

Packages (1) texlive-binextra-2023.66594-19

Total Removed Size:  112.67 MiB

:: Do you want to remove these packages? [Y/n] y
:: Processing package changes...
(1/1) removing texlive-binextra                                 [##################################] 100%
:: Running post-transaction hooks...
(1/3) Arming ConditionNeedsUpdate...
(2/3) Updating TeXLive filename database...
(3/3) Updating TeXLive format files...
Can't locate mktexlsr.pl in @INC (@INC entries checked: //tlpkg //texmf-dist/scripts/texlive /usr/lib/perl5/5.38/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/5.38/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/5.38/core_perl /usr/share/perl5/core_perl) at /usr/bin/fmtutil line 23.
BEGIN failed--compilation aborted at /usr/bin/fmtutil line 25.
error: command failed to execute correctly
checking dependencies...

Packages (1) texlive-context-2023.66594-19

Total Removed Size:  52.81 MiB

:: Do you want to remove these packages? [Y/n] y   
:: Processing package changes...
(1/1) removing texlive-context                                  [##################################] 100%
:: Running post-transaction hooks...
(1/3) Arming ConditionNeedsUpdate...
(2/3) Updating TeXLive filename database...
(3/3) Updating TeXLive font maps...
Use of uninitialized value $fn in concatenation (.) or string at /usr/bin/updmap line 2158.
Use of uninitialized value $fn in concatenation (.) or string at /usr/bin/updmap line 2159.
updmap: open() failed: No such file or directory at /usr/bin/updmap line 2159.
Use of uninitialized value $fn in concatenation (.) or string at /usr/bin/updmap line 2158.
Use of uninitialized value $fn in concatenation (.) or string at /usr/bin/updmap line 2159.
updmap: open() failed: No such file or directory at /usr/bin/updmap line 2159.
Use of uninitialized value $fn in concatenation (.) or string at /usr/bin/updmap line 2158.
Use of uninitialized value $fn in concatenation (.) or string at /usr/bin/updmap line 2159.
updmap: open() failed: No such file or directory at /usr/bin/updmap line 2159.
updmap [ERROR]: The following map file(s) couldn't be found:
updmap [ERROR]:     dvips35.map (in builtin)
updmap [ERROR]:     pdftex35.map (in builtin)
updmap [ERROR]:     ps2pk35.map (in builtin)
updmap [ERROR]: Did you run mktexlsr?

    You can disable non-existent map entries using the option
      --syncwithtrees.

error: command failed to execute correctly
checking dependencies...

Packages (1) texlive-fontsextra-2023.66594-19

Total Removed Size:  1433.62 MiB

:: Do you want to remove these packages? [Y/n] y
:: Processing package changes...
(1/1) removing texlive-fontsextra                               [##################################] 100%
:: Running post-transaction hooks...
(1/3) Arming ConditionNeedsUpdate...
(2/3) Updating TeXLive filename database...
(3/3) Updating TeXLive font maps...
Use of uninitialized value $fn in concatenation (.) or string at /usr/bin/updmap line 2158.
Use of uninitialized value $fn in concatenation (.) or string at /usr/bin/updmap line 2159.
updmap: open() failed: No such file or directory at /usr/bin/updmap line 2159.
Use of uninitialized value $fn in concatenation (.) or string at /usr/bin/updmap line 2158.
Use of uninitialized value $fn in concatenation (.) or string at /usr/bin/updmap line 2159.
updmap: open() failed: No such file or directory at /usr/bin/updmap line 2159.
Use of uninitialized value $fn in concatenation (.) or string at /usr/bin/updmap line 2158.
Use of uninitialized value $fn in concatenation (.) or string at /usr/bin/updmap line 2159.
updmap: open() failed: No such file or directory at /usr/bin/updmap line 2159.
updmap [ERROR]: The following map file(s) couldn't be found:
updmap [ERROR]:     dvips35.map (in builtin)
updmap [ERROR]:     pdftex35.map (in builtin)
updmap [ERROR]:     ps2pk35.map (in builtin)
updmap [ERROR]: Did you run mktexlsr?
...

제거할 패키지가 서로 종속되어 있어서 위의 명령을 여러번 실행해야 했습니다. 몇 번 실행한 후에 texlive패키지가 완전히 사라졌습니다.

$ sudo pacman -Qs texlive*

이 경우에는 작동하지만 쿼리에 정규식을 사용한 다음 다시 grep 쿼리에 다른 정규식을 사용하기 때문에 신뢰할 수 없습니다. texlive패키지 이름에 숫자가 포함된 경우 이 방법은 작동하지 않습니다. 단일 정규식과 일치하는 모든 패키지를 지우고 pacman가능한 경우 에만 사용하는 더 깔끔한 방법이 있습니까 ? 각 패키지에 대해 예라고 대답하지 않고 삭제할 수 있습니까?

답변1

-Q이 옵션을 사용하면 패키지 이름만 나열됩니다 q. 따라서 설치된 패키지 목록이 제공되어야 합니다(내 시스템의 출력은 사용자의 시스템과 다를 수 있음).

$ pacman -Qsq 'texlive*'
texlive-basic
texlive-bin
texlive-fontsextra
texlive-langgreek
texlive-latex
texlive-latexextra
texlive-latexrecommended
texlive-pictures

그건 그렇고, 'texlive*'따옴표로 묶인 방법을 확인하십시오. 인용되지 않은 내용은 *셸에 의해 확장되므로 이는 중요합니다.앞으로호출되므로 pacman현재 디렉터리에 일치하는 파일이나 디렉터리가 있으면 인용되지 않은 경우 해당 파일이나 디렉터리가 전달됩니다.texlive*pacman

이제 목록이 있으므로 제거하려는 항목에 종속된 모든 종속성과 패키지도 제거해야 합니다. 따라서 (에서) 다음 삭제 옵션이 필요합니다 man pacman.

제거 옵션(-R에 적용)

-c, --캐스케이드

모든 대상 패키지와 하나 이상의 대상 패키지에 의존하는 모든 패키지를 제거합니다. 이 작업은 재귀적이며 필요할 수 있는 많은 패키지를 제거할 수 있으므로 주의해서 사용해야 합니다.

-s, --재귀

(A) 다른 패키지에 필요하지 않고 (B) 사용자가 명시적으로 설치하지 않은 경우 모든 종속성을 포함하여 지정된 각 대상을 제거합니다. 이 작업은backward --sync 작업과 유사하게 재귀적이며 고아 없이 깨끗한 시스템을 유지하는 데 도움이 됩니다. 조건 (B)를 생략하려면 이 옵션을 두 번 전달하십시오.

따라서 모든 관련 패키지를 제거하려면 다음을 사용하십시오.

sudo pacman -Rcs $(pacman -Qsq 'texlive*')

내 시스템에서는 다음과 같습니다.

$ sudo pacman -Rcs $(pacman -Qsq 'texlive*')
checking dependencies...
:: evince optionally requires texlive-bin: DVI support
:: python-matplotlib optionally requires texlive-latexrecommended: usetex usage with pdflatex
:: python-sphinx optionally requires texlive-latexextra: for generation of PDF documentation
:: r optionally requires texlive-bin: latex sty files
:: xournalpp optionally requires texlive-latexextra: LaTeX package

Packages (15) dvisvgm-3.1.1-1  ffcall-2.4-2  fontawesome.sty-4.6.3.2-1  libsigsegv-2.14-2  otf-font-awesome-6.4.2-1
              t1lib-5.1.2-8  zziplib-0.13.72-2  texlive-basic-2023.66594-19  texlive-bin-2023.66984-16
              texlive-fontsextra-2023.66594-19  texlive-langgreek-2023.66594-19  texlive-latex-2023.66594-19
              texlive-latexextra-2023.66594-19  texlive-latexrecommended-2023.66594-19  texlive-pictures-2023.66594-19

Total Removed Size:  1786.02 MiB

관련 정보