-
Notifications
You must be signed in to change notification settings - Fork 27
/
renamelaunchtime.pl
158 lines (118 loc) · 3.36 KB
/
renamelaunchtime.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/perl
# this script makes the git branch and moves/renames the package name for the playstore
# "Clean Project" and test!
use warnings;
use strict;
use File::Basename;
my $gitbranch = "playstore80";
my $from_pack = "com.quaap.launchtime";
my $to_pack = "com.quaap.launchtime_official";
my $basedir = ".";
if (@ARGV>0) {
if (@ARGV==2 || @ARGV>4) {
die "Usage: $0 [gitbranch [from_package to_package [directory]]]";
}
if (@ARGV>=1) {
$gitbranch = $ARGV[0];
}
if (@ARGV>=3) {
$from_pack = $ARGV[1];
$to_pack = $ARGV[2];
}
if (@ARGV==4) {
$basedir = $ARGV[3];
chdir $basedir;
}
}
my @java_paths = (
"app/src/main/java"
);
my @skip = (
basename($0),
"build",
"assets",
"captures",
".git",
".idea",
".gradle",
"README.md",
"packages1.txt",
"packages2.txt",
"submitted_activities.txt",
"submitted_packages.txt"
);
#Check if there are tracked changes
my @out = `git status -uno -s`;
die "git changes found!\n@out\n" if @out>0;
#/**
# * Copyright (C) 2017 Tom Kliethermes
# *
# * This file is part of LaunchTime and is is free software; you can redistribute it and/or
# * modify it under the terms of the GNU General Public License as published by the
# * Free Software Foundation; either version 3 of the License, or (at your option) any
# * later version.
# *
# * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# * See the GNU General Public License for more details.
# */
sub look_dir {
my $ldir = shift;
opendir D, $ldir;
my @subs = readdir(D);
closedir(D);
for my $file (@subs) {
my $ffile = "$ldir/$file";
#my $repath = $ffile;
#$repath=~s{^\Q$basedir\E/?}{};
#if ( grep( /^\Q$file\E|\Q$repath\E$/, @skip ) ) { next; }
if ( grep( /^\Q$file\E$/, @skip ) ) { next; }
if (-d $ffile and $file ne "." and $file ne "..") {
look_dir($ffile);
} elsif (-T $ffile) {
print "$ffile\n";
open F, '<:utf8', $ffile;
my @lines = <F>;
close F;
my $mod = 0;
for (@lines) {
if (s/\b\Q$from_pack\E\b/$to_pack/g) {
$mod = 1;
}
}
if ($mod) {
print "$ffile\n";
open F, '>:utf8', $ffile;
for my $line (@lines) {
print F $line;
}
close F;
}
}
}
}
my $from_pack_dir = $from_pack;
my $to_pack_dir = $to_pack;
$from_pack_dir =~ s{\.}{/}g;
$to_pack_dir =~ s{\.}{/}g;
if (system("git branch $gitbranch")!=0) {
die "Couldn't make branch $gitbranch";
}
print "created branch $gitbranch\n";
if (system("git checkout $gitbranch")!=0) {
die "Couldn't checkout branch $gitbranch";
}
for my $jpath (@java_paths) {
my $dir = "$basedir/$jpath";
if (-d $dir) {
my $cmd = qq(git mv "$dir/$from_pack_dir" "$dir/$to_pack_dir");
print "$cmd\n";
if (system($cmd)!=0) {
die "Couldn't $cmd";
}
}
#print("move \"$dir/$from_pack_dir\",\"$dir/$to_pack_dir\"\n");
#move("$dir/$from_pack_dir","$dir/$to_pack_dir");
#system qq(git mv "$dir/$from_pack_dir" "$dir/$to_pack_dir");
}
look_dir($basedir);