]>
cygwin.com Git - cygwin-apps/setup.git/blob - cygpackage.cc
2 * Copyright (c) 2001, 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 <rbtcollins@hotmail.com>
16 /* this is the parent class for all package operations.
20 static const char *cvsid
=
24 #include "cygpackage.h"
29 #include "io_stream.h"
32 #include "package_version.h"
33 #include "cygpackage.h"
34 #include "LogSingleton.h"
36 /* this constructor creates an invalid package - further details MUST be provided */
37 cygpackage::cygpackage ():
45 status (package_installed
),
46 type (package_binary
),
50 memset( getfilenamebuffer
, '\0', MAX_PATH
);
52 /* FIXME: query the install database for the currently installed
58 cygpackage::createInstance (const std::string
& pkgname
,
59 const package_type_t type
)
61 cygpackage
*temp
= new cygpackage
;
64 return packageversion(temp
);
68 cygpackage::createInstance (const std::string
& pkgname
,
69 const std::string
& filename
,
70 const std::string
& version
,
71 package_status_t
const newstatus
,
72 package_type_t
const newtype
)
74 cygpackage
*temp
= new cygpackage
;
77 temp
->status
= newstatus
;
79 temp
->setCanonicalVersion (version
);
80 return packageversion(temp
);
83 /* tell the version */
85 cygpackage::setCanonicalVersion (const std::string
& version
)
88 char *start
= strchr (canonical
.c_str(), '-');
93 while ((next
= strchr (curr
+ 1, '-')))
95 /* curr = last - in the version string */
97 char tvendor
[version
.size() +1];
98 strcpy (tvendor
, version
.c_str());
99 tvendor
[curr
- start
] = '\0';
104 // FIXME: What's up with the "0"? It's probably a mistake, and should be
105 // "". It used to be written as 0, and was subject to a bizarre implicit
106 // conversion by the unwise String(int) constructor.
112 cygpackage::~cygpackage ()
117 /* helper functions */
120 cygpackage::destroy ()
125 cygpackage::getfirstfile ()
130 io_stream::open ("cygfile:///etc/setup/" + name
+ ".lst.gz", "rb", 0);
131 listdata
= compress::decompress (listfile
);
133 return std::string();
134 /* std::string(NULL) will crash, so be careful to test for that. */
135 const char *result
= listdata
->gets (getfilenamebuffer
, sizeof (getfilenamebuffer
));
137 log (LOG_PLAIN
) << "Corrupt package listing for " << name
<< ", can't uninstall old files." << endLog
;
138 return std::string (result
? result
: "");
142 cygpackage::getnextfile ()
146 /* std::string(NULL) will crash, so be careful to test for that. */
147 const char *sz
= listdata
->gets (getfilenamebuffer
,
148 sizeof (getfilenamebuffer
));
150 return std::string(sz
);
152 return std::string();
156 cygpackage::uninstall ()
161 io_stream::remove ("cygfile:///etc/setup/" + name
+ ".lst.gz");
171 cygpackage::Vendor_version ()
177 cygpackage::Package_version ()
183 cygpackage::Canonical_version ()
189 cygpackage::set_sdesc (const std::string
& desc
)
195 cygpackage::set_ldesc (const std::string
& desc
)
201 package_stability_t
cygpackage::Stability ()
This page took 0.043463 seconds and 5 git commands to generate.