From e6c1f9ca4bad8599a244b06dfb86ed5dfb79dc0d Mon Sep 17 00:00:00 2001 From: Saveliy Tretiakov Date: Wed, 13 Sep 2006 12:33:59 +0000 Subject: [PATCH] Add UnattendSetupEnabled key for enabling\disabling unattended setup without editing rbuild files. Modifing rbuild files all the time is not handy and slows down build process. svn path=/trunk/; revision=24095 --- reactos/base/setup/usetup/usetup.c | 23 +++++++++++++++-- reactos/boot/bootdata/unattend.inf.sample | 21 +++++++++++++--- reactos/dll/win32/syssetup/wizard.c | 30 +++++++++++++++++++++-- 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/reactos/base/setup/usetup/usetup.c b/reactos/base/setup/usetup/usetup.c index 3ca85ec7075..86f997ec60c 100644 --- a/reactos/base/setup/usetup/usetup.c +++ b/reactos/base/setup/usetup/usetup.c @@ -73,7 +73,7 @@ typedef enum _PAGE_NUMBER HANDLE ProcessHeap; UNICODE_STRING SourceRootPath; -BOOLEAN IsUnattendedSetup; +BOOLEAN IsUnattendedSetup = FALSE; LONG UnattendDestinationDiskNumber; LONG UnattendDestinationPartitionNumber; LONG UnattendMBRInstallType = -1; @@ -433,7 +433,6 @@ CheckUnattendedSetup(VOID) if (DoesFileExist(SourcePath.Buffer, L"unattend.inf") == FALSE) { DPRINT("Does not exist: %S\\%S\n", SourcePath.Buffer, L"unattend.inf"); - IsUnattendedSetup = FALSE; return; } @@ -475,6 +474,26 @@ CheckUnattendedSetup(VOID) return; } + /* Check if Unattend setup is enabled */ + if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"UnattendSetupEnabled", &Context)) + { + DPRINT("Can't find key 'UnattendSetupEnabled'\n"); + SetupCloseInfFile(&UnattendInf); + return; + } + if (!INF_GetData(&Context, NULL, &Value)) + { + DPRINT("Can't read key 'UnattendSetupEnabled'\n"); + SetupCloseInfFile(&UnattendInf); + return; + } + if (_wcsicmp(Value, L"yes") != 0) + { + DPRINT("Unattend setup is disabled by 'UnattendSetupEnabled' key!\n"); + SetupCloseInfFile(&UnattendInf); + return; + } + /* Search for 'DestinationDiskNumber' in the 'Unattend' section */ if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"DestinationDiskNumber", &Context)) { diff --git a/reactos/boot/bootdata/unattend.inf.sample b/reactos/boot/bootdata/unattend.inf.sample index 8469c182f01..955f3cb683c 100644 --- a/reactos/boot/bootdata/unattend.inf.sample +++ b/reactos/boot/bootdata/unattend.inf.sample @@ -1,18 +1,31 @@ -; Install to \Device\Harddisk0\Partition1\ReactOS +; In order to get unattended setup working: +; 1. Copy unattend.inf.sample to unattend.inf, adjust as needed +; 2. Uncomment the line in bootdata.rbuild to include it into bootcd + [Unattend] Signature = "$ReactOS$" + +; yes - unattend setup enabled +; no - unattend setup disabled +UnattendSetupEnabled = yes + +; Install to \Device\Harddisk0\Partition1\ReactOS DestinationDiskNumber = 0 DestinationPartitionNumber = 1 InstallationDirectory=ReactOS -;MBRInstallType=0 skips MBR installation -;MBRInstallType=1 install MBR on floppy -;MBRInstallType=2 install MBR on hdd + +; MBRInstallType=0 skips MBR installation +; MBRInstallType=1 install MBR on floppy +; MBRInstallType=2 install MBR on hdd MBRInstallType=2 + FullName="MyName" ;OrgName="MyOrg" ComputerName="MYCOMPUTERNAME"; AdminPassword="MyPassword" + ; TimeZone is set GMT as default TimeZoneIndex=85 + ; enable this setting to disable daylight saving changes ; DisableAutoDaylightTimeSet = 1 \ No newline at end of file diff --git a/reactos/dll/win32/syssetup/wizard.c b/reactos/dll/win32/syssetup/wizard.c index 807ecd2a822..4019a2870e6 100644 --- a/reactos/dll/win32/syssetup/wizard.c +++ b/reactos/dll/win32/syssetup/wizard.c @@ -1909,6 +1909,31 @@ ProcessUnattendInf(HINF hUnattendedInf) TCHAR szValue[256]; DWORD LineLength; + if (!SetupFindFirstLine(hUnattendedInf, + _T("Unattend"), + _T("UnattendSetupEnabled"), + &InfContext)) + { + DPRINT1("Error: Cant find UnattendSetupEnabled Key! %d\n", GetLastError()); + return FALSE; + } + + if (!SetupGetStringField(&InfContext, + 1, + szValue, + sizeof(szValue) / sizeof(TCHAR), + &LineLength)) + { + DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError()); + return FALSE; + } + + if (_tcscmp(szValue, _T("yes")) != 0) + { + DPRINT("Unattend setup was disabled by UnattendSetupEnabled key.\n"); + return FALSE; + } + if (!SetupFindFirstLine(hUnattendedInf, _T("Unattend"), NULL, @@ -1917,7 +1942,8 @@ ProcessUnattendInf(HINF hUnattendedInf) DPRINT1("Error: SetupFindFirstLine failed %d\n", GetLastError()); return FALSE; } - + + do { if (!SetupGetStringField(&InfContext, @@ -1994,7 +2020,7 @@ InstallWizard(VOID) /* Clear setup data */ ZeroMemory(&SetupData, sizeof(SETUPDATA)); - + hUnattendedInf = SetupOpenInfFileW(L"unattend.inf", NULL, INF_STYLE_OLDNT,