added a test installer app
source directory is currently hardcoded in InstallerWindow.cpp, it could be changed in a macro git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16197 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2,3 +2,4 @@ SubDir HAIKU_TOP src tests apps ;
|
|||||||
|
|
||||||
SubInclude HAIKU_TOP src tests apps miniterminal ;
|
SubInclude HAIKU_TOP src tests apps miniterminal ;
|
||||||
SubInclude HAIKU_TOP src tests apps fake_app_server ;
|
SubInclude HAIKU_TOP src tests apps fake_app_server ;
|
||||||
|
SubInclude HAIKU_TOP src tests apps installer ;
|
||||||
|
|||||||
@@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005-2006, Jérôme DUVAL. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "CopyEngine.h"
|
||||||
|
#include "InstallerWindow.h"
|
||||||
|
#include "PartitionMenuItem.h"
|
||||||
|
#include <Alert.h>
|
||||||
|
#include <FindDirectory.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <VolumeRoster.h>
|
||||||
|
|
||||||
|
//#define COPY_TRACE
|
||||||
|
#ifdef COPY_TRACE
|
||||||
|
#define CALLED() printf("CALLED %s\n",__PRETTY_FUNCTION__)
|
||||||
|
#else
|
||||||
|
#define CALLED()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char BOOT_PATH[] = "/boot";
|
||||||
|
|
||||||
|
extern void SizeAsString(off_t size, char *string);
|
||||||
|
|
||||||
|
|
||||||
|
CopyEngine::CopyEngine(InstallerWindow *window)
|
||||||
|
: BLooper("copy_engine"),
|
||||||
|
fWindow(window),
|
||||||
|
fPackages(NULL),
|
||||||
|
fSpaceRequired(0)
|
||||||
|
{
|
||||||
|
Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CopyEngine::MessageReceived(BMessage*msg)
|
||||||
|
{
|
||||||
|
CALLED();
|
||||||
|
switch (msg->what) {
|
||||||
|
case ENGINE_START:
|
||||||
|
Start(fWindow->GetSourceMenu(), fWindow->GetTargetMenu());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CopyEngine::SetStatusMessage(char *status)
|
||||||
|
{
|
||||||
|
BMessage msg(STATUS_MESSAGE);
|
||||||
|
msg.AddString("status", status);
|
||||||
|
BMessenger(fWindow).SendMessage(&msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CopyEngine::LaunchInitScript(BPath &path)
|
||||||
|
{
|
||||||
|
BPath bootPath;
|
||||||
|
find_directory(B_BEOS_BOOT_DIRECTORY, &bootPath);
|
||||||
|
BString command("/bin/sh ");
|
||||||
|
command += bootPath.Path();
|
||||||
|
command += "/InstallerInitScript ";
|
||||||
|
command += path.Path();
|
||||||
|
SetStatusMessage("Starting Installation.");
|
||||||
|
system(command.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CopyEngine::LaunchFinishScript(BPath &path)
|
||||||
|
{
|
||||||
|
BPath bootPath;
|
||||||
|
find_directory(B_BEOS_BOOT_DIRECTORY, &bootPath);
|
||||||
|
BString command("/bin/sh ");
|
||||||
|
command += bootPath.Path();
|
||||||
|
command += "/InstallerFinishScript ";
|
||||||
|
command += path.Path();
|
||||||
|
SetStatusMessage("Finishing Installation.");
|
||||||
|
system(command.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu)
|
||||||
|
{
|
||||||
|
CALLED();
|
||||||
|
PartitionMenuItem *targetItem = (PartitionMenuItem *)targetMenu->FindMarked();
|
||||||
|
PartitionMenuItem *srcItem = (PartitionMenuItem *)srcMenu->FindMarked();
|
||||||
|
if (!srcItem || !targetItem) {
|
||||||
|
fprintf(stderr, "bad menu items\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BMessage msg(INSTALL_FINISHED);
|
||||||
|
BMessenger(fWindow).SendMessage(&msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CopyEngine::ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu)
|
||||||
|
{
|
||||||
|
PartitionMenuItem *item = new PartitionMenuItem(NULL, "boot", NULL, new BMessage(SRC_PARTITION), 0);
|
||||||
|
srcMenu->AddItem(item);
|
||||||
|
|
||||||
|
PartitionMenuItem *item2 = new PartitionMenuItem(NULL, "target", NULL, new BMessage(TARGET_PARTITION), 0);
|
||||||
|
targetMenu->AddItem(item2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CopyEngine::SetPackagesList(BList *list)
|
||||||
|
{
|
||||||
|
if (fPackages)
|
||||||
|
delete fPackages;
|
||||||
|
fPackages = list;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005, Jérôme DUVAL. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CopyEngine_h
|
||||||
|
#define _CopyEngine_h
|
||||||
|
|
||||||
|
#include <Looper.h>
|
||||||
|
#include <Messenger.h>
|
||||||
|
|
||||||
|
class InstallerWindow;
|
||||||
|
|
||||||
|
const uint32 ENGINE_START = 'eSRT';
|
||||||
|
|
||||||
|
class CopyEngine : public BLooper {
|
||||||
|
public:
|
||||||
|
CopyEngine(InstallerWindow *window);
|
||||||
|
void MessageReceived(BMessage *msg);
|
||||||
|
void SetStatusMessage(char *status);
|
||||||
|
void Start(BMenu *srcMenu, BMenu *targetMenu);
|
||||||
|
void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu);
|
||||||
|
void SetPackagesList(BList *list);
|
||||||
|
void SetSpaceRequired(off_t bytes) { fSpaceRequired = bytes; };
|
||||||
|
private:
|
||||||
|
void LaunchInitScript(BPath &path);
|
||||||
|
void LaunchFinishScript(BPath &path);
|
||||||
|
void CopyFolder(BDirectory &srcDir, BDirectory &targetDir);
|
||||||
|
|
||||||
|
InstallerWindow *fWindow;
|
||||||
|
BList *fPackages;
|
||||||
|
off_t fSpaceRequired;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _CopyEngine_h */
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
SubDir HAIKU_TOP src tests apps installer ;
|
||||||
|
|
||||||
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
|
UsePrivateHeaders shared ;
|
||||||
|
UsePrivateHeaders storage ;
|
||||||
|
SubDirHdrs [ FDirName $(HAIKU_TOP) src kits tracker ] ;
|
||||||
|
SubDirHdrs [ FDirName $(HAIKU_TOP) src apps installer ] ;
|
||||||
|
|
||||||
|
Application TestInstaller :
|
||||||
|
CopyEngine.cpp
|
||||||
|
DrawButton.cpp
|
||||||
|
InstallerApp.cpp
|
||||||
|
InstallerWindow.cpp
|
||||||
|
PackageViews.cpp
|
||||||
|
PartitionMenuItem.cpp
|
||||||
|
: be tracker translation
|
||||||
|
: Installer.rdef ;
|
||||||
|
|
||||||
|
SEARCH on [ FGristFiles
|
||||||
|
DrawButton.cpp
|
||||||
|
InstallerApp.cpp
|
||||||
|
InstallerWindow.cpp
|
||||||
|
PackageViews.cpp
|
||||||
|
PartitionMenuItem.cpp
|
||||||
|
Installer.rdef
|
||||||
|
] = [ FDirName $(HAIKU_TOP) src apps installer ] ;
|
||||||
Reference in New Issue
Block a user