ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • NSIS
    개발/배포 2009. 8. 24. 23:55
    2.2 스크립트 파일
    NSIS 스크립트의 모든 줄은 명령으로 처리된다. 명령 줄이 너무 길면 줄 끝에 백슬래시(\)를 사용할 수 있다.

    문자열 내에서 더블쿼트를 쓰고 싶다면 $\"를 사용하거나 문자열을 `나 '로 감쌀 수 있다.

    스크립트 파일의 디폴트 확장자는 .nsi이고 헤더 파일은 .nsh 확장자를 사용한다. 스크립트 내에서 헤더 파일을 포함하기 위해서 !include를 사용한다. NSIS 설치 디렉토리의 Include 디렉토리에 위치하는 헤더파일을 사용할 때는 (경로 지정없이) 이름 만으로 포함시킬 수 있다. 예:
    !include Sections.nsh

    2.3 스크립트 구조
    NSIS 스크립트는 인스톨러 속성 명령과 섹션/함수를 포함할 수 있다. 필수 요소는 생성될 설치 프로그램의 위치를 지정하는 OutFile (인스톨러 속성) 명령과 하나의 섹션이다.

    콜백 함수가 정의되면 섹션 코드 전에 실행될 수 있다.
    .onInit
    페이지 콜백 함수들
    instfiles 페이지가 표시될 때 선택된 컴포넌트에 대응하는 섹션들이 실행된다.

    2.3.1 인스톨러 속성 명령(어트리뷰트?, 프래그마?, 디렉티브?)
    OutFile
    Name ; 타이틀바에 나타나는 이름
    InstallDir
    $INSTDIR
    XPStyle
    SetOverwrite

    2.3.2 페이지 (속성) 명령
    넌사일런트 인스톨러는 일련의 마법사 페이지들을 가진다.
    표시될 페이지들을 설정할 수 있고 콜백 함수들을 가진다.
    빌트인 페이지
    커스텀 페이지

    Page
    license
    components
    directory
    instfiles
    UninstPage
    uninstConfirm
    instfiles

    2.3.3 섹션(콜백?)
    각각의 섹션은 컴포넌트 페이지의 하나의 컴포넌트에 대응한다. 섹션 이름이 표시되는 컴포넌트 이름이다.
    If section_name is empty, omitted, or begins with a -, then it is a hidden section and the user will not have the option of disabling it.
    if ComponentText is set, the user will have the option of disabling/enabling each visible section
    If a section's name is 'Uninstall' or is prefixed with 'un.', it's an uninstaller section.

    예:
    Section "Installer Section"
    SectionEnd

    Section "un.Uninstaller Section"
    SectionEnd

    섹션 내의 명령은 인스톨러 속성 명령과 다르다.

    가장 기본적인 명령은 SetOutPath 인데 파일을 설치할 위치를 지정한다. File은 해당 파일을 설치한다.

    예:
    Section "My Program"
      SetOutPath $INSTDIR
      File "My Program.exe"
      File "Readme.txt"
    SectionEnd

    2.3.4 함수
    함수는 섹션과 동일한 스크립트 코드를 포함한다. 섹션과 함수의 차이는 호출되는 방식이다. 함수는 사용자 함수(user functions)와 콜백 함수(callback functions) 두가지 유형이 있다.

    사용자 함수는 섹션 혹은 다른 함수 내에서 Call 명령으로 호출한다.

    콜백 함수는 인스톨러 시작 등 특정한 이벤트가 발생했을 때 인스톨러가 호출한다. 콜백 함수는 옵션이다. 예:
    Function .onInit
      MessageBox MB_YESNO "This will install My Program. Do you wish to continue?" IDYES gogogo
        Abort
      gogogo:
    FunctionEnd

    Abort는 콜백 함수 내에서 특별한 의미를 가진다. 각각의 콜백 함수는 Abort 함수에 대해서 고유의 의미를 가진다. 위의 예에서 Abort는 인스롤러가 초기화를 멈추고 즉시 인스톨러 프로그램을 끝내도록 한다.

    * 인스톨시 콜백들
    .onGUIInit
    .onInit
        called when the installer is nearly finished initializing
    .onInstFailed
    .onInstSuccess
    .onGUIEnd
    .onMouseOverSection
    .onRebootFailed
    .onSelChange
    .onUserAbort
    .onVerifyInstDir
    * 언인스톨시 콜백들
    un.onGUIInit
    un.onInit
    un.onUninstFailed
    un.onUninstSuccess
    un.onGUIEnd
    un.onRebootFailed
    un.onSelChange
    un.onUserAbort
    *페이지 콜백들
    pre 함수
    (show 함수)
    leave 함수

    2.3.5 스크립트
    25 레지스터(임시 변수 - 20 범용, 5 스페셜), 1 스택
    $0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $R0, $R1, $R2, $R3, $R4, $R5, $R6, $R7, $R8, $R9
    Push
    Pop

    2.3.5.1 제어 구조
    StrCmp
    IntCmp
    IfErrors
    Goto

    !include LogicLib.nsh
    ${If} $0 == 'some value'
      MessageBox MB_OK '$$0 is some value'
    ${ElseIf} $0 == 'some other value'
      MessageBox MB_OK '$$0 is some other value'
    ${Else}
      MessageBox MB_OK '$$0 is "$0"'
    ${EndIf}

    ${If} $0 == ''
    ${AndIf} $1 == ''
      MessageBox MB_OK|MB_ICONSTOP 'both are empty!'
    ${EndIf}

    ${Switch} $0
      ${Case} 'some value'
        MessageBox MB_OK '$$0 is some value'
        ${Break}
      ${Case} 'some other value'
        MessageBox MB_OK '$$0 is some other value'
        ${Break}
      ${Default}
        MessageBox MB_OK '$$0 is "$0"'
        ${Break}
    ${EndSwitch}

    ${For} $R1 1 5
      .. $R1 ..
    ${Next}

    StrCpy $R1 0
    ${While} $R1 < 5
      IntOp $R1 $R1 + 1
      .. $R1 ..
    ${EndWhile}

    StrCpy $R1 0
    ${Do}
      IntOp $R1 $R1 + 1
      .. $R1 ..
    ${LoopUntil} $R1 >= 5

    2.3.5.2 (사용자) 변수

    변수는 (선언된 위치에 관계없이) 전역이고 섹션 혹은 (콜백, 사용자) 함수 내에서 쓰인다.

    c.f. !define

    Var ;변수 선언 (속성) 명령


    ... 명령(Instructions)
    Delete
    File

    writeUninstaller

    CreateDirectory
    CreateShortCut

    2.3.7 컴파일러 명령(프리프로세서) ; Compile Time Commands?
    컴파일러 명령은 컴파일시에만 실행된다.

    !include
        file inclusion
    !define
    c.f. $DESKTOP

    !undef
    !ifdef
        conditional compilation

    !ifndef
    !if
    !else
    !endif

    매크로
    !macro
    !macroend
    !insertmacro

    매크로 프로시저 호출

    !ifmacrodef
    !ifmacrondef
    !else
    !endif

    2.5 모던 UI
    welcom 페이지
    finish 페이지

    2.6 플러그인
    !addplugindir


    참조 사이트:


Designed by Tistory.