199 lines
7.0 KiB
Perl
Executable File
199 lines
7.0 KiB
Perl
Executable File
#!/usr/bin/perl -w
|
|
use strict;
|
|
use Cwd;
|
|
use Data::Dumper;
|
|
use Encode;
|
|
use File::Path;
|
|
use File::Copy;
|
|
|
|
use utf8;
|
|
binmode(STDIN,':encoding(utf8)');
|
|
binmode(STDOUT,':encoding(utf8)');
|
|
binmode(STDERR,':encoding(utf8)');
|
|
|
|
my %machine_kernel_map = ('s9863a-1h10-otaab' => 'kernel5.4',
|
|
's9863a-1h10-otadev' => 'kernel5.4',
|
|
's9863a-1h10' => 'kernel5.4',
|
|
'ums9620-1h10' => 'kernel5.4',
|
|
'ums9620-2h10-k515' => 'kernel5.15',
|
|
'ums9620-2h10-otaab' => 'kernel5.4',
|
|
'ums9620-2h10' => 'kernel5.4');
|
|
|
|
my $filepath = $ENV{'PWD'}; # code root path
|
|
my $deleted_repos = `repo forall --group=idh,idhdel -c 'echo \$REPO_PATH,'`; #device/sprd,vendor/sprd/proprietories-source
|
|
my $machine = $ENV{'MACHINE'}; #MACHINE=sp9832a
|
|
my $distro = $ENV{'DISTRO'}; #DISTRO=unisoc-console
|
|
my $userdebug = $ENV{'USERDEBUG'}; #USERDEBUG=user or userdebug
|
|
my $imgsuffix = $ENV{'IMAGESUFFIX'}; #IMAGESUFFIX=console or wayland
|
|
my $secboot = $ENV{'SECBOOT_ENABLE'}; #SECBOOT_ENABLE=sec or nosec
|
|
my $product = $ENV{'UNISOC_PRODUCT'}; #UNISOC_PRODUCT=uboot22
|
|
|
|
if ($deleted_repos) {
|
|
$deleted_repos =~ s/\s+//g;
|
|
print "deleted_repos:$deleted_repos\n";
|
|
}
|
|
|
|
my @delrepos=split(/,/,$deleted_repos);
|
|
|
|
my $basefile="$filepath/default.xml";
|
|
my $imgpath="$filepath/out/IDH";
|
|
my $WORKSPACE = "$imgpath/idh.code";
|
|
|
|
mkpath($imgpath);
|
|
chdir($filepath);
|
|
`repo manifest -o $basefile -r -g default,-idh,-idhdel,-sprd_kaios,-sprd_intel`;
|
|
|
|
`repo manifest -r -o $imgpath/cus-manifest.xml -g all,-idh,-idhdel`;
|
|
`repo manifest -r -o $imgpath/cus-manifest_k54.xml -g all,-k515,-idh,-idhdel`;
|
|
`repo manifest -r -o $imgpath/cus-manifest_k515.xml -g all,-k54,-idh,-idhdel`;
|
|
# `repo manifest -r -o $imgpath/cus-manifest_19b.xml -g all,-cusop,19b,-idh,-idhdel`;
|
|
# `repo manifest -r -o $imgpath/cus-manifest_orca.xml -g all,-cusop,orca,-idh,-idhdel`;
|
|
|
|
`sed -i '/kernel5.15/d' $imgpath/cus-manifest_k54.xml`;
|
|
`sed -i '/source\/bsp\/u-boot15/d' $imgpath/cus-manifest_k54.xml`;
|
|
`sed -i '/OP-TEE/d' $imgpath/cus-manifest_k54.xml`;
|
|
`sed -i '/OpenAvnu/d' $imgpath/cus-manifest_k54.xml`;
|
|
`sed -i '/9863a/d' $imgpath/cus-manifest_k54.xml`;
|
|
`sed -i '/uis8520/d' $imgpath/cus-manifest_k54.xml`;
|
|
`sed -i '/udx710/d' $imgpath/cus-manifest_k54.xml`;
|
|
`sed -i '/kernel5.4/d' $imgpath/cus-manifest_k515.xml`;
|
|
`sed -i '/u-boot22/d' $imgpath/cus-manifest_k515.xml`;
|
|
|
|
##################### generate conf-XXX.tgz ########################
|
|
compress_proprietories_out();
|
|
if (!-d $WORKSPACE) {
|
|
mkpath("$WORKSPACE");
|
|
`repo forall -e -j32 -c \"mkdir -p ${WORKSPACE}/\\\$REPO_PATH;git --git-dir .git --work-tree ${WORKSPACE}/\\\$REPO_PATH reset --hard HEAD\"`;
|
|
} else {
|
|
exit;
|
|
}
|
|
|
|
######################### delete unreleased repos #########################
|
|
chdir("$WORKSPACE");
|
|
foreach my $delete_repo(@delrepos) {
|
|
print "rmtree:$delete_repo\n";
|
|
rmtree($delete_repo);
|
|
}
|
|
|
|
############## delete unreleased kernel ######################
|
|
print "rm unreleased kernel\n";
|
|
rm_unreleased_kernel($machine_kernel_map{$machine});
|
|
|
|
|
|
################### link and copy files to idh path ####################
|
|
chdir("$WORKSPACE");
|
|
symlink("prebuilts/scripts/setup-environment","setup-environment") || warn "could not symlink files :$!";
|
|
symlink("prebuilts/scripts/build.sh", "build.sh") || warn "could not symlink files :$!";
|
|
|
|
|
|
sub compress_proprietories_out {
|
|
|
|
chdir("$filepath");
|
|
my $build_dir = "build-$distro/";
|
|
my $out_dir = $build_dir;
|
|
opendir(BUILD, "$build_dir") || die "Can't open $build_dir: $!\n";
|
|
while (my $file_name = readdir(BUILD)) {
|
|
if($file_name =~ m/tmp-/) {
|
|
$out_dir .= "$file_name";
|
|
last;
|
|
}
|
|
}
|
|
closedir(BUILD);
|
|
|
|
#collect sensorhub libs
|
|
my $sensorhub_libs = "";
|
|
my $sensorhub_lib_dir = "source/bsp/sensorhub/public/lib/unisoc";
|
|
my $sensorhubExist = -e "$sensorhub_lib_dir";
|
|
if ($sensorhubExist) {
|
|
opendir(SENSORHUB_LIB, "$sensorhub_lib_dir") || die "Can't open $sensorhub_lib_dir: $!\n";
|
|
while (my $sensor_lib = readdir(SENSORHUB_LIB)) {
|
|
if (index($sensor_lib, ".a") != -1) {
|
|
print "sensorhub lib name: $sensor_lib\n";
|
|
$sensorhub_libs .= " $sensorhub_lib_dir/$sensor_lib";
|
|
}
|
|
}
|
|
closedir(SENSORHUB_LIB);
|
|
}
|
|
|
|
#collect bins for pac
|
|
my $prebuilt_pac_bins = "";
|
|
my $machine_out_dir = "$out_dir/deploy/images/$machine";
|
|
opendir(D, "$machine_out_dir") || die "Can't open $machine_out_dir: $!\n";
|
|
while (my $filename = readdir(D)) {
|
|
if (index($filename, ".bin") != -1) {
|
|
$prebuilt_pac_bins .= " $machine_out_dir/$filename";
|
|
}
|
|
}
|
|
closedir D;
|
|
|
|
print "compress proprietories out binary\n";
|
|
$out_dir .= "/deploy/images/$machine/out";
|
|
my $module_prebuilt_dir = "prebuilts/unisoc_bin/$machine";
|
|
mkdir("$module_prebuilt_dir");
|
|
system("cp $out_dir $module_prebuilt_dir/ -afd");
|
|
my $str1 = $machine;
|
|
$str1 =~ s/-/_/g;
|
|
my $str2 = $distro;
|
|
$str2 =~ s/unisoc-//g;
|
|
$str2 =~ s/-/+/g;
|
|
if ($product && $product ne "default") {
|
|
system("zip -ry $imgpath/proprietories-$str1+$str2+$imgsuffix+$secboot+$product-$userdebug-native.zip $module_prebuilt_dir $prebuilt_pac_bins $sensorhub_libs");
|
|
} else {
|
|
system("zip -ry $imgpath/proprietories-$str1+$str2+$imgsuffix+$secboot-$userdebug-native.zip $module_prebuilt_dir $prebuilt_pac_bins $sensorhub_libs");
|
|
}
|
|
print "DEBUG: imgpath is\n";
|
|
system("ls -l $imgpath");
|
|
print "DEBUG: proprietories is\n";
|
|
system("ls -l $imgpath/proprietories-*");
|
|
rmtree("$module_prebuilt_dir");
|
|
}
|
|
|
|
sub rm_unreleased_kernel {
|
|
|
|
my $released_kernel_dir = $_[0];
|
|
|
|
print "released_kernel_dir: $released_kernel_dir\n";
|
|
|
|
chdir("$filepath");
|
|
my $build_dir = "build-$distro/";
|
|
my $deploy_dir = $build_dir;
|
|
opendir(BUILD, "$build_dir") || die "Can't open $build_dir: $!\n";
|
|
while (my $file_name = readdir(BUILD)) {
|
|
if($file_name =~ m/tmp-/) {
|
|
$deploy_dir .= "$file_name/deploy/images/$machine/";
|
|
last;
|
|
}
|
|
}
|
|
closedir(BUILD);
|
|
|
|
my $kernel_path_file = "$deploy_dir/kernel_path";
|
|
my $kernel_path_exist = -e "$kernel_path_file";
|
|
if ($kernel_path_exist) {
|
|
open(KERNEL_PATH_FILE, "<$kernel_path_file") || die "Can't open $kernel_path_file: $!\n";
|
|
my $line = <KERNEL_PATH_FILE>;
|
|
print "read line: $line\n";
|
|
my @split_strings = split(/\//,$line);
|
|
$released_kernel_dir = $split_strings[-2];
|
|
close(KERNEL_PATH_FILE);
|
|
}
|
|
|
|
print "released_kernel_dir: $released_kernel_dir\n";
|
|
if (length($released_kernel_dir) != 0) {
|
|
chdir("$WORKSPACE");
|
|
|
|
my $kernel_dir = "source/kernel";
|
|
my $kernelExist = -e "$kernel_dir";
|
|
if ($kernelExist) {
|
|
opendir(KERNEL_DIR, "$kernel_dir") || die "Can't open $kernel_dir: $!\n";
|
|
while (my $kernel = readdir(KERNEL_DIR)) {
|
|
if ((index($kernel, "kernel") != -1) && ($kernel ne $released_kernel_dir)) {
|
|
print "rmtree : $kernel\n";
|
|
rmtree("$kernel_dir/$kernel");
|
|
}
|
|
}
|
|
closedir(KERNEL_DIR);
|
|
}
|
|
|
|
}
|
|
}
|