I've updated the following three patches to make them apply cleanly against setup-2.599
6689-goossens-rev1-rh.patch 6688-switch-p-rh.patch 854-peschko-cmdlines-rh.patch I've also attached a "series" that can be used withe quilt to manage application and removal of the patches: Please note that this is 99% other peoples work and that all I've really done is massage it to fit into the HEAD source. Here's what the patches are supposed to do: 6689-goossens-rev1-rh.patch Adds -t and -c options to allow text-mode mounts and user mounts to allow unattended setups. I had to modify it so that it applies cleanly from within the setup tree 6688-switch-p-rh.patch Adds -s (--software) option to allow the user to specify a set of package names on the command line No local changes necessary. -s conflicts with the --site option. We could use -o (object/package) but for testing, you have to specify the full (--software) 854-peschko-cmdlines-rh.patch Adds -E (use IE5 settings) -H (proxy name) -P (proxy port) to allow unattended setups. Adds -a (install all) -u (uninstall all) and -e (reinstall all) I had to add a netIO class prefix in ConnectionSetting.cc I also hadd to add some missing class members to package_meta.h Please consider these for addition to future versions of setup. Cheers, Ralph Hempel
Index: setup/ConnectionSetting.cc =================================================================== --- setup.orig/ConnectionSetting.cc +++ setup/ConnectionSetting.cc @@ -26,27 +26,50 @@ static const char *cvsid = #include "resource.h" #include "String++.h" +#include "getopt++/BoolOption.h" +#include "getopt++/StringOption.h" + +static BoolOption UseIE5(false, 'E', "use-ie5", "Use IE5 connection settings"); +static StringOption ProxyHost( "" , 'H', "proxy-name", "Name of proxy to use in download", false ); +static StringOption ProxyPort( "" , 'P', "proxy-port", "Proxy port to use in download", false ); + void ConnectionSetting::load() { static int inited = 0; if (inited) return; - io_stream *f = UserSettings::Instance().settingFileForLoad("last-connection"); - if (f) + + if (UseIE5 || (((std::string) ProxyHost).size())) { - char localdir[1000]; - char *fg_ret = f->gets (localdir, 1000); - if (fg_ret) - NetIO::net_method = typeFromString(fg_ret); - fg_ret = f->gets (localdir, 1000); - if (fg_ret) - NetIO::net_proxy_host = strdup(fg_ret); - fg_ret = f->gets (localdir, 1000); - if (fg_ret) - NetIO::net_proxy_port = atoi(fg_ret); - delete f; + NetIO::net_method = typeFromString(""); + + if (((std::string)ProxyHost).size()) + { + NetIO::net_proxy_host = strdup(((std::string)ProxyHost).c_str()); + NetIO::net_proxy_port = (((std::string)ProxyPort).size())? + atoi(((std::string)ProxyPort).c_str()) : + 80; + } } + else + { + io_stream *f = UserSettings::Instance().settingFileForLoad("last-connection"); + if (f) + { + char localdir[1000]; + char *fg_ret = f->gets (localdir, 1000); + if (fg_ret) + NetIO::net_method = typeFromString(fg_ret); + fg_ret = f->gets (localdir, 1000); + if (fg_ret) + NetIO::net_proxy_host = strdup(fg_ret); + fg_ret = f->gets (localdir, 1000); + if (fg_ret) + NetIO::net_proxy_port = atoi(fg_ret); + delete f; + } + } inited = 1; } @@ -54,7 +77,7 @@ void ConnectionSetting::save() { char port_str[20]; - + io_stream *f = UserSettings::Instance().settingFileForSave("last-connection"); if (f) { @@ -81,6 +104,10 @@ ConnectionSetting::save() int ConnectionSetting::typeFromString(const std::string& aType) { + if (UseIE5) + return IDC_NET_IE5; + if (((std::string)ProxyHost).size()) + return IDC_NET_PROXY; if (!casecompare(aType, "Direct")) return IDC_NET_DIRECT; if (!casecompare(aType, "IE")) Index: setup/PickCategoryLine.h =================================================================== --- setup.orig/PickCategoryLine.h +++ setup/PickCategoryLine.h @@ -25,12 +25,18 @@ class PickView; class PickCategoryLine:public PickLine { public: - PickCategoryLine (PickView & aView, Category & _cat, size_t thedepth = 0, bool aBool = - true, bool aBool2 = - true):PickLine (_cat.first), - current_default (packagemeta::Default_action), cat (_cat), labellength (0), + PickCategoryLine ( + PickView & aView, + Category & _cat, + packagemeta::_actions _current_default = packagemeta::Default_action, + size_t thedepth = 0, + bool aBool = true, + bool aBool2 = true) : + + PickLine (_cat.first), cat (_cat), labellength (0), depth (thedepth), theView (aView) { + current_default = _current_default; if (aBool) { collapsed = true; @@ -41,6 +47,7 @@ public: collapsed = false; show_label = aBool2; } + set_action(current_default); }; ~PickCategoryLine () { Index: setup/PickView.cc =================================================================== --- setup.orig/PickView.cc +++ setup/PickView.cc @@ -182,7 +182,7 @@ PickView::setViewMode (views mode) (pkg.desired && (pkg.desired.picked () || // install bin pkg.desired.sourcePackage ().picked ())))) // src - + // "Up to date" : installed packages that will not be changed || (view_mode == PickView::views::PackageKeeps && (pkg.installed && pkg.desired && !pkg.desired.picked () @@ -191,7 +191,7 @@ PickView::setViewMode (views mode) // "Not installed" || (view_mode == PickView::views::PackageSkips && (!pkg.desired && !pkg.installed))) - + insert_pkg (pkg); } } @@ -213,6 +213,12 @@ PickView::setViewMode (views mode) scroll_ulc_x = scroll_ulc_y = 0; InvalidateRect (GetHWND(), &r, TRUE); + + if (packagemeta::action_from_argv() != packagemeta::Default_action) + { + packagedb().markUnVisited(); + contents.set_action(packagemeta::action_from_argv()); + } } const char * @@ -246,7 +252,7 @@ bool isObsolete (set <std::string, casecompare_lt_op> &categories) { set <std::string, casecompare_lt_op>::const_iterator i; - + for (i = categories.begin (); i != categories.end (); ++i) if (isObsolete (*i)) return true; @@ -256,7 +262,7 @@ isObsolete (set <std::string, casecompar bool isObsolete (const std::string& catname) { - if (casecompare(catname, "ZZZRemovedPackages") == 0 + if (casecompare(catname, "ZZZRemovedPackages") == 0 || casecompare(catname, "_", 1) == 0) return true; return false; @@ -276,7 +282,7 @@ PickView::insert_pkg (packagemeta & pkg) { if (!showObsolete && isObsolete (pkg.categories)) return; - + if (view_mode != views::Category) { PickLine & line = *new PickPackageLine (*this, pkg); @@ -292,8 +298,9 @@ PickView::insert_pkg (packagemeta & pkg) continue; packagedb db; - PickCategoryLine & catline = - *new PickCategoryLine (*this, *db.categories.find (*x), 1); + PickCategoryLine & catline = + *new PickCategoryLine (*this, *db.categories.find (*x), + packagemeta::action_from_argv(), 1); PickLine & line = *new PickPackageLine(*this, pkg); catline.insert (line); contents.insert (catline); @@ -308,7 +315,9 @@ PickView::insert_category (Category *cat if (casecompare(cat->first, "All") == 0 || (!showObsolete && isObsolete (cat->first))) return; - PickCategoryLine & catline = *new PickCategoryLine (*this, *cat, 1, collapsed); + PickCategoryLine & catline = *new PickCategoryLine(*this, *cat, + packagemeta::action_from_argv(), 1, collapsed); + for (vector <packagemeta *>::iterator i = cat->second.begin (); i != cat->second.end () ; ++i) { @@ -425,7 +434,7 @@ PickView::init_headers (HDC dc) // conversion by the unwise String(int) constructor. note_width (headers, dc, "0", HMARGIN + 11, bintick_col); note_width (headers, dc, "0", HMARGIN + 11, srctick_col); - + // accomodate the width of each category name packagedb db; for (packagedb::categoriesType::iterator n = packagedb::categories.begin(); @@ -465,14 +474,14 @@ PickView::init_headers (HDC dc) if (pkg.SDesc ().size()) s += std::string (": ") + std::string(pkg.SDesc ()); note_width (headers, dc, s, HMARGIN, pkg_col); - + if (view_mode != PickView::views::Category && pkg.categories.size () > 2) { - std::string compound_cat(""); + std::string compound_cat(""); std::set<std::string, casecompare_lt_op>::const_iterator cat; size_t cnt; - - for (cnt = 0, cat = pkg.categories.begin (); + + for (cnt = 0, cat = pkg.categories.begin (); cnt < NUM_CATEGORY_COL_WIDTH && cat != pkg.categories.end (); ++cat) { @@ -486,9 +495,9 @@ PickView::init_headers (HDC dc) note_width (headers, dc, compound_cat, HMARGIN, cat_col); } } - + // ensure that the new_col is wide enough for all the labels - const char *captions[] = { "Uninstall", "Skip", "Reinstall", "Retrieve", + const char *captions[] = { "Uninstall", "Skip", "Reinstall", "Retrieve", "Source", "Keep", NULL }; for (int i = 0; captions[i]; i++) note_width (headers, dc, captions[i], HMARGIN + SPIN_WIDTH, new_col); @@ -501,8 +510,8 @@ PickView::init_headers (HDC dc) PickView::PickView (Category &cat) : deftrust (TRUST_UNKNOWN), -contents (*this, cat, 0, false, true), showObsolete (false), -hasClientRect (false) +contents (*this, cat, packagemeta::action_from_argv(), false, true), +showObsolete (false), hasClientRect (false) { } @@ -521,8 +530,8 @@ PickView::init(views _mode) bm_checkno = LI (IDB_CHECK_NO); bm_checkna = LI (IDB_CHECK_NA); bm_treeplus = LI (IDB_TREE_PLUS); - bm_treeminus = LI (IDB_TREE_MINUS); -#undef LI + bm_treeminus = LI (IDB_TREE_MINUS); +#undef LI icon_dc = CreateCompatibleDC (dc); bm_icon = CreateCompatibleBitmap (dc, 11, 11); SelectObject (icon_dc, bm_icon); @@ -538,7 +547,7 @@ PickView::init(views _mode) // Ensure that the common control DLL is loaded, and then create // the header control. - INITCOMMONCONTROLSEX controlinfo = { sizeof (INITCOMMONCONTROLSEX), + INITCOMMONCONTROLSEX controlinfo = { sizeof (INITCOMMONCONTROLSEX), ICC_LISTVIEW_CLASSES }; InitCommonControlsEx (&controlinfo); @@ -717,7 +726,7 @@ PickView::WindowProc (UINT message, WPAR { int wheel_notches; UINT wheel_lines; - + switch (message) { case WM_HSCROLL: @@ -729,7 +738,7 @@ PickView::WindowProc (UINT message, WPAR case WM_MOUSEWHEEL: // this is how many 'notches' the wheel scrolled, forward/up = positive wheel_notches = GET_WHEEL_DELTA_WPARAM(wParam) / 120; - + // determine how many lines the user has configred for a mouse scroll SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &wheel_lines, 0); @@ -759,21 +768,21 @@ PickView::WindowProc (UINT message, WPAR { if (phdr->pitem && phdr->pitem->mask & HDI_WIDTH) headers[phdr->iItem].width = phdr->pitem->cxy; - + for (int i = 1; i <= last_col; i++) headers[i].x = headers[i - 1].x + headers[i - 1].width; - + RECT r = GetClientRect (); SCROLLINFO si; si.cbSize = sizeof (si); si.fMask = SIF_ALL | SIF_DISABLENOSCROLL; GetScrollInfo (GetHWND(), SB_HORZ, &si); - + int oldMax = si.nMax; si.nMax = headers[last_col].x + headers[last_col].width; if (si.nTrackPos && oldMax > si.nMax) si.nTrackPos += si.nMax - oldMax; - + si.nPage = r.right; SetScrollInfo (GetHWND(), SB_HORZ, &si, TRUE); InvalidateRect (GetHWND(), &r, TRUE); @@ -803,12 +812,12 @@ PickView::WindowProc (UINT message, WPAR } else hasClientRect = true; - + lastClientRect = clientRect; - return 0; + return 0; } } - + // default: can't handle this message return DefWindowProc (GetHWND(), message, wParam, lParam); } @@ -855,7 +864,7 @@ PickView::paint (HWND hwnd) // painting, it will retrigger us so that we can fix it PAINTSTRUCT ps; HDC hdc = BeginPaint (hwnd, &ps); - + SelectObject (hdc, sysfont); SetTextColor (hdc, GetSysColor (COLOR_WINDOWTEXT)); SetBkColor (hdc, GetSysColor (COLOR_WINDOW)); @@ -871,7 +880,7 @@ PickView::paint (HWND hwnd) int x = cr.left - scroll_ulc_x; int y = cr.top - scroll_ulc_y + header_height; - contents.paint (hdc, hUpdRgn, x, y, 0, (view_mode == + contents.paint (hdc, hUpdRgn, x, y, 0, (view_mode == PickView::views::Category) ? 0 : 1); if (contents.itemcount () == 0) @@ -888,7 +897,7 @@ PickView::paint (HWND hwnd) } -bool +bool PickView::Create (Window * parent, DWORD Style, RECT *r) { @@ -947,7 +956,7 @@ PickView::defaultTrust (trusts trust) { pkg.desired = pkg.trustp (trust); if (pkg.desired) - pkg.desired.pick (pkg.desired.accessible() && + pkg.desired.pick (pkg.desired.accessible() && pkg.desired != pkg.installed); } else @@ -970,7 +979,7 @@ void PickView::refresh() { HDC dc = GetDC (GetHWND ()); - + // we must set the font of the DC here, otherwise the width calculations // will be off because the system will use the wrong font metrics sysfont = GetStockObject (DEFAULT_GUI_FONT); @@ -979,12 +988,12 @@ PickView::refresh() // init headers for the current mode set_headers (); init_headers (dc); - + // save the current mode views cur_view_mode = view_mode; - + // switch to the other type and do those headers - view_mode = (view_mode == PickView::views::Category) ? + view_mode = (view_mode == PickView::views::Category) ? PickView::views::PackageFull : PickView::views::Category; set_headers (); init_headers (dc); Index: setup/net.cc =================================================================== --- setup.orig/net.cc +++ setup/net.cc @@ -136,12 +136,12 @@ NetPage::OnInit () CheckIfEnableNext(); // Check to see if any radio buttons are selected. If not, select a default. - if ((!SendMessage (GetDlgItem (IDC_NET_IE5), BM_GETCHECK, 0, 0) == + if ((!SendMessage (GetDlgItem (IDC_NET_DIRECT), BM_GETCHECK, 0, 0) == BST_CHECKED) && (!SendMessage (GetDlgItem (IDC_NET_PROXY), BM_GETCHECK, 0, 0) == BST_CHECKED)) { - SendMessage (GetDlgItem (IDC_NET_DIRECT), BM_CLICK, 0, 0); + SendMessage (GetDlgItem (IDC_NET_IE5), BM_CLICK, 0, 0); } } Index: setup/package_meta.cc =================================================================== --- setup.orig/package_meta.cc +++ setup/package_meta.cc @@ -28,6 +28,7 @@ using namespace std; #include <unistd.h> #include <strings.h> #include "getopt++/StringOption.h" +#include "getopt++/BoolOption.h" #include "io_stream.h" #include "compress.h" @@ -51,6 +52,10 @@ using namespace std; using namespace std; +static BoolOption AllInstall ( false, 'a', "all-install", "install it all"); +static BoolOption UnInstall ( false, 'u', "un-install", "un-install it all"); +static BoolOption ReInstall ( false, 'e', "re-install", "re-Install it all"); + /*****************/ const @@ -66,6 +71,18 @@ const packagemeta::_actions packagemeta::Uninstall_action (3); +packagemeta::_actions packagemeta::action_from_argv() +{ + + return + ( + (AllInstall)? packagemeta::Install_action : + (UnInstall)? packagemeta::Uninstall_action : + (ReInstall)? packagemeta::Reinstall_action : + packagemeta::Default_action + ); +} + char const * packagemeta::_actions::caption () { Index: setup/package_meta.h =================================================================== --- setup.orig/package_meta.h +++ setup/package_meta.h @@ -24,6 +24,7 @@ class category; #include <set> #include "PackageTrust.h" #include "package_version.h" +#include <iostream> typedef std::pair<const std::string, std::vector<packagemeta *> > Category; @@ -39,6 +40,7 @@ public: { } + void _printcanon(); packagemeta (const std::string& pkgname, const std::string& installedfrom):name (pkgname), key(pkgname), installed_from (installedfrom), @@ -56,6 +58,8 @@ public: bool hasNoCategories() const; void setDefaultCategories(); void addToCategoryAll(); + void addToCategoryBase(); + bool isManuallyWanted() const; class _actions { @@ -66,17 +70,22 @@ public: if (_value < 0 || _value > 3) _value = 0; } + +// _actions & operator= (int val); _actions & operator ++ (); bool operator == (_actions const &rhs) { return _value == rhs._value; } bool operator != (_actions const &rhs) { return _value != rhs._value; } + const char *caption (); private: int _value; }; + static const _actions Default_action; static const _actions Install_action; static const _actions Reinstall_action; static const _actions Uninstall_action; + static _actions action_from_argv(); void set_action (packageversion const &default_version); void set_action (_actions, packageversion const & default_version); void uninstall (); @@ -142,6 +151,7 @@ public: void logSelectionStatus() const; void logAllVersions() const; + protected: packagemeta &operator= (packagemeta const &); private:
difforig setup-2.588 Index: setup/install.cc =================================================================== --- setup.orig/install.cc +++ setup/install.cc @@ -135,7 +135,6 @@ Installer::StandardDirs[] = { static int num_installs, num_uninstalls; static void md5_one (const packagesource& source); -static bool rebootneeded; void Installer::preremoveOne (packagemeta & pkg) @@ -636,6 +635,9 @@ do_install_thread (HINSTANCE h, HWND own exit_msg = IDS_INSTALL_INCOMPLETE; else if (!unattended_mode) exit_msg = IDS_INSTALL_COMPLETE; + + if (rebootneeded) + exit_msg = IDS_REBOOT_REQUIRED; } static DWORD WINAPI Index: setup/main.cc =================================================================== --- setup.orig/main.cc +++ setup/main.cc @@ -200,8 +200,11 @@ main (int argc, char **argv) // Clean exit.. save user options. UserSettings::Instance().saveAllSettings(); - - theLog->exit (0); + if (rebootneeded) { + theLog->exit (IDS_REBOOT_REQUIRED); + } else { + theLog->exit (0); + } } TOPLEVEL_CATCH("main"); Index: setup/msg.cc =================================================================== --- setup.orig/msg.cc +++ setup/msg.cc @@ -29,6 +29,7 @@ static const char *cvsid = #include <stdio.h> #include <stdarg.h> #include "dialog.h" +#include "state.h" void msg (const char *fmt, ...) @@ -50,6 +51,27 @@ mbox (HWND owner, const char *name, int vsnprintf (buf, 1000, fmt, args); log (LOG_PLAIN) << "mbox " << name << ": " << buf << endLog; + if (unattended_mode) { + // Return some default values. + log (LOG_PLAIN) << "unattended_mode is set at mbox: returning default value" << endLog; + switch (type & MB_TYPEMASK) + { + case MB_OK | MB_OKCANCEL: + return IDOK; + break; + case MB_YESNO | MB_YESNOCANCEL: + return IDYES; + break; + case MB_ABORTRETRYIGNORE: + return IDIGNORE; + break; + case MB_RETRYCANCEL: + return IDCANCEL; + break; + default: + return 0; + } + } return MessageBox (owner, buf, "Cygwin Setup", type); } Index: setup/package_db.cc =================================================================== --- setup.orig/package_db.cc +++ setup/package_db.cc @@ -401,6 +401,7 @@ packagedb::setExistence () void packagedb::fillMissingCategory () { + for_each(packages.begin(), packages.end(), visit_if(mem_fun(&packagemeta::addToCategoryBase), mem_fun(&packagemeta::isManuallyWanted))); for_each(packages.begin(), packages.end(), visit_if(mem_fun(&packagemeta::setDefaultCategories), mem_fun(&packagemeta::hasNoCategories))); for_each(packages.begin(), packages.end(), mem_fun(&packagemeta::addToCategoryAll)); } Index: setup/package_db.h =================================================================== --- setup.orig/package_db.h +++ setup/package_db.h @@ -47,6 +47,7 @@ public: void fillMissingCategory(); void markUnVisited(); void setExistence(); + void addFromCmdLine(); /* all seen binary packages */ static std::vector < packagemeta *> packages; /* all seen source packages */ Index: setup/package_meta.cc =================================================================== --- setup.orig/package_meta.cc +++ setup/package_meta.cc @@ -27,6 +27,7 @@ using namespace std; #include <stdlib.h> #include <unistd.h> #include <strings.h> +#include "getopt++/StringOption.h" #include "io_stream.h" #include "compress.h" @@ -242,6 +243,26 @@ hasSDesc(packageversion const &pkg) return pkg.SDesc().size(); } +static StringOption PackageOption ("", 's', "software", "Software packages to include"); + +bool packagemeta::isManuallyWanted() const +{ + string packages_option = PackageOption; + string tname; + /* Split the packages listed in the option up */ + string::size_type loc = packages_option.find(",",0); + bool bReturn = false; + while ( loc != string::npos ) { + tname = packages_option.substr(0,loc); + packages_option = packages_option.substr(loc+1); + bReturn = bReturn || (name.compare(tname) == 0); + loc = packages_option.find(",",0); + } + /* At this point, no "," exists in packages_option */ + bReturn = bReturn || (name.compare(packages_option) == 0); + return bReturn; +} + const std::string packagemeta::SDesc () const { @@ -647,6 +668,12 @@ packagemeta::ScanDownloadedFiles () referenced are unselectable anyway. */ } +void +packagemeta::addToCategoryBase() +{ + add_category ("Base"); +} + bool packagemeta::hasNoCategories() const { Index: setup/state.cc =================================================================== --- setup.orig/state.cc +++ setup/state.cc @@ -23,6 +23,7 @@ static const char *cvsid = #include "state.h" bool unattended_mode; +bool rebootneeded; int source; Index: setup/state.h =================================================================== --- setup.orig/state.h +++ setup/state.h @@ -32,6 +32,7 @@ #include <string> extern bool unattended_mode; +extern bool rebootneeded; extern int source;
2008-05-28 Servaas Goossens <sgoossens-AT-ortec.nl> * root.cc (OnInit): Two new BoolOptions (TextModeOption, CurrentUserOption). These new options (-t and -c) allow the use of text-mode mounts and user mounts for unattended setups. diff -u setup/root.cc.orig setup/root.cc --- setup/root.cc.orig 2006-04-06 16:45:19.000000000 +0000 +++ setup/root.cc 2008-06-24 11:19:29.078125000 +0000 @@ -39,10 +39,15 @@ #include "mount.h" #include "getopt++/StringOption.h" +#include "getopt++/BoolOption.h" using namespace std; -StringOption RootOption ("", 'R', "root", "Root installation directory", false); +static StringOption RootOption ("", 'R', "root", "Root installation directory", false); +static BoolOption TextModeOption (false, 't', "text-mode", "Use text mode mount for root directory"); +static BoolOption CurrentUserOption (false, 'c', "current-user-only", +"Make cygwin available to the current user only"); + static ControlAdjuster::ControlInfo RootControlsInfo[] = { { IDC_ROOTDIR_GRP, CP_STRETCH, CP_TOP }, @@ -196,8 +201,14 @@ { makeClickable (IDC_FILEMODES_LINK, "http://cygwin.com/cygwin-ug-net/using-textbinary.html"); + if (((string)RootOption).size()) set_root_dir((string)RootOption); + if (TextModeOption) + root_text = IDC_ROOT_TEXT; + if (CurrentUserOption) + root_scope = IDC_ROOT_USER; + if (!get_root_dir ().size()) read_mounts (); load_dialog (GetHWND ());
6689-goossens-rev1-rh.patch 6688-switch-p-rh.patch 854-peschko-cmdlines-rh.patch