본문 바로가기
Programming/Tips(C++,C#)

대충 작성한 Qt설치 쉘 스크립트

by 곰네Zip 2011. 10. 13.

회사에서.. Qt를 설치할 일이 좀 많아서..
귀찮아서 걍 스크립트로 만들어봤다. 아직 수정하고 보완할 부분은 많지만.. 천천히 보강하고...
적어도 일일이 명령어 칠 필요는 없어졌자나.. ㅋㅋㅋ

#function define area

ErrorOccurred()
{
        PrintMessage "Detect Error! Installation aborted"
        exit
}

#성공시에 make혹은 first가 나오니까.. 우선 넣기는 하였으나 에러값 처리는 많은 고민이 필요
FindErrorString()
{
        errStr=$1
        echo $errStr > res.Log
        findCommand='grep -ic first res.Log'
        ret=$($findCommand)
        result=$ret
        findCommand='grep -ic make res.Log'
        ret=$($findCommand)
        result=`expr $ret + $result`
        rm -rf ./res.Log
        if [ $result == "0" ]
        then
                ErrorOccurred
        else
                PrintMessage "Move Next step."
        fi
}

MakeAndInstall()
{
        ChangeDirectory $1
        PrintMessage "Start Make"
        curCommand='make'
        ret=$($curCommand)
        FindErrorString "$ret"
        curCommand='make install'
        ret=$($curCommand)
        PrintMessage "make install finish"
}


ChangeDirectory()
{
        cd $1
        PrintMessage "Change path : "$PWD
}

StartConfig()
{
        ChangeDirectory $1
        command='./configure --prefix='$targetPath' -platform '$targetplatform' -no-tablet -release'
        $command
        PrintMessage "Config Finish. move next?"
        read nextCommand
        if [ $nextCommand == 'y' ]
        then
                PrintMessage "move next"
        else
                exit
        fi
}

StartCompile()
{
        StartConfig $1
 ChangeDirectory $1/src
        make clean
        MakeAndInstall $1/src/tools/moc
        MakeAndInstall $1/src/tools/rcc
        MakeAndInstall $1/src/tools/uic
        MakeAndInstall $1/src/corelib
        MakeAndInstall $1/src/network
        MakeAndInstall $1/src/gui
        MakeAndInstall $1/src/xml
        MakeAndInstall $1/src/plugins/codecs
        MakeAndInstall $1/src/testlib
        MakeAndInstall $1/src/svg
        PrintMessage "Make and Make Install Finished"
}

PrintMessage()
{
        echo "[QtInstaller] "$1
}
#function define area end

#command area
PrintMessage "Enter Qt Source Directory (ex. /home/root/qt..)"
read srcpath
PrintMessage "Source path : "$srcpath
PrintMessage "Enter TargetDirectory"
read targetPath
PrintMessage "Target path : "$targetPath
PrintMessage "Enter target Platform"
read targetplatform
StartCompile $srcpath $targetPath $targetplatform
ChangeDirectory $srcpath
PrintMessage "Copying need files"
cp -R bin $targetPath
cp -R mkspecs $targetPath
PrintMessage "Install Finish!"


PrintMessage "Target path : "$targetPath
PrintMessage "Enter target Platform"
read targetplatform
StartCompile $srcpath $targetPath $targetplatform
ChangeDirectory $srcpath
PrintMessage "Copying need files"
cp -R /bin $targetPath
cp -R /mkspecs $targetPath
PrintMessage "Install Finish!"

반응형

댓글