Mac codesign 및 실행 파일 변환 하는 Script

apple script 는 권한 문제가 있다

do sheel ..... with administrator privileges 권한문제 가 몬테레이에서 작동하지않는다.

해결이 안된다 sudo 를 암호 없이 실행하게 만들라 하는데 ..

Automator 에 빠른실행에 스크립터로 넣으면 된다.

쉘 스크립터가 더나은것같지만 실행파일변환시 와일드카드처럼작동한다,

---------------------------------------------Apple Script----------------------------

on run {input, parameters}

set getData to input

set orgPath to POSIX path of (getData as text)

set strPath to (alias getData as string) & "Contents:Macos:"

    set mypath to alias strPath

set {folder:Fo, package folder:Pa} to info for getData without size

if Fo and not Pa then

display dialog "😂선택한 항목은 폴더입니다 스크립터를 종료합니다😂"

else if Fo and Pa then

set p to POSIX path of ((choose file with prompt "😀실행파일로 변환할 파일을 선택하세요😀" of type {} default location mypath) as text)

do shell script "xattr -cr " & quoted form of orgPath & "; codesign --force --deep --sign - " & quoted form of orgPath & "; chmod 577 " & quoted form of p

else

do shell script "chmod 577 " & quoted form of orgPath & "; xattr -cr " & quoted form of orgPath & "; codesign --force --deep --sign - " & quoted form of orgPath

end if

end run

---------------------------------------------Shell Script----------------------------

export HISTIGNORE='*sudo -S*'

for f in "$@"

do

if [ -d "$f" ] ; then

echo "YOURPASSWORD" |sudo -S -k xattr -cr "$f"

echo "YOURPASSWORD" |sudo -S -k codesign --force --deep --sign - "$f"

# space filename no process. Macos folder all file EXE

for fileName in $(ls "$f/Contents/MacOS/"); do

    echo "YOURPASSWORD" |sudo -S -k chmod 577 "$f/Contents/MacOS/$fileName"

done

else

echo "YOURPASSWORD" |sudo -S -k chmod 577 "$f"

fi

done

댓글을 작성해보세요.