Jon Turney [Wed, 14 Dec 2016 00:00:02 +0000 (00:00 +0000)]
Make package size and checksum mandatory in setup.ini
The setup.ini grammar is written such that size and checksum are optional in
install: lines, and checksum is optional in source: lines. Presumably this
had some historical use.
Change to make package size and checksum mandatory.
Future work: We keep the asymmetry between install: and source: where
buildPackageSource() sets both pathname and size, but buildPackageInstall()
only sets pathname, relying on a separate buildInstallSize() to set the size
later for the moment, as fixing that ripples through to other place.
Jon Turney [Wed, 31 Aug 2016 10:31:22 +0000 (11:31 +0100)]
Allow setup to parse more than 3 versions from the setup.ini file
This recognizes any "[foo]" line as introducing the information for another
version, which doesn't have one of the trust levels [curr], [prev] or
[test], and so isn't automatically selected when setup is told to install
all packages at that trust level (by default, [curr]).
Setup already does all the necessary sorting in version order etc. to use
these additional versions.
The value of <foo> carries no meaning, but the setup.ini specification
will be amended to mandate the use of "[ver<digits>]".
* PackageTrust.h (trusts): Add TRUST_OTHER.
* inilex.ll: tokenize any other [version] as the T_OTHER token.
* iniparse.yy: Add T_OTHER token and set package trust
to TRUST_OTHER when it is used.
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Jon Turney [Tue, 22 Nov 2016 16:05:58 +0000 (16:05 +0000)]
Strip symbols to setup.dbg
As noted in https://cygwin.com/ml/cygwin/2016-11/msg00254.html debugging the
distributed setup executable is a lost cause at the moment. Preserve
symbols so it's not quite as hopeless.
Note: to debug the distributed setup executable with gdb, it will be
necessary to decompress the setup executable with 'upx -d', and, if the .dbg
file has been renamed to match the renamed setup executable, explicitly load
it into gdb with the 'symbol-file' command.
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Jon Turney [Thu, 1 Sep 2016 19:30:44 +0000 (20:30 +0100)]
Refuse to run on Windows XP and earlier
Refuse to run on Windows versions less than 6.0 (XP or previous), as they
are no longer supported by Cygwin.
Future work: The version checked against should be read from setup.ini,
rather than hard-coded here, so that this version of setup cannot be used to
download a future version of Cygwin which isn't compatible with the Windows
version it's running on...
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Jon Turney [Thu, 1 Sep 2016 18:21:55 +0000 (19:21 +0100)]
Fix incorrect heap memory access in SimpleSocket::gets()
nl is dereferenced to check if it's '\n' or '\r', before we check if we have
passed the start of the buffer. Re-order the check so we check if we have
passed the start of the buffer first.
Fix scope problem when using the return value of get_root_dir()
Let get_root_dir return a reference instead of a temporary
std::string object. In directory_is_absolute() and
directory_is_rootdir(), use std::string methods rather than
falling back to plain C techniques.
Jon Turney [Wed, 3 Aug 2016 21:15:25 +0000 (22:15 +0100)]
Build C++ code with -std=gnu++11
Use BASECXXFLAGS rather then AM_CXXFLAGS to make AM_CFLAGS
Rationalize BASECXXFLAGS, adding -Werror and removing -Wno-uninitialized
(since the bug preventing it being used is long fixed)
Fix a bug detected by -Wuninitialized
Build C++ code with -std=gnu++11 -Wno-deprecated-declarations
Jon Turney [Mon, 1 Aug 2016 17:05:14 +0000 (18:05 +0100)]
Add an additional filter view, showing packages which were user picked
Add an additional filter view, showing installed packages which were
selected for installation by the user, not installed as dependencies.
Future work:
Why is PickView::views is not an enum?
The view button would make more sense as a pop-up menu, allowing a specific
filter view to be directly selected, rather than cycling around the possible
filter views (and this situation is made worse by adding another filter
view)
Jon Turney [Tue, 2 Aug 2016 11:19:09 +0000 (12:19 +0100)]
Track if a package was installed by user, or as a dependency
Update the installed.db file format to version 3, containing the user_picked
flag.
This extends the semantics of user_pick somewhat: currently it is only used
for UI purposes, to record if a package was picked in the current session.
Now we also use it to record if an installed package has ever been picked
via the UI (otherwise it is only installed because it is a dependency).
So, we are careful not to set it when a currently installed package has it's
installed version adjusted via the GUI.
We also arrange for user_pick to be set when a package was selected for
installation via CLI.
Add a heuristic to initially populate user_pick when upgrading from older
installed.db formats: All non-base installed packages which aren't
dependencies are assumed to be user_pick-ed.
Note: other tools (e.g. cygcheck) which read the installed.db file will need
updating appropriately
v2:
Don't gratuitously break compatiblity with other existing readers of
installed.db, keep recording version as a notional filename.
Don't treat unknown future installed.db format versions as format version 1,
instead treat setup downgrading as a fatal error.
After rearranging the chooser controls in commit 6a36f6a,
the search field wasn't the first control anymore, thus it
didn;'t have the focus anymore. Fix that by setting the focus
to the search field explicitely in ChooserPage::OnInit.
Achim Gratz [Tue, 2 Aug 2016 08:47:43 +0000 (10:47 +0200)]
fromcwd.cc: Truncate search at the first extension in preference order
* fromcwd.cc (FindVisitor): Truncate search at the first extension
found in preference order in the same directory so that no multiple
setup files for the same (sub-)mirror are processed by do_local_ini.
* proppage.h (PropertyPage)
New member OnTimerMessage (delegates similarly to OnMouseWheel)
* proppage.cc
(DialogProc) Added handling of WM_TIMER
* choose.h (ChooserPage)
(OnTimerMessage) New function prototype
(timer_id) New member variable
Added DEFINE-ed default values for timer_id and search timer delay
Reorganized private members for consistency
* choose.cc
(constructor) Initialize timer_id
(OnMessageCmd) Replaced search-refresh with a SetTimer
(OnSearchTimer) New; contains search-refresh removed from OnMessageCmd
* IniDBBuilderPackage.cc (buildSourceSHA512): The source package is
using a different package version object than the binary package, so
we must use cspv here.
Yaakov Selkowitz [Fri, 11 Mar 2016 21:44:43 +0000 (22:44 +0100)]
Switch to "pending" page instead of category when updating or manually installing packages
* choose.cc (ChooserPage::createListview): When updating or manually
installing packages, switch directly to the "pending" page of the
chooser window instead of the categories since presumably that's
where the user wants to check what is going to happen.
Achim Gratz [Fri, 11 Mar 2016 19:05:15 +0000 (20:05 +0100)]
Implement option -f/--force-current to ensure that "curr" is selected for all packages
* choose.cc (ForceCurrentOption): New boolean option
-f/--force-current.
(ChooserPage::OnInit): Select "curr" version of the package when
ForceCurrentOption is true. This is mainly useful to downgrade packages
that were previously installed with their "test" version back to
"curr".
* Makefile.am (@SETUP@_LDADD): Link with ws2_32 instead of wsock32.
* nio-ftp.cc: Include winsock2.h instead of winsock.h.
* nio-http.cc: Ditto.
* simpsock.cc: Ditto.
Jon Turney [Tue, 20 Oct 2015 12:25:11 +0000 (13:25 +0100)]
Don't stop on various warning message boxes in unattended mode.
Change simple uses of MessageBox() to use the mbox() wrapper for MessageBox(),
which knows what to do in unattended mode.
There still remain the uses of MessageBox() which check the result, as these
need more detailed study, to choose an appropriate default for unattended mode.
Michael Bisbjerg [Fri, 18 Sep 2015 13:31:37 +0000 (14:31 +0100)]
Avoid double-slashes in URLs
I noticed once I set up a mirror of my own, that Cygwin Setup will
prepend all it's URL's with a double-slash. This does not seem to be
intentional, and I found the place in the sources where I believe the
error to be.
On line 160 of "download.cc", we see that the "n->key" is the source
of the repository, including a "/", as it is used as the name of the
local cache, which always has a "%2f" in its name. That key is then
used on line 165 in "get_url_to_file", where it is concatenated with
another slash and "pkgsource.Canonical" to make the final URL.
My (untested) patch removes this slash, so that the resulting URL's
will be with a single slash.
Achim Gratz [Sun, 18 Oct 2015 17:27:42 +0000 (19:27 +0200)]
Fix signature check for local directory installation and record names of local mirror directories
* ini.cc (check_ini_sig): Do not complain about a missing
signature file when installing from localdir. If it is present it
still must be checked, however. The "download only" mode should
pull down both the (compressed) setup file and the corresponding
signature (not yet implemented).
(do_local_ini): The builder needs to know the (unescaped) mirror
name it's associated with in order for the file validation to
work. The found_ini_list should directly provide the constituent
parts so that we don't need to extract them (not yet implemented).
* fromcwd.cc (FindVisitor): Remove superfluous path separator and
simply use SetupArch (which has previously compared equal to
aDir->cFileName) when constructing the setup file name.
* Makefile.am (GITVER): Do not use an explicit HEAD parameter and
add the "--dirty" option so that builds with uncommitted changes
get marked appropriately.
Achim Gratz [Tue, 4 Aug 2015 17:48:56 +0000 (19:48 +0200)]
Properly record SHA512 checksum presence and skip validation for ad-hoc installs
* package_source.h (packagesource): Add boolean member variable
sha512_isSet to record whether an SHA512 checksum has been set.
(packagesource): Initialize sha512_isSet to false.
* IniDBBuilderPackage.cc (buildInstallSHA512, buildSourceSHA512):
Only set the SHA512 checksum when it was previously unset like it
is done for MD5 checksums. That will generally be the checksum
recorded on the package line in setup.ini, any further checksums
in separate lines will thus be ignored.
* install.cc (chksum_one): Conditionalize the comparison of the
SHA512 checksum on whether or not it was previously set. Check
SHA512 checksum first since it is the default now. This is
necessary for ad-hoc installs from local disk without a setup.ini
file. Output a warning when the checksum was not be verified
because neither a MD5 nor a SHA512 checksum was set.
Achim Gratz [Mon, 3 Aug 2015 19:23:37 +0000 (21:23 +0200)]
Simplify parser, both SHA512 checksum types can parse to the same token
* inilex.ll: Introduce HEX and B64 definitions, use them in the
rules section. Parse both SHA512 and SHA512-Base64URL checksums
to the SHA512 token.
* iniparse.yy (packagedata): Remove all occurences of the
SHA512B64URL token.
Achim Gratz [Mon, 3 Aug 2015 19:19:53 +0000 (21:19 +0200)]
If MD5 checksum is missing then SHA512 must always be checked
* install.cc (chksum_one): If MD5 checksum is not available, then
SHA512 must always be checked even if just against the zeroed
digest as initialized. Otherwise a package with no checksum would
be treated as valid.
Achim Gratz [Mon, 3 Aug 2015 19:04:10 +0000 (21:04 +0200)]
Fix bug in nibbled1 and use character types throughout
* ini.h (nibbled1): Fix a thinko in this macro that made the
result always zero.
(hexnibble, nibbled1, b64url, b64d1, b64d2, b64d3): Use character
literals for all numeric constants dealing with characters.
Remove trailing semicolons.
David Hoke [Wed, 26 Jun 2013 19:13:48 +0000 (19:13 +0000)]
Implement -I/--include-source option to download and install sources automatically
* download.cc (IncludeSource): New command line switch
-I/--include-source. Automatically download sources
associated with any binary package being downloaded when
IncludeSource is true.
* install.cc (do_install_thread): Automatically install
sources associated with any binary package being installed
when IncludeSource is true.
Achim Gratz [Sat, 9 May 2015 18:25:43 +0000 (20:25 +0200)]
Implement -Y/--prune-install option to bring an installation into a known state
* choose.cc (PruneInstallOption): New option -Y/--prune-install.
(OnInit): Implement PruneInstallOption to downgrade packages
installed with a higher version and delete all packages not
explicitly requested to be installed. This brings an existing
installation to the same state a fresh installation would create.
Put the handling for upgrade==true into a separate else branch.
Refactor setup search and implement XZ compressed setup files
* ini.cc: Construct setup_ext_list from array until we can use
C++11 aggregate initializers. Clean up function parenthesis.
(decompress_ini): Refactored for use from do_local_ini and
do_remote_ini. Change outdated comment about setup.ini
uncompressed size.
(check_ini_sig): Factor out signature check.
(fetch_remote_ini): Refactored for use from do_remote_ini.
(do_local_ini): Iterate over search results in found_ini_list.
Use decompress_ini and check_ini_sig.
(do_remote_ini): Iterate over known setup file extensions from
setup_ext_list with early-out semantics, preferring ".xz" over
".bz2" over ".ini" extension. Use fetch_remote_ini and
check_ini_sig.
* ini.h: Remove unused macros.
* IniParseFindVisitor.cc: Remove, the search is already done by
SetupFindVisitor in do_from_local_dir.
* IniParseFindVisitor.cc: Ditto.
* Makefile.am (@SETUP@_SOURCES): Ditto.
* fromcwd.cc: Remove unused includes. Add global found_ini_list
to record the search result.
(SetupFindVisitor): Make setup.{ini,bz2,xz} known and provide bool
private variables to record whether we found them. Another bool
inidir to indicate whether we are currently inside a directory
where setup.ini files should exist.
(SetupFindVisitor::visitFile): When inidir is true, check if a
setup file with one of the known extensions was found and set the
corresponding bool variables.
(SetupFindVisitor::visitDirectory): Set inidir when appropriate.
Recurse into directories only if they are potential mirror dirs,
based on level. Truncate search and recurse into inidir. Record
any setup files in found_ini_list while preferring ".xz" over
".bz2" over ".ini" extension.
(SetupFindVisitor::operator bool): Return true when found_ini_list
is non-empty.
(do_from_local_dir): Restrict search to either a single mirror
hierarchy or multiple mirror hierarchy; setup files directly in
local directory or mixed hierarchies are no longer recognized.
The setup files must be present in an architecture dependent
directory of "x86/" or "x86_64/", either in the local directory
for single mirror or one level down for multiple mirrors.
This patch already finds setup.xz files, but the code to deal with
them will be in a later patch. The current code re-does the search
and ignores the results from here.
Achim Gratz [Sun, 28 Jun 2015 11:34:11 +0000 (13:34 +0200)]
Implement option "-i/--ini-basename" to set the basename for setup
* ini.h: Declare extern SetupBaseName, SetupArch and SetupIniDir.
Redefine macros to use them.
* main.cc: Provide option "-i/--ini-basename" to set the basename
for setup, keep the default as "setup" and store in SetupBaseName.
Initialize SetupArch and SetupIniDir based on effective
architecture.
Achim Gratz [Sun, 7 Jun 2015 07:10:13 +0000 (09:10 +0200)]
Implement Base64URL-encoded SHA512 checksums
* ini.h: Add macros for use within the implementation of the
checksum parsers. Hexdigest requires a 2-to-1 and Base64 a 4-to-3
conversion. Base64 uses the filename and URL safe alphabet from
RFC4648. It would be trivial to additionally process the normal
Base64 alphabet but we don't want to allow that in order to be
able to use the checksums as filenames without further conversion.
(hexnibble, b64url): Process single input character to input value.
(nibbled1): Convert 2 processed input values into 1 output value.
(b64d1, b64d2, b64d3): Convert 4 input values into 3 output
values.
* iniparse.yy: Add SHA512B64URL checksum in addition to MD5 and
SHA512. Keep symmetry with MD5LINE and also define SHA512LINE
syntax.
* inilex.ll: Implement existing MD5 and SHA512 checksum parsers
using new macros. Implement new SHA512B64URL parser using new
macros. Enforce Base64 alphabet as defined in RFC4648 with no
padding to enable direct use of checksum values as filenames.
Implement SHA512LINE parser.
Jon TURNEY [Tue, 3 Mar 2015 13:28:48 +0000 (13:28 +0000)]
Remove msg() and convert to log output
Remove msg(), which writes output to the debugger via OutputDebugString() and
convert it's uses to log output using the printf-style log adaptors.
Examining the uses of msg(), some of these are genuine errors, which should be
logged somewhere we might have a chance to see them. Convert those to
LOG_PLAIN. Convert the other uses of msg() for debug output to LOG_BABBLE.
ChangeLog:
2015-03-04 Jon TURNEY <jon.turney@dronecode.org.uk>
Jon TURNEY [Mon, 2 Mar 2015 13:35:40 +0000 (13:35 +0000)]
Remove msg() from LogFile::endEntry()
Every single line of log output is written to OutputDebugString() using msg().
This makes setup run quite slowly under a debugger. If you have stdout
connected to the terminal where your debugger is running (e.g. 'gdb setup'),
this output is duplicated.
Future work: there are some other uses of msg() to report real errors. At the
moment, these are completely invisible unless you are running setup under a
debugger. These should be converted to use the logger.
ChangeLog:
2015-03-02 Jon TURNEY <jon.turney@dronecode.org.uk>
Jon TURNEY [Mon, 2 Mar 2015 12:10:28 +0000 (12:10 +0000)]
Don't write LOG_BABBLE output to stdout
It somewhat hampers the use of setup as a command line tool that it writes
everything to stdout. Don't write LOG_BABBLE output to stdout. Add '--verbose'
flag to restore the previous behaviour.
ChangeLog:
2015-03-02 Jon TURNEY <jon.turney@dronecode.org.uk>
* LogFile.cc (VerboseOutput): Add option.
(endEntry): Only write LOG_PLAIN to stdout, unless VerboseOutput.
Add a 'Retry' button to the IDD_FILE_INUSE dialog, to press when you want to
manually stop the processes which were preventing a file from being replaced,
after you have done so.
Unfortunately the IDD_FILE_INUSE DIALOG is already rather cramped, so define
SETUP_MEDIUM_DIALOG_DIMS for a medium-size dialog, and adjust the dialog layout
appropriately.
Also do a bit of polish on the text used: "you will need to reboot" -> "the file
will be updated after a reboot"
XXX: This text should be dynamic, and should not appear if the NoReplaceOnReboot
option has been used.
Also spread out the text in the fallback MessageBox used when we can't enumerate
the processes which have the file in-use.
XXX: Note that there is no user notification, only a log message, if scheduling
a file to be replaced on reboot failed.
ChangeLog:
2015-03-02 Jon TURNEY <jon.turney@dronecode.org.uk>
Jon TURNEY [Sun, 1 Mar 2015 14:54:03 +0000 (14:54 +0000)]
Fix truncation of "Bin?" and "Src?" column headers
It seems that the the "Bin?" and "Src? columns in the PickView are usually not
quite wide enough, and display truncated with an ellipsis, e.g. 'B...' and
'S...', which is completely unintelligible.
Try to more correctly size these colums. 3*GetSystemMetrics(SM_CXEDGE) seems to
be documented as the default value for the margin of a header control, so text
length + twice that is the minimum header width needed.
ChangeLog:
2015-03-02 Jon TURNEY <jon.turney@dronecode.org.uk>
* PickView.cc (init_headers): More correctly size "Bin?" and
"Src?" columns.
Corinna Vinschen [Wed, 18 Feb 2015 15:26:13 +0000 (16:26 +0100)]
Choose curr package when user picks not yet installed package for the first time
* PickPackageLine.cc (PickPackageLine::click): Call
packagemeta::set_action with current trust level as argument.
* package_meta.cc (packagemeta::set_action): Take trust level as
argument. When the user picks a package for the first time (from
"Skip"), pick the version matching the current trust level. Improve
comments.
* package_meta.h (class packagemeta): Add member user_picked.
(packagemeta::packagemeta): Initialize user_picked to false.
(packagemeta::set_action): Align prototype to above change.