Index: ChangeLog =================================================================== RCS file: /cvs/src/src/winsup/cinstall/ChangeLog,v retrieving revision 2.7 diff -u -r2.7 ChangeLog --- ChangeLog 2000/08/30 01:05:41 2.7 +++ ChangeLog 2000/08/30 13:24:52 @@ -1,3 +1,25 @@ +2000-08-30 Andrej Borsenkow + + * localdir.cc: new, local package directory selection dialog + + * Makefile.in (OBJS): add localdir.o + * concat.cc (concat): preserve leading // to allow UNC names + * dialog.h: add prototype for do_local_dir + * download.cc (do_download): use local_dir as base directory + * fromcwd.cc (do_fromcwd): ditto + * install.cc (do_install): ditto + * log.cc (exit_setup): save log in local_dir, fall back to + current directory + * main.cc. (WinMain): initialize local_dir to cwd; + add call to do_local_dir + * net.cc (dialog_cmd): make DO_LOCAL_DIR next dialog + * source.cc (dialog_cmd): ditto + * res.rc: add DO_LOCAL_DIR dialog; remove "current directory" + from presented choices in IDD_SOURCE + * resource.h: defines for DO_LOCAL_DIR dialog + * root.cc (dialog_cmd): make DO_LOCAL_DIR previous dialog + * state.h: add local_dir variable + 2000-08-29 DJ Delorie * choose.cc (scan_downloaded_files): scan for existing files, so Index: Makefile.in =================================================================== RCS file: /cvs/src/src/winsup/cinstall/Makefile.in,v retrieving revision 2.4 diff -u -r2.4 Makefile.in --- Makefile.in 2000/08/30 01:05:41 2.4 +++ Makefile.in 2000/08/30 13:24:52 @@ -85,6 +85,7 @@ inilex.o \ iniparse.o \ install.o \ + localdir.o \ log.o \ main.o \ mkdir.o \ Index: concat.cc =================================================================== RCS file: /cvs/src/src/winsup/cinstall/concat.cc,v retrieving revision 2.0 diff -u -r2.0 concat.cc --- concat.cc 2000/08/08 00:27:54 2.0 +++ concat.cc 2000/08/30 13:24:52 @@ -71,7 +71,7 @@ *d++ = *++s; *d++ = *++s; } - else if (*s == '/') + else if (*s == '/' && s != rv) while (s[1] == '/') s++; } Index: dialog.h =================================================================== RCS file: /cvs/src/src/winsup/cinstall/dialog.h,v retrieving revision 2.0 diff -u -r2.0 dialog.h --- dialog.h 2000/08/08 00:27:54 2.0 +++ dialog.h 2000/08/30 13:24:53 @@ -32,6 +32,7 @@ D(do_fromcwd); D(do_ini); D(do_install); +D(do_local_dir); D(do_net); D(do_other); D(do_postinstall); Index: download.cc =================================================================== RCS file: /cvs/src/src/winsup/cinstall/download.cc,v retrieving revision 2.2 diff -u -r2.2 download.cc --- download.cc 2000/08/30 01:05:42 2.2 +++ download.cc 2000/08/30 13:24:53 @@ -44,7 +44,7 @@ for (i=0; i= 0) Index: fromcwd.cc =================================================================== RCS file: /cvs/src/src/winsup/cinstall/fromcwd.cc,v retrieving revision 2.3 diff -u -r2.3 fromcwd.cc --- fromcwd.cc 2000/08/24 21:50:14 2.3 +++ fromcwd.cc 2000/08/30 13:24:53 @@ -141,16 +141,18 @@ void do_fromcwd (HINSTANCE h) { - if (_access ("./setup.ini", 0) == 0) + if (_access (concat (local_dir, "/setup.ini", 0), 0) == 0) { - mirror_site = "."; + mirror_site = local_dir; next_dialog = IDD_S_LOAD_INI; return; } next_dialog = IDD_CHOOSE; - find (".", found_file); + npackages = 0; + + find (local_dir, found_file); return; } Index: install.cc =================================================================== RCS file: /cvs/src/src/winsup/cinstall/install.cc,v retrieving revision 2.2 diff -u -r2.2 install.cc --- install.cc 2000/08/30 01:05:42 2.2 +++ install.cc 2000/08/30 13:24:53 @@ -317,7 +317,7 @@ || package[i].action == ACTION_UPGRADE) && pi.install) { - char *local = pi.install, *cp, *fn, *base; + char *local = concat (local_dir, "/", pi.install, 0), *cp, *fn, *base; base = local; for (cp=pi.install; *cp; cp++) Index: log.cc =================================================================== RCS file: /cvs/src/src/winsup/cinstall/log.cc,v retrieving revision 2.2 diff -u -r2.2 log.cc --- log.cc 2000/08/30 01:05:42 2.2 +++ log.cc 2000/08/30 13:24:53 @@ -114,15 +114,20 @@ log (LOG_TIMESTAMP, "Ending cygwin install"); - if (source == IDC_SOURCE_DOWNLOAD || !root_dir) + if (source == IDC_SOURCE_DOWNLOAD && local_dir) { - log_save (LOG_BABBLE, "setup.log.full", 0); - log_save (0, "setup.log", 1); + log_save (LOG_BABBLE, concat (local_dir, "/setup.log.full", 0), 0); + log_save (0, concat (local_dir, "/setup.log", 0), 1); } - else + else if (root_dir) { log_save (LOG_BABBLE, concat (root_dir, "/setup.log.full", 0), 0); log_save (0, concat (root_dir, "/setup.log", 0), 1); + } + else + { + log_save (LOG_BABBLE, "setup.log.full", 0); + log_save (0, "setup.log", 1); } ExitProcess (exit_code); Index: main.cc =================================================================== RCS file: /cvs/src/src/winsup/cinstall/main.cc,v retrieving revision 2.2 diff -u -r2.2 main.cc --- main.cc 2000/08/25 01:32:08 2.2 +++ main.cc 2000/08/30 13:24:53 @@ -45,6 +45,8 @@ int next_dialog; int exit_msg = 0; +char cwd[_MAX_PATH]; + HINSTANCE hinstance; int WINAPI @@ -59,8 +61,8 @@ log (LOG_TIMESTAMP, "Starting cygwin install"); - char cwd[_MAX_PATH]; GetCurrentDirectory (sizeof (cwd), cwd); + local_dir = strdup (cwd); log (0, "Current Directory: %s", cwd); while (next_dialog) @@ -69,6 +71,7 @@ { case IDD_SPLASH: do_splash (h); break; case IDD_SOURCE: do_source (h); break; + case IDD_LOCAL_DIR: do_local_dir (h); break; case IDD_ROOT: do_root (h); break; case IDD_NET: do_net (h); break; case IDD_SITE: do_site (h); break; Index: net.cc =================================================================== RCS file: /cvs/src/src/winsup/cinstall/net.cc,v retrieving revision 2.2 diff -u -r2.2 net.cc --- net.cc 2000/08/30 01:05:42 2.2 +++ net.cc 2000/08/30 13:24:53 @@ -104,7 +104,7 @@ switch (source) { case IDC_SOURCE_DOWNLOAD: - NEXT (IDD_SOURCE); + NEXT (IDD_LOCAL_DIR); break; case IDC_SOURCE_NETINST: case IDC_SOURCE_CWD: Index: res.rc =================================================================== RCS file: /cvs/src/src/winsup/cinstall/res.rc,v retrieving revision 2.3 diff -u -r2.3 res.rc --- res.rc 2000/08/30 01:05:42 2.3 +++ res.rc 2000/08/30 13:24:54 @@ -36,13 +36,27 @@ DEFPUSHBUTTON "Next -->",IDOK,100,75,45,15,WS_DISABLED PUSHBUTTON "Cancel",IDCANCEL,165,75,45,15 ICON IDI_CYGWIN,-1,5,5,20,20 - CONTROL "Download from Internet to Current Directory", + CONTROL "Download from Internet", IDC_SOURCE_DOWNLOAD,"Button",BS_AUTORADIOBUTTON,55,15, 152,10 CONTROL "Install from Internet",IDC_SOURCE_NETINST,"Button", BS_AUTORADIOBUTTON,55,30,75,10 - CONTROL "Install from Current Directory",IDC_SOURCE_CWD,"Button", + CONTROL "Install from local directory",IDC_SOURCE_CWD,"Button", BS_AUTORADIOBUTTON,55,45,104,10 +END + +IDD_LOCAL_DIR DIALOG DISCARDABLE 0, 0, 215, 95 +STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Local package directory" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "Next -->",IDOK,100,75,45,15 + PUSHBUTTON "Cancel",IDCANCEL,165,75,45,15 + EDITTEXT IDC_LOCAL_DIR,55,25,127,12,ES_AUTOHSCROLL + LTEXT "Local package directory",IDC_STATIC,55,15,85,11 + PUSHBUTTON "<-- Back",IDC_BACK,55,75,45,15 + ICON IDI_CYGWIN,IDC_STATIC,5,5,20,20 + PUSHBUTTON "Browse...",IDC_LOCAL_DIR_BROWSE,150,10,34,14 END IDD_ROOT DIALOG DISCARDABLE 0, 0, 215, 95 Index: resource.h =================================================================== RCS file: /cvs/src/src/winsup/cinstall/resource.h,v retrieving revision 2.3 diff -u -r2.3 resource.h --- resource.h 2000/08/30 01:05:42 2.3 +++ resource.h 2000/08/30 13:24:54 @@ -81,6 +81,9 @@ #define IDC_CHOOSE_LIST 1039 #define IDC_INS_ACTION 1040 #define IDC_STATIC -1 +#define IDC_LOCAL_DIR_BROWSE 9994 +#define IDC_LOCAL_DIR 9995 +#define IDD_LOCAL_DIR 9997 // Next default values for new objects // Index: root.cc =================================================================== RCS file: /cvs/src/src/winsup/cinstall/root.cc,v retrieving revision 2.1 diff -u -r2.1 root.cc --- root.cc 2000/08/25 01:32:08 2.1 +++ root.cc 2000/08/30 13:24:54 @@ -202,7 +202,7 @@ case IDC_BACK: save_dialog (h); - NEXT (IDD_SOURCE); + NEXT (IDD_LOCAL_DIR); break; case IDCANCEL: Index: source.cc =================================================================== RCS file: /cvs/src/src/winsup/cinstall/source.cc,v retrieving revision 2.1 diff -u -r2.1 source.cc --- source.cc 2000/08/25 01:32:08 2.1 +++ source.cc 2000/08/30 13:24:54 @@ -65,16 +65,7 @@ case IDOK: save_dialog (h); - switch (source) - { - case IDC_SOURCE_DOWNLOAD: - NEXT (IDD_NET); - break; - case IDC_SOURCE_NETINST: - case IDC_SOURCE_CWD: - NEXT (IDD_ROOT); - break; - } + NEXT (IDD_LOCAL_DIR); break; case IDC_BACK: Index: state.h =================================================================== RCS file: /cvs/src/src/winsup/cinstall/state.h,v retrieving revision 2.0 diff -u -r2.0 state.h --- state.h 2000/08/08 01:00:30 2.0 +++ state.h 2000/08/30 13:24:54 @@ -20,6 +20,8 @@ extern int source; +extern char * local_dir; + extern char * root_dir; extern int root_text; extern int root_scope; --- /dev/null Wed Aug 30 17:25:00 2000 +++ localdir.cc Wed Aug 30 17:24:45 2000 @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2000, Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * A copy of the GNU General Public License can be found at + * http://www.gnu.org/ + * + * Written by Andrej Borsenkow + * + */ + +/* The purpose of this file is to ask the user where they want the + root of the installation to be, and to ask whether the user prefers + text or binary mounts. */ + +static char *cvsid = "\n%%% $Id: root.cc,v 2.1 2000/08/25 01:32:08 dj Exp $\n"; + +#include "win32.h" +#include +#include +#include +#include + +#include "dialog.h" +#include "resource.h" +#include "state.h" +#include "msg.h" +#include "mount.h" +#include "concat.h" +#include "log.h" + +static void +check_if_enable_next (HWND h) +{ + EnableWindow (GetDlgItem (h, IDOK), local_dir != 0); +} + +static void +load_dialog (HWND h) +{ + eset (h, IDC_LOCAL_DIR, local_dir); + check_if_enable_next (h); +} + +static void +save_dialog (HWND h) +{ + local_dir = eget (h, IDC_LOCAL_DIR, local_dir); +} + + +static int CALLBACK +browse_cb (HWND h, UINT msg, LPARAM lp, LPARAM data) +{ + switch (msg) + { + case BFFM_INITIALIZED: + if (local_dir) + SendMessage (h, BFFM_SETSELECTION, TRUE, (LPARAM)local_dir); + break; + } + return 0; +} + +static void +browse (HWND h) +{ + BROWSEINFO bi; + CHAR name[MAX_PATH]; + LPITEMIDLIST pidl; + memset (&bi, 0, sizeof (bi)); + bi.hwndOwner = h; + bi.pszDisplayName = name; + bi.lpszTitle = "Select download directory"; + bi.ulFlags = BIF_RETURNONLYFSDIRS; + bi.lpfn = browse_cb; + pidl = SHBrowseForFolder (&bi); + if (pidl) + { + if (SHGetPathFromIDList (pidl, name)) + eset (h, IDC_LOCAL_DIR, name); + } +} + + +static BOOL +dialog_cmd (HWND h, int id, HWND hwndctl, UINT code) +{ + switch (id) + { + + case IDC_LOCAL_DIR: + save_dialog (h); + check_if_enable_next (h); + break; + + case IDC_LOCAL_DIR_BROWSE: + browse (h); + break; + + case IDOK: + save_dialog (h); + switch (source) + { + case IDC_SOURCE_DOWNLOAD: + NEXT (IDD_NET); + break; + case IDC_SOURCE_NETINST: + case IDC_SOURCE_CWD: + NEXT (IDD_ROOT); + break; + default: + NEXT (0); + break; + } + break; + + case IDC_BACK: + save_dialog (h); + NEXT (IDD_SOURCE); + break; + + case IDCANCEL: + NEXT (0); + break; + } +} + +static BOOL CALLBACK +dialog_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG: + load_dialog (h); + return FALSE; + case WM_COMMAND: + return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd); + } + return FALSE; +} + +extern char cwd[_MAX_PATH]; + +void +do_local_dir (HINSTANCE h) +{ + int rv = 0; + rv = DialogBox (h, MAKEINTRESOURCE (IDD_LOCAL_DIR), 0, dialog_proc); + if (rv == -1) + fatal (IDS_DIALOG_FAILED); + + log (0, "Selected local directory: %s", local_dir); +} +