This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 253
/
Copy pathcreate_uninstaller.pl
executable file
·82 lines (61 loc) · 1.94 KB
/
create_uninstaller.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin qw($Bin);
use lib $Bin;
use Xposed;
use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
use Data::Dumper;
use File::Basename;
use File::Copy;
use File::Path qw(make_path remove_tree);
use Getopt::Std;
use POSIX qw(strftime);
use Tie::IxHash;
use Term::ANSIColor;
our $VERSION = '1.0';
my %opts;
$| = 1;
# Main routine
sub main() {
$Getopt::Std::STANDARD_HELP_VERSION = 1;
getopts('') || exit 2;
# Load the config file
print_status("Loading config file $Bin/build.conf...", 0);
$Xposed::cfg = Xposed::load_config("$Bin/build.conf") || exit 1;
# Check some build requirements
print_status('Checking requirements...', 0);
Xposed::check_requirements() || exit 1;
print_status('Creating ZIP archives...', 0);
foreach my $platform ('arm', 'x86', 'arm64', 'armv5') {
create_zip($platform) if -d "$Bin/zipstatic/$platform" || exit 1;
}
print_status('Done!', 0);
}
sub create_zip() {
my $platform = shift;
# Create a new ZIP file
my $zip = Archive::Zip->new();
$zip->addTree($Bin . '/zipstatic/_uninstaller/', '') == AZ_OK || return 0;
$zip->addTree($Bin . '/zipstatic/' . $platform . '/', '') == AZ_OK || return 0;
# Set last modification time to "now"
my $now = time();
foreach my $member($zip->members()) {
$member->setLastModFileDateTimeFromUnix($now);
}
# Write the ZIP file to disk
my $outdir = $Xposed::cfg->val('General', 'outdir');
my $zipname = sprintf('%s/uninstaller/xposed-uninstaller-%s-%s.zip', $outdir, strftime('%Y%m%d', localtime()), $platform);
make_path(dirname($zipname));
print "$zipname\n";
$zip->writeToFileNamed($zipname) == AZ_OK || return 0;
Xposed::sign_zip($zipname);
Xposed::gpg_sign($zipname) if Xposed::should_gpg_sign();
return 1;
}
sub HELP_MESSAGE() {
}
sub VERSION_MESSAGE() {
print "Xposed uninstaller creation script, version $VERSION\n";
}
main();