Yes! I Take IT

Linux kernel mainline contribution 본문

Development/Kernel

Linux kernel mainline contribution

JJungs-lee 2024. 2. 11. 21:53

오늘 Linux kernel mailine contribution 하는 방법을 알려드리려고 합니다.

 

저는 Linux kernel 개발을 했었고, 죽기 전에 꼭 한번쯤은 contribution 해서 저의 이름을 남겨보고 싶다는게 꿈이였습니다. 현재는 contribution을 몇개 해본 상황이고, 저와 같은 생각을 하시는 분이 있을 거라 생각하여 남깁니다.

 

  1. Linux mainline kernel source code을 clone하여 local PC에 받습니다.
    git clone https://github.com/torvalds/linux.git ./mainline_code
    
  2. git 환경세팅을 해줍니다. (git 환경 설정은 하신 분들은 skip)
    git config --global user.name "JJungs Lee"
    git config --global user.email "my_email@gmail.com"
    git config --global core.editor vi
    // --snip--
  3. 문제가 있는 코드(Bugs) or 새로운 기능(New features)을 수정합니다. 아래의 코드는 예시입니다.
    // test.c
    -int num = 0;
    +long long num = 0;
  4. git add 명령어를 통해 수정한 파일을 add 해주고, commit할때 -s or --signoff 사용하여 signed-off를 추가해줍니다.
    git add test.c
    git commit -s -m "test for commit"
    
  5. 위에서 만든 commit을 patch file로 만들어줍니다. 그리고 Linux kernel은 conding style 통일성을 유지하기 위해 노력하고 있기에, checkpatch tool를 활용하여 coding style을 검사합니다. 만약 coding style이 일치하지 않는 경우, checkpatch tool은 errors을 뿜을 겁니다. 당황하지 마시고 모두 고쳐주시면 됩니다(All errors, warnings, spaces, etc)
    git format-patch -1
    ./scripts/checkpatch.pl ./0001-test-for-commit.patch
    
  6. Linux는 엄청 큰 OS이기에 각 모듈을 담당하는 mainliner가 나뉘어져 있습니다.
    그러다보니 patch를 어떤 mainliner에게 전달해야 될지 모르는 경우가 많은데요.
    이때, get_maintainer tool을 통해서 mainliner를 파악할 수 있습니다.
    ./scripts/get_maintainer.pl ./0001-test-for-commit.patch
    
  7. 그리고 내가 만든 patch를 이메일로 전달하기 위해 아래의 명령어로 email tool을 설치합니다.
    물론 편하신 email을 사용하시면 됩니다. 
    sudo apt-get install git-email
    
  8. 저는 gti-email tool을 이용해 아래와 같이 patch를 작성해서 보냈습니다.
    만약 get send-email의 사용법에 대해 더 알고 싶으신 분들은 아래의 링크를 참고하세요.
    링크 - git send-email refer doc 
    git send-email \
    --to maintainer1@address.com \
    --to maintainer2@address.com \
    --cc cc_addr@mailinglist.org \
    ./0001-test-for-commit.patch
    
  9. 정상적으로 전송이 되었다면 아래의 site의 내가 보낸 patch가 조회가 됩니다.
    시간이 조금 걸리니 기다려주세요 :) 
    All of patch archive site - https://lkml.org/

 

Linux kernel에 contribution 할 수 있는 기회는 많지 않을텐데요. 꼭 기억해두셨다가 한번 쯤 기여해보시는건 어떠신가요?

 


 

참고 문서)

반응형