Raspberry Pi_Kor_17.4.3 GitHub를 이용해서 인터넷에서 download하는 방법


Published Book on Amazon


All of IOT

Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1

All of IOT

Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2


출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사

물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)

최신 라즈베리파이(Raspberry Pi)로 시작하는 사

물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)


Original Book Contents


17.4.3  GitHub를 이용해서 인터넷에서 download하는 방법

 

마직막으로는 GitHub에서 source 프로그램을 제공하는 프로그램들도 있다. GitHub open source 프로그램을 개발하고, 배포하고, 사후 수정하는 과정에서 개발 프로그램 source code들을 안전하게 관리할 수 있게 해주고, 개발 시작부터 사후 관리까지 계속적인 수정사항들에 대한 version을 관리할 수 있는 도구를 제공해 준다. 여기에서 관리하는 프로그램들은 GitHub repository에 보관되어 있는데, 필요한 사람들은 언제나 해당 프로그램 source download하여 사용할 수 있다.

 

GitHub에서 프로그램을 download하려면 먼저 Git 프로그램을 설치해야 한다. 최신판 Raspbian에는 기본적으로 설치되어 있어서 별도의 작업이 필요 없지만, 설치되어 있지 않다면 다음과 같이 설치한다.

sudo apt-get install git

 

GitHub에서 설치할 프로그램을 다운로드 받기 위해서는 "git" 명령을 사용할 수 있다.

 

[명령 형식]

git  [command]   [option] 

 

[명령 개요]

    GitHub에서 지정된 파일을 download한다.

    user 권한    -- 일반 user.

 

[상세 설명]

    Git URL은 기본적으로 ssh, git, http, https, ftp, ftps, and rsync protocols.을 지원한다. 각각의 protocol에 대해 사용하는 형식은 다음과 같다.

    ssh       -- ssh://[user@]host.xz[:port]/path/to/repo.git/

    git        -- git://host.xz[:port]/path/to/repo.git/

    http[s]   -- http[s]://host.xz[:port]/path/to/repo.git/

    ftp[s]     -- ftp[s]://host.xz[:port]/path/to/repo.git/

    rsync     -- rsync://host.xz/path/to/repo.git/

    download한 프로그램 package는 특별한 지정이 없는 한 현재 작업 directory에 저장된다.


 

[주요 command]

clean

Remove untracked files from the working tree.

clone

Clone a repository into a new directory.

download를 하고자 할 때 사용한다.

log

Show commit logs.

git-gc

Cleanup unnecessary files and optimize the local repository.

 

 

[주요 option]

--depth <depth>

특정 version source를 선택한다.

-C <path>

Run as if git was started in <path> instead of the current working directory.

-p, --paginate

 

Pipe all output into less (or if set, $PAGER) if standard output is a terminal. This overrides the pager.<cmd> configuration options (see the "Configuration Mechanism" section below).

 

 

[사용 Example]

다음은 GitHub에서 <WiringPi> library package download하는 방법이다. 이 사례는 download 파일 경로에 GitHub의 자체 경로인 git-path를 지정하여 처리되었다.   

 

pi@raspberrypi ~ $ git clone --depth 1 git://git.drogon.net/wiringPi

Cloning into 'wiringPi'...

remote: Counting objects: 167, done.

remote: Compressing objects: 100% (146/146), done.

remote: Total 167 (delta 79), reused 46 (delta 16)

Receiving objects: 100% (167/167), 156.26 KiB | 110 KiB/s, done.

Resolving deltas: 100% (79/79), done.

 

다음 사례는 download 파일의 경로에 아래와 같이 URL 경로를 지정하여 처리한 것이다.

 

pi@raspberrypi ~ $ git clone --depth 1  https://github.com/WiringPi/WiringPi

Cloning into 'WiringPi'...

remote: Counting objects: 70, done.

remote: Compressing objects: 100% (50/50), done.

remote: Total 70 (delta 25), reused 59 (delta 19), pack-reused 0

Unpacking objects: 100% (70/70), done.

 

해당 프로그램에 대한 download가 완료된 이후 [File Manager]에서 자료를 확인해 보면 아래와 같이 "WiringPi" directory가 생성되어 있고 내부에 여러 파일들이 download되어 있음을 확인할 수 잇다.