110 lines
3.2 KiB
PHP
Executable File
110 lines
3.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Enums\ClientIOSType;
|
|
use App\Model\Apps;
|
|
use App\Utils\Helps;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class IosIpaSign extends Command
|
|
{
|
|
/**
|
|
* 这个就是命令名称
|
|
*/
|
|
protected $signature = 'ios:ipa_sign {type}';
|
|
|
|
/**
|
|
* 命令的说明描述
|
|
* @var string
|
|
*/
|
|
protected $description = '';
|
|
|
|
/**
|
|
* 创建命令的构造方法。
|
|
* @param string $words 传入的字符参数
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function handle()
|
|
{
|
|
$clientType = $this->argument('type');
|
|
$types = [ ClientIOSType::BUYER, ClientIOSType::SELLER];
|
|
if (!in_array($clientType, $types)) {
|
|
dump('type error:' . $clientType);
|
|
return;
|
|
}
|
|
|
|
$outIpaPemPath = base_path('scripts/sign/ipas/'.date('Ymd'));
|
|
|
|
if (!file_exists($outIpaPemPath)) {
|
|
mkdir($outIpaPemPath,0777, true);
|
|
}
|
|
|
|
if ($clientType == ClientIOSType::BUYER) {
|
|
$version = Apps::buyerIOSVersion();
|
|
} else if ($clientType == ClientIOSType::SELLER) {
|
|
$version = Apps::sellerIOSVersion();
|
|
}
|
|
|
|
$uuid = 'a018277820e5eb371a8ffc5587afb3896410f40b';
|
|
$udidType = sprintf('release-%s-%s', $clientType, $version);
|
|
|
|
$provPath = $outIpaPemPath . '/'. $udidType . '.prov';
|
|
$certfPath = $outIpaPemPath . '/'. $udidType . '.certf';
|
|
|
|
if ($clientType == ClientIOSType::BUYER) {
|
|
$realIpaPath = Helps::ipaBuyerPath();
|
|
$appBundleId = 'com.pingco.daxiangzj';
|
|
} else {
|
|
$realIpaPath = Helps::ipaSellerPath();
|
|
$appBundleId = 'com.pingco.yunduoxd';
|
|
}
|
|
|
|
$shellPath = base_path('scripts/sign');
|
|
putenv('LANG=en_US.UTF-8');
|
|
|
|
$shell = "$shellPath/run.sh $appBundleId hanbin@pingco.com Zhang121748 2R4737WLD7 $uuid $shellPath/CertificateSigningRequest.certSigningRequest $provPath $certfPath";
|
|
|
|
exec($shell,$output, $outcode);
|
|
if ($outcode != 0) {
|
|
dump('生成profile文件失败', [
|
|
'code' => $outcode,
|
|
'error' => $output,
|
|
'shell' => $shell,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
$shellOutIpaPath = $outIpaPemPath . '/' . $udidType. '.ipa';
|
|
$shellIpa = "/usr/bin/zsign -k $shellPath/kefen.pem -p yunduoxd -m $provPath -o $shellOutIpaPath -z 9 $realIpaPath 2>&1";
|
|
exec($shellIpa,$outputIpa, $outCodeIpa);
|
|
if ($outCodeIpa != 0) {
|
|
dump('签名ipa文件失败', [
|
|
'code' => $outCodeIpa,
|
|
'error' => $outputIpa,
|
|
'shell' => $shellIpa,
|
|
]);
|
|
return;
|
|
}
|
|
|
|
$shellMv = "mv -f $shellOutIpaPath $realIpaPath";
|
|
exec($shellMv,$outputMv, $outCodeMv);
|
|
|
|
if ($outCodeMv != 0) {
|
|
Log::error('签名ipa文件失败', [
|
|
'code' => $outCodeMv,
|
|
'error' => $outputMv,
|
|
'shell' => $shellMv,
|
|
]);
|
|
return;
|
|
}
|
|
dump('IosIpaSign:: ipa build succeess~~~~~~~~~~~');
|
|
}
|
|
}
|