ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [4] 패치파일 만들기, 관리
    개발공부/openwrt 2024. 7. 27. 23:09

    ref: [OpenWrt Wiki] Patching your application: Editing existing files (openwrt)

    https://openwrt.org/docs/guide-developer/toolchain/use-patches-with-buildsystem (openwrt)

    https://trac.gateworks.com/wiki/OpenWrt/Patch (quilt 명령어 관련)

    https://hamonikr.org/oss/115576 (quilt 기초)

    sudo apt install quilt

    Q. 패치 파일 왜쓰나요?

    • 버전관리… 는 당연한 말이고
    • 빌드 과정에서 download ==>패치 ==> 컴파일 즉 내가 수정한 내용(패치에 없는) 이 반영 안되고 삭제되어 컴파일됨
    • 수정 내용을 패치로 관리, 적용이 필수다 (도움 by 조성욱 책임님conf)

    명령어설명

    quilt new 파일이름 새 패치 생성
    quilt series 모든 패치내용 보기
    quilt top 현재 패치
    quilt diff 변경사항 보기(git diff와 비슷하다)
    quilt edit 파일 nano편집기를 사용하여
    파일을 변경하고

    quilt diff 내용을 저장
    quilt refresh 패치 파일 생성(혹은 업데이트)
    quilt pop 변경사항을 버림, 복원
    quilt add 패치에 포함시킬 파일 추가 (git add와 유사)
    이후 변경해도 추적이 된다.

    ++make 명령어

    1. make package/example/download - download the soures of example
    2. make package/example/prepare - extract the sources, apply patches and download if necessary
    3. make package/example/compile - compile example, prepare and download if necessary
    4. make package/example/clean - clean the sourcecode
    5. make package/index - build a repository index to make the output directory usable as local opkg source

     

    • 기존 패키지 examples에 완전히 새로운 패치를 위해 소스 디렉터리 준비

    make package/mypackages/examples/helloworld/{clean,prepare} V=s QUILT=1

    (경로 : helloworld.c helloworld.o Makefile 만들었던 디렉토리)

    quilt = 1 은 make 명령이 prepare단계에서 quilt 패치도구를 관리하라 지시

    {clean,prepare}은 clean 후 prepare 하라는 지시

    make prepare = 소스 디렉터리 준비

     

    • 이미 존재했던 패치들 적용시키기

    cd build_dir/target-.../helloworld-1.0/ ==> 이 dir에 대한 설명이 없다.(helloworld-1.0)

    quilt push -a

    • 패치 만들기

    quilt new modhello.patch

    • 파일 수정하기

    quilt edit, quilt add 등으로 파일을 수정

    quilt diff 로 변경사항 확인

    • 저장하기

    quilt refresh ==> 패치파일이 생성된다.

     

    openwrt 작업의 최상단 폴더로 돌아와서 make package/…/helloworld/update

    를 실행시켜준다. (make package/mypackages/examples/helloworld/update)

    (만든 패치파일을 적용시키는 명령어인듯 하나 불명확 ==> 찾는중)


    quilt edit 으로 patch파일, 소스코드 변경

    quilt refresh로 패치파일 생성

    make update 적용

    그후 소스코드 변경

    빌드

    >> 소스코드 변경된 사항으로 적용


    6-1. patch 파일 적용시키기

    .patch 파일을 작업 폴더에 넣은 후 patch -p0 < 패치파일이름.patch 실행

Designed by Tistory.