BlankOnDev/Migration/bazaar2GitHub.pm untested

filter: Statementstmt 0.0% 0 / 3563 Branchbran 0.0% 0 / 630 Conditioncond 0.0% 0 / 142 MC/DCmcdc 0.0% 0 / 94 Subroutinesub 0.0% 0 / 69 Podpod 0.0% 0 / 55 totaltotal 0.0% 0 / 4553 CC 316 SCAR 50.8
CC
316
Cov
0%
_list_pkg
506.0
_addpkg
380.0
_gitpush_new
306.0
CRAP 160.5
1 package BlankOnDev::Migration::bazaar2GitHub;
2 use strict;
3 use warnings FATAL => 'all';
4  
5 # Import Module :
6 use Data::Dumper;
7 use JSON;
8 use JSON::XS;
9 use Term::ReadKey;
10 use Hash::MultiValue;
11 use BlankOnDev::DateTime;
12 use BlankOnDev::Utils::file;
13 use BlankOnDev::DataDev;
14 use BlankOnDev::HTTP::request;
15 use BlankOnDev::Migration::bazaar2GitHub::bazaar;
16 use BlankOnDev::Migration::bazaar2GitHub::github;
17 use Text::SimpleTable::AutoWidth;
18  
19 # Version :
20 our $VERSION = '0.1005';
21  
22 # Subroutine for get time :
23 # ------------------------------------------------------------------------
24 sub get_DateTime {
25 my ($self, $allconfig) = @_;
26  
27 # Get data current config :
28 my $curr_timezone = $allconfig->{'timezone'};
29 my $timestamp = time();
30 my $get_dataTime = BlankOnDev::DateTime->get($curr_timezone, $timestamp, {
31 'date' => '-',
32 'time' => ':',
33 'datetime' => ' ',
34 'format' => 'DD-MM-YYYY hms'
35 });
36 my $result = $get_dataTime->{'custom'};
37 return $result;
38 }
39 # Subroutine for action re migration :
40 # ------------------------------------------------------------------------
41 sub action_re_migration {
42 my ($self, $allconfig, $pkg_name, $pkg_group, $tmp_pkg, $time_branch) = @_;
43  
44 # Define hash or scalar :
45 my %data = ();
46 my $action_branch;
47 my $action_bzrCgit;
48 my $action_re_gtipush;
49 my $action_check;
50 my $time_gitpush;
51  
52 # Get data current config :
53 my $curr_pkg = $allconfig->{'pkg'};
54 my $dirpkg = $curr_pkg->{'dirpkg'};
55 my $locdir_pkg = $dirpkg.'/'.$pkg_group.'/'.$pkg_name;
56  
57 system("rm -rf $locdir_pkg");
58 system("mv -f $tmp_pkg $locdir_pkg");
59 $action_bzrCgit = BlankOnDev::Migration::bazaar2GitHub::bazaar->bzr2git_bzr_cgit($allconfig, $pkg_name);
60 if ($action_bzrCgit eq 1) {
61 print "[success] re-Action \"bzr convert git -> $pkg_name\" $action_bzrCgit\n";
62 $action_re_gtipush = BlankOnDev::Migration::bazaar2GitHub::github->bzr2git_reGitpush($allconfig, $pkg_name);
63 if ($action_re_gtipush eq 1) {
64 $time_gitpush = $self->get_DateTime($allconfig);
65 print "[success] Action \"re-git push -> $pkg_name\" \n";
66 $action_check = BlankOnDev::Migration::bazaar2GitHub::github->bzr2git_git_check($allconfig, $pkg_name);
67 if ($action_check ne 'undef') {
68 print "[success] Action \"git check -> $pkg_name\" $action_check\n";
69 } else {
70 print "[error] Action \"git check -> $pkg_name\" $action_check\n";
71 }
72 } else {
73 print "[error] Action \"re-git push -> $pkg_name\" | $action_re_gtipush\n";
74 }
75 } else {
76 print "[error] Action \"bzr convert git -> $pkg_name\" | $action_bzrCgit\n";
77 }
78  
79 # Prepare Configure :
80 my $prepare_config = prepare_config();
81 my $result_cfg = $prepare_config->{'bzr2git'}($allconfig, $pkg_name, $action_branch, $action_bzrCgit, $action_re_gtipush, $action_check, $time_branch, $time_gitpush);
82  
83 # Place :
84 $data{'bzr-cgit'} = $action_bzrCgit;
85 $data{'git-push'} = $action_re_gtipush;
86 $data{'git-check'} = $action_check;
87 $data{'result-cfg'} = $result_cfg;
88 return \%data;
89 }
90 # Subroutine for action migration :
91 # ------------------------------------------------------------------------
92 sub bzr2git_action_migration {
93 my ($self, $allconfig, $list_pkg) = @_;
94  
95 # Define scalar :
96 my $action_branch;
97 my $action_bzrCgit;
98 my $action_gitpush;
99 my $action_check;
100 my $time_branch;
101 my $time_gitpush;
102  
103 # Get data current config :
104 my $curr_timezone = $allconfig->{'timezone'};
105 my $curr_pkg = $allconfig->{'pkg'};
106 my $dirpkg = $curr_pkg->{'dirpkg'};
107  
108 # For Data Developer :
109 my $data_dev = BlankOnDev::DataDev::data_dev();
110 my $dir_tmp = $data_dev->{'dir_tmp'};
111  
112 # For List Packages :
113 my @list_packages = @{$list_pkg};
114  
115 # While loop to migration packages :
116 my $i_p = 0;
117 my $until_p = scalar @list_packages;
118 my $pkg_name;
119 my $pkg_group;
120 my $result_cfg = $allconfig;
121 while ($i_p < $until_p) {
122 $pkg_name = $list_packages[$i_p]->{'name'};
123 $pkg_group = $list_packages[$i_p]->{'group'};
124  
125 my $locdir_pkg = $dirpkg.'/'.$pkg_group.'/'.$pkg_name;
126 my $locdir_tmp_pkg = $dir_tmp.$pkg_group.'_'.$pkg_name;
127  
128 $action_branch = BlankOnDev::Migration::bazaar2GitHub::bazaar->bzr2git_branch($allconfig, $pkg_name, $pkg_group);
129 if ($action_branch eq 1) {
130 $time_branch = $self->get_DateTime($allconfig);
131 system("cp -rf $locdir_pkg $locdir_tmp_pkg");
132 print "[success] Action \"bzr branch -> $pkg_name\" : $action_branch\n";
133 $action_bzrCgit = BlankOnDev::Migration::bazaar2GitHub::bazaar->bzr2git_bzr_cgit($allconfig, $pkg_name);
134 if ($action_bzrCgit eq 1) {
135 print "[success] Action \"bzr convert git -> $pkg_name\" $action_bzrCgit\n";
136 $action_gitpush = BlankOnDev::Migration::bazaar2GitHub::github->bzr2git_gitpush($allconfig, $pkg_name);
137 if ($action_gitpush eq 1) {
138 $time_gitpush = $self->get_DateTime($allconfig);
139 print "[success] Action \"git push -> $pkg_name\" $action_gitpush\n";
140 $action_check = BlankOnDev::Migration::bazaar2GitHub::github->bzr2git_git_check($allconfig, $pkg_name);
141 if ($action_check ne 'undef') {
142 print "[success] Action \"git check -> $pkg_name\" $action_check\n";
143 } else {
144 print "[error] Action \"git check -> $pkg_name\" $action_check\n";
145 }
146 } else {
147 # Re migration :
148 my $action_reMig = $self->action_re_migration($result_cfg, $pkg_name, $pkg_group, $locdir_tmp_pkg, $time_branch);
149 $action_bzrCgit = $action_reMig->{'bzr-cgit'};
150 $action_gitpush = $action_reMig->{'git-push'};
151 $action_check = $action_reMig->{'git-check'};
152 $result_cfg = $action_reMig->{'result-cfg'};
153 }
154 } else {
155 print "[error] Action \"bzr convert git -> $pkg_name\" | $action_branch\n";
156 }
157 } else {
158 print "[error] Action \"bzr branch -> $pkg_name\" | $action_branch\n";
159 }
160 print "----" x 18 . "\n";
161  
162 # Prepare Configure :
163 my $prepare_config = prepare_config();
164 $result_cfg = $prepare_config->{'bzr2git'}($result_cfg, $pkg_name, $action_branch, $action_bzrCgit, $action_gitpush, $action_check, $time_branch, $time_gitpush);
165  
166 # Save configure :
167 my $saveConfig = save_newConfig();
168 $saveConfig->{'bzr2git'}($result_cfg);
169 $i_p++;
170 }
171 }
172 # Subroutine for action migration one package :
173 # ------------------------------------------------------------------------
174 sub action_bzr2git_single {
175 my ($self, $allconfig) = @_;
176  
177 # Define scalar :
178 my $pkg_name;
179 my $action_branch;
180 my $action_bzrCgit;
181 my $action_gitpush;
182 my $action_check;
183 my $time_branch;
184 my $time_gitpush;
185  
186 # For All config :
187 my $curr_pkg = $allconfig->{'pkg'};
188 my $dirpkg = $curr_pkg->{'dirpkg'};
189 my $pkg_list = $curr_pkg->{'pkgs'};
190  
191 # For Data Developer :
192 my $data_dev = BlankOnDev::DataDev::data_dev();
193 my $dir_tmp = $data_dev->{'dir_tmp'};
194  
195 # Form enter packages name ;
196 print "\n";
197 print "Enter packages name : ";
198 chomp($pkg_name = <STDIN>);
199 if ($pkg_name ne '') {
200 print "\n";
201 # Check Input Packages :
202 if (exists $pkg_list->{$pkg_name}) {
203 my $pkg_group = $pkg_list->{$pkg_name}->{'group'};
204  
205 my $locdir_pkg = $dirpkg.'/'.$pkg_group.'/'.$pkg_name;
206 my $locdir_tmp_pkg = $dir_tmp.$pkg_group.'_'.$pkg_name;
207 my $result_cfg = $allconfig;
208  
209 $action_branch = BlankOnDev::Migration::bazaar2GitHub::bazaar->bzr2git_branch($allconfig, $pkg_name, $pkg_group);
210 if ($action_branch eq 1) {
211 $time_branch = $self->get_DateTime($allconfig);
212 system("cp -rf $locdir_pkg $locdir_tmp_pkg");
213 print "[success] Action \"bzr branch -> $pkg_name\" : $action_branch\n";
214 $action_bzrCgit = BlankOnDev::Migration::bazaar2GitHub::bazaar->bzr2git_bzr_cgit($allconfig, $pkg_name);
215 if ($action_bzrCgit eq 1) {
216 print "[success] Action \"bzr convert git -> $pkg_name\" $action_bzrCgit\n";
217 $action_gitpush = BlankOnDev::Migration::bazaar2GitHub::github->bzr2git_gitpush($allconfig, $pkg_name);
218 if ($action_gitpush eq 1) {
219 $time_gitpush = $self->get_DateTime($allconfig);
220 print "[success] Action \"git push -> $pkg_name\" $action_gitpush\n";
221 $action_check = BlankOnDev::Migration::bazaar2GitHub::github->bzr2git_git_check($allconfig, $pkg_name);
222 if ($action_check ne 'undef') {
223 print "[success] Action \"git check -> $pkg_name\" $action_check\n";
224 } else {
225 print "[error] Action \"git check -> $pkg_name\" $action_check\n";
226 }
227 } else {
228 # Re migration :
229 my $action_reMig = $self->action_re_migration($result_cfg, $pkg_name, $pkg_group, $locdir_tmp_pkg);
230 $action_bzrCgit = $action_reMig->{'bzr-cgit'};
231 $action_gitpush = $action_reMig->{'git-push'};
232 $action_check = $action_reMig->{'git-check'};
233 $result_cfg = $action_reMig->{'result-cfg'};
234 }
235 } else {
236 print "[error] Action \"bzr convert git -> $pkg_name\" | $action_branch\n";
237 }
238 } else {
239 print "[error] Action \"bzr branch -> $pkg_name\" | $action_branch\n";
240 }
241  
242 # Prepare Configure :
243 my $prepare_config = prepare_config();
244 $result_cfg = $prepare_config->{'bzr2git'}($allconfig, $pkg_name, $action_branch, $action_bzrCgit, $action_gitpush, $action_check, $time_branch, $time_gitpush);
245  
246 # Save configure :
247 my $saveConfig = save_newConfig();
248 $saveConfig->{'bzr2git'}($result_cfg);
249 print "\n";
250 print "====" x 5 . " Migration packages \"$pkg_name\" has been finished ";
251 print "====" x 5 . "\n\n";
252 } else {
253 print "\n";
254 print "Warning : \n";
255 print "====" x 18 . "\n";
256 print "Packages \"$pkg_name\" is not exists...\n";
257 }
258 } else {
259 print "\n";
260 print "Info : \n";
261 print "====" x 18 . "\n";
262 print "Please Enter name package for Migration !!!\n";
263 exit 0;
264 }
265 }
266 # Subroutine for get amount of packages on group :
267 # ------------------------------------------------------------------------
268 sub amount_pkg {
269 my ($self, $allconfig, $input_group) = @_;
270  
271 # Get data current config :
272 my $curr_build = $allconfig->{'build'};
273 my $curr_pkg = $allconfig->{'pkg'};
274 my $list_pkg = $curr_pkg->{'pkgs'};
275  
276 # While loop to get list packages :
277 my $i = 0;
278 my @pre_data_pkg = ();
279 while (my ($key, $value) = each %$list_pkg) {
280 my $pkg_group = $list_pkg->{$key}->{'group'};
281 if ($pkg_group eq $input_group) {
282 $pre_data_pkg[$i] = $list_pkg->{$key};
283 }
284 $i++;
285 }
286 my @data_pkg = grep($_, @pre_data_pkg);
287 my $amount_pkg = scalar keys(@data_pkg);
288 return $amount_pkg;
289 }
290 # Subroutine for get list group and amount packages :
291 # ------------------------------------------------------------------------
292 sub bzr2git_get_list_group_amount_pkg {
293 my ($self, $allconfig) = @_;
294 my %data = ();
295  
296 # Get data current config :
297 my $curr_build = $allconfig->{'build'};
298 my $curr_pkg = $allconfig->{'pkg'};
299 my $list_group = $curr_pkg->{'group'};
300 my $size_list_group = scalar keys(%{$list_group});
301  
302 # Check count list packages group :
303 if ($size_list_group > 0) {
304  
305 # While loop for list packages group :
306 my $i = 0;
307 my @pre_list_pkggrp = ();
308 while (my ($key, $value) = each %$list_group) {
309 $pre_list_pkggrp[$i] = $key;
310 $i++;
311 }
312  
313 # Remove "undef" value on array :
314 my @list_pkggrp = grep($_, @pre_list_pkggrp);
315  
316 $i = 0;
317 my %data_group = ();
318 my $choice = '';
319 my $until = scalar @list_pkggrp;
320 my $num = 0;
321 my $amount_pkg;
322 while ($i < $until) {
323 $amount_pkg = $self->amount_pkg($allconfig, $list_pkggrp[$i]);
324 $num = $i + 1;
325 $data_group{$num} = $list_pkggrp[$i];
326 $choice .= sprintf("$num. %-25s %s\n", "$list_pkggrp[$i]", "[$amount_pkg]");
327 $i++;
328 }
329 $data{'data'} = \%data_group;
330 $data{'choice'} = $choice;
331 return \%data;
332 } else {
333 print "\n";
334 print "Info : \n";
335 print "====" x 18 . "\n";
336 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
337 exit 0;
338 }
339 }
340 # Subroutine for action migration by group :
341 # ------------------------------------------------------------------------
342 sub action_bzr2git2 {
343 my ($self, $allconfig) = @_;
344  
345 # Define scalar :
346 my $form_group;
347  
348 # Get data current config :
349 my $curr_pkg = $allconfig->{'pkg'};
350 my $data_list_grp = $self->bzr2git_get_list_group_amount_pkg($allconfig);
351 my $choice_grp = $data_list_grp->{'data'};
352  
353 # For Data Developer :
354 my $data_dev = BlankOnDev::DataDev::data_dev();
355 my $dir_tmp = $data_dev->{'dir_tmp'};
356  
357 # Form Group name :
358 print "\n";
359 print "Choose packages group : \n";
360 print "---" x 18 . "\n";
361 print $data_list_grp->{'choice'};
362 print "---" x 18 . "\n";
363 print "Enter number of group name : ";
364 chomp($form_group = <STDIN>);
365 if (exists $choice_grp->{$form_group}) {
366 my $input_group = $choice_grp->{$form_group};
367  
368 # Check group :
369 my $list_group = $self->filter_listpkg_based_group($allconfig, $input_group);
370 if ($list_group->{'result'} == 1) {
371 my @list_all_pkg = @{$list_group->{'data'}};
372  
373 print "\n";
374 print "Doing migration ...\n\n";
375  
376 # Action Migration :
377 $self->bzr2git_action_migration($allconfig, \@list_all_pkg);
378  
379 print "\n";
380 print "====" x 5 . " Migration all packages in group \"$input_group\" has been finished ";
381 print "====" x 5 . "\n\n";
382 } else {
383 print "\n";
384 print "Info : \n";
385 print "====" x 18 . "\n";
386 print "Not found packages in list on group \"$input_group\".\n";
387 print "Please run command \"boidev bzr2git addpkg\" to add new packages in group \"$input_group\",\n";
388 print "or \"boidev bzr2git addpkg-file\" to add new packages in group \"$input_group\".\n\n";
389 exit 0;
390 }
391 } else {
392 print "\n";
393 print "Info : Enter number choice\n";
394 print "====" x 18 . "\n";
395 print "Please enter number choice. \n\n";
396 exit 0;
397 }
398 }
399 # Subroutine for get amount of packages on group :
400 # ------------------------------------------------------------------------
401 sub bzr2git_list_group {
402 my ($self, $allconfig) = @_;
403  
404 # Define hash :
405 my %data = ();
406 my $data_list = '';
407  
408 # Get list group :
409 my $get_list_group = $self->list_all_pkg_group($allconfig);
410 my @list_group = @{$get_list_group->{'data'}};
411  
412 # While loop to get list packages group :
413 my $i = 0;
414 my $until = scalar keys(@list_group);
415 my $num = 0;
416 my $amount_pkg = '';
417 my @pre_dataGroup = ();
418 while ($i < $until) {
419 $amount_pkg = $self->amount_pkg($allconfig, $list_group[$i]);
420 if ($amount_pkg > 0) {
421 $num = $num + 1;
422 $data_list .= sprintf("$num. %-20s %s\n", "$list_group[$i]", "[$amount_pkg]");
423 $pre_dataGroup[$num] = $list_group[$i];
424 }
425 $i++;
426 }
427 my @data_group = grep($_, @pre_dataGroup);
428  
429 $data{'msg'} = $data_list;
430 $data{'data'} = \@data_group;
431 return \%data;
432 }
433 # Subroutine for action migration all packages :
434 # ------------------------------------------------------------------------
435 sub action_bzr2git1 {
436 my ($self, $allconfig) = @_;
437  
438 # Define scalar :
439 my $confirm_form;
440 my $confirm_form_pkg;
441 my $data_confirm = 0;
442 my $data_confirm_pkg = 0;
443  
444 # Get list group :
445 my $getList_group = $self->bzr2git_list_group($allconfig);
446 my $list = $getList_group->{'msg'};
447 my @list_groups = @{$getList_group->{'data'}};
448  
449 # Form Confirm :
450 print "\n";
451 print "You want migration all packages with automatically ? [y or n] ";
452 chomp($confirm_form = <STDIN>);
453 if ($confirm_form eq 'y' or $confirm_form eq 'Y') {
454 $data_confirm = 1;
455 $data_confirm_pkg = 1;
456 } else {
457 $data_confirm = 0;
458 }
459  
460 print "\n";
461 print "List Group packages to Migration : \n";
462 print "---" x 15 . "\n";
463 print $list;
464 print "---" x 15 . "\n";
465  
466 # While loop to migration :
467 my $i = 0;
468 my $until = scalar @list_groups;
469 my $amount_pkg = 0;
470 my $get_list_pkgs;
471 my @list_packages;
472 my $data_groups;
473 while ($i < $until) {
474 $data_groups = $list_groups[$i];
475 $get_list_pkgs = $self->filter_listpkg_based_group($allconfig, $data_groups);
476 $amount_pkg = $self->amount_pkg($allconfig, $data_groups);
477 @list_packages = @{$get_list_pkgs->{'data'}};
478  
479 # Check Confirm :
480 if ($data_confirm == 1) {
481  
482 print "\n";
483 print "Action Migration for all packages in group \"$data_groups [$amount_pkg]\" \n";
484 print "----" x 18 . "\n";
485  
486 # Action Migration :
487 $self->bzr2git_action_migration($allconfig, \@list_packages);
488 }
489 if ($data_confirm == 0) {
490 print "\n";
491 print "You want to migration all packages in group \"$data_groups [$amount_pkg]\" ? [y or n] ";
492 chomp($confirm_form_pkg = <STDIN>);
493 if ($confirm_form_pkg eq 'y' or $confirm_form_pkg eq 'Y') {
494 print "\n";
495 print "[migration] All packages in group \"$data_groups\" \n";
496 print "----" x 18 . "\n";
497  
498 # Action Migration :
499 $self->bzr2git_action_migration($allconfig, \@list_packages);
500 } else {
501 print "\n";
502 print "[no-migration] All packages in group \"$data_groups\" \n";
503 }
504 }
505 $i++;
506 }
507 print "\n";
508 print "====" x 5 . " Migration packages has been finished ";
509 print "====" x 5 . "\n\n";
510 }
511 # Action Bzr2git :
512 # ------------------------------------------------------------------------
513 sub action_bzr2git {
514 my ($self, $allconfig) = @_;
515 my $choose_act;
516  
517 # For Action :
518 my $switch_act = {
519 '1' => 'action_bzr2git1',
520 '2' => 'action_bzr2git2',
521 '3' => 'action_bzr2git_single'
522 };
523  
524 # Form action migration :
525 print "\n";
526 print "-----" x 15 . "\n";
527 print " Choose Action : \n";
528 print "-----" x 15 . "\n";
529 print "1. All Packages\n";
530 print "2. Specific Group Packages\n";
531 print "3. Single Packages\n";
532 print "Answer: ";
533 chomp($choose_act = <STDIN>);
534 if (exists $switch_act->{$choose_act}) {
535 my $subr_act = $switch_act->{$choose_act};
536 $self->$subr_act($allconfig);
537 } else {
538 print "\n";
539 print "System automatic choose to specific group name ...\n";
540 $self->action_bzr2git2($allconfig);
541 }
542 }
543 # Subroutine for option "bzr2git" :
544 # ------------------------------------------------------------------------
545 sub _bzr2git {
546 my ($self, $allconfig) = @_;
547  
548 my $options2 = {
549 'addpkg-group' => '_addpkg_group',
550 'addpkg' => '_addpkg',
551 'addpkg-file' => '_addpkg_file',
552 'rename-pkg-group' => '_rename_group_pkg',
553 'remove-pkg-group' => '_remove_group_pkg',
554 'remove-pkg' => '_removepkg',
555 'list-pkg' => '_list_pkg',
556 'list-pkg-group' => '_list_pkggrp',
557 'search-pkg' => '_search_pkg',
558 'branch' => '_branch',
559 'bzr-cgit' => '_bzr_cgit',
560 'git-push' => '_gitpush',
561 'git-push-new' => '_gitpush_new',
562 'git-check' => '_git_check',
563 're-branch' => '_re_branch',
564 're-gitpush' => '_re_gitpush',
565 };
566
567 my $options3 = {
568 'help' => 'usage_arg_3',
569 };
570  
571 # Check Argv :
572 my $arg_len = scalar @ARGV;
573 if ($arg_len > 1) {
574 if ($arg_len == 2) {
575 if ($allconfig->{'bzr'}->{'url'} eq '' or $allconfig->{'git'}->{'url'} eq '') {
576 print "\n";
577 print "Warning : \n";
578 print "=====" x 16 . "\n";
579 print "Please run command \"boidev mig_prepare\" to complete config this application !!! \n\n";
580 exit 0;
581 } else {
582 # Check Option :
583 if (exists $options2->{$ARGV[1]}) {
584 my $sub_act = $options2->{$ARGV[1]};
585 $self->$sub_act($allconfig);
586 } else {
587 print "\n";
588 print "Warning : \n";
589 print "=====" x 16 . "\n";
590 print "Error: Undefined arguments. You must valid input for argument two.\n";
591 $self->usage();
592 }
593 }
594 }
595 elsif ($arg_len == 3) {
596 if (exists $options2->{$ARGV[1]}) {
597 if (exists $options3->{$ARGV[2]}) {
598 my $sub_act = $options3->{$ARGV[2]};
599 $self->$sub_act($allconfig);
600 } else {
601 my $sub_act = $options2->{$ARGV[1]};
602 $self->$sub_act($allconfig);
603 }
604 } else {
605 print "\n";
606 print "Warning : \n";
607 print "=====" x 16 . "\n";
608 print "Error: Undefined arguments. You must valid input for argument two.\n";
609 $self->usage();
610 }
611 }
612 else {
613 print "\n";
614 print "Warning : \n";
615 print "=====" x 16 . "\n";
616 print "Error: Undefined arguments. You must input 1 - 3 arguments for command [boidev].\n";
617 exit 0;
618 }
619 }
620 elsif ($arg_len == 1) {
621 $self->action_bzr2git($allconfig);
622 }
623 else {
624 print "\n";
625 print "Warning : \n";
626 print "=====" x 16 . "\n";
627 print "Error : Undefined arguments. You must input arguments for command [boidev].\n";
628 $self->usage();
629 }
630 }
631 # Subroutine for check exists group :
632 # ------------------------------------------------------------------------
633 sub check_exists_group {
634 my ($self, $type, $group_cfg, $new_group) = @_;
635  
636 my %data = ();
637 my $result = 1;
638 my $list_grp = '';
639 my $check_list = 0;
640 my $count = scalar keys(%{$group_cfg});
641  
642 if ($type eq 'list') {
643 if ($count > 0) {
644 while (my ($key, $value) = each %{$group_cfg}) {
645 $list_grp .= "- $key\n";
646 }
647 $check_list = 1;
648 } else {
649 $check_list = 0;
650 }
651 $result = 1;
652 } else {
653 print "Jumlah $count\n";
654 if ($count >= 1) {
655 while (my ($key, $value) = each %{$group_cfg}) {
656 $list_grp .= "- $key\n";
657 if (exists $group_cfg->{$new_group}) {
658 $result = 0;
659 } else {
660 $result = 1;
661 }
662 }
663 $check_list = 1;
664 } else {
665 $list_grp = '';
666 $check_list = 1;
667 }
668 }
669 $data{'result'} = $result;
670 $data{'check'} = $check_list;
671 $data{'data'} = $list_grp;
672  
673 return \%data;
674 }
675 # Subroutine for add packages group :
676 # ------------------------------------------------------------------------
677 sub _addpkg_group {
678 my ($self, $allconfig) = @_;
679  
680 # Define scalar :
681 my $arg_len = scalar @ARGV;
682 my $input_new_grp = '';
683 my $new_grp = '';
684  
685 # For Data Developer :
686 my $data_dev = BlankOnDev::DataDev::data_dev();
687 my $dir_dev = $data_dev->{'dir_dev'};
688 my $dir_pkgs = $data_dev->{'dir_pkg'};
689  
690 # get data current pkg :
691 my $curr_build = $allconfig->{'build'};
692 my $build_rilis = $curr_build->{'rilis'};
693 my $curr_pkg = $allconfig->{'pkg'};
694  
695 # ------------------------------------------------------------------------
696 # Check IF $arg_len == 2 :
697 # ------------------------------------------------------------------------
698 if ($arg_len == 2) {
699  
700 # Check List Group :
701 my $check_list_group = $self->check_exists_group('list', $curr_pkg->{'group'}, '');
702  
703 # Form add group :
704 if ($check_list_group->{result} == 1) {
705 print "\n";
706 print "Exists Groups : \n";
707 print "---" x 18 . "\n";
708 print $check_list_group->{'data'};
709 print "\n\n";
710 }
711 print "Enter new group name : ";
712 chomp($input_new_grp = <STDIN>);
713 if ($input_new_grp ne '') {
714 if ($input_new_grp =~ m/^[A-Za-z0-9\-\_]+$/) {
715 $new_grp = $input_new_grp;
716 }
717 else {
718 $new_grp = '';
719 print "\n";
720 print "Name of group package must combination : \n";
721 print "- Alphabetic\n";
722 print "- Alphabetic Numberic\n";
723 print "- Alpabetic Numberic and [_] character or/and [-] character\n";
724 print "\n";
725 exit 0;
726 }
727  
728 # Check Group Name :
729 my $check_group = $self->check_exists_group('check', $curr_pkg->{'group'}, $new_grp);
730 if ($check_group->{'result'} == 1) {
731 my $locdir_pkg = $dir_dev.$dir_pkgs;
732 my $locdir_rilis = $locdir_pkg.'/'.$build_rilis;
733 my $locdir_pkggroup = $locdir_rilis.'/'.$new_grp;
734  
735 # Make Dir Group Packages :
736 unless (-d $locdir_pkggroup) {
737 mkdir($locdir_pkggroup);
738 }
739  
740 # Prepare Config ;
741 my $save_config = prepare_config();
742 my $result_addgrp = $save_config->{'add-group'}($allconfig, $new_grp);
743  
744 # Save Configure :
745 unless (exists $curr_pkg->{'group'}->{$new_grp}) {
746 my $for_saveCfg = save_newConfig();
747 $for_saveCfg->{'addgroup'}($result_addgrp);
748 }
749  
750 print "\n";
751 print "Success added package group with name \"$new_grp\"\n\n";
752 } else {
753 print "\n";
754 print "Warning : \n";
755 print "=====" x 16 . "\n";
756 print "group name is already exists, Please input another group name !!! \n\n";
757 exit 0;
758 }
759 } else {
760 print "\n";
761 print "Warning : \n";
762 print "=====" x 16 . "\n";
763 print "Input valid name group \n\n";
764 exit 0;
765 }
766 }
767 # ------------------------------------------------------------------------
768 # Check IF $arg_len == 3 :
769 # ------------------------------------------------------------------------
770 elsif ($arg_len == 3) {
771 # get data argument :
772 $new_grp = $ARGV[2];
773  
774 # Check Group Name :
775 my $check_group = $self->check_exists_group('check', $curr_pkg->{'group'}, $new_grp);
776 if ($check_group->{'result'} == 1) {
777 my $locdir_pkg = $dir_dev.$dir_pkgs;
778 my $locdir_rilis = $locdir_pkg.'/'.$build_rilis;
779 my $locdir_pkggroup = $locdir_rilis.'/'.$new_grp;
780  
781 # Make Dir Group Packages :
782 unless (-d $locdir_pkggroup) {
783 mkdir($locdir_pkggroup);
784 }
785  
786 # Prepare Config ;
787 my $save_config = prepare_config();
788 my $result_addgrp = $save_config->{'add-group'}($allconfig, $new_grp);
789  
790 # Save Configure :
791 unless (exists $curr_pkg->{'group'}->{$new_grp}) {
792 my $for_saveCfg = save_newConfig();
793 $for_saveCfg->{'addgroup'}($result_addgrp);
794 }
795  
796 print "\n";
797 print "Success added package group with name \"$new_grp\"\n\n";
798 } else {
799 print "\n";
800 print "Warning : \n";
801 print "=====" x 16 . "\n";
802 print "group name is already exists, Please input another group name !!! \n\n";
803 exit 0;
804 }
805 }
806 # ------------------------------------------------------------------------
807 # Check IF $arg_len == 3 or $arg_len == 2 :
808 # ------------------------------------------------------------------------
809 else {
810 my $arguments = '';
811 for (my $i = 0; $arg_len; $i++)
812 {
813 if ($i == $arg_len) {
814 $arguments .= $ARGV[$i];
815 } else {
816 $arguments .= $ARGV[$i].' ';
817 }
818 }
819 print "\n";
820 print "====" x 18 . "\n";
821 print "your command: boidev $arguments\n";
822 print "----" x 18 . "\n";
823 print "\n";
824 print "Warning : \n";
825 print "====" x 18 . "\n";
826 print "Error input arguments\n\n";
827 exit 0;
828 }
829 # ------------------------------------------------------------------------
830 # End of check IF $arg_len == 3 or $arg_len == 2.
831 # ========================================================================
832 }
833 # Subroutine for list packages group :
834 # ------------------------------------------------------------------------
835 sub _list_pkggrp {
836 my ($self, $allconfig) = @_;
837  
838 # get data current pkg :
839 my $curr_pkg = $allconfig->{'pkg'};
840  
841 # Check List Group :
842 my $check_list_group = $self->check_exists_group('list', $curr_pkg->{'group'}, '');
843  
844 # Form add group :
845 if ($check_list_group->{result} == 1) {
846 print "\n";
847 print "Exists Groups : \n";
848 print "---" x 18 . "\n";
849 print $check_list_group->{'data'};
850 print "\n\n";
851 } else {
852 print "\n";
853 print "Info : \n";
854 print "---" x 18 . "\n";
855 print "No group in list\n\n";
856 }
857 }
858 # Subroutine for Rename Group Packages :
859 # ------------------------------------------------------------------------
860 sub _rename_group_pkg {
861 my ($self, $allconfig) = @_;
862  
863 # Check Argumenets :
864 my $arg_len = scalar @ARGV;
865 my $input_grp;
866 my $new_input_group;
867 my $old_pkg_group;
868  
869 # Define scalar for config :
870 my $curr_data_pkg = $allconfig->{'pkg'};
871 my $list_group = $curr_data_pkg->{'group'};
872  
873 # ------------------------------------------------------------------------
874 # Check IF $arg_len == 2 :
875 # ------------------------------------------------------------------------
876 if ($arg_len == 2) {
877 print "\n";
878 print "Choose Group Packages.\n";
879  
880 my $num = 0;
881 my %num_grp = ();
882 while (my ($key, $value) = each %{$list_group}) {
883 my $_num = $num + 1;
884 $num_grp{$_num} = $key;
885 print "$_num. $key\n";
886 $num++;
887 }
888 print "Enter Number choice : ";
889 chomp($input_grp = <STDIN>);
890 if ($input_grp ne '') {
891 if ($input_grp =~ m/^[0-9]+$/) {
892 $old_pkg_group = $num_grp{$input_grp};
893  
894 # Check Packages Group :
895 if (exists $list_group->{$old_pkg_group}) {
896 # Form New Group Name :
897 print "\n";
898 print "Enter new group name : ";
899 chomp($new_input_group = <STDIN>);
900 if ($new_input_group ne '') {
901 # Check Group name :
902 unless (exists $list_group->{$new_input_group}) {
903 my $dataPkg_cfg;
904  
905 # Get list Packages based group :
906 my $get_list_pkg = $self->filter_listpkg_based_group($allconfig, $old_pkg_group);
907 if ($get_list_pkg->{'result'} == 1) {
908 my @list_pkgs = @{$get_list_pkg->{'data'}};
909  
910 my $i = 0;
911 my $size_list = scalar keys(@list_pkgs);
912 $dataPkg_cfg = $allconfig;
913 while ($i < $size_list) {
914 my $data_list_pkgs = $list_pkgs[$i]->{'name'};
915  
916 # Prepare Config :
917 my $prepare_cfgPkgs = prepare_config();
918 $dataPkg_cfg = $prepare_cfgPkgs->{'rename-pkg-group'}($dataPkg_cfg, $old_pkg_group, $new_input_group, $data_list_pkgs);
919  
920 print "Packages \"$data_list_pkgs\" change Group name \"$old_pkg_group\" to \"$new_input_group\" has success changed...\n";
921  
922 $i++;
923 }
924  
925 my $prepare_cfgGrp = prepare_config();
926 $dataPkg_cfg = $prepare_cfgGrp->{'rename-group-pkg'}($dataPkg_cfg, $old_pkg_group, $new_input_group);
927  
928 # Execute Config :
929 my $execute_config = save_newConfig();
930 $execute_config->{'rename-pkg-group'}($dataPkg_cfg);
931  
932 print "Packages change Group name \"$old_pkg_group\" to \"$new_input_group\" has success changed...\n";
933 } else {
934 $dataPkg_cfg = $allconfig;
935 my $prepare_cfgGrp = prepare_config();
936 $dataPkg_cfg = $prepare_cfgGrp->{'rename-group-pkg'}($dataPkg_cfg, $old_pkg_group, $new_input_group);
937  
938 # Execute Config :
939 my $execute_config = save_newConfig();
940 $execute_config->{'rename-pkg-group'}($dataPkg_cfg);
941  
942 print "Packages change Group name \"$old_pkg_group\" to \"$new_input_group\" has success changed...\n";
943 }
944 } else {
945 print "\n";
946 print "Warning : \n";
947 print "====" x 18 . "\n";
948 print "New Group name is exists !! \n\n";
949 exit 0;
950 }
951 } else {
952 print "\n";
953 print "Warning : \n";
954 print "====" x 18 . "\n";
955 print "No input new name grup !! \n\n";
956 exit 0;
957 }
958 } else {
959 print "\n";
960 print "Warning : \n";
961 print "====" x 18 . "\n";
962 print "Input Group Packages is not found\n\n";
963 exit 0;
964 }
965 } else {
966 print "\n";
967 print "Choice Group only Numberic...\n\n";
968 exit 0;
969 }
970 } else {
971 print "\n";
972 print "Warning : \n";
973 print "====" x 18 . "\n";
974 print "Please Number choice for Group Packages if you want to rename group packages on apps system.\n";
975 print "Or run command \"boidev bzr2git rename-pkg-group <Name_packages>\".\n\n";
976 exit 0;
977 }
978 }
979 # ------------------------------------------------------------------------
980 # Check IF $arg_len == 3 :
981 # ------------------------------------------------------------------------
982 elsif ($arg_len == 3) {
983 # Define scalar :
984 $old_pkg_group = $ARGV[2];
985  
986 # Check Packages Group :
987 if (exists $list_group->{$old_pkg_group}) {
988 # Form New Group Name :
989 print "\n";
990 print "Enter new group name : ";
991 chomp($new_input_group = <STDIN>);
992 if ($new_input_group ne '') {
993 # Check Group name :
994 unless (exists $list_group->{$new_input_group}) {
995 my $dataPkg_cfg;
996  
997 # Get list Packages based group :
998 my $get_list_pkg = $self->filter_listpkg_based_group($allconfig, $old_pkg_group);
999 if ($get_list_pkg->{'result'} eq 1) {
1000 my @list_pkgs = @{$get_list_pkg->{'data'}};
1001  
1002 my $i = 0;
1003 my $size_list = scalar keys(@list_pkgs);
1004 $dataPkg_cfg = $allconfig;
1005 while ($i < $size_list) {
1006 my $data_list_pkgs = $list_pkgs[$i]->{'name'};
1007  
1008 # Prepare Config :
1009 my $prepare_cfgPkgs = prepare_config();
1010 $dataPkg_cfg = $prepare_cfgPkgs->{'rename-pkg-group'}($dataPkg_cfg, $old_pkg_group, $new_input_group, $data_list_pkgs);
1011  
1012 print "Packages \"$data_list_pkgs\" change Group name \"$old_pkg_group\" to \"$new_input_group\", success...\n";
1013  
1014 $i++;
1015 }
1016  
1017 my $prepare_cfgGrp = prepare_config();
1018 $dataPkg_cfg = $prepare_cfgGrp->{'rename-group-pkg'}($dataPkg_cfg, $old_pkg_group, $new_input_group);
1019  
1020 # Execute Config :
1021 my $execute_config = save_newConfig();
1022 $execute_config->{'rename-pkg-group'}($dataPkg_cfg);
1023  
1024 print "Packages change Group name \"$old_pkg_group\" to \"$new_input_group\" has success changed...\n";
1025 } else {
1026 $dataPkg_cfg = $allconfig;
1027 my $prepare_cfgGrp = prepare_config();
1028 $dataPkg_cfg = $prepare_cfgGrp->{'rename-group-pkg'}($dataPkg_cfg, $old_pkg_group, $new_input_group);
1029  
1030 # Execute Config :
1031 my $execute_config = save_newConfig();
1032 $execute_config->{'rename-pkg-group'}($dataPkg_cfg);
1033  
1034 print "Packages change Group name \"$old_pkg_group\" to \"$new_input_group\" has success changed...\n";
1035 }
1036 } else {
1037 print "\n";
1038 print "Warning : \n";
1039 print "====" x 18 . "\n";
1040 print "New Group name is exists !! \n\n";
1041 }
1042 } else {
1043 print "\n";
1044 print "Warning : \n";
1045 print "====" x 18 . "\n";
1046 print "No input new name grup !! \n\n";
1047 }
1048 } else {
1049 print "\n";
1050 print "Warning : \n";
1051 print "====" x 18 . "\n";
1052 print "Input Group Packages is not found\n\n";
1053 }
1054 }
1055 # ------------------------------------------------------------------------
1056 # Check IF $arg_len == 3 or $arg_len == 2 :
1057 # ------------------------------------------------------------------------
1058 else {
1059 my $i = 0;
1060 my $data_cmd = '';
1061 foreach my $arg (each @ARGV) {
1062 if ($arg_len - 1 == $i) {
1063 $data_cmd .= $arg;
1064 } else {
1065 $data_cmd .= "$arg ";
1066 }
1067 $i++;
1068 }
1069 print "\n";
1070 print "====" x 18 . "\n";
1071 print "your command: boidev $data_cmd\n";
1072 print "----" x 18 . "\n";
1073 print "\n";
1074 print "Warning : \n";
1075 print "====" x 18 . "\n";
1076 print "Error input arguments\n\n";
1077 exit 0;
1078 }
1079 # ------------------------------------------------------------------------
1080 # End of check IF $arg_len == 3 or $arg_len == 2.
1081 # ========================================================================
1082 }
1083 # Subroutine for Remove PkgGroup :
1084 # ------------------------------------------------------------------------
1085 sub remove_pkg_grp {
1086 my ($self, $allconfig, $input_group) = @_;
1087  
1088 # Define scalar :
1089 my $new_input_group;
1090 my $confirm_remove;
1091 my $confirm_remove_pkg;
1092 my $confirm_add_pkggrp;
1093 my $form_rename_pkg_grp;
1094 my $confirm_rename_pkg_grp = 0;
1095 my $new_group_name = '';
1096  
1097 # For Data Developer :
1098 my $data_dev = BlankOnDev::DataDev::data_dev();
1099 my $dir_dev = $data_dev->{'dir_dev'};
1100 my $dir_pkgs = $data_dev->{'dir_pkg'};
1101  
1102 # get data current pkg :
1103 my $curr_build = $allconfig->{'build'};
1104 my $build_rilis = $curr_build->{'rilis'};
1105  
1106 # Get list Packages based group :
1107 my $get_list_pkg = $self->filter_listpkg_based_group($allconfig, $input_group);
1108 if ($get_list_pkg->{'result'} == 1) {
1109 my @list_pkgs = @{$get_list_pkg->{'data'}};
1110  
1111 # Confirm to rename group name in data packages :
1112 print "\n";
1113 print "Found Packages related on group name\n";
1114 print "You want to remove group name [y/n] : ";
1115 chomp($confirm_remove = <STDIN>);
1116 if ($confirm_remove eq 'y' or $confirm_remove eq 'Y') {
1117  
1118 # Form Remove All Packages :
1119 print "\n";
1120 print "You want remove all packages in group [y/n] : ";
1121 chomp($confirm_remove_pkg = <STDIN>);
1122 if ($confirm_remove_pkg eq 'y' or $confirm_remove_pkg eq 'Y') {
1123 $confirm_remove_pkg = 1;
1124 } else {
1125 $confirm_remove_pkg = 0;
1126 }
1127  
1128 # From for add new group :
1129 print "\n";
1130 print "You want to create new group : [y/n] : ";
1131 chomp($confirm_add_pkggrp = <STDIN>);
1132 if ($confirm_add_pkggrp eq 'y' or $confirm_add_pkggrp eq 'Y') {
1133 $confirm_add_pkggrp = 1;
1134 } else {
1135 $confirm_add_pkggrp = 0;
1136 }
1137  
1138 # For Dir Groups :
1139 my $locdir_pkg = $dir_dev.$dir_pkgs;
1140 my $locdir_rilis = $locdir_pkg.'/'.$build_rilis;
1141 my $locdir_pkggroup = $locdir_rilis.'/'.$input_group;
1142 my $dataPkg_cfg = $allconfig;
1143  
1144 # Form Rename Group :
1145 if ($confirm_remove_pkg == 0 and $confirm_add_pkggrp == 1) {
1146 print "\n";
1147 print "You want to rename group in data packages [y/n] : ";
1148 chomp($form_rename_pkg_grp = <STDIN>);
1149 if ($form_rename_pkg_grp eq 'y' or $form_rename_pkg_grp eq 'Y') {
1150 $confirm_rename_pkg_grp = 1;
1151 print "Enter new group name : ";
1152 chomp($new_group_name = <STDIN>);
1153 if ($new_group_name ne '') {
1154 $new_group_name = $new_group_name;
1155 } else {
1156 $new_group_name = 'undef-group';
1157 }
1158 }
1159 }
1160  
1161 my $i = 0;
1162 my $size_list = scalar keys(@list_pkgs);
1163 while ($i < $size_list) {
1164 my $data_list_pkgs = $list_pkgs[$i]->{'name'};
1165 my $data_old_pkg_grp = $list_pkgs[$i]->{'group'};
1166 my $locdir_datapkg = $locdir_rilis.'/'.$input_group.'/'.$data_list_pkgs;
1167  
1168 if ($confirm_remove_pkg == 1) {
1169 # Prepare Config :
1170 my $prepare_cfgPkgs = prepare_config();
1171 $dataPkg_cfg = $prepare_cfgPkgs->{'remove-pkg'}($dataPkg_cfg, $data_list_pkgs);
1172 } else {
1173 if ($confirm_rename_pkg_grp eq 1) {
1174 # Prepare Config :
1175 my $prepare_cfgPkgs = prepare_config();
1176 $dataPkg_cfg = $prepare_cfgPkgs->{'rename-pkg-group'}($dataPkg_cfg, $data_old_pkg_grp, $new_group_name, $data_list_pkgs);
1177 }
1178 }
1179  
1180 $i++;
1181 }
1182 if ($confirm_remove_pkg == 0 and $confirm_rename_pkg_grp == 1) {
1183  
1184 print "\n";
1185 print "All packages change group name to \"$new_group_name\" \n\n";
1186 }
1187  
1188 # Remove Group Name :
1189 my $remove_grup = prepare_config();
1190 $dataPkg_cfg = $remove_grup->{'remove-group'}($dataPkg_cfg, $input_group);
1191  
1192 # Save Config :
1193 my $saveConfig = save_newConfig();
1194 $saveConfig->{'remove-group'}($dataPkg_cfg);
1195  
1196 # Make Dir Group Packages :
1197 if (-d $locdir_pkggroup) {
1198 system("rm -rf $locdir_pkggroup");
1199 }
1200  
1201 print "\n";
1202 print "Group name \"$input_group\" has success deleted...\n\n";
1203  
1204 if ($confirm_add_pkggrp == 1) {
1205  
1206 if ($confirm_add_pkggrp == 1 and $confirm_remove_pkg == 1) {
1207 print "Enter new group name : ";
1208 chomp($new_group_name = <STDIN>);
1209 if ($new_group_name ne '') {
1210 $new_group_name = $new_group_name;
1211 } else {
1212 $new_group_name = 'undef-group';
1213 }
1214 }
1215  
1216 # add Group Name :
1217 my $add_grp = prepare_config();
1218 $dataPkg_cfg = $add_grp->{'add-group'}($dataPkg_cfg, $new_group_name);
1219  
1220 # Save Config :
1221 $saveConfig = save_newConfig();
1222 $saveConfig->{'addgroup'}($dataPkg_cfg);
1223  
1224 print "Add group name \"$new_group_name\" has success added...\n\n";
1225 }
1226 } else {
1227 print "\n";
1228 print "Warning : \n";
1229 print "====" x 18 . "\n";
1230 print "Input Group Packages is not found\n\n";
1231 exit 0;
1232 }
1233 } else {
1234 # Remove Group Name :
1235 my $dataPkg_cfg = $allconfig;
1236 my $remove_grup = prepare_config();
1237 $dataPkg_cfg = $remove_grup->{'remove-group'}($dataPkg_cfg, $input_group);
1238  
1239 # Save Config :
1240 my $saveConfig = save_newConfig();
1241 $saveConfig->{'remove-group'}($dataPkg_cfg);
1242  
1243 # For Dir Groups :
1244 my $locdir_pkg = $dir_dev.$dir_pkgs;
1245 my $locdir_rilis = $locdir_pkg.'/'.$build_rilis;
1246 my $locdir_pkggroup = $locdir_rilis.'/'.$input_group;
1247  
1248 # Make Dir Group Packages :
1249 if (-d $locdir_pkggroup) {
1250 system("rm -rf $locdir_pkggroup");
1251 }
1252  
1253 print "Group name \"$input_group\" has success deleted...\n\n";
1254 exit 0;
1255 }
1256 }
1257 # Subroutine for Remove Group Packages :
1258 # ------------------------------------------------------------------------
1259 sub _remove_group_pkg {
1260 my ($self, $allconfig) = @_;
1261  
1262 # Check Argumenets :
1263 my $arg_len = scalar @ARGV;
1264 my $input_grp;
1265 my $old_pkg_group;
1266  
1267 # Define scalar for config :
1268 my $curr_data_pkg = $allconfig->{'pkg'};
1269 my $list_group = $curr_data_pkg->{'group'};
1270  
1271 # ------------------------------------------------------------------------
1272 # Check IF $arg_len == 2 :
1273 # ------------------------------------------------------------------------
1274 if ($arg_len == 2) {
1275 print "\n";
1276 print "Choose Group Packages.\n";
1277  
1278 my $num = 0;
1279 my %num_grp = ();
1280 while (my ($key, $value) = each %{$list_group}) {
1281 my $_num = $num + 1;
1282 $num_grp{$_num} = $key;
1283 print "$_num. $key\n";
1284 $num++;
1285 }
1286 print "Enter Number choice : ";
1287 chomp($input_grp = <STDIN>);
1288 if ($input_grp ne '') {
1289 if ($input_grp =~ m/^[0-9]+$/) {
1290 $old_pkg_group = $num_grp{$input_grp} if exists $num_grp{$input_grp};
1291 $old_pkg_group = 'no' unless exists $num_grp{$input_grp};
1292  
1293 # Check Packages Group :
1294 if (exists $list_group->{$old_pkg_group}) {
1295 # Action Remove Group :
1296 $self->remove_pkg_grp($allconfig, $old_pkg_group);
1297 } else {
1298 print "\n";
1299 print "Warning : \n";
1300 print "====" x 18 . "\n";
1301 print "Input Group Packages is not found\n\n";
1302 exit 0;
1303 }
1304  
1305 } else {
1306 print "\n";
1307 print "Choice Group only Numberic...\n\n";
1308 exit 0;
1309 }
1310 } else {
1311 print "\n";
1312 print "Warning : \n";
1313 print "====" x 18 . "\n";
1314 print "Please Number choice for Group Packages if you want to remove group packages on apps system.\n";
1315 print "Or run command \"boidev bzr2git remove-pkg-group <Name_packages>\".\n\n";
1316 exit 0;
1317 }
1318 }
1319 # ------------------------------------------------------------------------
1320 # Check IF $arg_len == 3 :
1321 # ------------------------------------------------------------------------
1322 elsif ($arg_len == 3) {
1323 # For Get arguments :
1324 my $input_arg = $ARGV[2];
1325  
1326 # Check Packages Group :
1327 if (exists $list_group->{$input_arg}) {
1328 # Action Remove Group :
1329 $self->remove_pkg_grp($allconfig, $input_arg);
1330 } else {
1331 print "\n";
1332 print "Warning : \n";
1333 print "====" x 18 . "\n";
1334 print "Input Group Packages is not found\n\n";
1335 exit 0;
1336 }
1337 }
1338 # ------------------------------------------------------------------------
1339 # Check IF $arg_len == 3 or $arg_len == 2 :
1340 # ------------------------------------------------------------------------
1341 else {
1342 my $i = 0;
1343 my $data_cmd = '';
1344 foreach my $arg (each @ARGV) {
1345 if ($arg_len - 1 == $i) {
1346 $data_cmd .= $arg;
1347 } else {
1348 $data_cmd .= "$arg ";
1349 }
1350 $i++;
1351 }
1352 print "\n";
1353 print "====" x 18 . "\n";
1354 print "your command: boidev $data_cmd\n";
1355 print "----" x 18 . "\n";
1356 print "\n";
1357 print "Warning : \n";
1358 print "====" x 18 . "\n";
1359 print "Error input arguments\n\n";
1360 exit 0;
1361 }
1362 # ------------------------------------------------------------------------
1363 # End of check IF $arg_len == 3 or $arg_len == 2.
1364 # ========================================================================
1365 }
1366 # Subroutine for Group Packages :
1367 # ------------------------------------------------------------------------
1368 sub group_pkg {
1369 my ($self, $allconfig) = @_;
1370  
1371 # Define hash or scalar ;
1372 my %data = ();
1373 my $num_pkg_group;
1374 my $input_pkg_group = '';
1375 my $pkg_group = '';
1376 my $pkg_group_stts = 0;
1377 my $r_pkg_group;
1378  
1379 # Define scalar for group packages :
1380 if (exists $allconfig->{'pkg'}->{'group'}) {
1381 my $curr_dataPkg_grp = $allconfig->{'pkg'}->{'group'};
1382 my $size_datapkg = scalar keys(%{$curr_dataPkg_grp});
1383 if ($size_datapkg > 0) {
1384 print "\n";
1385 print "Choose Group Packages.\n";
1386  
1387 my $num = 0;
1388 my %num_grp = ();
1389 while (my ($key, $value) = each %{$curr_dataPkg_grp}) {
1390 my $_num = $num + 1;
1391 $num_grp{$_num} = $key;
1392 print "$_num. $key\n";
1393 $num++;
1394 }
1395 print "Enter Number choice : ";
1396 chomp($num_pkg_group = <STDIN>);
1397 if ($num_pkg_group eq '') {
1398 $r_pkg_group = 0;
1399 $pkg_group = '';
1400 print "\n";
1401 print "Please Number choice for Group Packages...\n";
1402 } else {
1403 if ($num_pkg_group =~ m/^[0-9]+$/) {
1404 $pkg_group = $num_grp{$num_pkg_group};
1405 $r_pkg_group = 1;
1406 $pkg_group_stts = 2;
1407 } else {
1408 print "\n";
1409 print "Choice Group only Numberic...\n\n";
1410 exit 0;
1411 }
1412 }
1413 } else {
1414 print "\n";
1415 print "Enter group name packages before migration : ";
1416 chomp($input_pkg_group = <STDIN>);
1417 if ($input_pkg_group =~ m/^[A-Za-z0-9\-\_]+$/) {
1418 $pkg_group = $input_pkg_group;
1419 $r_pkg_group = 1;
1420 $pkg_group_stts = 1;
1421 }
1422 elsif ($input_pkg_group =~ m/^[A-Za-z]+$/) {
1423 $pkg_group = $input_pkg_group;
1424 $r_pkg_group = 1;
1425 $pkg_group_stts = 1;
1426 }
1427 else {
1428 $r_pkg_group = 0;
1429 $pkg_group = '';
1430 $pkg_group_stts = 0;
1431 print "\n";
1432 print "Name of group package must combination : \n";
1433 print "- Alphabetic\n";
1434 print "- Alphabetic Numberic\n";
1435 print "- Alpabetic Numberic and [_] character or/and [-] character\n";
1436 print "\n";
1437 exit 0;
1438 }
1439 }
1440 } else {
1441 print "\n";
1442 print "Enter group name packages before migration.\n";
1443 chomp($input_pkg_group = <STDIN>);
1444 if ($input_pkg_group =~ m/^[A-Za-z0-9\-\_]+$/) {
1445 $pkg_group = $input_pkg_group;
1446 $r_pkg_group = 1;
1447 $pkg_group_stts = 1;
1448 }
1449 elsif ($input_pkg_group =~ m/^[A-Za-z]+$/) {
1450 $pkg_group = $input_pkg_group;
1451 $r_pkg_group = 1;
1452 $pkg_group_stts = 1;
1453 }
1454 else {
1455 $r_pkg_group = 0;
1456 $pkg_group = '';
1457 $pkg_group_stts = 0;
1458 print "\n";
1459 print "Name of group package must combination : \n";
1460 print "- Alphabetic\n";
1461 print "- Alphabetic Numberic\n";
1462 print "- Alpabetic Numberic and [_] character or/and [-] character\n";
1463 print "\n";
1464 exit 0;
1465 }
1466 }
1467  
1468 $data{'result'} = $r_pkg_group;
1469 $data{'data'} = $pkg_group;
1470 $data{'status'} = $pkg_group_stts;
1471  
1472 return \%data;
1473 }
1474 # Subroutine for option "addpkg" :
1475 # ------------------------------------------------------------------------
1476 sub _addpkg {
1477 my ($self, $allconfig) = @_;
1478  
1479 # Define scalar :
1480 my $new_pkg;
1481 my $arg_len = scalar @ARGV;
1482  
1483 # For Data Developer :
1484 my $data_dev = BlankOnDev::DataDev::data_dev();
1485 my $dir_dev = $data_dev->{'dir_dev'};
1486 my $dir_pkgs = $data_dev->{'dir_pkg'};
1487  
1488 # Check Package Group :
1489 my $pkg_group = $self->group_pkg($allconfig);
1490  
1491 if ($pkg_group->{'result'} eq 1) {
1492 # Define scalar for data packages :
1493 my $input_group = $pkg_group->{'data'};
1494 my $status_group = $pkg_group->{'status'};
1495 my $build = $allconfig->{build};
1496 my $build_rilis = $build->{'rilis'};
1497 my $build_gpg = $build->{'gpg'};
1498 my $data_bzr = $allconfig->{bzr}->{url};
1499 my $data_git = $allconfig->{git}->{url};
1500 my $curr_data_pkg = $allconfig->{'pkg'};
1501 my $locdir_pkg = $dir_dev.$dir_pkgs;
1502 my $locdir_rilis = $locdir_pkg.'/'.$build_rilis;
1503  
1504 # Check Status group packages :
1505 if ($status_group == 1) {
1506 # Define hash or scalar :
1507 my %data = ();
1508 my $locdir_pkggroup = $locdir_rilis.'/'.$input_group;
1509  
1510 # Make Dir Group Packages :
1511 unless (-d $locdir_pkggroup) {
1512 mkdir($locdir_pkggroup);
1513 }
1514  
1515 # Check Arguments :
1516 if ($arg_len == 2) {
1517  
1518 print "Enter Packages : ";
1519 chomp($new_pkg = <STDIN>);
1520 if ($new_pkg ne '') {
1521 unless (exists $allconfig->{'pkg'}->{'pkgs'}->{$new_pkg}) {
1522  
1523 # Define scalar for config :
1524 my $save_config = prepare_config();
1525 my $rdt_config = $save_config->{'newpkg'}($allconfig, {
1526 'pkg' => $new_pkg,
1527 'group' => $input_group
1528 });
1529 my $for_saveCfg;
1530  
1531 # Add list pkgs :
1532 unless (exists $curr_data_pkg->{'group'}->{$input_group} && exists $curr_data_pkg->{'pkgs'}->{$new_pkg}) {
1533 $for_saveCfg = save_newConfig();
1534 $for_saveCfg->{'addpkg'}($rdt_config);
1535 }
1536 } else {
1537 print "\n";
1538 print "Info : \n";
1539 print "====" x 18 . "\n";
1540 print "Packages \"$new_pkg\" is exists...\n";
1541 exit 0;
1542 }
1543  
1544 } else {
1545 print "Please Enter name package for add !!!\n";
1546 exit 0;
1547 }
1548 } elsif ($arg_len == 3) {
1549 $new_pkg = $ARGV[2];
1550 unless (exists $allconfig->{'pkg'}->{'pkgs'}->{$new_pkg}) {
1551  
1552 # Define scalar for config :
1553 my $save_config = prepare_config();
1554 my $rdt_config = $save_config->{'newpkg'}($allconfig, {
1555 'pkg' => $new_pkg,
1556 'group' => $input_group
1557 });
1558 my $for_saveCfg;
1559  
1560 # Add list pkgs :
1561 unless (exists $curr_data_pkg->{'group'}->{$input_group} && exists $curr_data_pkg->{'pkgs'}->{$new_pkg}) {
1562 $for_saveCfg = save_newConfig();
1563 $for_saveCfg->{'addpkg'}($rdt_config);
1564 }
1565 } else {
1566 print "\n";
1567 print "Info : \n";
1568 print "====" x 18 . "\n";
1569 print "Packages \"$new_pkg\" is exists...\n";
1570 exit 0;
1571 }
1572 } else {
1573 print "\n";
1574 print "====" x 18 . "\n";
1575 print "your command: boidev $ARGV[0] $ARGV[1] $ARGV[2]\n";
1576 print "----" x 18 . "\n";
1577 print "\n";
1578 print "Warning : \n";
1579 print "====" x 18 . "\n";
1580 print "Error input arguments\n\n";
1581 exit 0;
1582 }
1583 }
1584 elsif ($status_group eq 2) {
1585  
1586 # Check Arguments :
1587 if ($arg_len == 2) {
1588 # Form Add Package :
1589 print "Enter New Packages : ";
1590 chomp($new_pkg = <STDIN>);
1591 if ($new_pkg ne '') {
1592 unless (exists $allconfig->{'pkg'}->{'pkgs'}->{$new_pkg}) {
1593 my $locdir_pkggroup = $locdir_rilis.'/'.$input_group;
1594 my $curr_group = $curr_data_pkg->{$input_group};
1595 my $url_repo = $data_bzr.'/'.$new_pkg;
1596 my $loc_localrepo = $locdir_pkggroup.'/'.$new_pkg;
1597  
1598 # Define scalar for config :
1599 my $save_config = prepare_config();
1600 my $rdt_config = $save_config->{'newpkg-grp-exists'}($allconfig, {
1601 'pkg' => $new_pkg,
1602 'group' => $input_group
1603 });
1604 my $for_saveCfg;
1605  
1606 # Add list pkgs :
1607 unless (exists $curr_data_pkg->{'group'}->{$input_group} && exists $curr_data_pkg->{'pkgs'}->{$new_pkg}) {
1608 $for_saveCfg = save_newConfig();
1609 $for_saveCfg->{'addpkg'}($rdt_config);
1610 }
1611 } else {
1612 print "\n";
1613 print "Info : \n";
1614 print "====" x 18 . "\n";
1615 print "Packages \"$new_pkg\" is exists...\n";
1616 exit 0;
1617 }
1618 } else {
1619 print "\n";
1620 print "Warning : \n";
1621 print "====" x 18 . "\n";
1622 print "Please Enter name package for add !!!\n";
1623 exit 0;
1624 }
1625 } elsif ($arg_len == 3) {
1626 $new_pkg = $ARGV[2];
1627 unless (exists $allconfig->{'pkg'}->{'pkgs'}->{$new_pkg}) {
1628  
1629 my $locdir_pkggroup = $locdir_rilis.'/'.$input_group;
1630 my $curr_group = $curr_data_pkg->{$input_group};
1631 my $url_repo = $data_bzr.'/'.$new_pkg;
1632 my $loc_localrepo = $locdir_pkggroup.'/'.$new_pkg;
1633  
1634 # Define scalar for config :
1635 my $save_config = prepare_config();
1636 my $rdt_config = $save_config->{'newpkg-grp-exists'}($allconfig, {
1637 'pkg' => $new_pkg,
1638 'group' => $input_group
1639 });
1640 my $for_saveCfg;
1641  
1642 # Add list pkgs :
1643 unless (exists $curr_data_pkg->{'group'}->{$input_group} && exists $curr_data_pkg->{'pkgs'}->{$new_pkg}) {
1644 $for_saveCfg = save_newConfig();
1645 $for_saveCfg->{'addpkg'}($rdt_config);
1646 }
1647 } else {
1648 print "\n";
1649 print "Info : \n";
1650 print "====" x 18 . "\n";
1651 print "Packages \"$new_pkg\" is exists...\n";
1652 exit 0;
1653 }
1654 } else {
1655 print "\n";
1656 print "====" x 18 . "\n";
1657 print "your command: boidev $ARGV[0] $ARGV[1] $ARGV[2]\n";
1658 print "----" x 18 . "\n";
1659 print "\n";
1660 print "Warning : \n";
1661 print "====" x 18 . "\n";
1662 print "Error input arguments\n\n";
1663 exit 0;
1664 }
1665 } else {
1666 print "\n";
1667 print "Warning : \n";
1668 print "====" x 18 . "\n";
1669 print "Please Enter valid name for Group Packages...\n";
1670 exit 0;
1671 }
1672 } else {
1673 print "\n";
1674 print "Warning : \n";
1675 print "====" x 18 . "\n";
1676 print "Please Enter valid name for Group Packages...\n";
1677 exit 0;
1678 }
1679 }
1680  
1681 # Subroutine for option "addpkg-file".
1682 # This subroutine functionate to add packages to list from File.
1683 # ------------------------------------------------------------------------
1684 sub _addpkg_file {
1685 my ($self, $allconfig) = @_;
1686  
1687 # Check Argumenets :
1688 my $arg_len = scalar @ARGV;
1689  
1690 # For Data Developer :
1691 my $data_dev = BlankOnDev::DataDev::data_dev();
1692 my $dir_dev = $data_dev->{'dir_dev'};
1693 my $filepkg_ext = $data_dev->{'filePkg_ext'};
1694 my $dir_pkgs = $data_dev->{'dir_pkg'};
1695  
1696 # ------------------------------------------------------------------------
1697 # Check IF $arg_len == 3 :
1698 # ------------------------------------------------------------------------
1699 if ($arg_len == 3) {
1700  
1701 if ($ARGV[2] =~ m/$filepkg_ext$/) {
1702  
1703 # Check File :
1704 if (-e $ARGV[2]) {
1705 my $loc_file_cfg = $ARGV[2];
1706  
1707 # Define scalar :
1708 my $new_pkg;
1709 my @list_pkg = ();
1710  
1711 # Check Package Group :
1712 my $pkg_group = $self->group_pkg($allconfig);
1713  
1714 # Get List Command :
1715 my $list_cmd = list_cmd();
1716  
1717 # Define hash or scalar :
1718 my $input_group = $pkg_group->{'data'};
1719 my $status_group = $pkg_group->{'status'};
1720 my $build = $allconfig->{build};
1721 my $build_rilis = $build->{'rilis'};
1722 my $curr_data_pkg = $allconfig->{'pkg'};
1723 my $list_pkgs = $curr_data_pkg->{'pkgs'};
1724 my $locdir_pkg = $dir_dev.$dir_pkgs;
1725 my $locdir_rilis = $locdir_pkg.'/'.$build_rilis;
1726 my $locdir_pkggroup = $locdir_rilis.'/'.$input_group;
1727  
1728 if ($status_group == 1) {
1729  
1730 # Make Dir Group Packages :
1731 unless (-d $locdir_pkggroup) {
1732 mkdir($locdir_pkggroup);
1733 }
1734  
1735 # Read file list packages :
1736 my $save_config;
1737 my $rdt_config;
1738 my $data_allcfg = $allconfig;
1739 open(FH, '<', $loc_file_cfg) or die $! . " - " . $loc_file_cfg;
1740 while (my $lines = <FH>) {
1741 $lines =~ s/^\s+//g;
1742 $lines =~ s/\s+$//g;
1743 $new_pkg = $lines;
1744  
1745 # Check if pkg is exists :
1746 unless (exists $list_pkgs->{$new_pkg}) {
1747  
1748 # Define scalar for config :
1749 $save_config = prepare_config();
1750 $data_allcfg = $save_config->{'newpkg'}($data_allcfg, {
1751 'pkg' => $lines,
1752 'group' => $input_group
1753 });
1754 print "$new_pkg has success added. \n";
1755 push(@list_pkg, $lines);
1756 } else {
1757 print "$new_pkg is exists. \n";
1758 }
1759  
1760 my $for_saveCfg;
1761 unless (exists $curr_data_pkg->{'group'}->{$input_group} && exists $curr_data_pkg->{'pkgs'}->{$lines}) {
1762 $for_saveCfg = save_newConfig();
1763 $for_saveCfg->{'addpkg'}($data_allcfg);
1764 }
1765 }
1766  
1767 # CLose File :
1768 close (FH);
1769 my $size_pkgs = scalar @list_pkg;
1770 print "\n $size_pkgs packages has added...\n"
1771 }
1772 elsif ($status_group == 2) {
1773  
1774 # Read file list packages :
1775 my $save_config;
1776 my $rdt_config;
1777 my $data_allcfg = $allconfig;
1778 open(FH, '<', $loc_file_cfg) or die $! . " - " . $loc_file_cfg;
1779 while (my $lines = <FH>) {
1780 $lines =~ s/^\s+//g;
1781 $lines =~ s/\s+$//g;
1782  
1783 # Define scalar for config :
1784 $save_config = prepare_config();
1785 $data_allcfg = $save_config->{'newpkg'}($data_allcfg, {
1786 'pkg' => $lines,
1787 'group' => $input_group
1788 });
1789 my $for_saveCfg;
1790 print "\"$lines\" has success added.\n";
1791 push(@list_pkg, $lines);
1792  
1793 unless (exists $curr_data_pkg->{'group'}->{$input_group} && exists $curr_data_pkg->{'pkgs'}->{$lines}) {
1794 $for_saveCfg = save_newConfig();
1795 $for_saveCfg->{'addpkg'}($data_allcfg);
1796 }
1797 }
1798  
1799 # CLose File :
1800 close (FH);
1801 my $size_pkgs = scalar @list_pkg;
1802 print "\n $size_pkgs packages has added...\n"
1803 }
1804 else {
1805 print "\n";
1806 print "Warning : \n";
1807 print "====" x 18 . "\n";
1808 print "Please Enter valid name for Group Packages...\n\n";
1809 exit 0;
1810 }
1811 }
1812  
1813 } else {
1814 print "\n";
1815 print "====" x 18 . "\n";
1816 print "your command: boidev $ARGV[0] $ARGV[1] $ARGV[2]\n";
1817 print "----" x 18 . "\n";
1818 print "\n";
1819 print "Warning : \n";
1820 print "====" x 18 . "\n";
1821 print "File extension is not valid. Extension file list packages must \"$filepkg_ext\"\n";
1822 print "or Please using valid arguments three\n\n";
1823 BlankOnDev::usage_bzr2git_addpkgfile();
1824 }
1825 }
1826 # ------------------------------------------------------------------------
1827 # Check IF $arg_len != 3 :
1828 # ------------------------------------------------------------------------
1829 else {
1830 my $i = 0;
1831 my $data_cmd = '';
1832 foreach my $arg (each @ARGV) {
1833 if ($arg_len - 1 == $i) {
1834 $data_cmd .= $arg;
1835 } else {
1836 $data_cmd .= "$arg ";
1837 }
1838 $i++;
1839 }
1840 print "\n";
1841 print "====" x 18 . "\n";
1842 print "your command: boidev $data_cmd\n";
1843 print "----" x 18 . "\n";
1844 print "\n";
1845 print "Warning : \n";
1846 print "====" x 18 . "\n";
1847 print "Error input arguments\n\n";
1848 exit 0;
1849 }
1850 # ------------------------------------------------------------------------
1851 # End of check IF $arg_len != 3.
1852 # ========================================================================
1853 }
1854 # Subroutine for remove packages :
1855 # ------------------------------------------------------------------------
1856 sub _removepkg {
1857 my ($self, $allconfig) = @_;
1858  
1859 # Check Argumenets :
1860 my $arg_len = scalar @ARGV;
1861 my $input_pkg;
1862  
1863 # Define scalar for config :
1864 my $curr_data_pkg = $allconfig->{'pkg'};
1865 my $list_group = $curr_data_pkg->{'group'};
1866 my $list_pkgs = $curr_data_pkg->{'pkgs'};
1867  
1868 # ------------------------------------------------------------------------
1869 # Check IF $arg_len == 2 :
1870 # ------------------------------------------------------------------------
1871 if ($arg_len == 2) {
1872 # Form Packages :
1873 print "\n";
1874 print "---------" x 8 . "\n";
1875 print " Form Remove Packages on Apps System : \n";
1876 print "---------" x 8 . "\n";
1877 print "\n";
1878 print "Enter packages name : ";
1879 chomp($input_pkg = <STDIN>);
1880 if ($input_pkg ne '') {
1881 if (exists $list_pkgs->{$input_pkg}) {
1882  
1883 # Prepare Config :
1884 my $prepare_config = prepare_config();
1885 my $r_Cfg = $prepare_config->{'remove-pkg'}($allconfig, $input_pkg);
1886  
1887 # Execute Config :
1888 my $execute_config = save_newConfig();
1889 $execute_config->{'removePkg'}($r_Cfg);
1890  
1891 } else {
1892 print "\n";
1893 print "Warning : \n";
1894 print "====" x 18 . "\n";
1895 print "Packages is not found\n\n";
1896 exit 0;
1897 }
1898 } else {
1899 print "\n";
1900 print "Warning : \n";
1901 print "====" x 18 . "\n";
1902 print "Enter packages name if you want to remove packages on apps system.\n";
1903 print "Or run command \"boidev bzr2git remove-pkg <Name_packages>\".\n\n";
1904 exit 0;
1905 }
1906 }
1907  
1908 # ------------------------------------------------------------------------
1909 # Check IF $arg_len == 3 :
1910 # ------------------------------------------------------------------------
1911 elsif ($arg_len == 3) {
1912 # get data arguments :
1913 my $input_argv = $ARGV[2];
1914 my $remove_pkgInGrp;
1915 my $remove_pkg;
1916  
1917 # Check Packages Group :
1918 if (exists $list_group->{$input_argv}) {
1919 # Form Packageg Group :
1920 print "\n";
1921 print "=========" x 8 . "\n";
1922 print "=========" x 8 . "\n";
1923 print " Are you sure to remove all packages in group \"$input_argv\" [y/n] : \n";
1924 print " IF you not valid input, packages not removed\n";
1925 print "---------" x 8 . "\n";
1926 print "Your Answer : ";
1927 chomp($remove_pkgInGrp = <STDIN>);
1928 if ($remove_pkgInGrp eq 'y' or $remove_pkgInGrp eq 'Y') {
1929  
1930 # Get List Packages :
1931 my $listOf_pkg = $self->filter_listpkg_based_group($allconfig, $input_argv);
1932 if ($listOf_pkg->{'result'} eq 1) {
1933 my @list_pkgs = @{$listOf_pkg->{'data'}};
1934  
1935 my $i = 0;
1936 my $size_list = scalar keys(@list_pkgs);
1937 my $dataPkg_cfg = $allconfig;
1938 while ($i < $size_list) {
1939 my $num = $i + 1;
1940 my $this_currPkg = $list_pkgs[$i]->{'name'};
1941  
1942 # Prepare Config :
1943 my $prepare_config = prepare_config();
1944 $dataPkg_cfg = $prepare_config->{'remove-pkg'}($dataPkg_cfg, $this_currPkg);
1945  
1946 # Execute Config :
1947 my $execute_config = save_newConfig();
1948 $execute_config->{'removePkg'}($dataPkg_cfg);
1949  
1950 print "Packages \"$this_currPkg\" on Group \"$input_argv\", has success deleted...\n";
1951 $i++;
1952 }
1953  
1954 }
1955 }
1956 } else {
1957 # Check Packages :
1958 if (exists $list_pkgs->{$input_argv}) {
1959 my $group_name = $list_pkgs->{$input_argv}->{'group'};
1960 # Form Packages :
1961 print "\n";
1962 print "=========" x 8 . "\n";
1963 print "=========" x 8 . "\n";
1964 print " Are you sure to packages \"$input_argv\" [y/n] : \n";
1965 print " IF you not valid input, packages not removed\n";
1966 print "---------" x 8 . "\n";
1967 print "Your Answer : ";
1968 chomp($remove_pkg = <STDIN>);
1969 if ($remove_pkg eq 'Y' or $remove_pkg eq 'y') {
1970  
1971 # Prepare Config :
1972 my $prepare_config = prepare_config();
1973 my $r_Cfg = $prepare_config->{'remove-pkg'}($allconfig, $input_argv);
1974  
1975 # Execute Config :
1976 my $execute_config = save_newConfig();
1977 $execute_config->{'removePkg'}($r_Cfg);
1978  
1979 print "Packages \"$input_argv\" on Group \"$group_name\", success deleted...\n\n";
1980 }
1981 } else {
1982 print "\n";
1983 print "Warning : \n";
1984 print "====" x 18 . "\n";
1985 print "Packages is not found\n\n";
1986 exit 0;
1987 }
1988 }
1989 }
1990 # ------------------------------------------------------------------------
1991 # Check IF $arg_len == 3 or $arg_len == 2 :
1992 # ------------------------------------------------------------------------
1993 else {
1994 my $i = 0;
1995 my $data_cmd = '';
1996 foreach my $arg (each @ARGV) {
1997 if ($arg_len - 1 == $i) {
1998 $data_cmd .= $arg;
1999 } else {
2000 $data_cmd .= "$arg ";
2001 }
2002 $i++;
2003 }
2004 print "\n";
2005 print "====" x 18 . "\n";
2006 print "your command: boidev $data_cmd\n";
2007 print "----" x 18 . "\n";
2008 print "\n";
2009 print "Warning : \n";
2010 print "====" x 18 . "\n";
2011 print "Error input arguments\n\n";
2012 exit 0;
2013 }
2014 # ------------------------------------------------------------------------
2015 # End of check IF $arg_len == 3 or $arg_len == 2.
2016 # ========================================================================
2017 }
2018 # Subroutine for filter list pkg based group name :
2019 # ------------------------------------------------------------------------
2020 sub filter_listpkg_based_group {
2021 my ($self, $allconfig, $group) = @_;
2022  
2023 # Define hash or scalar :
2024 my %data = ();
2025  
2026 # Get data current config :
2027 my $curr_pkg = $allconfig->{'pkg'};
2028 my $list_pkg = $curr_pkg->{'pkgs'};
2029  
2030 # Check List Packages :
2031 my $i = 0;
2032 my $size_pkgs = scalar keys(%{$list_pkg});
2033 if ($size_pkgs > 0) {
2034  
2035 # Check Group :
2036 if (exists $curr_pkg->{'group'}->{$group}) {
2037  
2038 # While loop for list pkgs :
2039 my $num_true = 0;
2040 my $num_false = 0;
2041 my $num = 0;
2042 my @pre_data_rows = ();
2043 while (my ($key, $value) = each %$list_pkg) {
2044 if ($list_pkg->{$key}->{'group'} eq $group) {
2045 $num_true = $num_true + 1;
2046 $pre_data_rows[$num] = $list_pkg->{$key};
2047 } else {
2048 $num_false = $num_false + 1;
2049 }
2050 $num++;
2051 }
2052  
2053 # Remove "undef" value on array :
2054 my @data_rows = grep($_, @pre_data_rows);
2055  
2056 # Place result :
2057 $data{'result'} = 1 if $num_true > 0;
2058 $data{'result'} = 0 if $num_true == 0 && $num_false > 0;
2059 $data{'data'} = \@data_rows;
2060  
2061 return \%data;
2062  
2063 } else {
2064 print "\n";
2065 print "Info : \n";
2066 print "====" x 18 . "\n";
2067 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
2068 exit 0;
2069 }
2070 } else {
2071 print "\n";
2072 print "Info : \n";
2073 print "====" x 18 . "\n";
2074 print "Not found packages in list. Please run command \"boidev bzr2git addpkg\" to add new packages.\n\n";
2075 exit 0;
2076 }
2077 }
2078 # Subroutine for list all packages group :
2079 # ------------------------------------------------------------------------
2080 sub list_all_pkg_group {
2081 my ($self, $allconfig) = @_;
2082  
2083 # Define hash or scalar :
2084 my %data = ();
2085  
2086 # Get data current config :
2087 my $curr_pkg = $allconfig->{'pkg'};
2088 my $list_group = $curr_pkg->{'group'};
2089 my $size_list_group = scalar keys(%{$list_group});
2090  
2091 # Check count list packages group :
2092 if ($size_list_group > 0) {
2093  
2094 # While loop for list packages group :
2095 my $i = 0;
2096 my @pre_data_rows = ();
2097 while (my ($key, $value) = each %$list_group) {
2098 $pre_data_rows[$i] = $key;
2099 $i++;
2100 }
2101  
2102 # Remove "undef" value on array :
2103 my @data_rows = grep($_, @pre_data_rows);
2104  
2105 # Place result :
2106 $data{'data'} = \@data_rows;
2107  
2108 return \%data;
2109 } else {
2110 print "\n";
2111 print "Info : \n";
2112 print "====" x 18 . "\n";
2113 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
2114 exit 0;
2115 }
2116 }
2117 # Subroutine for list packages by group :
2118 # ------------------------------------------------------------------------
2119 sub list_pkg_by_group {
2120 my ($self, $allconfig, $group) = @_;
2121  
2122 # Define hash or scalar :
2123 my %data = ();
2124  
2125 # Get data current config :
2126 my $curr_build = $allconfig->{'build'};
2127 my $curr_pkg = $allconfig->{'pkg'};
2128 my $list_pkg = $curr_pkg->{'pkgs'};
2129  
2130 # Check List Packages :
2131 my $i = 0;
2132 my $size_pkgs = scalar keys(%{$list_pkg});
2133 if ($size_pkgs > 0) {
2134  
2135 # Check Group :
2136 if (exists $curr_pkg->{'group'}->{$group}) {
2137  
2138 # While loop for list pkgs :
2139 my $num_true = 0;
2140 my $num_false = 0;
2141 my $num = 0;
2142 my @pre_data_rows = ();
2143 while (my ($key, $value) = each %$list_pkg) {
2144 if ($list_pkg->{$key}->{'group'} eq $group) {
2145 $num_true = $num_true + 1;
2146 $pre_data_rows[$num] = $list_pkg->{$key};
2147 } else {
2148 $num_false = $num_false + 1;
2149 }
2150 $num++;
2151 }
2152  
2153 # Remove "undef" value on array :
2154 my @data_rows = grep($_, @pre_data_rows);
2155  
2156 # Place result :
2157 $data{'result'} = 1 if $num_true > 0;
2158 $data{'result'} = 0 if $num_true == 0 && $num_false > 0;
2159 $data{'data'} = \@data_rows;
2160  
2161 } else {
2162 $data{'result'} = 0;
2163 $data{'data'} = [];
2164 }
2165 } else {
2166 $data{'result'} = 0;
2167 $data{'data'} = [];
2168 }
2169  
2170 return \%data;
2171 }
2172 # Subroutine for list pkg :
2173 # ------------------------------------------------------------------------
2174 sub _list_pkg {
2175 my ($self, $allconfig) = @_;
2176  
2177 # Define scalar :
2178 my $date_branch;
2179 my $date_gitpush;
2180  
2181 # For All config :
2182 my $curr_build = $allconfig->{'build'};
2183 my $buld_rilis = $curr_build->{'rilis'};
2184 my $curr_pkg = $allconfig->{'pkg'};
2185  
2186 # For Data Developer :
2187 my $data_dev = BlankOnDev::DataDev::data_dev();
2188 my $dir_dev = $data_dev->{'dir_dev'};
2189 my $prefix_flcfg = $data_dev->{'prefix_flcfg'};
2190 my $file_cfg_ext = $data_dev->{'fileCfg_ext'};
2191 my $file_nameCfg = $prefix_flcfg.$buld_rilis.$file_cfg_ext;
2192 my $loc_fileCfg = $dir_dev.$file_nameCfg;
2193  
2194 # Check Argumenets :
2195 my $arg_len = scalar @ARGV;
2196  
2197 # ------------------------------------------------------------------------
2198 # Check IF $arg_len == 3 :
2199 # ------------------------------------------------------------------------
2200 if ($arg_len == 3) {
2201  
2202 # Check file config :
2203 if (-e $loc_fileCfg) {
2204  
2205 # Check if $ARGV[2] == 'all' :
2206 if ($ARGV[2] eq 'all') {
2207 my $list_all_pkggroup = $self->list_all_pkg_group($allconfig);
2208 my @list_allpkg_group = @{$list_all_pkggroup->{'data'}};
2209  
2210 # Create Text Table :
2211 my $textTbl;
2212  
2213 # While loop to get list packages group :
2214 my $i = 0;
2215 my $until = scalar @list_allpkg_group;
2216 my $data_list = '';
2217 my $size_list = 0;
2218 my $get_list_pkg_bygrp = '';
2219 while ($i < $until) {
2220  
2221 my $group_name = $list_allpkg_group[$i];
2222  
2223 # Get list packages by Group :
2224 $get_list_pkg_bygrp = $self->list_pkg_by_group($allconfig, $group_name);
2225 if ($get_list_pkg_bygrp->{'result'} eq 1) {
2226 my @list_all_pkg = @{$get_list_pkg_bygrp->{'data'}};
2227  
2228 # Print "Header" :
2229 $data_list .= "\n";
2230 $data_list .= "List Packages for group \"$group_name\"\n";
2231  
2232 # Create Text Table :
2233 $textTbl = Text::SimpleTable::AutoWidth->new(captions => [( '#', 'Group Name', 'Packages Name', 'Date Add', 'Date bzr branch', 'Date git push', 'status', 'on GitHub')]);
2234  
2235 # While loop to get list packages :
2236 my $i_p = 0;
2237 my $until_p = scalar @list_all_pkg;
2238 while ($i_p < $until_p) {
2239 $size_list = $size_list + 1;
2240 my $num = $i_p + 1;
2241 my $curr_grpname = $list_all_pkg[$i_p]->{'group'};
2242 my $pkg_name = $list_all_pkg[$i_p]->{'name'};
2243 my $date_add = $list_all_pkg[$i_p]->{'date-add'};
2244 $date_branch = exists $list_all_pkg[$i_p]->{'date-branch'} && $list_all_pkg[$i_p]->{'date-branch'} eq '' ? '-' : $list_all_pkg[$i_p]->{'date-branch'};
2245 $date_gitpush = exists $list_all_pkg[$i_p]->{'date-gitpush'} && $list_all_pkg[$i_p]->{'date-gitpush'} eq '' ? '-' : $list_all_pkg[$i_p]->{'date-gitpush'};
2246 my $status_branch = $list_all_pkg[$i_p]->{'status'}->{'bzr-branch'};
2247 my $status_gitpush = $list_all_pkg[$i_p]->{'status'}->{'git-push'};
2248 my $status_gitCgit = $list_all_pkg[$i_p]->{'status'}->{'bzrConvertGit'};
2249 my $status = "bzrBranch = $status_branch, bzrConvertGit = $status_gitCgit, gitPush = $status_gitpush";
2250 my $status_ongit = exists $list_all_pkg[$i_p]->{'status'}->{'ongit'} ? $list_all_pkg[$i_p]->{'status'}->{'ongit'} : '';
2251 my @data_rows = ($num, $curr_grpname, $pkg_name, $date_add, $date_branch, $date_gitpush, $status, $status_ongit);
2252 # my @data_rows = ($num, $curr_grpname, $pkg_name, $date_add, '-', '-', $status, $status_ongit);
2253 $textTbl->row(@data_rows);
2254 $i_p++
2255 }
2256 $data_list .= $textTbl->draw();
2257 }
2258 $i++;
2259 }
2260  
2261 # Print List :
2262 print "\n";
2263 print "---------" x 11 . "\n";
2264 print " List Packages with amount \"$size_list\" packages : \n";
2265 print "---------" x 11 . "\n";
2266 printf("%s", "Status :\n");
2267 print "---------" x 11 . "\n";
2268 BlankOnDev::help_list_pkg();
2269 print "\n";
2270 print $data_list;
2271 print "\n";
2272 print "---------" x 11 . "\n";
2273 printf("%s", "Status :\n");
2274 print "---------" x 11 . "\n";
2275 BlankOnDev::help_list_pkg();
2276 print "\n";
2277 exit 0;
2278 }
2279  
2280 # Check New Group :
2281 my $check_group = $self->check_exists_group('check', $curr_pkg->{'group'}, $ARGV[2]);
2282 if ($check_group->{'result'} == 0) {
2283 my $get_list_pkg = $self->filter_listpkg_based_group($allconfig, $ARGV[2]);
2284 if ($get_list_pkg->{'result'} eq 1) {
2285 my @list_pkgs = @{$get_list_pkg->{'data'}};
2286  
2287 # Create Text Table :
2288 my $textTbl = Text::SimpleTable::AutoWidth->new(captions => [( '#', 'Group Name', 'Packages Name', 'Date Add', 'Date bzr branch', 'Date git push', 'status', 'on GitHub')]);
2289  
2290 my $i = 0;
2291 my $size_list = scalar keys(@list_pkgs);
2292 while ($i < $size_list) {
2293 my $num = $i + 1;
2294 my $group_name = $list_pkgs[$i]->{'group'};
2295 my $pkg_name = $list_pkgs[$i]->{'name'};
2296 my $date_add = $list_pkgs[$i]->{'date-add'};
2297 my $date_branch = $list_pkgs[$i]->{'date-branch'} eq '' ? '-' : $list_pkgs[$i]->{'date-branch'};
2298 my $date_gitpush = $list_pkgs[$i]->{'date-gitpush'} eq '' ? '-' : $list_pkgs[$i]->{'date-gitpush'};
2299 my $status_branch = $list_pkgs[$i]->{'status'}->{'bzr-branch'};
2300 my $status_gitpush = $list_pkgs[$i]->{'status'}->{'git-push'};
2301 my $status_gitCgit = $list_pkgs[$i]->{'status'}->{'bzrConvertGit'};
2302 my $status = "bzrBranch = $status_branch, bzrConvertGit = $status_gitCgit, gitPush = $status_gitpush";
2303 my $status_ongit = exists $list_pkgs[$i]->{'status'}->{'ongit'} ? $list_pkgs[$i]->{'status'}->{'ongit'} : '';
2304 my @data_rows = ($num, $group_name, $pkg_name, $date_add, $date_branch, $date_gitpush, $status, $status_ongit);
2305 $textTbl->row(@data_rows);
2306 $i++;
2307 }
2308  
2309 # Print List :
2310 print "\n";
2311 print "---------" x 11 . "\n";
2312 print " List Packages in group \"$ARGV[2]\" and result \"$size_list\" packages : \n";
2313 print "---------" x 11 . "\n";
2314 printf("%s", "Status :\n");
2315 print "---------" x 11 . "\n";
2316 BlankOnDev::help_list_pkg();
2317 print "\n";
2318 print $textTbl->draw();
2319 print "\n";
2320 print "---------" x 11 . "\n";
2321 printf("%s", "Status :\n");
2322 print "---------" x 11 . "\n";
2323 BlankOnDev::help_list_pkg();
2324 print "\n";
2325 } else {
2326 print "\n";
2327 print "Info : \n";
2328 print "====" x 18 . "\n";
2329 print "Not found packages in list on group $ARGV[2]. Please run command \"boidev bzr2git addpkg\" to add new packages in group.\n\n";
2330 exit 0;
2331 }
2332 } else {
2333 print "\n";
2334 print "Info : \n";
2335 print "====" x 18 . "\n";
2336 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
2337 exit 0;
2338 }
2339 } else {
2340 print "\n";
2341 print "Warning : \n";
2342 print "====" x 18 . "\n";
2343 print "Not found configure. Please run command \"boidev mig_prepare\" first. \n\n";
2344 exit 0;
2345 }
2346 }
2347 # ----------------------------------------------------------------
2348 # check IF $arg_len == 2 :
2349 # ----------------------------------------------------------------
2350 elsif ($arg_len == 2) {
2351  
2352 # Define scalar :
2353 my $num_pkg_group;
2354 my $pkg_group = '';
2355  
2356 # Data current config :
2357 my $curr_dataPkg_grp = $allconfig->{'pkg'}->{'group'};
2358 my $size_datapkg = scalar keys(%{$curr_dataPkg_grp});
2359  
2360 if ($size_datapkg > 0) {
2361 print "\n";
2362 print "Choose Group Packages.\n";
2363  
2364 my $num = 0;
2365 my %num_grp = ();
2366 while (my ($key, $value) = each %{$curr_dataPkg_grp}) {
2367 my $_num = $num + 1;
2368 $num_grp{$_num} = $key;
2369 print "$_num. $key\n";
2370 $num++;
2371 }
2372 print "Enter Number choice : ";
2373 chomp($num_pkg_group = <STDIN>);
2374 if ($num_pkg_group eq '') {
2375 $pkg_group = '';
2376 print "\n";
2377 print "Please Number choice for Group Packages...\n";
2378 } else {
2379 if ($num_pkg_group =~ m/^[0-9]+$/) {
2380 $pkg_group = $num_grp{$num_pkg_group};
2381 } else {
2382 print "\n";
2383 print "Choice Group only Numberic...\n\n";
2384 exit 0;
2385 }
2386 }
2387  
2388 # Execute :
2389 my $get_list_pkg = $self->filter_listpkg_based_group($allconfig, $pkg_group);
2390 if ($get_list_pkg->{'result'} eq 1) {
2391 my @list_pkgs = @{$get_list_pkg->{'data'}};
2392  
2393 # Create Text Table :
2394 my $textTbl = Text::SimpleTable::AutoWidth->new(captions => [( '#', 'Group Name', 'Packages Name', 'Date Add', 'Date bzr branch', 'Date git push', 'status', 'on GitHub')]);
2395  
2396 my $i = 0;
2397 my $size_list = scalar keys(@list_pkgs);
2398 while ($i < $size_list) {
2399 my $numb = $i + 1;
2400 my $group_name = $list_pkgs[$i]->{'group'};
2401 my $pkg_name = $list_pkgs[$i]->{'name'};
2402 my $date_add = $list_pkgs[$i]->{'date-add'};
2403 my $date_branch = $list_pkgs[$i]->{'date-branch'} eq '' ? '-' : $list_pkgs[$i]->{'date-branch'};
2404 my $date_gitpush = $list_pkgs[$i]->{'date-gitpush'} eq '' ? '-' : $list_pkgs[$i]->{'date-gitpush'};
2405 my $status_branch = $list_pkgs[$i]->{'status'}->{'bzr-branch'};
2406 my $status_gitpush = $list_pkgs[$i]->{'status'}->{'git-push'};
2407 my $status_gitCgit = $list_pkgs[$i]->{'status'}->{'bzrConvertGit'};
2408 my $status = "bzrBranch = $status_branch, bzrConvertGit = $status_gitCgit, gitPush = $status_gitpush";
2409 my $status_ongit = exists $list_pkgs[$i]->{'status'}->{'ongit'} ? $list_pkgs[$i]->{'status'}->{'ongit'} : '';
2410 my @data_rows = ($numb, $group_name, $pkg_name, $date_add, $date_branch, $date_gitpush, $status, $status_ongit);
2411 $textTbl->row(@data_rows);
2412 $i++;
2413 }
2414  
2415 # Print List :
2416 print "\n";
2417 print "---------" x 11 . "\n";
2418 print " List Packages in group \"$pkg_group\" and result \"$size_list\" packages : \n";
2419 print "---------" x 11 . "\n";
2420 printf("%s", "Status :\n");
2421 print "---------" x 11 . "\n";
2422 BlankOnDev::help_list_pkg();
2423 print "\n";
2424 print $textTbl->draw();
2425 print "\n";
2426 print "---------" x 11 . "\n";
2427 printf("%s", "Status :\n");
2428 print "---------" x 11 . "\n";
2429 BlankOnDev::help_list_pkg();
2430 print "\n";
2431 } else {
2432 print "\n";
2433 print "Info : \n";
2434 print "====" x 18 . "\n";
2435 print "Not found packages in list on group $pkg_group. Please run command \"boidev bzr2git addpkg\" to add new packages in group.\n\n";
2436 exit 0;
2437 }
2438 } else {
2439 print "\n";
2440 print "Info : \n";
2441 print "====" x 18 . "\n";
2442 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
2443 exit 0;
2444 }
2445 }
2446 # ------------------------------------------------------------------------
2447 # Check IF $arg_len != 3 :
2448 # ------------------------------------------------------------------------
2449 else {
2450 my $i = 0;
2451 my $data_cmd = '';
2452 foreach my $arg (each @ARGV) {
2453 if ($arg_len - 1 == $i) {
2454 $data_cmd .= $arg;
2455 } else {
2456 $data_cmd .= "$arg ";
2457 }
2458 $i++;
2459 }
2460 print "\n";
2461 print "====" x 18 . "\n";
2462 print "your command: boidev $data_cmd\n";
2463 print "----" x 18 . "\n";
2464 print "\n";
2465 print "Warning : \n";
2466 print "====" x 18 . "\n";
2467 print "Error input arguments\n\n";
2468 exit 0;
2469 }
2470 # ------------------------------------------------------------------------
2471 # End of check IF $arg_len != 3.
2472 # ========================================================================
2473 }
2474 # Subroutine for search packages :
2475 # ------------------------------------------------------------------------
2476 sub search_pkg {
2477 my ($self, $allconfig, $pkg) = @_;
2478  
2479 # Define hash or scalar :
2480 my %data = ();
2481  
2482 # Get data current config :
2483 my $curr_pkg = $allconfig->{'pkg'};
2484 my $list_pkg = $curr_pkg->{'pkgs'};
2485  
2486 # Check List Packages :
2487 my $i = 0;
2488 my $size_pkgs = scalar keys(%{$list_pkg});
2489 if ($size_pkgs > 0) {
2490  
2491 # While loop for list pkgs :
2492 my $num_true = 0;
2493 my $num_false = 0;
2494 my $num = 0;
2495 my @pre_data_rows = ();
2496 while (my ($key, $value) = each %{$list_pkg}) {
2497 if ($key =~ m/$pkg/) {
2498 $num_true = $num_true + 1;
2499 $pre_data_rows[$num] = $list_pkg->{$key};
2500 } else {
2501 $num_false = $num_false + 1;
2502 }
2503 $num++;
2504 }
2505  
2506 # Remove "undef" value on array :
2507 my @data_rows = grep($_, @pre_data_rows);
2508  
2509 # Place result :
2510 $data{'result'} = 1 if $num_true > 0;
2511 $data{'result'} = 0 if $num_true == 0 && $num_false > 0;
2512 $data{'data'} = \@data_rows;
2513  
2514 return \%data;
2515  
2516 } else {
2517 print "\n";
2518 print "Info : \n";
2519 print "====" x 18 . "\n";
2520 print "Not found packages in list. Please run command \"boidev bzr2git addpkg\" to add new packages.\n\n";
2521 exit 0;
2522 }
2523 }
2524 # Subroutine for form search packages :
2525 # ------------------------------------------------------------------------
2526 sub form_search_pkg {
2527 # Define scalar
2528 my $data = '';
2529 my $search_pkg;
2530 my $re_search_pkg;
2531  
2532 # Form Search :
2533 print "\n";
2534 print "Please Enter name of packages will be search : ";
2535 chomp($search_pkg = <STDIN>);
2536 if ($search_pkg ne '') {
2537  
2538 } else {
2539 print "\n";
2540 print "You not input packages name for search. \n";
2541 print "You want re-search Packages [y/n]";
2542 chomp($re_search_pkg = <STDIN>);
2543 if ($re_search_pkg eq 'y' or $re_search_pkg eq 'Y') {
2544 form_search_pkg();
2545 } else {
2546 exit 0;
2547 }
2548 }
2549  
2550 $data = $search_pkg;
2551  
2552 }
2553 # Subroutine for search packages :
2554 # ------------------------------------------------------------------------
2555 sub _search_pkg {
2556 my ($self, $allconfig) = @_;
2557  
2558 # For Arguments :
2559 my $arg_len = scalar @ARGV;
2560  
2561 # ------------------------------------------------------------------------
2562 # Check IF $arg_len == 2 :
2563 # ------------------------------------------------------------------------
2564 if ($arg_len == 2) {
2565  
2566 # Form Search :
2567 my $search_pkg = form_search_pkg();
2568  
2569 # Check Packages :
2570 my $check_packages = $self->search_pkg($allconfig, $search_pkg);
2571 if ($check_packages->{'result'} == 1) {
2572 my @list_pkgs = @{$check_packages->{'data'}};
2573  
2574 # Create Text Table :
2575 my $textTbl = Text::SimpleTable::AutoWidth->new(captions => [( '#', 'Group Name', 'Packages Name', 'Date Add', 'Date bzr branch', 'Date git push', 'status')]);
2576  
2577 my $i = 0;
2578 my $size_list = scalar keys(@list_pkgs);
2579 while ($i < $size_list) {
2580 my $num = $i + 1;
2581 my $group_name = $list_pkgs[$i]->{'group'};
2582 my $pkg_name = $list_pkgs[$i]->{'name'};
2583 my $date_add = $list_pkgs[$i]->{'date-add'};
2584 my $date_branch = $list_pkgs[$i]->{'date-branch'} eq '' ? '-' : $list_pkgs[$i]->{'date-branch'};
2585 my $date_gitpush = $list_pkgs[$i]->{'date-gitpush'} eq '' ? '-' : $list_pkgs[$i]->{'date-gitpush'};
2586 my $status_branch = $list_pkgs[$i]->{'status'}->{'bzr-branch'};
2587 my $status_gitpush = $list_pkgs[$i]->{'status'}->{'git-push'};
2588 my $status_gitCgit = $list_pkgs[$i]->{'status'}->{'bzrConvertGit'};
2589 my $status = "bzrBranch = $status_branch, bzrConvertGit = $status_gitCgit, gitPush = $status_gitpush";
2590 my @data_rows = ($num, $group_name, $pkg_name, $date_add, $date_branch, $date_gitpush, $status);
2591 $textTbl->row(@data_rows);
2592 $i++;
2593 }
2594  
2595 # Print List :
2596 print "\n";
2597 print "---------" x 11 . "\n";
2598 print " Result Search Packages \"$search_pkg\" And result of \"$size_list\" : \n";
2599 print "---------" x 11 . "\n";
2600 printf("%s", "Status :\n");
2601 print "---------" x 11 . "\n";
2602 BlankOnDev::help_list_pkg();
2603 print "\n";
2604 print $textTbl->draw();
2605 print "\n";
2606 print "---------" x 11 . "\n";
2607 printf("%s", "Status :\n");
2608 print "---------" x 11 . "\n";
2609 BlankOnDev::help_list_pkg();
2610 print "\n";
2611 } else {
2612 print "\n";
2613 print "-----" x 15 . "\n";
2614 print " Your Search Packages \"$search_pkg\" is not Found\n";
2615 print "-----" x 15 . "\n";
2616 print "\n";
2617 exit 0;
2618 }
2619 }
2620 # ------------------------------------------------------------------------
2621 # Check IF $arg_len == 3 :
2622 # ------------------------------------------------------------------------
2623 elsif ($arg_len == 3) {
2624  
2625 # Get Arguments :
2626 my $search_pkg = $ARGV[2];
2627  
2628 # Check Packages :
2629 my $check_packages = $self->search_pkg($allconfig, $search_pkg);
2630 if ($check_packages->{'result'} == 1) {
2631 my @list_pkgs = @{$check_packages->{'data'}};
2632  
2633 # Create Text Table :
2634 my $textTbl = Text::SimpleTable::AutoWidth->new(captions => [( '#', 'Group Name', 'Packages Name', 'Date Add', 'Date bzr branch', 'Date git push', 'status')]);
2635 my $i = 0;
2636 my $size_list = scalar keys(@list_pkgs);
2637 while ($i < $size_list) {
2638 my $num = $i + 1;
2639 my $group_name = $list_pkgs[$i]->{'group'};
2640 my $pkg_name = $list_pkgs[$i]->{'name'};
2641 my $date_add = $list_pkgs[$i]->{'date-add'};
2642 my $date_branch = $list_pkgs[$i]->{'date-branch'} eq '' ? '-' : $list_pkgs[$i]->{'date-branch'};
2643 my $date_gitpush = $list_pkgs[$i]->{'date-gitpush'} eq '' ? '-' : $list_pkgs[$i]->{'date-gitpush'};
2644 my $status_branch = $list_pkgs[$i]->{'status'}->{'bzr-branch'};
2645 my $status_gitpush = $list_pkgs[$i]->{'status'}->{'git-push'};
2646 my $status = "bzrBranch = $status_branch, gitPush = $status_gitpush";
2647 my @data_rows = ($num, $group_name, $pkg_name, $date_add, $date_branch, $date_gitpush, $status);
2648 $textTbl->row(@data_rows);
2649 $i++;
2650 }
2651  
2652 # Print List :
2653 print "\n";
2654 print "---------" x 11 . "\n";
2655 print " Result Search Packages \"$ARGV[2]\" And result of \"$size_list\" packages : \n";
2656 print "---------" x 11 . "\n";
2657 printf("%s", "Status :\n");
2658 print "---------" x 11 . "\n";
2659 BlankOnDev::help_list_pkg();
2660 print "\n";
2661 print $textTbl->draw();
2662 print "\n";
2663 print "---------" x 11 . "\n";
2664 printf("%s", "Status :\n");
2665 print "---------" x 11 . "\n";
2666 BlankOnDev::help_list_pkg();
2667 print "\n";
2668 } else {
2669 print "\n";
2670 print "-----" x 15 . "\n";
2671 print " Your Search Packages \"$search_pkg\" is not Found\n";
2672 print "-----" x 15 . "\n";
2673 print "\n";
2674 exit 0;
2675 }
2676 }
2677 # ------------------------------------------------------------------------
2678 # Check IF $arg_len != 3 or $arg_len != 2 :
2679 # ------------------------------------------------------------------------
2680 else {
2681 my $i = 0;
2682 my $data_cmd = '';
2683 foreach my $arg (each @ARGV) {
2684 if ($arg_len - 1 == $i) {
2685 $data_cmd .= $arg;
2686 } else {
2687 $data_cmd .= "$arg ";
2688 }
2689 $i++;
2690 }
2691 print "\n";
2692 print "====" x 18 . "\n";
2693 print "your command: boidev $data_cmd\n";
2694 print "----" x 18 . "\n";
2695 print "\n";
2696 print "Warning : \n";
2697 print "====" x 18 . "\n";
2698 print "This command max three arguments\n\n";
2699 exit;
2700 }
2701 # ------------------------------------------------------------------------
2702 # End of check IF $arg_len != 3 or $arg_len != 2.
2703 # ========================================================================
2704 }
2705 # Subroutine for branch packages :
2706 # ------------------------------------------------------------------------
2707 sub branch_pkg {
2708 my ($self, $allconfig, $group_pkg, $pkg_name, $action_rebranch) = @_;
2709  
2710 # For All config :
2711 my $curr_build = $allconfig->{'build'};
2712 my $build_rilis = $curr_build->{'rilis'};
2713 my $curr_pkg = $allconfig->{'pkg'};
2714 my $dir_pkgs = $curr_pkg->{'dirpkg'};
2715 my $locdir_group = $dir_pkgs.'/'.$group_pkg;
2716  
2717 # Check Group Directori :
2718 unless (-d $locdir_group) {
2719 mkdir($locdir_group);
2720 }
2721  
2722 # Action bzr Branch :
2723 my $act_branch = BlankOnDev::Migration::bazaar2GitHub::bazaar->branch($action_rebranch, $allconfig, $group_pkg, $pkg_name);
2724  
2725 # Prepare Configure Bzr Branch :
2726 my $prepare_cfg = prepare_config();
2727 my $result_cfg = $prepare_cfg->{'bzr-branch'}($allconfig, $pkg_name, $act_branch);
2728  
2729 # Save Configure :
2730 my $saveConfig = save_newConfig();
2731 $saveConfig->{'bzr-branch'}($result_cfg);
2732 print "\n";
2733 print "====" x 5 . " Packages $pkg_name has been finished to bzr branch ";
2734 print "====" x 5 . "\n\n";
2735 exit 0;
2736 }
2737 # Subroutine for Branch based group :
2738 # ------------------------------------------------------------------------
2739 sub branch_pkg_group {
2740 my ($self, $allconfig, $input_group) = @_;
2741  
2742 # Define scalar :
2743 my $confirm_rebranch;
2744 my $action_rebranch = 'new';
2745  
2746 # For All config :
2747 my $curr_pkg = $allconfig->{'pkg'};
2748 my $dir_pkgs = $curr_pkg->{'dirpkg'};
2749 my $locdir_group = $dir_pkgs.'/'.$input_group;
2750  
2751 # Check Group Directori :
2752 unless (-d $locdir_group) {
2753 mkdir($locdir_group);
2754 }
2755  
2756 # Get list Packages based Group :
2757 my $list_pkg = $self->filter_listpkg_based_group($allconfig, $input_group);
2758 if ($list_pkg->{'result'} == 1) {
2759 my @list_pkgs = @{$list_pkg->{'data'}};
2760  
2761 # From for rebranch :
2762 print "\n";
2763 print "You want to re-branch if packages is exists on local directory [y/n] : ";
2764 chomp($confirm_rebranch = <STDIN>);
2765 if ($confirm_rebranch eq 'y' or $confirm_rebranch eq 'Y') {
2766 $action_rebranch = 'rm';
2767 } else {
2768 $action_rebranch = 'no'
2769 }
2770  
2771 my $i = 0;
2772 my $size_list = scalar keys(@list_pkgs);
2773 my $saveConfig;
2774 my $result_cfg = $allconfig;
2775 my $count_branch = 0;
2776 my $count_rebranch = 0;
2777 my $num = $i;
2778 while ($i < $size_list) {
2779 $num = $num + 1;
2780 my $group_name = $list_pkgs[$i]->{'group'};
2781 my $pkg_name = $list_pkgs[$i]->{'name'};
2782  
2783 # For file/dir pkgs :
2784 my $dest_dir = $dir_pkgs.'/'.$input_group.'/'.$pkg_name;
2785  
2786 # Check exists pkg :
2787 if (-d $dest_dir) {
2788 if ($action_rebranch eq 'rm') {
2789 $count_rebranch = $count_branch + 1;
2790 }
2791 } else {
2792 $count_branch = $count_branch + 1;
2793 }
2794  
2795 # Action bzr Branch :
2796 my $act_branch = BlankOnDev::Migration::bazaar2GitHub::bazaar->branch($action_rebranch, $result_cfg, $group_name, $pkg_name);
2797  
2798 print "Result Action branch : $act_branch\n";
2799  
2800 # Prepare Configure Bzr Branch :
2801 my $prepare_cfg = prepare_config();
2802 $result_cfg = $prepare_cfg->{'bzr-branch'}($result_cfg, $pkg_name, $act_branch);
2803  
2804 # Save Configure :
2805 $saveConfig = save_newConfig();
2806 $saveConfig->{'bzr-branch'}($result_cfg);
2807  
2808 $i++;
2809 }
2810 my $notes = " Re-branch : $count_rebranch - New Branch : $count_branch ";
2811 print "\n";
2812 print "====" x 5 . " bzr branch has finished ";
2813 print "====" x 5 . "\n\n";
2814 exit 0;
2815 } else {
2816 print "\n";
2817 print "Info : \n";
2818 print "====" x 18 . "\n";
2819 print "Not found packages in list on group $input_group. Please run command \"boidev bzr2git addpkg\" to add new packages in group.\n\n";
2820 exit 0;
2821 }
2822  
2823 }
2824 # Subroutine for option "branch" :
2825 # ------------------------------------------------------------------------
2826 sub _branch {
2827 my ($self, $allconfig) = @_;
2828  
2829 # Define scalar :
2830 my $arg_len = scalar @ARGV;
2831 my $num_pkg_group;
2832 my $input_group;
2833 my $confirm_rebranch;
2834  
2835 # For All config :
2836 my $curr_pkg = $allconfig->{'pkg'};
2837 my $dir_pkgs = $curr_pkg->{'dirpkg'};
2838 my $pkg_groups = $curr_pkg->{'group'};
2839 my $pkg_list = $curr_pkg->{'pkgs'};
2840  
2841 # Data current config :
2842 my $curr_dataPkg_grp = $allconfig->{'pkg'}->{'group'};
2843 my $curr_data_pkg = $allconfig->{'pkg'}->{'pkgs'};
2844 my $size_pkgGrp = scalar keys(%{$curr_dataPkg_grp});
2845 my $size_pkg = scalar keys(%{$curr_data_pkg});
2846  
2847 # ------------------------------------------------------------------------
2848 # Check IF $arg_len == 2 :
2849 # ------------------------------------------------------------------------
2850 if ($arg_len == 2) {
2851  
2852 # Check Group :
2853 if ($size_pkgGrp > 0) {
2854  
2855 # Check list Packages
2856 if ($size_pkg > 0) {
2857 # Form Group Packages :
2858 print "\n";
2859 print "Choose Group Packages.\n";
2860  
2861 my $num = 0;
2862 my %num_grp = ();
2863 while (my ($key, $value) = each %{$curr_dataPkg_grp}) {
2864 my $_num = $num + 1;
2865 $num_grp{$_num} = $key;
2866 print "$_num. $key\n";
2867 $num++;
2868 }
2869 print "Enter Number choice : ";
2870 chomp($num_pkg_group = <STDIN>);
2871 if ($num_pkg_group eq '') {
2872 $input_group = '';
2873 print "\n";
2874 print "Please Number choice for Group Packages...\n";
2875 } else {
2876 if ($num_pkg_group =~ m/^[0-9]+$/) {
2877 $input_group = $num_grp{$num_pkg_group} if exists $num_grp{$num_pkg_group};
2878 $input_group = 'no' unless exists $num_grp{$num_pkg_group};
2879 } else {
2880 print "\n";
2881 print "Choice Group only Numberic...\n\n";
2882 exit 0;
2883 }
2884 }
2885  
2886 # Check Group Packages Input :
2887 if (exists $curr_dataPkg_grp->{$input_group}) {
2888  
2889 # Action Branch :
2890 $self->branch_pkg_group($allconfig, $input_group);
2891  
2892 } else {
2893 print "\n";
2894 print "Info : \n";
2895 print "====" x 18 . "\n";
2896 print "Group is not found !!!\n\n";
2897 exit 0;
2898 }
2899 } else {
2900 print "\n";
2901 print "Info : \n";
2902 print "====" x 18 . "\n";
2903 print "No more packages in list. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
2904 exit 0;
2905 }
2906 } else {
2907 print "\n";
2908 print "Info : \n";
2909 print "====" x 18 . "\n";
2910 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
2911 exit 0;
2912 }
2913 }
2914 # ------------------------------------------------------------------------
2915 # Check IF $arg_len == 3 :
2916 # ------------------------------------------------------------------------
2917 if ($arg_len == 3) {
2918  
2919 # Define scalar :
2920 my $input_arg = $ARGV[2];
2921 my $confirm_grp;
2922  
2923 # Check Group :
2924 if (exists $pkg_groups->{$input_arg}) {
2925  
2926 # For Confirm :
2927 print "\n";
2928 print "You want to branch based group [y/n] : ";
2929 chomp($confirm_grp = <STDIN>);
2930 if ($confirm_grp eq 'y' or $confirm_grp eq 'Y') {
2931  
2932 # Action Branch :
2933 $self->branch_pkg_group($allconfig, $input_arg);
2934 } else {
2935  
2936 }
2937 } else {
2938 # Check Packages :
2939 if (exists $pkg_list->{$input_arg}) {
2940 my $r_pkgGrp = $pkg_list->{$input_arg}->{'group'};
2941  
2942 # For file/dir pkgs :
2943 my $dest_dir = $dir_pkgs.'/'.$r_pkgGrp.'/'.$input_arg;
2944  
2945 # Check packages in Local dir :
2946 if (-d $dest_dir) {
2947  
2948 # Form Confirm :
2949 print "\n";
2950 print "You want to Re-branch [y/n] : ";
2951 chomp($confirm_rebranch = <STDIN>);
2952 if ($confirm_rebranch eq 'y' or $confirm_rebranch eq 'Y') {
2953  
2954 # Msg :
2955 print "\n";
2956 print "Bazaar re-branch for packages : \"$input_arg\"\n";
2957  
2958 # Action Branch :
2959 $self->branch_pkg($allconfig, $r_pkgGrp, $input_arg, 'rm');
2960 }
2961 } else {
2962  
2963 # Msg :
2964 print "\n";
2965 print "Bazaar Branch for packages : \"$input_arg\"\n";
2966  
2967 # Action Branch :
2968 $self->branch_pkg($allconfig, $r_pkgGrp, $input_arg, 'new');
2969 }
2970 } else {
2971 print "\n";
2972 print "Info : \n";
2973 print "====" x 18 . "\n";
2974 print "Not found packages. Please try another packages.\n\n";
2975 exit 0;
2976 }
2977 }
2978 }
2979 # ------------------------------------------------------------------------
2980 # Check IF $arg_len != 3 or $arg_len != 2 :
2981 # ------------------------------------------------------------------------
2982 else {
2983 my $i = 0;
2984 my $data_cmd = '';
2985 foreach my $arg (each @ARGV) {
2986 if ($arg_len - 1 == $i) {
2987 $data_cmd .= $arg;
2988 } else {
2989 $data_cmd .= "$arg ";
2990 }
2991 $i++;
2992 }
2993 print "\n";
2994 print "====" x 18 . "\n";
2995 print "your command: boidev $data_cmd\n";
2996 print "----" x 18 . "\n";
2997 print "\n";
2998 print "Warning : \n";
2999 print "====" x 18 . "\n";
3000 print "This command max three arguments\n\n";
3001 exit;
3002 }
3003 # ------------------------------------------------------------------------
3004 # End of check IF $arg_len != 3 or $arg_len != 2.
3005 # ========================================================================
3006 }
3007 # Subroutine for convert packages from repo bazaar to github :
3008 # ------------------------------------------------------------------------
3009 sub bazaar_cgit_pkg {
3010 my ($self, $allconfig, $pkg_name) = @_;
3011  
3012 # For All config :
3013 my $curr_pkg = $allconfig->{'pkg'};
3014 my $dir_pkgs = $curr_pkg->{'dirpkg'};
3015 my $pkg_list = $curr_pkg->{'pkgs'};
3016  
3017 # Loc dir packages :
3018 my $data_pkg = $pkg_list->{$pkg_name};
3019 my $group_pkg = $data_pkg->{'group'};
3020 my $bzrbranch = $data_pkg->{'brz-branch'};
3021 my $bzrbranch_status = $data_pkg->{'status'}->{'bzr-branch'};
3022 my $locdir_pkg = $dir_pkgs.'/'.$group_pkg.'/'.$pkg_name;
3023  
3024 # Check Branch :
3025 if ($bzrbranch eq 1 or ($bzrbranch eq 0 and $bzrbranch_status eq 1)) {
3026  
3027 # Check File Packages :
3028 if (-d $locdir_pkg) {
3029  
3030 # Action Convert Bzr to git :
3031 my $action_bzr2git = BlankOnDev::Migration::bazaar2GitHub::bazaar->bzr_convert_git($allconfig, $pkg_name);
3032  
3033 # Prepare Config :
3034 my $prepare_config = prepare_config();
3035 my $result_cfg = $prepare_config->{'bzr-convert'}($allconfig, $pkg_name, $action_bzr2git);
3036  
3037 # Save Configure :
3038 my $saveConfig = save_newConfig();
3039 $saveConfig->{'bzr-convert'}($result_cfg);
3040 print "\n";
3041 print "====" x 5 . " Packages $pkg_name has been finished to convert ";
3042 print "====" x 5 . "\n\n";
3043 exit 0;
3044  
3045 } else {
3046 print "\n";
3047 print "Info : \n";
3048 print "====" x 18 . "\n";
3049 print "File Packages [$pkg_name] is not found. \n";
3050 print "Please run command \"boidev bzr2git branch <packages_name>\" to branch package [$pkg_name] from bazaar server repository..\n\n";
3051 exit 0;
3052 }
3053 } else {
3054 print "\n";
3055 print "Info : Branch status \n";
3056 print "====" x 18 . "\n";
3057 print "File Packages [$pkg_name] is not found. \n";
3058 print "Please run command \"boidev bzr2git branch <packages_name>\" to branch package [$pkg_name] from bazaar server repository..\n\n";
3059 exit 0;
3060 }
3061 }
3062 # Subroutine for convert packages in group from repo bazaar to github :
3063 # ------------------------------------------------------------------------
3064 sub bazaar_cgit_pkg_group {
3065 my ($self, $allconfig, $input_group) = @_;
3066  
3067 # For All config :
3068 my $curr_pkg = $allconfig->{'pkg'};
3069 my $dir_pkgs = $curr_pkg->{'dirpkg'};
3070  
3071 my $list_pkg = $self->filter_listpkg_based_group($allconfig, $input_group);
3072 if ($list_pkg->{'result'} == 1) {
3073 my @list_pkgs = @{$list_pkg->{'data'}};
3074  
3075 # While loop to convert repository format :
3076 my $i = 0;
3077 my $until = scalar @list_pkgs;
3078 my $saveConfig;
3079 my $result_cfg = $allconfig;
3080 while ($i < $until) {
3081 my $pkg_name = $list_pkgs[$i]->{'name'};
3082 my $bzrbranch = $list_pkgs[$i]->{'bzr-branch'};
3083 my $bzrbranch_status = $list_pkgs[$i]->{'status'}->{'bzr-branch'};
3084 my $locdir_pkg = $dir_pkgs.'/'.$input_group.'/'.$pkg_name;
3085  
3086 # Check Status Branch :
3087 if ($bzrbranch eq 1 or ($bzrbranch eq 0 and $bzrbranch_status eq 1)) {
3088  
3089 # Check If data repo is exists :
3090 if (-d $locdir_pkg) {
3091  
3092 # Action Convert Bzr to git :
3093 my $action_bzr2git = BlankOnDev::Migration::bazaar2GitHub::bazaar->bzr_convert_git($allconfig, $pkg_name);
3094  
3095 print "Action Convert $pkg_name : $action_bzr2git\n";
3096  
3097 # Prepare Config :
3098 my $prepare_config = prepare_config();
3099 $result_cfg = $prepare_config->{'bzr-convert'}($result_cfg, $pkg_name, $action_bzr2git);
3100  
3101 # Save Configure :
3102 $saveConfig = save_newConfig();
3103 $saveConfig->{'bzr-convert'}($result_cfg);
3104 } else {
3105  
3106 print "\n";
3107 print "File Packages [$pkg_name] has deleted. \n";
3108 print "Please run command \"boidev bzr2git re-branch <packages_name>\" to download file package [$pkg_name] from bazaar server repository..\n\n";
3109 }
3110 } else {
3111  
3112 print "\n";
3113 print "File Packages [$pkg_name] is not found. \n";
3114 print "Please run command \"boidev bzr2git branch <packages_name>\" to branch package [$pkg_name] from bazaar server repository..\n\n";
3115 }
3116 $i++;
3117 }
3118 print "\n";
3119 print "====" x 5 . " Packages in group \"$input_group\" has been finished to convert ";
3120 print "====" x 5 . "\n\n";
3121 exit 0;
3122 } else {
3123 print "\n";
3124 print "Info : \n";
3125 print "====" x 18 . "\n";
3126 print "Not found packages in list on group $input_group. Please run command \"boidev bzr2git addpkg\" to add new packages in group.\n\n";
3127 exit 0;
3128 }
3129 }
3130 # Subroutine for option "bzr-cgit" :
3131 # ------------------------------------------------------------------------
3132 sub _bzr_cgit {
3133 my ($self, $allconfig) = @_;
3134  
3135 # Define scalar :
3136 my $arg_len = scalar @ARGV;
3137 my $num_pkg_group;
3138 my $input_group;
3139  
3140 # For All config :
3141 my $curr_pkg = $allconfig->{'pkg'};
3142 my $pkg_groups = $curr_pkg->{'group'};
3143 my $pkg_list = $curr_pkg->{'pkgs'};
3144 my $bzr = $allconfig->{'bzr'};
3145  
3146 # Data current config :
3147 my $curr_dataPkg_grp = $allconfig->{'pkg'}->{'group'};
3148 my $curr_data_pkg = $allconfig->{'pkg'}->{'pkgs'};
3149 my $size_pkgGrp = scalar keys(%{$curr_dataPkg_grp});
3150 my $size_pkg = scalar keys(%{$curr_data_pkg});
3151  
3152 # ------------------------------------------------------------------------
3153 # Check IF $arg_len == 2 :
3154 # ------------------------------------------------------------------------
3155 if ($arg_len == 2) {
3156  
3157 # Check Group :
3158 if ($size_pkgGrp > 0) {
3159  
3160 # Check list Packages
3161 if ($size_pkg > 0) {
3162 # Form Group Packages :
3163 print "\n";
3164 print "Choose Group Packages.\n";
3165  
3166 my $num = 0;
3167 my %num_grp = ();
3168 while (my ($key, $value) = each %{$curr_dataPkg_grp}) {
3169 my $_num = $num + 1;
3170 $num_grp{$_num} = $key;
3171 print "$_num. $key\n";
3172 $num++;
3173 }
3174 print "Enter Number choice : ";
3175 chomp($num_pkg_group = <STDIN>);
3176 if ($num_pkg_group eq '') {
3177 $input_group = '';
3178 print "\n";
3179 print "Please Number choice for Group Packages...\n";
3180 } else {
3181 if ($num_pkg_group =~ m/^[0-9]+$/) {
3182 $input_group = $num_grp{$num_pkg_group} if exists $num_grp{$num_pkg_group};
3183 $input_group = 'no' unless exists $num_grp{$num_pkg_group};
3184 } else {
3185 print "\n";
3186 print "Choice Group only Numberic...\n\n";
3187 exit 0;
3188 }
3189 }
3190  
3191 print "\n";
3192 print "Converting .... \n";
3193 print "\n";
3194  
3195 # Action Convert :
3196 $self->bazaar_cgit_pkg_group($allconfig, $input_group);
3197
3198 } else {
3199 print "\n";
3200 print "Info : \n";
3201 print "====" x 18 . "\n";
3202 print "No more packages in list. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
3203 exit 0;
3204 }
3205 } else {
3206 print "\n";
3207 print "Info : \n";
3208 print "====" x 18 . "\n";
3209 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
3210 exit 0;
3211 }
3212 }
3213 # ------------------------------------------------------------------------
3214 # Check IF $arg_len == 3 :
3215 # ------------------------------------------------------------------------
3216 elsif ($arg_len == 3) {
3217 # Get data argument ;
3218 my $input_arg = $ARGV[2];
3219  
3220 # Check Group :
3221 if ($size_pkgGrp > 0) {
3222  
3223 # Check list Packages
3224 if ($size_pkg > 0) {
3225  
3226 # Check Group Input :
3227 if (exists $pkg_groups->{$input_arg}) {
3228  
3229 print "\n";
3230 print "Converting .... \n";
3231 print "\n";
3232  
3233 # Action Convert :
3234 $self->bazaar_cgit_pkg_group($allconfig, $input_arg);
3235 } else {
3236 # Check Packages Input :
3237 if (exists $pkg_list->{$input_arg}) {
3238  
3239 print "\n";
3240 print "Converting .... \n";
3241 print "\n";
3242  
3243 # Action Convert :
3244 $self->bazaar_cgit_pkg($allconfig, $input_arg);
3245 } else {
3246 print "\n";
3247 print "Info : \n";
3248 print "====" x 18 . "\n";
3249 print "Packages is not found. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
3250 }
3251 }
3252 } else {
3253 print "\n";
3254 print "Info : \n";
3255 print "====" x 18 . "\n";
3256 print "No more packages in list. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
3257 exit 0;
3258 }
3259 } else {
3260 print "\n";
3261 print "Info : \n";
3262 print "====" x 18 . "\n";
3263 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
3264 exit 0;
3265 }
3266 }
3267 # ------------------------------------------------------------------------
3268 # Check IF $arg_len == 3 or $arg_len == 2 :
3269 # ------------------------------------------------------------------------
3270 else {
3271 my $i = 0;
3272 my $data_cmd = '';
3273 foreach my $arg (each @ARGV) {
3274 if ($arg_len - 1 == $i) {
3275 $data_cmd .= $arg;
3276 } else {
3277 $data_cmd .= "$arg ";
3278 }
3279 $i++;
3280 }
3281 print "\n";
3282 print "====" x 18 . "\n";
3283 print "your command: boidev $data_cmd\n";
3284 print "----" x 18 . "\n";
3285 print "\n";
3286 print "Warning : \n";
3287 print "====" x 18 . "\n";
3288 print "This command max three arguments\n\n";
3289 exit;
3290 }
3291 # ------------------------------------------------------------------------
3292 # End of check IF $arg_len == 3 or $arg_len == 2.
3293 # ========================================================================
3294 }
3295 # Subroutine for git push pkg handle :
3296 # ------------------------------------------------------------------------
3297 sub gitpush_pkg {
3298 my ($self, $allconfig, $pkg_name) = @_;
3299  
3300 # For All config :
3301 my $curr_build = $allconfig->{'build'};
3302 my $build_rilis = $curr_build->{'rilis'};
3303 my $curr_pkg = $allconfig->{'pkg'};
3304 my $dir_pkgs = $curr_pkg->{'dirpkg'};
3305 my $pkg_list = $curr_pkg->{'pkgs'};
3306  
3307 # Loc dir packages :
3308 my $data_pkg = $pkg_list->{$pkg_name};
3309 my $group_pkg = $data_pkg->{'group'};
3310 my $bzrbranch = $data_pkg->{'brz-branch'};
3311 my $bzrbranch_status = $data_pkg->{'status'}->{'bzr-branch'};
3312 my $locdir_pkg = $dir_pkgs.'/'.$group_pkg.'/'.$pkg_name;
3313  
3314 # Check Status Branch :
3315 if ($bzrbranch eq 1 or ($bzrbranch eq 0 and $bzrbranch_status eq 1)) {
3316  
3317 # Check If data repo is exists :
3318 if (-d $locdir_pkg) {
3319  
3320 # Action Git Push :
3321 my $action_gitpush = BlankOnDev::Migration::bazaar2GitHub::github->git_push($allconfig, $pkg_name, $build_rilis);
3322  
3323 # Print Action :
3324 print "Action Git push for packages $pkg_name : $action_gitpush \n";
3325  
3326 # Prepare Config :
3327 my $prepare_config = prepare_config();
3328 my $result_cfg = $prepare_config->{'git-push'}($allconfig, $pkg_name, $action_gitpush);
3329  
3330 # Save Configure :
3331 my $saveConfig = save_newConfig();
3332 $saveConfig->{'git-push'}($result_cfg);
3333 } else {
3334 print "\n";
3335 print "Info : \n";
3336 print "====" x 18 . "\n";
3337 print "File Packages [$pkg_name] is not found. \n";
3338 print "Please run command \"boidev bzr2git branch <packages_name>\" to branch package [$pkg_name] from bazaar server repository..\n\n";
3339 exit 0;
3340 }
3341 } else {
3342 print "\n";
3343 print "Info : \n";
3344 print "====" x 18 . "\n";
3345 print "File Packages [$pkg_name] is not found. \n";
3346 print "Please run command \"boidev bzr2git branch <packages_name>\" to branch package [$pkg_name] from bazaar server repository..\n\n";
3347 }
3348 }
3349 # Subroutine for git push pkg handle by group :
3350 # ------------------------------------------------------------------------
3351 sub gitpush_pkg_group {
3352 my ($self, $allconfig, $input_group) = @_;
3353  
3354 # For All config :
3355 my $curr_build = $allconfig->{'build'};
3356 my $build_rilis = $curr_build->{'rilis'};
3357 my $curr_pkg = $allconfig->{'pkg'};
3358 my $dir_pkgs = $curr_pkg->{'dirpkg'};
3359  
3360 # Get list Packages based Group :
3361 my $list_pkg = $self->filter_listpkg_based_group($allconfig, $input_group);
3362 if ($list_pkg->{'result'} == 1) {
3363 my @list_pkgs = @{$list_pkg->{'data'}};
3364  
3365 # While loop to action git push :
3366 my $i = 0;
3367 my $until = scalar @list_pkgs;
3368 my $saveConfig;
3369 my $result_cfg = $allconfig;
3370 while ($i < $until) {
3371 my $pkg_name = $list_pkgs[$i]->{'name'};
3372 my $bzrbranch = $list_pkgs[$i]->{'bzr-branch'};
3373 my $bzrbranch_status = $list_pkgs[$i]->{'status'}->{'bzr-branch'};
3374 my $locdir_pkg = $dir_pkgs.'/'.$input_group.'/'.$pkg_name;
3375  
3376 # Check Status Branch :
3377 if ($bzrbranch eq 1 or ($bzrbranch eq 0 and $bzrbranch_status eq 1)) {
3378  
3379 # Check If data repo is exists :
3380 if (-d $locdir_pkg) {
3381  
3382 # Action Git Push :
3383 my $action_gitpush = BlankOnDev::Migration::bazaar2GitHub::github->git_push($allconfig, $pkg_name, $build_rilis);
3384  
3385 # Print Action :
3386 print "Action Git push for packages $pkg_name : $action_gitpush \n";
3387  
3388 # Prepare Config :
3389 my $prepare_config = prepare_config();
3390 $result_cfg = $prepare_config->{'git-push'}($result_cfg, $pkg_name, $action_gitpush);
3391  
3392 # Save Configure :
3393 $saveConfig = save_newConfig();
3394 $saveConfig->{'git-push'}($result_cfg);
3395 } else {
3396  
3397 print "\n";
3398 print "File Packages [$pkg_name] has deleted. \n";
3399 print "Please run command \"boidev bzr2git re-branch <packages_name>\" to download file package [$pkg_name] from bazaar server repository..\n\n";
3400 }
3401 } else {
3402  
3403 print "\n";
3404 print "File Packages [$pkg_name] is not found. \n";
3405 print "Please run command \"boidev bzr2git branch <packages_name>\" to branch package [$pkg_name] from bazaar server repository..\n\n";
3406 }
3407 $i++;
3408 }
3409 print "\n";
3410 print "====" x 5 . " Packages in group \"$input_group\" has been finished to git push ";
3411 print "====" x 5 . "\n\n";
3412 exit 0;
3413 } else {
3414 print "\n";
3415 print "Info : \n";
3416 print "====" x 18 . "\n";
3417 print "Not found packages in list on group $input_group. Please run command \"boidev bzr2git addpkg\" to add new packages in group.\n\n";
3418 exit 0;
3419 }
3420 }
3421 # Subroutine for option "git-push" :
3422 # ------------------------------------------------------------------------
3423 sub _gitpush {
3424 my ($self, $allconfig) = @_;
3425  
3426 # Define scalar :
3427 my $arg_len = scalar @ARGV;
3428 my $num_pkg_group;
3429 my $input_group;
3430  
3431 # For All config :
3432 my $curr_pkg = $allconfig->{'pkg'};
3433 my $pkg_groups = $curr_pkg->{'group'};
3434 my $pkg_list = $curr_pkg->{'pkgs'};
3435  
3436 # Data current config :
3437 my $curr_dataPkg_grp = $allconfig->{'pkg'}->{'group'};
3438 my $curr_data_pkg = $allconfig->{'pkg'}->{'pkgs'};
3439 my $size_pkgGrp = scalar keys(%{$curr_dataPkg_grp});
3440 my $size_pkg = scalar keys(%{$curr_data_pkg});
3441  
3442 # ------------------------------------------------------------------------
3443 # Check IF $arg_len == 2 :
3444 # ------------------------------------------------------------------------
3445 if ($arg_len == 2) {
3446  
3447 # Check Group :
3448 if ($size_pkgGrp > 0) {
3449  
3450 # Check list Packages
3451 if ($size_pkg > 0) {
3452  
3453 # Form Group Packages :
3454 print "\n";
3455 print "Choose Group Packages.\n";
3456  
3457 my $num = 0;
3458 my %num_grp = ();
3459 while (my ($key, $value) = each %{$curr_dataPkg_grp}) {
3460 my $_num = $num + 1;
3461 $num_grp{$_num} = $key;
3462 print "$_num. $key\n";
3463 $num++;
3464 }
3465 print "Enter Number choice : ";
3466 chomp($num_pkg_group = <STDIN>);
3467 if ($num_pkg_group eq '') {
3468 $input_group = '';
3469 print "\n";
3470 print "Please Number choice for Group Packages...\n";
3471 } else {
3472 if ($num_pkg_group =~ m/^[0-9]+$/) {
3473 $input_group = $num_grp{$num_pkg_group} if exists $num_grp{$num_pkg_group};
3474 $input_group = 'no' unless exists $num_grp{$num_pkg_group};
3475 } else {
3476 print "\n";
3477 print "Choice Group only Numberic...\n\n";
3478 exit 0;
3479 }
3480 }
3481  
3482 print "\n";
3483 print "Push to github .... \n";
3484 print "\n";
3485  
3486 # Action git push by group :
3487 $self->gitpush_pkg_group($allconfig, $input_group);
3488  
3489 } else {
3490 print "\n";
3491 print "Info : \n";
3492 print "====" x 18 . "\n";
3493 print "No more packages in list. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
3494 exit 0;
3495 }
3496 } else {
3497 print "\n";
3498 print "Info : \n";
3499 print "====" x 18 . "\n";
3500 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
3501 exit 0;
3502 }
3503 }
3504 # ------------------------------------------------------------------------
3505 # Check IF $arg_len == 3 :
3506 # ------------------------------------------------------------------------
3507 if ($arg_len == 3) {
3508 # Get data argument ;
3509 my $input_arg = $ARGV[2];
3510  
3511 # Check Group :
3512 if ($size_pkgGrp > 0) {
3513  
3514 # Check list Packages
3515 if ($size_pkg > 0) {
3516  
3517 # Check Group input :
3518 if (exists $pkg_groups->{$input_arg}) {
3519  
3520 print "\n";
3521 print "Push to github .... \n";
3522 print "\n";
3523  
3524 # Action git push by group :
3525 $self->gitpush_pkg_group($allconfig, $input_arg);
3526 } else {
3527  
3528 # Check Packages Input :
3529 if (exists $pkg_list->{$input_arg}) {
3530  
3531 print "\n";
3532 print "Push to github for packages $input_arg\n";
3533 print "\n";
3534  
3535 # Action git push :
3536 $self->gitpush_pkg($allconfig, $input_arg);
3537 } else {
3538 print "\n";
3539 print "Info : \n";
3540 print "====" x 18 . "\n";
3541 print "Packages is not found. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
3542 }
3543 }
3544 } else {
3545 print "\n";
3546 print "Info : \n";
3547 print "====" x 18 . "\n";
3548 print "No more packages in list. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
3549 exit 0;
3550 }
3551 } else {
3552 print "\n";
3553 print "Info : \n";
3554 print "====" x 18 . "\n";
3555 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
3556 exit 0;
3557 }
3558 }
3559 # ------------------------------------------------------------------------
3560 # Check IF $arg_len == 3 or $arg_len == 2 :
3561 # ------------------------------------------------------------------------
3562 else {
3563 my $i = 0;
3564 my $data_cmd = '';
3565 foreach my $arg (each @ARGV) {
3566 if ($arg_len - 1 == $i) {
3567 $data_cmd .= $arg;
3568 } else {
3569 $data_cmd .= "$arg ";
3570 }
3571 $i++;
3572 }
3573 print "\n";
3574 print "====" x 18 . "\n";
3575 print "your command: boidev $data_cmd\n";
3576 print "----" x 18 . "\n";
3577 print "\n";
3578 print "Warning : \n";
3579 print "====" x 18 . "\n";
3580 print "This command max three arguments\n\n";
3581 exit 0;
3582 }
3583 # ------------------------------------------------------------------------
3584 # End of check IF $arg_len == 3 or $arg_len == 2.
3585 # ========================================================================
3586 }
3587 # Subroutine for handling "git-push-new" for one packages :
3588 # ------------------------------------------------------------------------
3589 sub gitpush_new_pkg {
3590 my ($self, $allconfig, $pkg_name, $commit) = @_;
3591  
3592 # For All config :
3593 my $curr_pkg = $allconfig->{'pkg'};
3594 my $dir_pkgs = $curr_pkg->{'dirpkg'};
3595 my $pkg_list = $curr_pkg->{'pkgs'};
3596  
3597 # Loc dir packages :
3598 my $data_pkg = $pkg_list->{$pkg_name};
3599 my $group_pkg = $data_pkg->{'group'};
3600 my $bzrbranch = $data_pkg->{'brz-branch'};
3601 my $bzrbranch_status = $data_pkg->{'status'}->{'bzr-branch'};
3602 my $locdir_pkg = $dir_pkgs.'/'.$group_pkg.'/'.$pkg_name;
3603  
3604 # Check Status Branch :
3605 if ($bzrbranch eq 1 or ($bzrbranch eq 0 and $bzrbranch_status eq 1)) {
3606  
3607 # Check If data repo is exists :
3608 if (-d $locdir_pkg) {
3609  
3610 # Action git push for new repo ;
3611 BlankOnDev::Migration::bazaar2GitHub::github->gitpush_new($allconfig, $pkg_name, $commit);
3612  
3613 print "\n";
3614 print "Git push new repositori : $pkg_name \n";
3615 print "Commit git push : \"$commit\"\n\n";
3616 exit 0;
3617 } else {
3618 print "\n";
3619 print "Info : Not convert to git \n";
3620 print "====" x 18 . "\n";
3621 print "File Packages [$pkg_name] has deleted. \n";
3622 print "Please run command \"boidev bzr2git re-branch <packages_name>\" to download file package [$pkg_name] from bazaar server repository..\n\n";
3623 exit 0;
3624 }
3625 } else {
3626 print "\n";
3627 print "Info : \n";
3628 print "====" x 18 . "\n";
3629 print "File Packages [$pkg_name] is not found. \n";
3630 print "Please run command \"boidev bzr2git branch <packages_name>\" to branch package [$pkg_name] from bazaar server repository..\n\n";
3631 exit 0;
3632 }
3633 }
3634 # Subroutine for handling "git-push-new" packages by group :
3635 # ------------------------------------------------------------------------
3636 sub gitpush_new_pkg_group {
3637 my ($self, $allconfig, $input_group, $commit) = @_;
3638  
3639 # For All config :
3640 my $curr_pkg = $allconfig->{'pkg'};
3641 my $dir_pkgs = $curr_pkg->{'dirpkg'};
3642  
3643 my $list_pkg = $self->filter_listpkg_based_group($allconfig, $input_group);
3644 if ($list_pkg->{'result'} == 1) {
3645 my @list_pkgs = @{$list_pkg->{'data'}};
3646  
3647 # While loop for git push new repo :
3648 my $i = 0;
3649 my $until = scalar @list_pkgs;
3650 while ($i < $until) {
3651 my $pkg_name = $list_pkgs[$i]->{'name'};
3652 my $bzrbranch = $list_pkgs[$i]->{'bzr-branch'};
3653 my $bzrbranch_status = $list_pkgs[$i]->{'status'}->{'bzr-branch'};
3654 my $locdir_pkg = $dir_pkgs.'/'.$input_group.'/'.$pkg_name;
3655  
3656 # Check Status Branch :
3657 if ($bzrbranch eq 1 or ($bzrbranch eq 0 and $bzrbranch_status eq 1)) {
3658  
3659 # Check If data repo is exists :
3660 if (-d $locdir_pkg) {
3661  
3662 # Action git push for new repo ;
3663 BlankOnDev::Migration::bazaar2GitHub::github->gitpush_new($allconfig, $pkg_name, $commit);
3664  
3665 print "\n";
3666 print "Git push new repositori : $pkg_name \n";
3667 print "Commit git push : \"$commit\"\n";
3668 } else {
3669  
3670 print "\n";
3671 print "File Packages [$pkg_name] has deleted. \n";
3672 print "Please run command \"boidev bzr2git re-branch <packages_name>\" to download file package [$pkg_name] from bazaar server repository..\n\n";
3673 }
3674 } else {
3675  
3676 print "\n";
3677 print "File Packages [$pkg_name] is not found. \n";
3678 print "Please run command \"boidev bzr2git branch <packages_name>\" to branch package [$pkg_name] from bazaar server repository..\n\n";
3679 }
3680 $i++;
3681 }
3682  
3683 print "\n";
3684 print "push to git has been finished \n";
3685 print "----" x 10 . "\n\n";
3686 exit 0;
3687 } else {
3688 print "\n";
3689 print "Info : \n";
3690 print "====" x 18 . "\n";
3691 print "Not found packages in list on group $input_group. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file <location_of_packages_list.boikg>\" to add new packages in group.\n\n";
3692 exit 0;
3693 }
3694 }
3695 # Subroutine for option "git-push-new" :
3696 # ------------------------------------------------------------------------
3697 sub _gitpush_new {
3698 my ($self, $allconfig) = @_;
3699  
3700 # Define scalar :
3701 my $arg_len = scalar @ARGV;
3702 my $num_pkg_group;
3703 my $input_group;
3704 my $input_commit = 'new repositori';
3705  
3706 # For All config :
3707 my $curr_pkg = $allconfig->{'pkg'};
3708 my $pkg_groups = $curr_pkg->{'group'};
3709 my $pkg_list = $curr_pkg->{'pkgs'};
3710  
3711 # Data current config :
3712 my $curr_dataPkg_grp = $allconfig->{'pkg'}->{'group'};
3713 my $curr_data_pkg = $allconfig->{'pkg'}->{'pkgs'};
3714 my $size_pkgGrp = scalar keys(%{$curr_dataPkg_grp});
3715 my $size_pkg = scalar keys(%{$curr_data_pkg});
3716  
3717 # ------------------------------------------------------------------------
3718 # Check IF $arg_len == 2 :
3719 # ------------------------------------------------------------------------
3720 if ($arg_len == 2) {
3721  
3722 # Check Group :
3723 if ($size_pkgGrp > 0) {
3724  
3725 # Check list Packages
3726 if ($size_pkg > 0) {
3727  
3728 # Form Group Packages :
3729 print "\n";
3730 print "Choose Group Packages.\n";
3731  
3732 my $num = 0;
3733 my %num_grp = ();
3734 while (my ($key, $value) = each %{$curr_dataPkg_grp}) {
3735 my $_num = $num + 1;
3736 $num_grp{$_num} = $key;
3737 print "$_num. $key\n";
3738 $num++;
3739 }
3740 print "Enter Number choice : ";
3741 chomp($num_pkg_group = <STDIN>);
3742 if ($num_pkg_group eq '') {
3743 $input_group = '';
3744 print "\n";
3745 print "Please Number choice for Group Packages...\n";
3746 } else {
3747 if ($num_pkg_group =~ m/^[0-9]+$/) {
3748 $input_group = $num_grp{$num_pkg_group} if exists $num_grp{$num_pkg_group};
3749 $input_group = 'no' unless exists $num_grp{$num_pkg_group};
3750 } else {
3751 print "\n";
3752 print "Choice Group only Numberic...\n\n";
3753 exit 0;
3754 }
3755 }
3756  
3757 print "\n";
3758 print "Push to github .... \n";
3759 print "----" x 10 . "\n";
3760 print "\n";
3761  
3762 # Form for enter your commit :
3763 print "\n";
3764 print "Enter \"commit\" for git push : ";
3765 chomp($input_commit = <STDIN>);
3766 if ($input_commit ne '') {
3767 $input_commit = $input_commit;
3768 $input_commit =~ s/\"+//g;
3769 $input_commit =~ s/\'+//g;
3770 }
3771  
3772 # Action git push by group :
3773 $self->gitpush_new_pkg_group($allconfig, $input_group, $input_commit);
3774  
3775 } else {
3776 print "\n";
3777 print "Info : \n";
3778 print "====" x 18 . "\n";
3779 print "No more packages in list. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
3780 exit 0;
3781 }
3782 } else {
3783 print "\n";
3784 print "Info : \n";
3785 print "====" x 18 . "\n";
3786 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
3787 exit 0;
3788 }
3789 }
3790 # ------------------------------------------------------------------------
3791 # Check IF $arg_len == 3 :
3792 # ------------------------------------------------------------------------
3793 elsif ($arg_len == 3) {
3794 # Get data argument ;
3795 my $input_arg = $ARGV[2];
3796  
3797 # Check Group :
3798 if ($size_pkgGrp > 0) {
3799  
3800 # Check list Packages
3801 if ($size_pkg > 0) {
3802  
3803 print "\n";
3804 print "Push to github .... \n";
3805 print "----" x 10 . "\n";
3806 print "\n";
3807  
3808 # Check Group Input :
3809 if (exists $pkg_groups->{$input_arg}) {
3810  
3811 # Form for enter your commit :
3812 print "\n";
3813 print "Enter \"commit\" for git push : ";
3814 chomp($input_commit = <STDIN>);
3815 if ($input_commit ne '') {
3816 $input_commit = $input_commit;
3817 }
3818  
3819 # Action git push by group :
3820 $self->gitpush_new_pkg_group($allconfig, $input_arg, $input_commit);
3821  
3822 } else {
3823 # Check Packages Input :
3824 if (exists $pkg_list->{$input_arg}) {
3825  
3826 # Form for enter your commit :
3827 print "\n";
3828 print "Enter \"commit\" for git push : ";
3829 chomp($input_commit = <STDIN>);
3830 if ($input_commit ne '') {
3831 $input_commit = $input_commit;
3832 $input_commit =~ s/\"+//g;
3833 $input_commit =~ s/\'+//g;
3834 }
3835  
3836 # action :
3837 $self->gitpush_new_pkg($allconfig, $input_arg, $input_commit);
3838 } else {
3839 print "\n";
3840 print "Info : \n";
3841 print "====" x 18 . "\n";
3842 print "Packages is not found. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
3843 exit 0;
3844 }
3845 }
3846 } else {
3847 print "\n";
3848 print "Info : \n";
3849 print "====" x 18 . "\n";
3850 print "No more packages in list. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
3851 exit 0;
3852 }
3853 } else {
3854 print "\n";
3855 print "Info : \n";
3856 print "====" x 18 . "\n";
3857 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
3858 exit 0;
3859 }
3860 }
3861 # ------------------------------------------------------------------------
3862 # Check IF $arg_len == 3 or $arg_len == 2 :
3863 # ------------------------------------------------------------------------
3864 else {
3865 my $i = 0;
3866 my $data_cmd = '';
3867 foreach my $arg (each @ARGV) {
3868 if ($arg_len - 1 == $i) {
3869 $data_cmd .= $arg;
3870 } else {
3871 $data_cmd .= "$arg ";
3872 }
3873 $i++;
3874 }
3875 print "\n";
3876 print "====" x 18 . "\n";
3877 print "your command: boidev $data_cmd\n";
3878 print "----" x 18 . "\n";
3879 print "\n";
3880 print "Warning : \n";
3881 print "====" x 18 . "\n";
3882 print "This command max three arguments\n\n";
3883 exit 0;
3884 }
3885 # ------------------------------------------------------------------------
3886 # End of check IF $arg_len == 3 or $arg_len == 2.
3887 # ========================================================================
3888 }
3889 # Subroutine for action re-branch pkg :
3890 # ------------------------------------------------------------------------
3891 sub rebranch_pkg {
3892 my ($self, $allconfig, $group_pkg, $pkg_name, $action_rebranch) = @_;
3893  
3894 # For All config :
3895 my $curr_pkg = $allconfig->{'pkg'};
3896 my $dir_pkgs = $curr_pkg->{'dirpkg'};
3897 my $locdir_group = $dir_pkgs.'/'.$group_pkg;
3898  
3899 # Check Group Directori :
3900 unless (-d $locdir_group) {
3901 mkdir($locdir_group);
3902 }
3903  
3904 # Action bzr Branch :
3905 my $act_branch = BlankOnDev::Migration::bazaar2GitHub::bazaar->branch($action_rebranch, $allconfig, $group_pkg, $pkg_name);
3906  
3907 # Prepare Configure Bzr Branch :
3908 my $prepare_cfg = prepare_config();
3909 my $result_cfg = $prepare_cfg->{'bzr-branch'}($allconfig, $pkg_name, $act_branch);
3910  
3911 # Save Configure :
3912 my $saveConfig = save_newConfig();
3913 $saveConfig->{'bzr-branch'}($result_cfg);
3914 print "\n";
3915 print "====" x 5 . " Packages $pkg_name has been finished to bzr branch ";
3916 print "====" x 5 . "\n\n";
3917 exit 0;
3918 }
3919 # Subroutine for action re-branch pkg by group :
3920 # ------------------------------------------------------------------------
3921 sub rebranch_pkg_group {
3922 my ($self, $allconfig, $input_group) = @_;
3923  
3924 # Define scalar :
3925 my $act_branch;
3926  
3927 # For All config :
3928 my $curr_build = $allconfig->{'build'};
3929 my $build_rilis = $curr_build->{'rilis'};
3930 my $curr_pkg = $allconfig->{'pkg'};
3931 my $dir_pkgs = $curr_pkg->{'dirpkg'};
3932 my $locdir_group = $dir_pkgs.'/'.$input_group;
3933  
3934 # Check Group Directori :
3935 unless (-d $locdir_group) {
3936 mkdir($locdir_group);
3937 }
3938  
3939 print "\n";
3940  
3941 # For Data Developer :
3942 my $data_dev = BlankOnDev::DataDev::data_dev();
3943 my $logs_dir = $data_dev->{'dirlogs'};
3944 my $prefix_log = $data_dev->{'prefix_bzrbranch_log'};
3945 my $ext_out_log = $data_dev->{'log_ext_out'};
3946 my $ext_err_log = $data_dev->{'log_ext_err'};
3947  
3948 # Get list Packages based Group :
3949 my $list_pkg = $self->filter_listpkg_based_group($allconfig, $input_group);
3950 if ($list_pkg->{'result'} == 1) {
3951 my @list_pkgs = @{$list_pkg->{'data'}};
3952  
3953 my $i = 0;
3954 my $size_list = scalar keys(@list_pkgs);
3955 my $saveConfig;
3956 my $result_cfg = $allconfig;
3957 my $num = $i;
3958 while ($i < $size_list) {
3959 $num = $num + 1;
3960 my $group_name = $list_pkgs[$i]->{'group'};
3961 my $pkg_name = $list_pkgs[$i]->{'name'};
3962  
3963 # For file/dir pkgs :
3964 my $dest_dir = $dir_pkgs.'/'.$input_group.'/'.$pkg_name;
3965  
3966 # Check exists pkg :
3967 if (-d $dest_dir) {
3968  
3969 # Action bzr Branch :
3970 $act_branch = BlankOnDev::Migration::bazaar2GitHub::bazaar->branch('rm', $result_cfg, $group_name, $pkg_name);
3971 } else {
3972  
3973 # Action bzr Branch :
3974 $act_branch = BlankOnDev::Migration::bazaar2GitHub::bazaar->branch('no', $result_cfg, $group_name, $pkg_name);
3975 }
3976  
3977 print " $act_branch\n";
3978  
3979 # Prepare Configure Bzr Branch :
3980 my $prepare_cfg = prepare_config();
3981 $result_cfg = $prepare_cfg->{'bzr-branch'}($result_cfg, $pkg_name, $act_branch);
3982  
3983 # Save Configure :
3984 $saveConfig = save_newConfig();
3985 $saveConfig->{'bzr-branch'}($result_cfg);
3986  
3987 $i++;
3988 }
3989  
3990 print "\n";
3991 print "====" x 5 . " bzr branch has finished ";
3992 print "====" x 5 . "\n\n";
3993 exit 0;
3994 } else {
3995 print "\n";
3996 print "Info : \n";
3997 print "====" x 18 . "\n";
3998 print "Not found packages in list on group $input_group. Please run command \"boidev bzr2git addpkg\" to add new packages in group.\n\n";
3999 exit 0;
4000 }
4001 }
4002 # Subroutine for option "re-branch" :
4003 # ------------------------------------------------------------------------
4004 sub _re_branch {
4005 my ($self, $allconfig) = @_;
4006  
4007 # Define scalar :
4008 my $arg_len = scalar @ARGV;
4009 my $num_pkg_group;
4010 my $input_group;
4011 my $confirm_rebranch;
4012  
4013 # For All config :
4014 my $curr_build = $allconfig->{'build'};
4015 my $curr_pkg = $allconfig->{'pkg'};
4016 my $dir_pkgs = $curr_pkg->{'dirpkg'};
4017 my $pkg_groups = $curr_pkg->{'group'};
4018 my $pkg_list = $curr_pkg->{'pkgs'};
4019  
4020 # Data current config :
4021 my $curr_dataPkg_grp = $allconfig->{'pkg'}->{'group'};
4022 my $curr_data_pkg = $allconfig->{'pkg'}->{'pkgs'};
4023 my $size_pkgGrp = scalar keys(%{$curr_dataPkg_grp});
4024 my $size_pkg = scalar keys(%{$curr_data_pkg});
4025  
4026 # ------------------------------------------------------------------------
4027 # Check IF $arg_len == 2 :
4028 # ------------------------------------------------------------------------
4029 if ($arg_len == 2) {
4030  
4031 # Check Group :
4032 if ($size_pkgGrp > 0) {
4033  
4034 # Check list Packages
4035 if ($size_pkg > 0) {
4036 # Form Group Packages :
4037 print "\n";
4038 print "Choose Group Packages.\n";
4039  
4040 my $num = 0;
4041 my %num_grp = ();
4042 while (my ($key, $value) = each %{$curr_dataPkg_grp}) {
4043 my $_num = $num + 1;
4044 $num_grp{$_num} = $key;
4045 print "$_num. $key\n";
4046 $num++;
4047 }
4048 print "Enter Number choice : ";
4049 chomp($num_pkg_group = <STDIN>);
4050 if ($num_pkg_group eq '') {
4051 $input_group = '';
4052 print "\n";
4053 print "Please Number choice for Group Packages...\n";
4054 } else {
4055 if ($num_pkg_group =~ m/^[0-9]+$/) {
4056 $input_group = $num_grp{$num_pkg_group} if exists $num_grp{$num_pkg_group};
4057 $input_group = 'no' unless exists $num_grp{$num_pkg_group};
4058 } else {
4059 print "\n";
4060 print "Choice Group only Numberic...\n\n";
4061 exit 0;
4062 }
4063 }
4064  
4065 # Check Group Packages Input :
4066 if (exists $curr_dataPkg_grp->{$input_group}) {
4067  
4068 # Action Branch :
4069 $self->rebranch_pkg_group($allconfig, $input_group);
4070  
4071 } else {
4072 print "\n";
4073 print "Info : \n";
4074 print "====" x 18 . "\n";
4075 print "Group is not found !!!\n\n";
4076 exit 0;
4077 }
4078 } else {
4079 print "\n";
4080 print "Info : \n";
4081 print "====" x 18 . "\n";
4082 print "No more packages in list. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
4083 exit 0;
4084 }
4085 } else {
4086 print "\n";
4087 print "Info : \n";
4088 print "====" x 18 . "\n";
4089 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
4090 exit 0;
4091 }
4092 }
4093 # ------------------------------------------------------------------------
4094 # Check IF $arg_len == 3 :
4095 # ------------------------------------------------------------------------
4096 elsif ($arg_len == 3) {
4097  
4098 # Define scalar :
4099 my $input_arg = $ARGV[2];
4100 my $confirm_grp;
4101  
4102 # Check Group :
4103 if (exists $pkg_groups->{$input_arg}) {
4104  
4105 # For Confirm :
4106 print "\n";
4107 print "You want to branch based group [y/n] : ";
4108 chomp($confirm_grp = <STDIN>);
4109 if ($confirm_grp eq 'y' or $confirm_grp eq 'Y') {
4110  
4111 # Action Branch :
4112 $self->rebranch_pkg_group($allconfig, $input_arg);
4113 } else {
4114  
4115 print "\n";
4116 print "Program has aborted.\n\n";
4117 }
4118 } else {
4119 # Check Packages :
4120 if (exists $pkg_list->{$input_arg}) {
4121 my $r_pkgGrp = $pkg_list->{$input_arg}->{'group'};
4122  
4123 # For file/dir pkgs :
4124 my $dest_dir = $dir_pkgs.'/'.$r_pkgGrp.'/'.$input_arg;
4125  
4126 # Check packages in Local dir :
4127 if (-d $dest_dir) {
4128  
4129 # Form Confirm :
4130 print "\n";
4131 print "You want to Re-branch [y/n] : ";
4132 chomp($confirm_rebranch = <STDIN>);
4133 if ($confirm_rebranch eq 'y' or $confirm_rebranch eq 'Y') {
4134  
4135 # Msg :
4136 print "\n";
4137 print "Bazaar re-branch for packages : \"$input_arg\"\n";
4138  
4139 # Action Branch :
4140 $self->rebranch_pkg($allconfig, $r_pkgGrp, $input_arg, 'rm');
4141 }
4142 } else {
4143  
4144 # Msg :
4145 print "\n";
4146 print "Bazaar Branch for packages : \"$input_arg\"\n";
4147  
4148 # Action Branch :
4149 $self->branch_pkg($allconfig, $r_pkgGrp, $input_arg, 'new');
4150 }
4151 } else {
4152 print "\n";
4153 print "Info : \n";
4154 print "====" x 18 . "\n";
4155 print "Not found packages. Please try another packages.\n\n";
4156 exit 0;
4157 }
4158 }
4159 }
4160 # ------------------------------------------------------------------------
4161 # Check IF $arg_len == 3 or $arg_len == 2 :
4162 # ------------------------------------------------------------------------
4163 else {
4164 my $i = 0;
4165 my $data_cmd = '';
4166 foreach my $arg (each @ARGV) {
4167 if ($arg_len - 1 == $i) {
4168 $data_cmd .= $arg;
4169 } else {
4170 $data_cmd .= "$arg ";
4171 }
4172 $i++;
4173 }
4174 print "\n";
4175 print "====" x 18 . "\n";
4176 print "your command: boidev $data_cmd\n";
4177 print "----" x 18 . "\n";
4178 print "\n";
4179 print "Warning : \n";
4180 print "====" x 18 . "\n";
4181 print "This command max three arguments\n\n";
4182 exit 0;
4183 }
4184 # ------------------------------------------------------------------------
4185 # End of check IF $arg_len == 3 or $arg_len == 2.
4186 # ========================================================================
4187 }
4188 # Subroutine for handle action "re-gitpush" package :
4189 # ------------------------------------------------------------------------
4190 sub regitpush_pkg {
4191 my ($self, $allconfig, $pkg_name) = @_;
4192  
4193 # For All config :
4194 my $curr_build = $allconfig->{'build'};
4195 my $build_rilis = $curr_build->{'rilis'};
4196 my $curr_pkg = $allconfig->{'pkg'};
4197 my $dir_pkgs = $curr_pkg->{'dirpkg'};
4198 my $pkg_list = $curr_pkg->{'pkgs'};
4199  
4200 # For Check Branch :
4201 my $data_pkg = $pkg_list->{$pkg_name};
4202 my $group_pkg = $data_pkg->{'group'};
4203 my $bzrbranch = $data_pkg->{'brz-branch'};
4204 my $bzrbranch_status = $data_pkg->{'status'}->{'bzr-branch'};
4205 my $bzrCgit_status = $data_pkg->{'status'}->{'bzrConvertGit'};
4206 my $locdir_pkg = $dir_pkgs.'/'.$group_pkg.'/'.$pkg_name;
4207  
4208 # Check Status Branch :
4209 if ($bzrbranch eq 1 or ($bzrbranch eq 0 and $bzrbranch_status eq 1)) {
4210  
4211 # Check File :
4212 if (-d $locdir_pkg) {
4213  
4214 # Check Result convert to github format :
4215 if ($bzrCgit_status eq 1) {
4216  
4217 # Action :
4218 my $action_gitpush = BlankOnDev::Migration::bazaar2GitHub::github->repush_git($allconfig, $pkg_name, $build_rilis);
4219  
4220 # Prepare Config :
4221 my $prepare_config = prepare_config();
4222 my $result_cfg = $prepare_config->{'git-push'}($allconfig, $pkg_name, $action_gitpush);
4223  
4224 # Save Configure :
4225 my $saveConfig = save_newConfig();
4226 $saveConfig->{'git-push'}($result_cfg);
4227  
4228 print "\n";
4229 print "re-push to git for packages \"$pkg_name\" has success. \n";
4230 print "\n";
4231 exit 0;
4232 } else {
4233 print "\n";
4234 print "Info : Not convert to git \n";
4235 print "====" x 18 . "\n";
4236 print "File Packages [$pkg_name] not convert to github format repository. \n";
4237 print "Please run command \"boidev bzr2git bzr-cgit <packages_name>\" for converting format repository to github.\n\n";
4238 exit 0;
4239 }
4240 } else {
4241 print "\n";
4242 print "Info : \n";
4243 print "====" x 18 . "\n";
4244 print "File Packages [$pkg_name] has deleted. \n";
4245 print "Please run command \"boidev bzr2git re-branch <packages_name>\" to download file package [$pkg_name] from bazaar server repository..\n\n";
4246 exit 0;
4247 }
4248 } else {
4249 print "\n";
4250 print "Info : \n";
4251 print "====" x 18 . "\n";
4252 print "File Packages [$pkg_name] is not found. \n";
4253 print "Please run command \"boidev bzr2git branch <packages_name>\" to branch package from bazaar server repository..\n\n";
4254 exit 0;
4255 }
4256 }
4257 # Subroutine for handle action "re-gitpush" packages by group :
4258 # ------------------------------------------------------------------------
4259 sub regitpush_pkg_group {
4260 my ($self, $allconfig, $input_group) = @_;
4261  
4262 # For All config :
4263 my $curr_build = $allconfig->{'build'};
4264 my $build_rilis = $curr_build->{'rilis'};
4265 my $curr_pkg = $allconfig->{'pkg'};
4266 my $dir_pkgs = $curr_pkg->{'dirpkg'};
4267  
4268 # Get list Packages based Group :
4269 my $list_pkg = $self->filter_listpkg_based_group($allconfig, $input_group);
4270 if ($list_pkg->{'result'} == 1) {
4271 my @list_pkgs = @{$list_pkg->{'data'}};
4272  
4273 # While loop to action git push :
4274 my $i = 0;
4275 my $until = scalar @list_pkgs;
4276 my $result_cfg = $allconfig;
4277 while ($i < $until) {
4278 my $pkg_name = $list_pkgs[$i]->{'name'};
4279 my $bzrbranch = $list_pkgs[$i]->{'bzr-branch'};
4280 my $bzrbranch_status = $list_pkgs[$i]->{'status'}->{'bzr-branch'};
4281 my $bzrCgit_status = $list_pkgs[$i]->{'status'}->{'bzrConvertGit'};
4282 my $locdir_pkg = $dir_pkgs.'/'.$input_group.'/'.$pkg_name;
4283  
4284 # Check Status Branch :
4285 if ($bzrbranch eq 1 or ($bzrbranch eq 0 and $bzrbranch_status eq 1)) {
4286  
4287 # Check File ;
4288 if (-d $locdir_pkg) {
4289  
4290 # Check result convert :
4291 if ($bzrCgit_status eq 1) {
4292  
4293 # Action Git Push :
4294 my $action_gitpush = BlankOnDev::Migration::bazaar2GitHub::github->repush_git($allconfig, $pkg_name, $build_rilis);
4295  
4296 # Print Action :
4297 print "Action re-push git for packages $pkg_name : $action_gitpush \n";
4298  
4299 # Prepare Config :
4300 my $prepare_config = prepare_config();
4301 $result_cfg = $prepare_config->{'git-push'}($result_cfg, $pkg_name, $action_gitpush);
4302  
4303 # Save Configure :
4304 my $saveConfig = save_newConfig();
4305 $saveConfig->{'git-push'}($result_cfg);
4306 } else {
4307 print "\n";
4308 print "File Packages [$pkg_name] not convert to github format repository. \n";
4309 print "Please run command \"boidev bzr2git bzr-cgit <packages_name>\" for converting format repository to github.\n\n";
4310 }
4311 } else {
4312 print "\n";
4313 print "File Packages [$pkg_name] has deleted. \n";
4314 print "Please run command \"boidev bzr2git re-branch <packages_name>\" to download file package [$pkg_name] from bazaar server repository..\n\n";
4315 }
4316 } else {
4317  
4318 print "\n";
4319 print "File Packages [$pkg_name] is not found. \n";
4320 print "Please run command \"boidev bzr2git branch <packages_name>\" to branch package [$pkg_name] from bazaar server repository..\n\n";
4321 }
4322 $i++;
4323 }
4324 print "\n";
4325 print "====" x 5 . " Packages in group \"$input_group\" has been finished re-push to git";
4326 print "====" x 5 . "\n\n";
4327 exit 0;
4328 } else {
4329 print "\n";
4330 print "Info : \n";
4331 print "====" x 18 . "\n";
4332 print "Not found packages in list on group $input_group. Please run command \"boidev bzr2git addpkg\" to add new packages in group.\n\n";
4333 exit 0;
4334 }
4335 }
4336 # Subroutine for option "re-gitpush" :
4337 # ------------------------------------------------------------------------
4338 sub _re_gitpush {
4339 my ($self, $allconfig) = @_;
4340  
4341 # Define scalar :
4342 my $arg_len = scalar @ARGV;
4343 my $num_pkg_group;
4344 my $input_group;
4345  
4346 # For All config :
4347 my $curr_pkg = $allconfig->{'pkg'};
4348 my $pkg_groups = $curr_pkg->{'group'};
4349 my $pkg_list = $curr_pkg->{'pkgs'};
4350  
4351 # Data current config :
4352 my $curr_dataPkg_grp = $allconfig->{'pkg'}->{'group'};
4353 my $curr_data_pkg = $allconfig->{'pkg'}->{'pkgs'};
4354 my $size_pkgGrp = scalar keys(%{$curr_dataPkg_grp});
4355 my $size_pkg = scalar keys(%{$curr_data_pkg});
4356  
4357 # ------------------------------------------------------------------------
4358 # Check IF $arg_len == 2 :
4359 # ------------------------------------------------------------------------
4360 if ($arg_len == 2) {
4361  
4362 # Check Group :
4363 if ($size_pkgGrp > 0) {
4364  
4365 # Check list Packages
4366 if ($size_pkg > 0) {
4367  
4368 # Form Group Packages :
4369 print "\n";
4370 print "Choose Group Packages.\n";
4371  
4372 my $num = 0;
4373 my %num_grp = ();
4374 while (my ($key, $value) = each %{$curr_dataPkg_grp}) {
4375 my $_num = $num + 1;
4376 $num_grp{$_num} = $key;
4377 print "$_num. $key\n";
4378 $num++;
4379 }
4380 print "Enter Number choice : ";
4381 chomp($num_pkg_group = <STDIN>);
4382 if ($num_pkg_group eq '') {
4383 $input_group = '';
4384 print "\n";
4385 print "Please Number choice for Group Packages...\n";
4386 } else {
4387 if ($num_pkg_group =~ m/^[0-9]+$/) {
4388 $input_group = $num_grp{$num_pkg_group} if exists $num_grp{$num_pkg_group};
4389 $input_group = 'no' unless exists $num_grp{$num_pkg_group};
4390 } else {
4391 print "\n";
4392 print "Choice Group only Numberic...\n\n";
4393 exit 0;
4394 }
4395 }
4396  
4397 print "\n";
4398 print "Re-push to GitHub .... \n";
4399 print "----" x 10 . "\n";
4400 print "\n";
4401  
4402 # Action git push by group :
4403 $self->regitpush_pkg_group($allconfig, $input_group);
4404  
4405 } else {
4406 print "\n";
4407 print "Info : \n";
4408 print "====" x 18 . "\n";
4409 print "No more packages in list. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
4410 exit 0;
4411 }
4412 } else {
4413 print "\n";
4414 print "Info : \n";
4415 print "====" x 18 . "\n";
4416 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
4417 exit 0;
4418 }
4419 }
4420 # ------------------------------------------------------------------------
4421 # Check IF $arg_len == 3 :
4422 # ------------------------------------------------------------------------
4423 elsif ($arg_len == 3) {
4424  
4425 # Define scalar :
4426 my $input_arg = $ARGV[2];
4427  
4428 # Check Group :
4429 if ($size_pkgGrp > 0) {
4430  
4431 # Check list Packages
4432 if ($size_pkg > 0) {
4433  
4434 print "\n";
4435 print "Re-push to GitHub .... \n";
4436 print "----" x 10 . "\n";
4437 print "\n";
4438  
4439 # Check Group input :
4440 if (exists $pkg_groups->{$input_arg}) {
4441  
4442 # Action git push by group :
4443 $self->regitpush_pkg_group($allconfig, $input_arg);
4444 } else {
4445  
4446 # Check Packages Input :
4447 if (exists $pkg_list->{$input_arg}) {
4448  
4449 # Action git push for one packages :
4450 $self->regitpush_pkg($allconfig, $input_arg);
4451 } else {
4452 print "\n";
4453 print "Info : \n";
4454 print "====" x 18 . "\n";
4455 print "Packages is not found. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
4456 }
4457 }
4458 } else {
4459 print "\n";
4460 print "Info : \n";
4461 print "====" x 18 . "\n";
4462 print "No more packages in list. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
4463 exit 0;
4464 }
4465 } else {
4466 print "\n";
4467 print "Info : \n";
4468 print "====" x 18 . "\n";
4469 print "Not found packages groups. Please run command \"boidev bzr2git addpkg-group\" to add new group packages.\n\n";
4470 exit 0;
4471 }
4472 }
4473 # ------------------------------------------------------------------------
4474 # Check IF $arg_len == 3 or $arg_len == 2 :
4475 # -----------------------------------------------------------------b-------
4476 else {
4477 my $i = 0;
4478 my $data_cmd = '';
4479 foreach my $arg (each @ARGV) {
4480 if ($arg_len - 1 == $i) {
4481 $data_cmd .= $arg;
4482 } else {
4483 $data_cmd .= "$arg ";
4484 }
4485 $i++;
4486 }
4487 print "\n";
4488 print "====" x 18 . "\n";
4489 print "your command: boidev $data_cmd\n";
4490 print "----" x 18 . "\n";
4491 print "\n";
4492 print "Warning : \n";
4493 print "====" x 18 . "\n";
4494 print "This command max three arguments\n\n";
4495 exit 0;
4496 }
4497 # ------------------------------------------------------------------------
4498 # End of check IF $arg_len == 3 or $arg_len == 2.
4499 # ========================================================================
4500 }
4501 # Subroutine for check all packages on github :
4502 # ------------------------------------------------------------------------
4503 sub git_check_allpkg {
4504 my ($self, $allconfig) = @_;
4505  
4506 # For All config :
4507 my $curr_pkg = $allconfig->{'pkg'};
4508 my $dir_pkgs = $curr_pkg->{'dirpkg'};
4509  
4510 # Get list packages group :
4511 my $get_list_grp = $self->list_all_pkg_group($allconfig);
4512  
4513 my @list_group = %{$get_list_grp->{'data'}};
4514  
4515 # While loop for group packages :
4516 my $i = 0;
4517 my $until = scalar @list_group;
4518 my $prepare_config;
4519 my $result_cfg;
4520 while ($i < $until) {
4521 my $pkg_group = $list_group[$i];
4522  
4523 # Print Header :
4524 print "\n";
4525 print "Check repo on github for packages in group $pkg_group : \n";
4526  
4527 # Get list packages by group :
4528 my $list_pkg = $self->filter_listpkg_based_group($allconfig, $pkg_group);
4529 if ($list_pkg->{'result'} eq 1) {
4530 my @list_pkg = @{$list_pkg->{'data'}};
4531  
4532 # While loop for check packages :
4533 my $i_p = 0;
4534 my $until_p = scalar @list_pkg;
4535 while ($i_p < $until_p) {
4536 my $data_package = $list_pkg[$i_p];
4537 my $data_pkg_name = $data_package->{'name'};
4538 my $data_pkg_group = $data_package->{'group'};
4539 my $locdir_pkg = $dir_pkgs.'/'.$data_pkg_group.'/'.$data_pkg_name;
4540  
4541 # Check dir packages :
4542 if (-d $locdir_pkg) {
4543  
4544 # Action Command :
4545 my $action_check = BlankOnDev::Migration::bazaar2GitHub::github->git_check($allconfig, $data_pkg_name);
4546  
4547 print "Group packages $pkg_group = No List Packages\n";
4548  
4549 # prepare Config :
4550 $prepare_config = prepare_config();
4551 $result_cfg = $prepare_config->{'git-check'}($allconfig, $data_pkg_name, $action_check);
4552  
4553 # Save Configure :
4554 my $saveConfig = save_newConfig();
4555 $saveConfig->{'git-check'}($result_cfg);
4556 } else {
4557  
4558 print "\n";
4559 print "File Packages [$data_pkg_name] is not found. \n";
4560 print "Please run command \"boidev bzr2git branch <packages_name>\" to download file package [$data_pkg_name] from bazaar server repository..\n\n";
4561 }
4562  
4563 $i_p++;
4564 }
4565 print "\n";
4566 print "====" x 5 . " Git Check All Packages has finished";
4567 print "====" x 5 . "\n\n";
4568 exit 0;
4569 } else {
4570 print "Group packages $pkg_group = No List Packages\n";
4571 }
4572 $i++;
4573 }
4574 }
4575 # Subroutine for check all packages by group :
4576 # ------------------------------------------------------------------------
4577 sub git_check_allpkg_grp {
4578 my ($self, $allconfig, $input_group) = @_;
4579  
4580 # Define scalar :
4581 my $act_gitcheck;
4582  
4583 # For All config :
4584 my $curr_build = $allconfig->{'build'};
4585 my $build_rilis = $curr_build->{'rilis'};
4586 my $curr_pkg = $allconfig->{'pkg'};
4587 my $dir_pkgs = $curr_pkg->{'dirpkg'};
4588 my $locdir_group = $dir_pkgs.'/'.$input_group;
4589  
4590 my $get_list_pkg = $self->filter_listpkg_based_group($allconfig, $input_group);
4591 if ($get_list_pkg->{'result'} eq 1) {
4592 my @list_pkgs = @{$get_list_pkg->{'data'}};
4593  
4594 # Print Header :
4595 print "\n";
4596 print "Check repo on github for all packages : \n";
4597  
4598 # While loop to action git push :
4599 my $i = 0;
4600 my $until = scalar @list_pkgs;
4601 my $saveConfig;
4602 my $result_cfg = $allconfig;
4603 while ($i < $until) {
4604 my $data_package = $list_pkgs[$i];
4605 my $data_pkg_name = $data_package->{'name'};
4606 my $data_pkg_group = $data_package->{'group'};
4607 my $locdir_pkg = $dir_pkgs.'/'.$input_group.'/'.$data_pkg_name;
4608  
4609 # Check dir packages :
4610 if (-d $locdir_pkg) {
4611  
4612 # Action Command :
4613 $act_gitcheck = BlankOnDev::Migration::bazaar2GitHub::github->git_check($allconfig, $data_pkg_name);
4614  
4615 # Print "Header"
4616 print "Check Repo [$data_pkg_name] on github : $act_gitcheck \n";
4617  
4618 # prepare Config :
4619 my $prepare_config = prepare_config();
4620 $result_cfg = $prepare_config->{'git-check'}($result_cfg, $data_pkg_name, $act_gitcheck);
4621  
4622 # Save Configure :
4623 $saveConfig = save_newConfig();
4624 $saveConfig->{'git-check'}($result_cfg);
4625 } else {
4626  
4627 print "\n";
4628 print "File Packages [$data_pkg_name] is not found. \n";
4629 print "Please run command \"boidev bzr2git branch <packages_name>\" to download file package [$data_pkg_name] from bazaar server repository..\n\n";
4630 }
4631 $i++;
4632 }
4633 print "\n";
4634 print "====" x 5 . " Git Check All Packages on Group [$input_group] has finished";
4635 print "====" x 5 . "\n\n";
4636 exit 0;
4637 } else {
4638 print "\n";
4639 print "Info : \n";
4640 print "====" x 18 . "\n";
4641 print "Not found packages in list on group $input_group. Please run command \"boidev bzr2git addpkg\" to add new packages in group.\n\n";
4642 exit 0;
4643 }
4644 }
4645 # Subroutine for option "git-check" :
4646 # ------------------------------------------------------------------------
4647 sub _git_check {
4648 my ($self, $allconfig) = @_;
4649  
4650 # Define scalar :
4651 my $arg_len = scalar @ARGV;
4652 my $form_group;
4653  
4654 # For All config :
4655 my $curr_pkg = $allconfig->{'pkg'};
4656 my $curr_dirpkg = $curr_pkg->{'dirpkg'};
4657 my $pkg_groups = $curr_pkg->{'group'};
4658 my $pkg_list = $curr_pkg->{'pkgs'};
4659 my $data_list_grp = $self->bzr2git_get_list_group_amount_pkg($allconfig);
4660 my $choice_grp = $data_list_grp->{'data'};
4661  
4662 # ------------------------------------------------------------------------
4663 # Check IF $arg_len == 2 :
4664 # ------------------------------------------------------------------------
4665 if ($arg_len == 2) {
4666  
4667 # Form :
4668 print "\n";
4669 print "Choose packages group : \n";
4670 print "---" x 18 . "\n";
4671 print $data_list_grp->{'choice'};
4672 print "---" x 18 . "\n";
4673 print "Enter number of group name : ";
4674 chomp($form_group = <STDIN>);
4675 if (exists $choice_grp->{$form_group}) {
4676 my $input_group = $choice_grp->{$form_group};
4677  
4678 # Action Check :
4679 $self->git_check_allpkg_grp($allconfig, $input_group);
4680 } else {
4681 print "\n";
4682 print "Info : Enter number choice\n";
4683 print "====" x 18 . "\n";
4684 print "Please enter number choice. \n\n";
4685 exit 0;
4686 }
4687 }
4688 # ------------------------------------------------------------------------
4689 # Check IF $arg_len == 3 :
4690 # ------------------------------------------------------------------------
4691 elsif ($arg_len == 3) {
4692 # Get data argument ;
4693 my $input_arg = $ARGV[2];
4694  
4695 # Check if $input_arg == 'all' :
4696 if ($input_arg eq 'all') {
4697  
4698 # Check All group :
4699 $self->git_check_allpkg($allconfig);
4700  
4701 } else {
4702  
4703 # Check Input in Group :
4704 if (exists $pkg_groups->{$input_arg}) {
4705  
4706 # Action Check :
4707 $self->git_check_allpkg_grp($allconfig, $input_arg);
4708 } else {
4709  
4710 # Check Input in packages :
4711 if (exists $pkg_list->{$input_arg}) {
4712 my $data_package = $pkg_list->{$input_arg};
4713 my $data_pkg_name = $data_package->{'name'};
4714 my $data_pkg_group = $data_package->{'group'};
4715 my $loc_of_pkg = $curr_dirpkg.'/'.$data_pkg_group.'/'.$data_pkg_name;
4716  
4717 # Check if exists dir packages :
4718 if (-d $loc_of_pkg) {
4719  
4720 # Action Command :
4721 my $action_check = BlankOnDev::Migration::bazaar2GitHub::github->git_check($allconfig, $data_pkg_name);
4722  
4723 # Print "Header"
4724 print "Check Repo [$data_pkg_name] on github : $action_check \n";
4725  
4726 # prepare Config :
4727 my $prepare_config = prepare_config();
4728 my $result_cfg = $prepare_config->{'git-check'}($allconfig, $data_pkg_name, $action_check);
4729  
4730 # Save Configure :
4731 my $saveConfig = save_newConfig();
4732 $saveConfig->{'git-check'}($result_cfg);
4733  
4734 print "\n";
4735 print "git check repository for packages \"$data_pkg_name\" | $action_check. \n";
4736 print "\n";
4737 } else {
4738 print "\n";
4739 print "Info : \n";
4740 print "====" x 18 . "\n";
4741 print "File Packages [$data_pkg_name] has deleted. \n";
4742 print "Please run command \"boidev bzr2git re-branch <packages_name>\" to download file package [$data_pkg_name] from bazaar server repository..\n\n";
4743 exit 0;
4744 }
4745  
4746 } else {
4747 print "\n";
4748 print "Info : \n";
4749 print "====" x 18 . "\n";
4750 print "Packages is not found. Please run command \"boidev bzr2git addpkg\" or \"boidev bzr2git addpkg-file\" to add new packages in list.\n\n";
4751 exit 0;
4752 }
4753 }
4754 }
4755 }
4756 # ------------------------------------------------------------------------
4757 # Check IF $arg_len == 3 or $arg_len == 2 :
4758 # ------------------------------------------------------------------------
4759 else {
4760 my $i = 0;
4761 my $data_cmd = '';
4762 foreach my $arg (each @ARGV) {
4763 if ($arg_len - 1 == $i) {
4764 $data_cmd .= $arg;
4765 } else {
4766 $data_cmd .= "$arg ";
4767 }
4768 $i++;
4769 }
4770 print "\n";
4771 print "====" x 18 . "\n";
4772 print "your command: boidev $data_cmd\n";
4773 print "----" x 18 . "\n";
4774 print "\n";
4775 print "Warning : \n";
4776 print "====" x 18 . "\n";
4777 print "This command max three arguments\n\n";
4778 exit 0;
4779 }
4780 # ------------------------------------------------------------------------
4781 # End of check IF $arg_len == 3 or $arg_len == 2.
4782 # ========================================================================
4783 }
4784 # Subroutine for option "help" :
4785 # ------------------------------------------------------------------------
4786 sub usage {
4787 print "\n";
4788 print "-----" x 15 . "\n";
4789 print " For Help Command : \n";
4790 print "-----" x 15 . "\n";
4791 print "\n";
4792  
4793 print "USAGE : boidev bzr2git <OPTIONS2>\n";
4794 BlankOnDev::usage_bzr2git;
4795 print "\n";
4796 exit 0;
4797 }
4798 # Subroutine for option help command "boidev bzr2git <OPTIONS2> <OPTIONS3> :
4799 # ------------------------------------------------------------------------
4800 sub usage_arg_3 {
4801 my $options3 = {
4802 'addpkg-group' => sub {
4803 print "\n";
4804 print "-----" x 15 . "\n";
4805 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4806 print "-----" x 15 . "\n";
4807 print "\n";
4808  
4809 print "USAGE : boidev bzr2git addpkg-group <OPTIONS3>\n\n";
4810 BlankOnDev::usage_bzr2git_addpkg_group();
4811 print "\n";
4812 exit 0;
4813 },
4814 'addpkg' => sub {
4815 print "\n";
4816 print "-----" x 15 . "\n";
4817 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4818 print "-----" x 15 . "\n";
4819 print "\n";
4820  
4821 print "USAGE : boidev bzr2git addpkg <OPTIONS3>\n\n";
4822 BlankOnDev::usage_bzr2git_addpkg();
4823 print "\n";
4824 exit 0;
4825 },
4826 'addpkg-file' => sub {
4827 print "\n";
4828 print "-----" x 15 . "\n";
4829 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4830 print "-----" x 15 . "\n";
4831 print "\n";
4832  
4833 print "USAGE : boidev bzr2git addpkg-file <OPTIONS3>\n\n";
4834 BlankOnDev::usage_bzr2git_addpkgfile();
4835 print "\n";
4836 exit 0;
4837 },
4838 'list-pkg' => sub {
4839 print "\n";
4840 print "-----" x 15 . "\n";
4841 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4842 print "-----" x 15 . "\n";
4843 print "\n";
4844  
4845 print "USAGE : boidev bzr2git list-pkg <OPTIONS3>\n\n";
4846 BlankOnDev::usage_bzr2git_listpkg();
4847 print "\n";
4848 exit 0;
4849 },
4850 'rename-pkg-group' => sub {
4851 print "\n";
4852 print "-----" x 15 . "\n";
4853 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4854 print "-----" x 15 . "\n";
4855 print "\n";
4856  
4857 print "USAGE : boidev bzr2git rename-pkg-group <OPTIONS3>\n\n";
4858 BlankOnDev::usage_bzr2git_renamepkg_group();
4859 print "\n";
4860 exit 0;
4861 },
4862 'remove-pkg-group' => sub {
4863 print "\n";
4864 print "-----" x 15 . "\n";
4865 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4866 print "-----" x 15 . "\n";
4867 print "\n";
4868  
4869 print "USAGE : boidev bzr2git remove-pkg-group <OPTIONS3>\n\n";
4870 BlankOnDev::usage_bzr2git_removepkg_group();
4871 print "\n";
4872 exit 0;
4873 },
4874 'remove-pkg' => sub {
4875 print "\n";
4876 print "-----" x 15 . "\n";
4877 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4878 print "-----" x 15 . "\n";
4879 print "\n";
4880  
4881 print "USAGE : boidev bzr2git removepkg <OPTIONS3>\n\n";
4882 BlankOnDev::usage_bzr2git_removepkg();
4883 print "\n";
4884 exit 0;
4885 },
4886 'search-pkg' => sub {
4887 print "\n";
4888 print "-----" x 15 . "\n";
4889 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4890 print "-----" x 15 . "\n";
4891 print "\n";
4892  
4893 print "USAGE : boidev bzr2git search-pkg <OPTIONS3>\n";
4894 print "-- or --\n";
4895 print "USAGE : boidev bzr2git search-pkg <INPUT>\n\n";
4896 BlankOnDev::usage_bzr2git_searchpkg();
4897 print "\n";
4898 exit 0;
4899 },
4900 'branch' => sub {
4901 print "\n";
4902 print "-----" x 15 . "\n";
4903 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4904 print "-----" x 15 . "\n";
4905 print "\n";
4906  
4907 print "USAGE : boidev bzr2git branch <OPTIONS3>\n";
4908 print "-- or --\n";
4909 print "USAGE : boidev bzr2git branch <INPUT>\n\n";
4910 BlankOnDev::usage_bzr2git_branch();
4911 print "\n";
4912 exit 0;
4913 },
4914 'bzr-cgit' => sub {
4915 print "\n";
4916 print "-----" x 15 . "\n";
4917 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4918 print "-----" x 15 . "\n";
4919 print "\n";
4920  
4921 print "USAGE : boidev bzr2git bzr-cgit <OPTIONS3>\n";
4922 print "-- or --\n";
4923 print "USAGE : boidev bzr2git bzr-cgit <INPUT>\n\n";
4924 BlankOnDev::usage_bzr2git_bzr_cgit();
4925 print "\n";
4926 exit 0;
4927 },
4928 'git-push' => sub {
4929 print "\n";
4930 print "-----" x 15 . "\n";
4931 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4932 print "-----" x 15 . "\n";
4933 print "\n";
4934  
4935 print "USAGE : boidev bzr2git git-push <OPTIONS3>\n";
4936 print "-- or --\n";
4937 print "USAGE : boidev bzr2git git-push <INPUT>\n\n";
4938 BlankOnDev::usage_bzr2git_gitpush();
4939 print "\n";
4940 exit 0;
4941 },
4942 'git-push-new' => sub {
4943 print "\n";
4944 print "-----" x 15 . "\n";
4945 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4946 print "-----" x 15 . "\n";
4947 print "\n";
4948  
4949 print "USAGE : boidev bzr2git git-push-new <OPTIONS3>\n";
4950 print "-- or --\n";
4951 print "USAGE : boidev bzr2git git-push-new <INPUT>\n\n";
4952 BlankOnDev::usage_bzr2git_gitpush_new();
4953 print "\n";
4954 exit 0;
4955 },
4956 'git-check' => sub {
4957 print "\n";
4958 print "-----" x 15 . "\n";
4959 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4960 print "-----" x 15 . "\n";
4961 print "\n";
4962  
4963 print "USAGE : boidev bzr2git git-check <OPTIONS3>\n";
4964 print "-- or --\n";
4965 print "USAGE : boidev bzr2git git-check <INPUT>\n\n";
4966 BlankOnDev::usage_bzr2git_git_check();
4967 print "\n";
4968 exit 0;
4969 },
4970 're-branch' => sub {
4971 print "\n";
4972 print "-----" x 15 . "\n";
4973 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4974 print "-----" x 15 . "\n";
4975 print "\n";
4976  
4977 print "USAGE : boidev bzr2git re-branch <OPTIONS3>\n";
4978 print "-- or --\n";
4979 print "USAGE : boidev bzr2git re-branch <INPUT>\n\n";
4980 BlankOnDev::usage_bzr2git_reBranch();
4981 print "\n";
4982 exit 0;
4983 },
4984 're-gitpush' => sub {
4985 print "\n";
4986 print "-----" x 15 . "\n";
4987 print " For Help Command : boidev $ARGV[0] $ARGV[1] \n";
4988 print "-----" x 15 . "\n";
4989 print "\n";
4990  
4991 print "USAGE : boidev bzr2git re-branch <OPTIONS3>\n";
4992 print "-- or --\n";
4993 print "USAGE : boidev bzr2git re-branch <INPUT>\n\n";
4994 BlankOnDev::usage_bzr2git_reGitpush();
4995 print "\n";
4996 exit 0;
4997 }
4998 };
4999 if (exists $options3->{$ARGV[1]}) {
5000 $options3->{$ARGV[1]}();
5001 } else {
5002 usage();
5003 }
5004 }
5005 # Subroutine for cmd :
5006 # ------------------------------------------------------------------------
5007 sub list_cmd {
5008 my %data = ();
5009 $data{'bzr'} = {
5010 'branch' => 'bzr branch',
5011 'bzr' => {
5012 'bzr-export' => 'bzr fast-export',
5013 'bzr-fast-import' => 'git fast-import'
5014 },
5015 'git' => {
5016 'init' => 'git init',
5017 'reset-head' => 'git reset HEAD',
5018 'remote' => 'git remote add origin',
5019 'push' => 'git push -u origin master',
5020 }
5021 };
5022 return \%data;
5023 }
5024 # Subroutine for save new configure :
5025 # ------------------------------------------------------------------------
5026 sub save_newConfig {
5027 my $data_rilis = $BlankOnDev::config::rilisCfg;
5028  
5029 # For Data Developer :
5030 my $data_dev = BlankOnDev::DataDev::data_dev();
5031 my $dir_dev = $data_dev->{'dir_dev'};
5032 my $prefix_flcfg = $data_dev->{'prefix_flcfg'};
5033 my $file_cfg_ext = $data_dev->{'fileCfg_ext'};
5034 my $file_name = $prefix_flcfg.$data_rilis.$file_cfg_ext;
5035  
5036 # Define hashref for switch :
5037 my $switch = {
5038 'addpkg' => sub {
5039 my ($new_config) = @_;
5040  
5041 # Create File :
5042 my $newData_cfg = encode_json($new_config);
5043 BlankOnDev::Utils::file->create($file_name, $dir_dev, $newData_cfg);
5044 },
5045 'addgroup' => sub {
5046 my ($new_config) = @_;
5047  
5048 # Create File :
5049 my $newData_cfg = encode_json($new_config);
5050 BlankOnDev::Utils::file->create($file_name, $dir_dev, $newData_cfg);
5051 },
5052 'removePkg' => sub {
5053 my ($new_config) = @_;
5054  
5055 # Create File :
5056 my $newData_cfg = encode_json($new_config);
5057 BlankOnDev::Utils::file->create($file_name, $dir_dev, $newData_cfg);
5058 },
5059 'rename-pkg-group' => sub {
5060 my ($new_config) = @_;
5061  
5062 # Create File :
5063 my $newData_cfg = encode_json($new_config);
5064 BlankOnDev::Utils::file->create($file_name, $dir_dev, $newData_cfg);
5065 },
5066 'remove-group' => sub {
5067 my ($new_config) = @_;
5068  
5069 # Create File :
5070 my $newData_cfg = encode_json($new_config);
5071 BlankOnDev::Utils::file->create($file_name, $dir_dev, $newData_cfg);
5072 },
5073 'bzr-branch' => sub {
5074 my ($new_config) = @_;
5075  
5076 # Create File :
5077 my $newData_cfg = encode_json($new_config);
5078 BlankOnDev::Utils::file->create($file_name, $dir_dev, $newData_cfg);
5079 },
5080 'bzr-convert' => sub {
5081 my ($new_config) = @_;
5082  
5083 # Create File :
5084 my $newData_cfg = encode_json($new_config);
5085 BlankOnDev::Utils::file->create($file_name, $dir_dev, $newData_cfg);
5086 },
5087 'git-push' => sub {
5088 my ($new_config) = @_;
5089  
5090 # Create File :
5091 my $newData_cfg = encode_json($new_config);
5092 BlankOnDev::Utils::file->create($file_name, $dir_dev, $newData_cfg);
5093 },
5094 'git-check' => sub {
5095 my ($new_config) = @_;
5096  
5097 # Create File :
5098 my $newData_cfg = encode_json($new_config);
5099 BlankOnDev::Utils::file->create($file_name, $dir_dev, $newData_cfg);
5100 },
5101 'bzr2git' => sub {
5102 my ($new_config) = @_;
5103  
5104 # Create File :
5105 my $newData_cfg = encode_json($new_config);
5106 BlankOnDev::Utils::file->create($file_name, $dir_dev, $newData_cfg);
5107 }
5108 };
5109  
5110 return $switch;
5111 }
5112 # Subroutine for prepare new configure :
5113 # ------------------------------------------------------------------------
5114 sub prepare_config {
5115  
5116 # Define hashref for switch :
5117 my $switch = {
5118 'newpkg' => sub {
5119 my ($curr_cfg, $data_newpkg) = @_;
5120  
5121 # Define hash of scalar :
5122 my %data = ();
5123 my $newData_pkg;
5124  
5125 # Define scalar for new pkg :
5126 my $new_group = $data_newpkg->{'group'};
5127 my $new_pkg = $data_newpkg->{'pkg'};
5128  
5129 # get data current pkg :
5130 my $curr_timezone = $curr_cfg->{'timezone'};
5131 my $curr_prepare = $curr_cfg->{'prepare'};
5132 my $curr_build = $curr_cfg->{'build'};
5133 my $curr_bzr = $curr_cfg->{'bzr'};
5134 my $curr_git = $curr_cfg->{'git'};
5135 my $curr_pkg = $curr_cfg->{'pkg'};
5136  
5137 # Get DateTime :
5138 my $timestamp = time();
5139 my $get_dataTime = BlankOnDev::DateTime->get($curr_timezone, $timestamp, {
5140 'date' => '-',
5141 'time' => ':',
5142 'datetime' => ' ',
5143 'format' => 'DD-MM-YYYY hms'
5144 });
5145 my $time_add = $get_dataTime->{'custom'};
5146  
5147 # Check data group pkg :
5148 if (exists $curr_pkg->{'group'}) {
5149 # Add Group Packages :
5150 my $add_group = Hash::MultiValue->new(%{$curr_pkg->{'group'}});
5151 $add_group->add($new_group => 0);
5152 my $r_addGroup = $add_group->as_hashref;
5153  
5154 # Add Packages :
5155 my $add_pkg = Hash::MultiValue->new(%{$curr_pkg->{'pkgs'}});
5156 $add_pkg->add($new_pkg => {
5157 'name' => $new_pkg,
5158 'group' => $new_group,
5159 'brz-branch' => 0,
5160 'git-push' => 0,
5161 'status' => {
5162 'bzr-branch' => 0,
5163 'git-push' => 0,
5164 'bzrConvertGit' => 0,
5165 },
5166 'date-add' => $time_add,
5167 'date-branch' => '',
5168 'date-gitpush' => '',
5169 });
5170 my $r_addPkg = $add_pkg->as_hashref;
5171  
5172 # Merge :
5173 my $mergePkg = Hash::MultiValue->new(%{$curr_pkg});
5174 $mergePkg->set('group' => $r_addGroup);
5175 $mergePkg->set('pkgs' => $r_addPkg);
5176 $newData_pkg = $mergePkg->as_hashref;
5177 } else {
5178 # Add Group Packages :
5179 my $add_group = Hash::MultiValue->new(%{$curr_cfg->{'pkg'}});
5180 $add_group->add('group' => {
5181 $new_group => 1
5182 });
5183 my $r_addGroup = $add_group->as_hashref;
5184  
5185 # Add Packages :
5186 my $add_pkg = Hash::MultiValue->new(%{$r_addGroup});
5187 $add_pkg->add('pkgs' => {
5188 $new_pkg => {
5189 'group' => $new_group,
5190 'brz-branch' => 0,
5191 'git-push' => 0,
5192 }
5193 });
5194 my $r_addPkg = $add_pkg->as_hashref;
5195  
5196 # Merge :
5197 $newData_pkg = $r_addPkg;
5198 }
5199  
5200 # Create New Data :
5201 $data{'timezone'} = $curr_timezone;
5202 $data{'prepare'} = $curr_prepare;
5203 $data{'build'} = $curr_build;
5204 $data{'bzr'} = $curr_bzr;
5205 $data{'git'} = $curr_git;
5206 $data{'pkg'} = $newData_pkg;
5207  
5208 return \%data;
5209 },
5210 'newpkg-grp-exists' => sub {
5211 my ($curr_cfg, $data_newpkg) = @_;
5212  
5213 # Define hash of scalar :
5214 my %data = ();
5215 my $newData_pkg;
5216 my $mergePkgs;
5217  
5218 # Define scalar for new pkg :
5219 my $new_group = $data_newpkg->{'group'};
5220 my $new_pkg = $data_newpkg->{'pkg'};
5221  
5222 # get data current pkg :
5223 my $curr_timezone = $curr_cfg->{'timezone'};
5224 my $curr_prepare = $curr_cfg->{'prepare'};
5225 my $curr_build = $curr_cfg->{'build'};
5226 my $curr_bzr = $curr_cfg->{'bzr'};
5227 my $curr_git = $curr_cfg->{'git'};
5228 my $curr_pkg = $curr_cfg->{'pkg'};
5229  
5230 # Get DateTime :
5231 my $timestamp = time();
5232 my $get_dataTime = BlankOnDev::DateTime->get($curr_timezone, $timestamp, {
5233 'date' => '-',
5234 'time' => ':',
5235 'datetime' => ' ',
5236 'format' => 'DD-MM-YYYY hms'
5237 });
5238 my $time_add = $get_dataTime->{'custom'};
5239  
5240 # Add Packages :
5241 my $add_pkg = Hash::MultiValue->new(%{$curr_pkg->{'pkgs'}});
5242 $add_pkg->add($new_pkg => {
5243 'name' => $new_pkg,
5244 'group' => $new_group,
5245 'brz-branch' => 0,
5246 'git-push' => 0,
5247 'status' => {
5248 'bzr-branch' => 0,
5249 'git-push' => 0,
5250 'bzrConvertGit' => 0,
5251 },
5252 'date-add' => $time_add,
5253 'date-branch' => '',
5254 'date-gitpush' => '',
5255 });
5256 my $r_addPkg = $add_pkg->as_hashref;
5257  
5258 # Merge :
5259 $mergePkgs = Hash::MultiValue->new(%{$curr_pkg});
5260 $mergePkgs->set('pkgs' => $r_addPkg);
5261 $newData_pkg = $mergePkgs->as_hashref;
5262  
5263 # Create New Data :
5264 $data{'timezone'} = $curr_timezone;
5265 $data{'prepare'} = $curr_prepare;
5266 $data{'build'} = $curr_build;
5267 $data{'bzr'} = $curr_bzr;
5268 $data{'git'} = $curr_git;
5269 $data{'pkg'} = $newData_pkg;
5270  
5271 return \%data;
5272 },
5273 'add-group' => sub {
5274 my ($curr_cfg, $data_newgrp) = @_;
5275  
5276 # Define hash of scalar :
5277 my %data = ();
5278 my $newData_group;
5279 my $result_merge;
5280  
5281 # get data current pkg :
5282 my $curr_timezone = $curr_cfg->{'timezone'};
5283 my $curr_prepare = $curr_cfg->{'prepare'};
5284 my $curr_build = $curr_cfg->{'build'};
5285 my $curr_bzr = $curr_cfg->{'bzr'};
5286 my $curr_git = $curr_cfg->{'git'};
5287 my $curr_pkg = $curr_cfg->{'pkg'};
5288 my $pkg_group = $curr_pkg->{'group'};
5289 my $size_group = scalar keys(%{$pkg_group});
5290  
5291 if ($size_group > 0) {
5292 my $add_group = Hash::MultiValue->new(%{$pkg_group});
5293 $add_group->add($data_newgrp => 0);
5294 $newData_group = $add_group->as_hashref;
5295 } else {
5296 my $add_group = Hash::MultiValue->new(%{$pkg_group});
5297 $add_group->add($data_newgrp => 0);
5298 $newData_group = $add_group->as_hashref;
5299 }
5300  
5301 # Merge :
5302 my $forMerger = Hash::MultiValue->new(%{$curr_pkg});
5303 $forMerger->set('group' => $newData_group);
5304 $result_merge = $forMerger->as_hashref;
5305  
5306 # Place new data :
5307 $data{'timezone'} = $curr_timezone;
5308 $data{'prepare'} = $curr_prepare;
5309 $data{'build'} = $curr_build;
5310 $data{'bzr'} = $curr_bzr;
5311 $data{'git'} = $curr_git;
5312 $data{'pkg'} = $result_merge;
5313  
5314 return \%data;
5315 },
5316 'rename-group-pkg' => sub {
5317 my ($curr_cfg, $old_pkg_group, $new_pkg_group) = @_;
5318  
5319 # Define hash of scalar :
5320 my %data = ();
5321 my $newData_group;
5322  
5323 # get data current pkg :
5324 my $curr_timezone = $curr_cfg->{'timezone'};
5325 my $curr_prepare = $curr_cfg->{'prepare'};
5326 my $curr_build = $curr_cfg->{'build'};
5327 my $build_rilis = $curr_build->{'rilis'};
5328 my $curr_bzr = $curr_cfg->{'bzr'};
5329 my $curr_git = $curr_cfg->{'git'};
5330 my $curr_pkg = $curr_cfg->{'pkg'};
5331 my $curr_dirpkgs = $curr_pkg->{'dirpkg'};
5332 my $curr_pkgGrp = $curr_pkg->{'group'};
5333 my $curr_pkgs = $curr_pkg->{'pkgs'};
5334  
5335 # For Data Developer :
5336 my $data_dev = BlankOnDev::DataDev::data_dev();
5337  
5338 # For Data Packages :
5339 my $dir_pkgs = $data_dev->{'dir_pkg'};
5340 my $locdir_pkgs = $dir_pkgs.'/'.$build_rilis.'/'.$old_pkg_group.'/';
5341 my $new_locdir_pkgs = $dir_pkgs.'/'.$build_rilis.'/'.$new_pkg_group.'/';
5342  
5343 # Check Local Directory Packages :
5344 if (-d $locdir_pkgs) {
5345 system("mv -f $locdir_pkgs $new_locdir_pkgs");
5346 }
5347  
5348 # Rename Group name :
5349 my $rename_grp = Hash::MultiValue->new(%{$curr_pkgGrp});
5350 $rename_grp->remove($old_pkg_group);
5351 $rename_grp->add($new_pkg_group => 0);
5352 $newData_group = $rename_grp->as_hashref;
5353  
5354 # Place data :
5355 $data{'timezone'} = $curr_timezone;
5356 $data{'prepare'} = $curr_prepare;
5357 $data{'build'} = $curr_build;
5358 $data{'bzr'} = $curr_bzr;
5359 $data{'git'} = $curr_git;
5360 $data{'pkg'} = {
5361 'dirpkg' => $curr_dirpkgs,
5362 'group' => $newData_group,
5363 'pkgs' => $curr_pkgs
5364 };
5365  
5366 return \%data;
5367  
5368 },
5369 'rename-pkg-group' => sub {
5370 my ($curr_cfg, $old_pkg_group, $new_pkg_group, $pkg_name) = @_;
5371  
5372 # Define hash of scalar :
5373 my %data = ();
5374 my $newData_pkg;
5375  
5376 # get data current pkg :
5377 my $curr_timezone = $curr_cfg->{'timezone'};
5378 my $curr_prepare = $curr_cfg->{'prepare'};
5379 my $curr_build = $curr_cfg->{'build'};
5380 my $build_rilis = $curr_build->{'rilis'};
5381 my $curr_bzr = $curr_cfg->{'bzr'};
5382 my $curr_git = $curr_cfg->{'git'};
5383 my $curr_pkg = $curr_cfg->{'pkg'};
5384 my $curr_dirpkgs = $curr_pkg->{'dirpkg'};
5385 my $curr_pkgGrp = $curr_pkg->{'group'};
5386 my $list_pkgs = $curr_pkg->{'pkgs'};
5387  
5388 # For Data Developer :
5389 my $data_dev = BlankOnDev::DataDev::data_dev();
5390  
5391 # For Data Packages :
5392 my $dir_pkgs = $data_dev->{'dir_pkg'};
5393 my $locdir_pkgs = $dir_pkgs.'/'.$build_rilis.'/'.$old_pkg_group.'/';
5394 my $new_locdir_pkgs = $dir_pkgs.'/'.$build_rilis.'/'.$new_pkg_group.'/';
5395  
5396 # Check Local Directory Packages :
5397 if (-d $locdir_pkgs) {
5398 system("mv -f $locdir_pkgs $new_locdir_pkgs");
5399 }
5400  
5401 # Rename group in data packages :
5402 my $rename_grpInPkg = Hash::MultiValue->new(%{$list_pkgs->{$pkg_name}});
5403 $rename_grpInPkg->set('group' => $new_pkg_group);
5404 my $result_changeGrp = $rename_grpInPkg->as_hashref;
5405  
5406 # Merge Data :
5407 my $forMerge = Hash::MultiValue->new(%{$list_pkgs});
5408 $forMerge->set($pkg_name => $result_changeGrp);
5409 $newData_pkg = $forMerge->as_hashref;
5410  
5411 # Place data :
5412 $data{'timezone'} = $curr_timezone;
5413 $data{'prepare'} = $curr_prepare;
5414 $data{'build'} = $curr_build;
5415 $data{'bzr'} = $curr_bzr;
5416 $data{'git'} = $curr_git;
5417 $data{'pkg'} = {
5418 'dirpkg' => $curr_dirpkgs,
5419 'group' => $curr_pkgGrp,
5420 'pkgs' => $newData_pkg
5421 };
5422  
5423 return \%data;
5424 },
5425 'remove-group' => sub {
5426 my ($curr_cfg, $old_group_name) = @_;
5427  
5428 # Define hash of scalar :
5429 my %data = ();
5430 my $newData_group;
5431  
5432 # get data current pkg :
5433 my $curr_timezone = $curr_cfg->{'timezone'};
5434 my $curr_prepare = $curr_cfg->{'prepare'};
5435 my $curr_build = $curr_cfg->{'build'};
5436 my $build_rilis = $curr_build->{'rilis'};
5437 my $curr_bzr = $curr_cfg->{'bzr'};
5438 my $curr_git = $curr_cfg->{'git'};
5439 my $curr_pkg = $curr_cfg->{'pkg'};
5440 my $curr_dirpkgs = $curr_pkg->{'dirpkg'};
5441 my $curr_pkgGrp = $curr_pkg->{'group'};
5442 my $curr_pkgs = $curr_pkg->{'pkgs'};
5443  
5444 # For Data Developer :
5445 my $data_dev = BlankOnDev::DataDev::data_dev();
5446  
5447 # For Data Packages :
5448 my $dir_pkgs = $data_dev->{'dir_pkg'};
5449 my $locdir_group = $dir_pkgs.'/'.$build_rilis.'/'.$old_group_name.'/';
5450  
5451 # Check Local Group :
5452 if (-d $locdir_group) {
5453 system("rm -rf $locdir_group");
5454 }
5455  
5456 # Remove Group :
5457 my $remove_group = Hash::MultiValue->new(%{$curr_pkgGrp});
5458 $remove_group->remove($old_group_name);
5459 $newData_group = $remove_group->as_hashref;
5460  
5461 # Place data :
5462 $data{'timezone'} = $curr_timezone;
5463 $data{'prepare'} = $curr_prepare;
5464 $data{'build'} = $curr_build;
5465 $data{'bzr'} = $curr_bzr;
5466 $data{'git'} = $curr_git;
5467 $data{'pkg'} = {
5468 'dirpkg' => $curr_dirpkgs,
5469 'group' => $newData_group,
5470 'pkgs' => $curr_pkgs
5471 };
5472  
5473 return \%data;
5474 },
5475 'remove-pkg' => sub {
5476 my ($curr_cfg, $pkg_names) = @_;
5477  
5478 # Define hash of scalar :
5479 my %data = ();
5480 my $newData_pkg;
5481 my $delData_pkg;
5482  
5483 # get data current pkg :
5484 my $curr_timezone = $curr_cfg->{'timezone'};
5485 my $curr_prepare = $curr_cfg->{'prepare'};
5486 my $curr_build = $curr_cfg->{'build'};
5487 my $build_rilis = $curr_build->{'rilis'};
5488 my $curr_bzr = $curr_cfg->{'bzr'};
5489 my $curr_git = $curr_cfg->{'git'};
5490 my $curr_pkg = $curr_cfg->{'pkg'};
5491 my $curr_dirpkgs = $curr_pkg->{'dirpkg'};
5492 my $curr_pkgGrp = $curr_pkg->{'group'};
5493 my $list_pkgs = $curr_pkg->{'pkgs'};
5494  
5495 # For Data Developer :
5496 my $data_dev = BlankOnDev::DataDev::data_dev();
5497 my $home_dir = $data_dev->{'home_dir'};
5498 my $dir_dev = $data_dev->{'dir_dev'};
5499 my $prefix_flcfg = $data_dev->{'prefix_flcfg'};
5500 my $file_cfg_ext = $data_dev->{'fileCfg_ext'};
5501  
5502 # For Data Packages :
5503 my $dir_pkgs = $data_dev->{'dir_pkg'};
5504 my $dir_pkgGrp = $list_pkgs->{$pkg_names}->{'group'};
5505 my $locdir_pkgs = $dir_pkgs.'/'.$build_rilis.'/'.$dir_pkgGrp.'/';
5506  
5507 # Remove in config ;
5508 my $remove_pkgs = Hash::MultiValue->new(%{$list_pkgs});
5509 $remove_pkgs->remove($pkg_names);
5510 $newData_pkg = $remove_pkgs->as_hashref;
5511  
5512 # Check Local Directory Packages :
5513 if (-d $locdir_pkgs) {
5514 # Form :
5515 print "\n";
5516 print "You want delete Packages in Local Directory [y/n] : ";
5517 chomp($delData_pkg = <STDIN>);
5518 if ($delData_pkg eq 'y' or $delData_pkg eq 'Y') {
5519 rmdir $locdir_pkgs;
5520 }
5521 }
5522  
5523 # Place data :
5524 $data{'timezone'} = $curr_timezone;
5525 $data{'prepare'} = $curr_prepare;
5526 $data{'build'} = $curr_build;
5527 $data{'bzr'} = $curr_bzr;
5528 $data{'git'} = $curr_git;
5529 $data{'pkg'} = {
5530 'dirpkg' => $curr_dirpkgs,
5531 'group' => $curr_pkgGrp,
5532 'pkgs' => $newData_pkg
5533 };
5534  
5535 return \%data;
5536 },
5537 'bzr-branch' => sub {
5538 my ($curr_cfg, $pkg_input, $r_branch) = @_;
5539  
5540 # Define hash or scalar :
5541 my %data = ();
5542  
5543 # get data current pkg :
5544 my $curr_timezone = $curr_cfg->{'timezone'};
5545 my $curr_prepare = $curr_cfg->{'prepare'};
5546 my $curr_build = $curr_cfg->{'build'};
5547 my $build_rilis = $curr_build->{'rilis'};
5548 my $curr_bzr = $curr_cfg->{'bzr'};
5549 my $curr_git = $curr_cfg->{'git'};
5550 my $curr_pkg = $curr_cfg->{'pkg'};
5551 my $pkg_dirpkg = $curr_pkg->{'dirpkg'};
5552 my $pkg_group = $curr_pkg->{'group'};
5553 my $pkg_list = $curr_pkg->{'pkgs'};
5554  
5555 # Data Current Packages :
5556 my $dataCurr_pkg = $pkg_list->{$pkg_input};
5557 my $status_pkg = $dataCurr_pkg->{'status'};
5558 my $stts_bzrPush = $status_pkg->{'git-push'};
5559 my $stts_bzrCgit = $status_pkg->{'bzrConvertGit'};
5560  
5561 # Get DateTime :
5562 my $timestamp = time();
5563 my $get_dataTime = BlankOnDev::DateTime->get($curr_timezone, $timestamp, {
5564 'date' => '-',
5565 'time' => ':',
5566 'datetime' => ' ',
5567 'format' => 'DD-MM-YYYY hms'
5568 });
5569 my $time_branch = $get_dataTime->{'custom'};
5570  
5571 # Update Packages:
5572 my $updatePkg_stts = Hash::MultiValue->new(%{$pkg_list->{$pkg_input}});
5573 $updatePkg_stts->set('status' => {
5574 'bzr-branch' => $r_branch,
5575 'git-push' => $stts_bzrPush,
5576 'bzrConvertGit' => $stts_bzrCgit,
5577 });
5578 $updatePkg_stts->set('bzr-branch' => 1);
5579 $updatePkg_stts->set('date-branch' => $time_branch);
5580 my $rUpdate_sttsPkg = $updatePkg_stts->as_hashref;
5581  
5582 # Update Data Packages :
5583 my $updatePkgs = Hash::MultiValue->new(%{$pkg_list});
5584 $updatePkgs->set($pkg_input => $rUpdate_sttsPkg);
5585 my $newData_pkg = $updatePkgs->as_hashref;
5586  
5587 # Create New Data :
5588 $data{'timezone'} = $curr_timezone;
5589 $data{'prepare'} = $curr_prepare;
5590 $data{'build'} = $curr_build;
5591 $data{'bzr'} = $curr_bzr;
5592 $data{'git'} = $curr_git;
5593 $data{'pkg'} = {
5594 'dirpkg' => $pkg_dirpkg,
5595 'group' => $pkg_group,
5596 'pkgs' => $newData_pkg,
5597 };
5598  
5599 return \%data;
5600 },
5601 'bzr-convert' => sub {
5602 my ($curr_cfg, $pkg_input, $r_bzrConver) = @_;
5603  
5604 # Define hash or scalar :
5605 my %data = ();
5606  
5607 # get data current pkg :
5608 my $curr_timezone = $curr_cfg->{'timezone'};
5609 my $curr_prepare = $curr_cfg->{'prepare'};
5610 my $curr_build = $curr_cfg->{'build'};
5611 my $curr_bzr = $curr_cfg->{'bzr'};
5612 my $curr_git = $curr_cfg->{'git'};
5613 my $curr_pkg = $curr_cfg->{'pkg'};
5614 my $pkg_dirpkg = $curr_pkg->{'dirpkg'};
5615 my $pkg_group = $curr_pkg->{'group'};
5616 my $pkg_list = $curr_pkg->{'pkgs'};
5617  
5618 # Data Current Packages :
5619 my $dataCurr_pkg = $pkg_list->{$pkg_input};
5620 my $status_pkg = $dataCurr_pkg->{'status'};
5621 my $stts_bzrBranch = $status_pkg->{'bzr-branch'};
5622 my $stts_bzrPush = $status_pkg->{'git-push'};
5623 my $stts_bzrCgit = $status_pkg->{'bzrConvertGit'};
5624  
5625 # Update Packages:
5626 my $updatePkg_stts = Hash::MultiValue->new(%{$pkg_list->{$pkg_input}});
5627 $updatePkg_stts->set('status' => {
5628 'bzr-branch' => $stts_bzrBranch,
5629 'git-push' => $stts_bzrPush,
5630 'bzrConvertGit' => $r_bzrConver,
5631 });
5632 my $rUpdate_sttsPkg = $updatePkg_stts->as_hashref;
5633  
5634 # Update Data Packages :
5635 my $updatePkgs = Hash::MultiValue->new(%{$pkg_list});
5636 $updatePkgs->set($pkg_input => $rUpdate_sttsPkg);
5637 my $newData_pkg = $updatePkgs->as_hashref;
5638  
5639 # Create New Data :
5640 $data{'timezone'} = $curr_timezone;
5641 $data{'prepare'} = $curr_prepare;
5642 $data{'build'} = $curr_build;
5643 $data{'bzr'} = $curr_bzr;
5644 $data{'git'} = $curr_git;
5645 $data{'pkg'} = {
5646 'dirpkg' => $pkg_dirpkg,
5647 'group' => $pkg_group,
5648 'pkgs' => $newData_pkg,
5649 };
5650  
5651 return \%data;
5652 },
5653 'git-push' => sub {
5654 my ($curr_cfg, $pkg_input, $r_gitpush) = @_;
5655  
5656 # Define hash or scalar :
5657 my %data = ();
5658  
5659 # get data current pkg :
5660 my $curr_timezone = $curr_cfg->{'timezone'};
5661 my $curr_prepare = $curr_cfg->{'prepare'};
5662 my $curr_build = $curr_cfg->{'build'};
5663 my $build_rilis = $curr_build->{'rilis'};
5664 my $curr_bzr = $curr_cfg->{'bzr'};
5665 my $curr_git = $curr_cfg->{'git'};
5666 my $curr_pkg = $curr_cfg->{'pkg'};
5667 my $pkg_dirpkg = $curr_pkg->{'dirpkg'};
5668 my $pkg_group = $curr_pkg->{'group'};
5669 my $pkg_list = $curr_pkg->{'pkgs'};
5670  
5671 # Data Current Packages :
5672 my $dataCurr_pkg = $pkg_list->{$pkg_input};
5673 my $status_pkg = $dataCurr_pkg->{'status'};
5674 my $stts_bzrBranch = $status_pkg->{'bzr-branch'};
5675 my $stts_bzrCgit = $status_pkg->{'bzrConvertGit'};
5676  
5677 # Get DateTime :
5678 my $timestamp = time();
5679 my $get_dataTime = BlankOnDev::DateTime->get($curr_timezone, $timestamp, {
5680 'date' => '-',
5681 'time' => ':',
5682 'datetime' => ' ',
5683 'format' => 'DD-MM-YYYY hms'
5684 });
5685 my $time_gitpush = $get_dataTime->{'custom'};
5686  
5687 # Update Packages:
5688 my $updatePkg_stts = Hash::MultiValue->new(%{$pkg_list->{$pkg_input}});
5689 $updatePkg_stts->set('status' => {
5690 'bzr-branch' => $stts_bzrBranch,
5691 'git-push' => $r_gitpush,
5692 'bzrConvertGit' => $stts_bzrCgit,
5693 });
5694 $updatePkg_stts->set('git-push' => 1);
5695 $updatePkg_stts->set('date-gitpush' => $time_gitpush);
5696 my $rUpdate_sttsPkg = $updatePkg_stts->as_hashref;
5697  
5698 # Update Data Packages :
5699 my $updatePkgs = Hash::MultiValue->new(%{$pkg_list});
5700 $updatePkgs->set($pkg_input => $rUpdate_sttsPkg);
5701 my $newData_pkg = $updatePkgs->as_hashref;
5702  
5703 # Create New Data :
5704 $data{'timezone'} = $curr_timezone;
5705 $data{'prepare'} = $curr_prepare;
5706 $data{'build'} = $curr_build;
5707 $data{'bzr'} = $curr_bzr;
5708 $data{'git'} = $curr_git;
5709 $data{'pkg'} = {
5710 'dirpkg' => $pkg_dirpkg,
5711 'group' => $pkg_group,
5712 'pkgs' => $newData_pkg,
5713 };
5714  
5715 return \%data;
5716 },
5717 'git-check' => sub {
5718 my ($curr_cfg, $pkg_input, $r_gitcheck) = @_;
5719  
5720 # Define hash or scalar :
5721 my %data = ();
5722  
5723 # get data current pkg :
5724 my $curr_timezone = $curr_cfg->{'timezone'};
5725 my $curr_prepare = $curr_cfg->{'prepare'};
5726 my $curr_build = $curr_cfg->{'build'};
5727 my $curr_bzr = $curr_cfg->{'bzr'};
5728 my $curr_git = $curr_cfg->{'git'};
5729 my $curr_pkg = $curr_cfg->{'pkg'};
5730 my $pkg_dirpkg = $curr_pkg->{'dirpkg'};
5731 my $pkg_group = $curr_pkg->{'group'};
5732 my $pkg_list = $curr_pkg->{'pkgs'};
5733  
5734 # Data Current Packages :
5735 my $dataCurr_pkg = $pkg_list->{$pkg_input};
5736 my $status_pkg = $dataCurr_pkg->{'status'};
5737 my $stts_bzrPush = $status_pkg->{'git-push'};
5738 my $stts_bzrBranch = $status_pkg->{'bzr-branch'};
5739 my $stts_bzrCgit = $status_pkg->{'bzrConvertGit'};
5740  
5741 # Update Packages:
5742 my $updatePkg_stts = Hash::MultiValue->new(%{$pkg_list->{$pkg_input}});
5743 $updatePkg_stts->set('status' => {
5744 'bzr-branch' => $stts_bzrBranch,
5745 'git-push' => $stts_bzrPush,
5746 'bzrConvertGit' => $stts_bzrCgit,
5747 'ongit' => $r_gitcheck,
5748 });
5749 my $rUpdate_sttsPkg = $updatePkg_stts->as_hashref;
5750  
5751 # Update Data Packages :
5752 my $updatePkgs = Hash::MultiValue->new(%{$pkg_list});
5753 $updatePkgs->set($pkg_input => $rUpdate_sttsPkg);
5754 my $newData_pkg = $updatePkgs->as_hashref;
5755  
5756 # Create New Data :
5757 $data{'timezone'} = $curr_timezone;
5758 $data{'prepare'} = $curr_prepare;
5759 $data{'build'} = $curr_build;
5760 $data{'bzr'} = $curr_bzr;
5761 $data{'git'} = $curr_git;
5762 $data{'pkg'} = {
5763 'dirpkg' => $pkg_dirpkg,
5764 'group' => $pkg_group,
5765 'pkgs' => $newData_pkg,
5766 };
5767  
5768 return \%data;
5769 },
5770 'bzr2git' => sub {
5771 my ($curr_cfg, $pkg_input, $branch, $bzr_cgit, $git_push, $git_check, $time_branch, $time_gitpush) = @_;
5772  
5773 # Define hash or scalar :
5774 my %data = ();
5775  
5776 # get data current pkg :
5777 my $curr_timezone = $curr_cfg->{'timezone'};
5778 my $curr_prepare = $curr_cfg->{'prepare'};
5779 my $curr_build = $curr_cfg->{'build'};
5780 my $curr_bzr = $curr_cfg->{'bzr'};
5781 my $curr_git = $curr_cfg->{'git'};
5782 my $curr_pkg = $curr_cfg->{'pkg'};
5783 my $pkg_dirpkg = $curr_pkg->{'dirpkg'};
5784 my $pkg_group = $curr_pkg->{'group'};
5785 my $pkg_list = $curr_pkg->{'pkgs'};
5786  
5787 # Update Packages:
5788 my $updatePkg_stts = Hash::MultiValue->new(%{$pkg_list->{$pkg_input}});
5789 $updatePkg_stts->set('status' => {
5790 'bzr-branch' => $branch,
5791 'git-push' => $bzr_cgit,
5792 'bzrConvertGit' => $git_push,
5793 'ongit' => $git_check,
5794 });
5795 $updatePkg_stts->set('date-branch' => $time_branch);
5796 $updatePkg_stts->set('date-gitpush' => $time_gitpush);
5797 my $rUpdate_sttsPkg = $updatePkg_stts->as_hashref;
5798  
5799 # Update Data Packages :
5800 my $updatePkgs = Hash::MultiValue->new(%{$pkg_list});
5801 $updatePkgs->set($pkg_input => $rUpdate_sttsPkg);
5802 my $newData_pkg = $updatePkgs->as_hashref;
5803  
5804 # Create New Data :
5805 $data{'timezone'} = $curr_timezone;
5806 $data{'prepare'} = $curr_prepare;
5807 $data{'build'} = $curr_build;
5808 $data{'bzr'} = $curr_bzr;
5809 $data{'git'} = $curr_git;
5810 $data{'pkg'} = {
5811 'dirpkg' => $pkg_dirpkg,
5812 'group' => $pkg_group,
5813 'pkgs' => $newData_pkg,
5814 };
5815  
5816 return \%data;
5817 },
5818 };
5819  
5820 return $switch;
5821 }
5822 # Subroutine for save new configure to file config :
5823 # ------------------------------------------------------------------------
5824 sub save_to_file {
5825 my ($self, $filename, $dest_dir, $data) = @_;
5826  
5827 my $data_file = encode_json($data);
5828 my $create_file = BlankOnDev::Utils::file->create($filename, $dest_dir, $data_file);
5829  
5830 return $create_file;
5831 }
5832 1;