diff options
author | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2015-12-12 00:00:30 +0100 |
---|---|---|
committer | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2015-12-12 00:00:30 +0100 |
commit | 839e6ef83c3c39e7a525ca713d5feecb5b85ea2e (patch) | |
tree | f2e217966c4f6cdc5a4600cb60851413d128ac6f /SBO-Lib/lib | |
parent | c95f0b44ba2f9ab743875e655a48bf7c634a6213 (diff) | |
download | sbotools2-839e6ef83c3c39e7a525ca713d5feecb5b85ea2e.tar.xz |
Automatically migrate a version 1.x repo to a 2.x one
Diffstat (limited to 'SBO-Lib/lib')
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index e9eab3a..fb15ac7 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -216,9 +216,28 @@ sub get_slack_version { # does the SLACKBUILDS.TXT file exist in the sbo tree? sub chk_slackbuilds_txt { + if (-f "$config{SBO_HOME}/SLACKBUILDS.TXT") { migrate_repo(); } return -f $slackbuilds_txt ? 1 : undef; } +# Checks if the first argument equals any of the subsequent ones +sub in { + my ($first, @rest) @_; + foreach my $arg (@rest) { return 1 if $first eq $arg; } + return 0; +} + +# Move everything in /usr/sbo except distfiles and repo dirs into repo dir +sub migrate_repo { + make_path($repo_path) unless -d $repo_path; + opendir(my $dh, $config{SBO_HOME}); + foreach my $entry (readdir($dh)) { + next if in($entry => qw/ . .. repo distfiles /); + move("$config{SBO_HOME}/$entry", "$repo_path/$entry"); + } + close $dh; +} + # check for the validity of new $config{SBO_HOME} sub check_repo { if (-d $repo_path) { |