]>
cygwin.com Git - cygwin-apps/setup.git/blob - ScanFindVisitor.cc
2 * Copyright (c) 2002 Robert Collins.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <robertc@hotmail.com>
17 static const char *cvsid
=
21 #include "ScanFindVisitor.h"
22 #include "filemanip.h"
23 #include "IniDBBuilder.h"
25 ScanFindVisitor::ScanFindVisitor(IniDBBuilder
&aBuilder
) : _Builder (aBuilder
) {}
26 ScanFindVisitor::~ScanFindVisitor(){}
28 /* look for potential packages we can add to the in-memory package
32 ScanFindVisitor::visitFile(String
const &basePath
, const WIN32_FIND_DATA
*theFile
)
34 // Sanity check: Does the file look like a package ?
36 if (!parse_filename (theFile
->cFileName
, f
))
39 // Sanity check: Zero length package files get thrown out.
40 if (!(theFile
->nFileSizeLow
|| theFile
->nFileSizeHigh
))
43 // Build a new package called f.pkg
44 _Builder
.buildPackage (f
.pkg
);
46 // Set the version we are bulding
47 _Builder
.buildPackageVersion (f
.ver
);
49 // Add the file as a installable package
52 _Builder
.buildPackageInstall (basePath
+ theFile
->cFileName
, theFile
->nFileSizeLow
);
54 // patch or src, assume src until someone complains
55 _Builder
.buildPackageSource (basePath
+ theFile
->cFileName
, theFile
->nFileSizeLow
);
57 // TODO: Review the below code. We may wish to reinstate it *somewhere*.
60 /* Scan existing package list looking for a match between a known
61 package and a tar archive on disk.
62 While scanning, keep track of appropriate "holes" in the trust
63 table where a tar file could be put if no known entry
66 We have 4 specific insertion points and one generic point.
67 The generic point is in versioned order in the package version array.
68 The specific points are
74 if the version number matches a version in the db,
75 we simply add this as a mirror source to that version.
76 If it matches no version, we add a new version to the db.
78 Lastly if the version number does not matche one of installed/prev/current/exp
79 AND we had to create a new version entry
80 we apply the following heuristic:
81 if there is no exp, we link this in exp.
82 If there is an exp and this is higher, we link this in exp, and
83 if there is no curr, bump what was in exp to curr. If there was a curr, we leave it be.
84 if this is lower than exp, and there is no curr, link as curr. If there is a curr, leave it be.
85 If this is lower than curr, and there is no prev, link as prev, if there is a prev, leave it be.
87 Whilst this logic is potentially wrong from time to time, it guarantees that
88 setup.ini defined stability won't be altered unintentially. An alternative is to
89 mark setup.ini defined prev/curr/exp packages as such, when this algorithm, can
92 So, if setup.ini knows that ash-20010425-1.tar.gz is the current
93 version and there is an ash-20010426-1.tar.gz in the current directory,
94 the 20010426 version will be placed in the "test" slot, assuming that
95 there is no test version listed in setup.ini. */
98 for (size_t n
= 1; n
<= pkg
->versions
.number (); n
++)
100 if (!f
.ver
.casecompare (pkg
->versions
[n
]->Canonical_version ()))
102 if (f
.what
== String ())
105 pkg
->versions
[n
]->bin
.set_cached (String ("file://") + basePath
+ theFile
->cFileName
);
107 else if (f
.what
== "src")
110 pkg
->versions
[n
]->src
.set_cached (String ("file://") + basePath
+ theFile
->cFileName
);
118 // Do we want old versions to show up
119 packageversion
*pv
= new cygpackage (f
.pkg
);
120 ((cygpackage
*) pv
)->set_canonical_version (f
.ver
);
122 pv
->bin
.set_cached (String ("file://") + path
);
124 // patch or src, assume src until someone complains
125 pv
->src
.set_cached (String ("file://") + path
);
126 pkg
->add_version (*pv
);
130 /* And now the hole finder */
133 pkg
->exp
= thenewver
;
134 else if (strcasecmp (f
.ver
, pkg
->versions
[n
]->Canonicalversion ()) < 0)
137 pkg
->curr
= thenewver
;
138 else if (strcasecmp (f
.ver
, pkg
->versions
[n
]->Canonicalversion ()) <
142 pkg
->prev
= thenewver
;
This page took 0.042709 seconds and 5 git commands to generate.