diff options
-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) { |