From 839e6ef83c3c39e7a525ca713d5feecb5b85ea2e Mon Sep 17 00:00:00 2001 From: Andreas Guldstrand Date: Sat, 12 Dec 2015 00:00:30 +0100 Subject: Automatically migrate a version 1.x repo to a 2.x one --- SBO-Lib/lib/SBO/Lib.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'SBO-Lib/lib/SBO/Lib.pm') 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) { -- cgit v1.2.3