socsvn commit: r253467 - soc2013/mattbw/backend
mattbw at FreeBSD.org
mattbw at FreeBSD.org
Tue Jun 25 01:20:36 UTC 2013
Author: mattbw
Date: Tue Jun 25 01:20:35 2013
New Revision: 253467
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253467
Log:
hook up get-details to licence NAME getter (for some reason get-details wants name and not enum, may need to ask about this...).
Modified:
soc2013/mattbw/backend/get-details.c
soc2013/mattbw/backend/licenses.c
soc2013/mattbw/backend/licenses.h
Modified: soc2013/mattbw/backend/get-details.c
==============================================================================
--- soc2013/mattbw/backend/get-details.c Tue Jun 25 01:12:25 2013 (r253466)
+++ soc2013/mattbw/backend/get-details.c Tue Jun 25 01:20:35 2013 (r253467)
@@ -25,8 +25,11 @@
#include "pkg.h"
#include "db.h" /* open_remote_db */
-#include "groups.h" /* group_from_origin */
#include "get-details.h" /* get_details_thread prototype */
+#include "groups.h" /* group_from_origin */
+#include "licenses.h" /* license_from_pkg */
+
+static const int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_LICENSES;
/* TODO: move out of get-details? */
const char *null_if_empty(const char *in);
@@ -88,7 +91,7 @@
found = FALSE;
match = NULL;
do {
- err = pkgdb_it_next(matches, &match, PKG_LOAD_BASIC);
+ err = pkgdb_it_next(matches, &match, LOAD_FLAGS);
if (err == EPKG_OK) {
const char *arch;
const char *data;
@@ -140,7 +143,7 @@
/* TODO: implement category, size and licence */
pk_backend_details(backend,
new_id,
- NULL,
+ license_name_from_pkg(match),
group_from_origin(origin),
description,
www,
Modified: soc2013/mattbw/backend/licenses.c
==============================================================================
--- soc2013/mattbw/backend/licenses.c Tue Jun 25 01:12:25 2013 (r253466)
+++ soc2013/mattbw/backend/licenses.c Tue Jun 25 01:20:35 2013 (r253467)
@@ -18,13 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "pkg.h" /* struct pkg, etc */
-#include "pk-backend.h" /* PkLicenseEnum, PK_* */
+#include "pkg.h" /* struct pkg, etc */
+#include "pk-backend.h" /* PkLicenseEnum, PK_* */
-#include "licenses.h" /* prototypes */
-#include "mappings.h" /* mapping macros */
-
-static const char * license_name_from_pkg(struct pkg *pkg);
+#include "licenses.h" /* prototypes */
+#include "mappings.h" /* mapping macros */
struct license_mapping {
const char *key;
@@ -32,9 +30,9 @@
};
/*
- * Mappings between the output of "pkg_license_name" and the closest available
- * PackageKit license.
- *
+ * Mappings between the output of "pkg_license_name" and the closest
+ * available PackageKit license.
+ *
* These should ALWAYS be in ASCIIbetical order of license names. This is in
* case anything relies on this property when searching the list (for example
* binary searching).
@@ -44,24 +42,26 @@
{NULL, PK_LICENSE_ENUM_UNKNOWN}
};
-/* Returns the closest approximation packagekit has to this package's license.
- *
+/*
+ * Returns the closest approximation packagekit has to this package's
+ * license.
+ *
* PackageKit only has a simple concept of licencing, so this is inherently a
* very lossy mapping.
*/
PkLicenseEnum
license_from_pkg(struct pkg *pkg)
{
- const char *pkg_license_name;
+ const char *pkg_license_name;
struct license_mapping *map;
- PkLicenseEnum result;
+ PkLicenseEnum result;
pkg_license_name = license_name_from_pkg(pkg);
- /* Is it in our manual license mapping?
- * If not, then try interpreting it as a PackageKit license name and
- * convert it back (messy, but hopefully safe), but only if it isn't
- * NULL.
+ /*
+ * Is it in our manual license mapping? If not, then try interpreting
+ * it as a PackageKit license name and convert it back (messy, but
+ * hopefully safe), but only if it isn't NULL.
*/
MAPPING_FIND(pkg_license_name, &map, license_mappings);
if (pkg_license_name != NULL && map->key == NULL)
@@ -73,11 +73,11 @@
}
/* Retrieves the name of the FIRST license attached to the package. */
-static const char *
+const char *
license_name_from_pkg(struct pkg *pkg)
{
- int err;
- const char *match;
+ int err;
+ const char *match;
struct pkg_license *lic;
lic = NULL;
Modified: soc2013/mattbw/backend/licenses.h
==============================================================================
--- soc2013/mattbw/backend/licenses.h Tue Jun 25 01:12:25 2013 (r253466)
+++ soc2013/mattbw/backend/licenses.h Tue Jun 25 01:20:35 2013 (r253467)
@@ -24,5 +24,6 @@
#include "pk-backend.h"
PkLicenseEnum license_from_pkg(struct pkg *pkg);
+const char *license_name_from_pkg(struct pkg *pkg);
#endif /* _PKGNG_BACKEND_LICENSES_H_ */
More information about the svn-soc-all
mailing list