]>
cygwin.com Git - cygwin-apps/setup.git/blob - fromcwd.cc
2 * Copyright (c) 2000, Red Hat, Inc.
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 DJ Delorie <dj@cygnus.com>
16 /* The purpose of this file is to handle the case where we're
17 installing from files that already exist in the current directory.
18 If a setup.ini file is present, we set the mirror site to "." and
19 pretend we're installing from the `internet' ;-) else we have to
20 find all the .tar.gz files, deduce their versions, and try to
21 compare versions in the case where the current directory contains
22 multiple versions of any given package. We do *not* try to compare
23 versions with already installed packages; we always choose a
24 package in the current directory over one that's already installed
25 (otherwise, why would you have asked to install it?). Note
26 that we search recursively. */
28 static char *cvsid
= "\n%%% $Id$\n";
45 #include "filemanip.h"
51 is_test_version (char *v
)
54 for (i
=0; v
[i
] && isdigit (v
[i
]); i
++) ;
55 return (i
>= 6) ? 1 : 0;
59 canonicalize_version (char *v
)
61 static char nv
[3][100];
63 char *np
, *dp
, *ov
= v
;
73 for (dp
=v
; *dp
&& isdigit (*dp
); dp
++) ;
74 for (i
=dp
-v
; i
<12; i
++)
87 found_file (char *path
, unsigned int fsize
)
92 if (!parse_filename (path
, f
))
95 if (f
.what
[0] != '\0')
99 for (int i
= 0; i
< npackages
; i
++)
100 if (strcmp (package
[i
].name
, f
.pkg
) == 0)
107 p
= new_package (strdup (base
));
109 int trust
= is_test_version (f
.ver
) ? TRUST_TEST
: TRUST_CURR
;
111 /* See if this version is older than what we have */
112 if (p
->info
[trust
].version
)
114 char *ov
= canonicalize_version (p
->info
[trust
].version
);
115 char *nv
= canonicalize_version (f
.ver
);
116 if (strcmp (ov
, nv
) > 0)
120 p
->info
[trust
].version
= _strdup (f
.ver
);
121 p
->info
[trust
].install
= _strdup (path
);
122 p
->info
[trust
].install_size
= fsize
;
126 do_fromcwd (HINSTANCE h
)
128 if (_access ("./setup.ini", 0) == 0)
131 next_dialog
= IDD_S_LOAD_INI
;
135 next_dialog
= IDD_CHOOSE
;
137 find (".", found_file
);
139 // Now see about source tarballs
142 char srcpath
[_MAX_PATH
];
143 for (i
= 0; i
< npackages
; i
++)
146 for (t
= TRUST_PREV
; t
<= TRUST_TEST
; t
++)
147 if (p
->info
[t
].install
)
149 int n
= find_tar_ext (p
->info
[t
].install
);
150 strcpy (srcpath
, p
->info
[t
].install
);
151 strcpy (srcpath
+ n
, "-src.tar.gz");
152 msg ("looking for %s", srcpath
);
155 HANDLE h
= FindFirstFile (srcpath
, &wfd
);
156 if (h
== INVALID_HANDLE_VALUE
)
158 strcpy (srcpath
+ n
, "-src.tar.bz2");
159 h
= FindFirstFile (srcpath
, &wfd
);
161 if (h
!= INVALID_HANDLE_VALUE
)
165 p
->info
[t
].source
= _strdup (srcpath
);
166 p
->info
[t
].source_size
= wfd
.nFileSizeLow
;
This page took 0.043607 seconds and 5 git commands to generate.