douba5540 2018-08-13 09:52
浏览 418

使用PHP exec shell(codesign)在Mac上重新签名IPA

I wrote some code to package channel IPA and resign IPA with shell. When I run this shell in command line it works ok.

Main shell code:

#!/bin/bash

name=$1
needchannel=$2
appName="$name.app"
ipa="$name.ipa"
plistName="${name}_${needchannel}.plist"

# echo "${1} ${2} $ipa"
if [ ! -f "./Payload" ];then
    # echo "not exit Payload"
    unzip $ipa
    chmod -R 0777 Payload
else
    echo "exit Payload"
fi  
cd Payload
cd $appName

ipaPath="${name}_${needchannel}.ipa"
/usr/libexec/PlistBuddy -c "set Channel $needchannel" "Channel.plist"

cd ../..

/usr/bin/codesign -f -s "iPhone Distribution: xxxx, ooo" --entitlements entitlements.plist "Payload/${appName}"
zip -rq  "./app/${ipaPath}" "Payload"

PHP code:

<?php

    $webid = $_GET["webid"];
    $appfinder = "./app/";
    $filename = "Channel_".$webid.".ipa";

    if (!file_exists($appfinder.$filename)) 
    {
        $shell = "sh produceApp.sh Channel $webid";

        system($shell, $status);

        if( $status ){
            echo "produceApp error";
            var_dump($status);
             return;
        }
    }
?>

I don't know why the shell run success in command line and fail in PHP. Can anybody help me.

Everything works except codesign.

ps:i write the shell code in php,run directly,system() return 1;like this:

<?php
    $shell = "/usr/bin/codesign -f -s \"iPhone Distribution: xxx, ooo\" --entitlements entitlements.plist \"Payload/Channel.app\"";
    echo "$shell";
    echo "<br>";
    system($shell, $status);
    print_r($status);
?>

the chrome show shell is:

/usr/bin/codesign -f -s "iPhone Distribution: xxx, ooo" --entitlements entitlementds.plist "Payload/Channel.app"

and function system() return $status is 1..

web show result of system run codesign...

  • 写回答

1条回答 默认 最新

  • duandi8838 2018-08-13 10:40
    关注

    The problem is in path! Log the path when you run php and correct it.

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿