개발자

리눅스와 맥에서 홈브루를 이용해 패키지를 설치하는 방법

Sandra Henry-Stocker | InfoWorld 2021.10.29
홈브루(Homebrew)에 대해 들어본 적이 있는가? 독특한 기능을 가진 패키지 매니저다. 이를 이용하면 일반 사용자가 sudo를 사용하지 않고도 패키지를 설치할 수 있다. 맥과 리눅스 모두에서 사용할 수 있는 것은 물론이다. 맥 버전은 홈브루라고 부르고, 리눅스 버전은 리눅스브루(linuxbrew)로 설치된다.
 
ⓒ Getty Images Bank

일단 설치하면 사용자가 홈브루의 브루 명령어를 이용해 패키지를 매우 쉽게 설치할 수 있다. 그러나 홈브루 자체를 설치하는 것은 보통 sudo 권한이 필요하며 /home/linuxbrew 위치에 설치된다.
 

홈브루의 장점

홈브루는 다음과 같은 장점이 있다.
 
  • 사용하기 매우 쉽고, 편리하고 유연하게 리눅스 툴을 설치할 수 있다.
  • sudo 없이도 패키지를 설치한다.
  • 맥OS와 리눅스에서 쓸 수 있다.

시스템을 업데이트하거나 설치를 준비하려면 다음 명령어를 실행하면 된다.
 
$ sudo dnf update
$ sudo dnf groupinstall ‘Development Tools’ && sudo dnf install curl file git
$ sudo dnf install libxcrypt-compat

이들 작업을 마치려면 잠시 시간이 걸린다. 특히 최근 업데이트하지 않았지만 더 그렇다. 이제 홈브루를 /home/linuxbrew/.linuxbrew에 설치하기 위해 다음 명령을 실행한다.
 
$ /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”

이 명령을 실행하면 암호를 입력하도록 한다. 테스트해보려면 다음과 같은 명령으로 툴을 설치할 수 있다.
 
$ brew install fortune
Updating Homebrew...
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
aws-sso-util
==> Updated Formulae
Updated 133 formulae.

==> Downloading https://ghcr.io/v2/linuxbrew/core/fortune/manifests/9708-4
########################################################################
==> Downloading https://ghcr.io/v2/linuxbrew/core/fortune/blobs/sha256:64feb5e5c695578
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:6
######################################################################## 100.0%
==> Pouring fortune—9708.x86_64_linux.bottle.4.tar.gz
????  /home/linuxbrew/.linuxbrew/Cellar/fortune/9708: 82 files, 2.4MB

설치된 앱을 실행하면 다음과 같이 화면이 나온다.
 
$ fortune
Space is to place as eternity is to time.
               —Joseph Joubert
$ which fortune
/home/linuxbrew/.linuxbrew/bin/fortune

이제 그 명령 아래 줄에 두 번째 패키지가 설치된다.
 
$ brew install hello
==> Downloading https://ghcr.io/v2/linuxbrew/core/hello/manifests/2.10
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/linuxbrew/core/hello/blobs/sha256:f81d7c0a3eee9fd62
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:f
######################################################################## 100.0%
==> Pouring hello—2.10.x86_64_linux.bottle.tar.gz
????  /home/linuxbrew/.linuxbrew/Cellar/hello/2.10: 52 files, 595.7KB

리눅스브루 디렉터리는 다음과 같은 형태일 것이다.
 
$ ls -ld /home/linuxbrew
drwxr-xr-x. 3 root root 4096 Sep 30 14:51 /home/linuxbrew
$ ls -a /home/linuxbrew
.  ..  .linuxbrew
$ ls -l /home/linuxbrew/.linuxbrew
total 48
drwxrwxr-x.  2 shs shs 4096 Oct  6 16:17 bin
drwxrwxr-x.  2 shs shs 4096 Oct  4 15:30 Caskroom
drwxrwxr-x.  3 shs shs 4096 Oct  6 16:17 Cellar
drwxrwxr-x.  3 shs shs 4096 Oct  4 13:17 etc
drwxrwxr-x.  2 shs shs 4096 Oct  4 12:54 Frameworks
drwxr-xr-x. 11 shs shs 4096 Oct  4 15:45 Homebrew
drwxrwxr-x.  2 shs shs 4096 Oct  4 13:17 include
drwxrwxr-x.  2 shs shs 4096 Oct  4 13:17 lib
drwxrwxr-x.  2 shs shs 4096 Oct  6 16:17 opt
drwxrwxr-x.  2 shs shs 4096 Oct  4 13:17 sbin
drwxrwxr-x.  6 shs shs 4096 Oct  6 16:17 share
drwxrwxr-x.  3 shs shs 4096 Oct  4 15:30 var

브루 명령으로 설치된 패키지를 보려면 다음과 같이 하면 된다.
 
$ brew list
==> Formulae            <== package browser
fortune  hello            <== installed packages

결과를 보면 포뮬리(Formulae)는 패키지 브라우저다. 2번째 줄은 설치된 패키지 목록이다. 홈브루로 설치한 패키지를 삭제하려면 brew remove 또는 brew remove 명령어를 사용하면 된다. 같은 기능을 하는 것으로 모두 특정 패키지를 제거한다.
 
$ brew remove hello
Uninstalling /home/linuxbrew/.linuxbrew/Cellar/hello/2.10... (52 files, 595.7KB)

잘 삭제됐는지 확인하면 다음과 같다.
 
$ brew list
==> Formulae
Fortune                      <== hello is gone

홈브루는 glibc, gcc를 제외하면 호스트 시스템이 제공하는 어떤 라이브러리도 사용하지 않는다. 또한, 오래된 리눅스 배포판의 경우 홈브루가 glibc, gcc의 현재 버전을 설치한다. 홈브루는 커맨드라인 패키지 인스톨러처럼 작동한다. 다운로드하는 것이 무엇인지 확실히 알고 있기만 하면 안전하게 쓸 수 있는 툴이다. 패키지 검증 확인에 SHA256을 사용한다.
 

리눅스브루 필요 사양

리눅스브루를 사용하려면 다음과 같은 환경이 필요하다.
 
  • GCC 4.7.0 혹은 그 이후 버전
  • Linux 2.6.32 혹은 그 이후 버전
  • Glibc 2.13 혹은 그 이후 버전
  • 64비트 x86_64 CPU

editor@itworld.co.kr
Sponsored

회사명 : 한국IDG | 제호: ITWorld | 주소 : 서울시 중구 세종대로 23, 4층 우)04512
| 등록번호 : 서울 아00743 등록발행일자 : 2009년 01월 19일

발행인 : 박형미 | 편집인 : 박재곤 | 청소년보호책임자 : 한정규
| 사업자 등록번호 : 214-87-22467 Tel : 02-558-6950

Copyright © 2024 International Data Group. All rights reserved.