diff --git a/uppsrc/umk/UppHub.cpp b/uppsrc/umk/UppHub.cpp index e2f0c4d47..2e61a37bf 100644 --- a/uppsrc/umk/UppHub.cpp +++ b/uppsrc/umk/UppHub.cpp @@ -21,7 +21,7 @@ struct UppHubDlg { Value LoadJson(const String& url); void Load(int tier, const String& url); void Load(); - void Install(const Index& ii, bool update = false); + bool Install(const Index& ii, bool update = false); }; Value UppHubDlg::LoadJson(const String& url) @@ -120,7 +120,7 @@ void UppHubDlg::Load() Load(0, url); } -void UppHubDlg::Install(const Index& ii_, bool update) +bool UppHubDlg::Install(const Index& ii_, bool update) { Index ii = clone(ii_); if(ii.GetCount()) { @@ -137,7 +137,9 @@ void UppHubDlg::Install(const Index& ii_, bool update) cmd << n->repo; cmd << ' ' << dir; PutConsole(cmd); - system(cmd); + if (system(cmd) != 0) + return false; + for(String p : FindAllPaths(dir, "*.upp")) { Package pkg; pkg.Load(p); @@ -153,20 +155,24 @@ void UppHubDlg::Install(const Index& ii_, bool update) String cmd = GetGitPath() + " -C "; cmd << dir << " clean -fxd"; PutConsole(cmd); - system(cmd); + if (system(cmd) != 0) + return false; + cmd = GetGitPath() + " -C "; cmd << dir << " pull"; PutConsole(cmd); - system(cmd); + if (system(cmd) != 0) + return false; } } } InvalidatePackageCache(); } ResetBlitz(); + return true; } -bool UppHubAuto(const String& main) +bool UppHub::AutoInstall(const String& main) { Index pmissing; for(;;) { @@ -191,7 +197,8 @@ bool UppHubAuto(const String& main) found.FindAdd(n.name); if(missing != pmissing) { - dlg.Install(found); + if (!dlg.Install(found)) + return false; pmissing = clone(missing); continue; } @@ -201,7 +208,7 @@ bool UppHubAuto(const String& main) return true; } -void UppHubUpdate(const String& main) +bool UppHub::Update(const String& main) { UppHubDlg dlg; dlg.Load(); @@ -216,5 +223,5 @@ void UppHubUpdate(const String& main) packages.FindAdd(n.name); } } - dlg.Install(packages, true); + return dlg.Install(packages, true); } diff --git a/uppsrc/umk/umake.cpp b/uppsrc/umk/umake.cpp index 898ef1493..f0aa6640d 100644 --- a/uppsrc/umk/umake.cpp +++ b/uppsrc/umk/umake.cpp @@ -257,12 +257,14 @@ CONSOLE_APP_MAIN return; } if(auto_hub || update_hub) { - if(!UppHubAuto(ide.main)) { + if(!UppHub::AutoInstall(ide.main)) { + SetExitCode(6); + return; + } + if (update_hub && !UppHub::Update(ide.main)) { SetExitCode(6); return; } - if (update_hub) - UppHubUpdate(ide.main); } ide.wspc.Scan(ide.main); const Workspace& wspc = ide.IdeWorkspace(); diff --git a/uppsrc/umk/umake.h b/uppsrc/umk/umake.h index c9d5f010a..fcb080de2 100644 --- a/uppsrc/umk/umake.h +++ b/uppsrc/umk/umake.h @@ -5,8 +5,10 @@ extern bool SilentMode; -bool UppHubAuto(const String& main); -void UppHubUpdate(const String& main); +namespace UppHub { +bool AutoInstall(const String& main); +bool Update(const String& main); +} class Console { public: