From owner-svn-soc-all@FreeBSD.ORG Sun Jul 7 02:25:57 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B5B4D2FD for ; Sun, 7 Jul 2013 02:25:57 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A67051CF4 for ; Sun, 7 Jul 2013 02:25:57 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r672Pvl1005614 for ; Sun, 7 Jul 2013 02:25:57 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r672Pvjf005597 for svn-soc-all@FreeBSD.org; Sun, 7 Jul 2013 02:25:57 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 7 Jul 2013 02:25:57 GMT Message-Id: <201307070225.r672Pvjf005597@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254274 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 02:25:57 -0000 Author: mattbw Date: Sun Jul 7 02:25:56 2013 New Revision: 254274 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254274 Log: more currently fruitless work on installfiles; fix getfiles Modified: soc2013/mattbw/backend/actions/actions.h soc2013/mattbw/backend/actions/get-files.c soc2013/mattbw/backend/actions/install-files.c soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/actions/actions.h ============================================================================== --- soc2013/mattbw/backend/actions/actions.h Sun Jul 7 01:52:05 2013 (r254273) +++ soc2013/mattbw/backend/actions/actions.h Sun Jul 7 02:25:56 2013 (r254274) @@ -31,8 +31,9 @@ gboolean get_details_thread(PkBackend *backend); gboolean get_files_thread(PkBackend *backend); gboolean get_repo_list_thread(PkBackend *backend); -gboolean install_packages_thread(PkBackend *backend); gboolean install_files_thread(PkBackend *backend); +gboolean install_packages_thread(PkBackend *backend); +gboolean simulate_install_files_thread(PkBackend *backend); gboolean simulate_install_packages_thread(PkBackend *backend); #endif /* !_PKGNG_BACKEND_ACTIONS_H_ */ Modified: soc2013/mattbw/backend/actions/get-files.c ============================================================================== --- soc2013/mattbw/backend/actions/get-files.c Sun Jul 7 01:52:05 2013 (r254273) +++ soc2013/mattbw/backend/actions/get-files.c Sun Jul 7 02:25:56 2013 (r254274) @@ -56,12 +56,11 @@ { gboolean success; int err; - int sb_err; - char *filenames; struct pkg_file *file; struct sbuf *sb; success = FALSE; + file = NULL; /* * Construct a string of the form ";file1;file2;file3;...". We'll get @@ -71,22 +70,21 @@ for (HASH_FOR(err, pkg_files, pkg, &file)) sbuf_printf(sb, ";%s", pkg_file_path(file)); - sb_err = sbuf_finish(sb); - if (sb_err) { - pk_backend_error_code(query_backend(q), - PK_ERROR_ENUM_INTERNAL_ERROR, - "couldn't construct filename string"); - goto cleanup; - } - - filenames = sbuf_data(sb); - /* Skip over any initial ; */ - if (filenames[0] == ';') - filenames++; + if (sbuf_finish(sb) != 0) + (void)pk_backend_error_code(query_backend(q), + PK_ERROR_ENUM_INTERNAL_ERROR, + "couldn't construct filename string"); + else { + char *filenames; + + filenames = sbuf_data(sb); + /* Skip over any initial ; */ + if (filenames[0] == ';') + filenames++; - success = pk_backend_files(query_backend(q), id, filenames); + success = pk_backend_files(query_backend(q), id, filenames); + } -cleanup: sbuf_delete(sb); return success; } Modified: soc2013/mattbw/backend/actions/install-files.c ============================================================================== --- soc2013/mattbw/backend/actions/install-files.c Sun Jul 7 01:52:05 2013 (r254273) +++ soc2013/mattbw/backend/actions/install-files.c Sun Jul 7 02:25:56 2013 (r254274) @@ -30,20 +30,114 @@ #include "actions.h" /* install_files_thread prototype */ +static gboolean do_file(const gchar *path, PkBackend *backend, gboolean simulate); +static gboolean do_files(PkBackend *backend, gboolean simulate); + /* - * The thread that performs an InstallFiles operation. Should be invoked - * by the pk_backend_install_files hook. + * The thread that performs an InstallFiles operation. Should be invoked by + * the pk_backend_install_files hook. */ gboolean install_files_thread(PkBackend *backend) { - guint len; - gchar **package_ids; + + return do_files(backend, FALSE); +} + +/* + * The thread that performs a simulated InstallFiles operation. Should be + * invoked by the pk_backend_install_files hook. + */ +gboolean +simulate_install_files_thread(PkBackend *backend) +{ + + return do_files(backend, TRUE); +} + +/* + * Installs a single package file, or pretends to. + */ +static gboolean +do_file(const gchar *path, PkBackend *backend, gboolean simulate) +{ + gboolean success; + struct pkg *pkg; + struct pkg_manifest_key *keys; + struct pkgdb *db; + + success = FALSE; + pkg = NULL; + keys = NULL; + db = NULL; + + (void)pkg_manifest_keys_new(&keys); + + if (simulate) { + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); + + if (pkg_open(&pkg, path, keys, PKG_FLAG_NONE) != EPKG_OK) { + (void)pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_CORRUPT, + "could not open file"); + goto cleanup; + } + pkgutils_emit(pkg, backend, pkgutils_pkg_install_state(pkg)); + + success = TRUE; + } else { + /* TODO: event hook */ + + if (open_remote_db(&db, backend) != EPKG_OK) + goto cleanup; + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); + + if (pkg_add(db, path, PKG_FLAG_NONE, keys) != EPKG_OK) { + (void)pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, + "could not install file"); + goto cleanup; + } + + success = TRUE; + } + +cleanup: + pkgdb_close(db); + pkg_free(pkg); + pkg_manifest_keys_free(keys); - package_ids = pk_backend_get_strv(backend, "package_ids"); - len = g_strv_length(package_ids); + return success; +} - pk_backend_finished(backend); +/* + * Does a file install operation, or a simulation thereof. + */ +static gboolean +do_files(PkBackend *backend, gboolean simulate) +{ + gboolean success; + gchar **paths; - return FALSE; + success = FALSE; + + paths = pk_backend_get_strv(backend, "full_paths"); + if (paths == NULL) + (void)pk_backend_error_code(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not get path vector"); + else if (*paths == NULL) + (void)pk_backend_error_code(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "path vector is empty"); + else { + gchar **p; + + for (p = paths, success = TRUE; *p != NULL && success; p++) + success = do_file(*p, backend, simulate); + } + + pk_backend_finished(backend); + return success; } Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Sun Jul 7 01:52:05 2013 (r254273) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Sun Jul 7 02:25:56 2013 (r254274) @@ -132,19 +132,21 @@ INTENTIONALLY_IGNORE(backend); - /* (Backformed from pkg.h: pkg_formats) */ - return g_strdup("application/x-gzip;" - "application/x-tar;" - "application/x-bzip2;" - "application/x-xz;"); + /* + * (Backformed from pkg.h: pkg_formats) and using `gvfs-info filename + * -a "standard::content-type" + */ + return g_strdup("application/x-tar;" + "application/x-compressed-tar;" + "application/x-bzip-compressed-tar;" + "application/x-xz-compressed-tar;"); } void pk_backend_get_repo_list(PkBackend *backend, PkBitfield filters) { - INTENTIONALLY_IGNORE(filters); /* not yet supported */ - + INTENTIONALLY_IGNORE(filters); /* not yet supported */ pk_backend_thread_create(backend, get_repo_list_thread); } @@ -169,11 +171,17 @@ } void -pk_backend_simulate_install_packages(PkBackend *backend, gchar **package_ids) +pk_backend_simulate_install_files(PkBackend *backend, gchar **full_paths) { - INTENTIONALLY_IGNORE(package_ids); - + INTENTIONALLY_IGNORE(full_paths); /* retrieved from backend */ pk_backend_thread_create(backend, simulate_install_packages_thread); } +void +pk_backend_simulate_install_packages(PkBackend *backend, gchar **package_ids) +{ + + INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + pk_backend_thread_create(backend, simulate_install_packages_thread); +} From owner-svn-soc-all@FreeBSD.ORG Sun Jul 7 02:28:12 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0D1FF310 for ; Sun, 7 Jul 2013 02:28:12 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id F08E41CF7 for ; Sun, 7 Jul 2013 02:28:11 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r672SBFe031263 for ; Sun, 7 Jul 2013 02:28:11 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r672SBVr031254 for svn-soc-all@FreeBSD.org; Sun, 7 Jul 2013 02:28:11 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 7 Jul 2013 02:28:11 GMT Message-Id: <201307070228.r672SBVr031254@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254275 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 02:28:12 -0000 Author: mattbw Date: Sun Jul 7 02:28:11 2013 New Revision: 254275 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254275 Log: at least simulated install works now Modified: soc2013/mattbw/backend/actions/install-files.c soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/actions/install-files.c ============================================================================== --- soc2013/mattbw/backend/actions/install-files.c Sun Jul 7 02:25:56 2013 (r254274) +++ soc2013/mattbw/backend/actions/install-files.c Sun Jul 7 02:28:11 2013 (r254275) @@ -134,7 +134,9 @@ else { gchar **p; - for (p = paths, success = TRUE; *p != NULL && success; p++) + for (p = paths, success = TRUE; + (*p != NULL) && success == TRUE; + p++) success = do_file(*p, backend, simulate); } Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Sun Jul 7 02:25:56 2013 (r254274) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Sun Jul 7 02:28:11 2013 (r254275) @@ -175,7 +175,7 @@ { INTENTIONALLY_IGNORE(full_paths); /* retrieved from backend */ - pk_backend_thread_create(backend, simulate_install_packages_thread); + pk_backend_thread_create(backend, simulate_install_files_thread); } void From owner-svn-soc-all@FreeBSD.ORG Sun Jul 7 02:30:04 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5C7BD32D for ; Sun, 7 Jul 2013 02:30:04 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 4F7E21CFF for ; Sun, 7 Jul 2013 02:30:04 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r672U4io053340 for ; Sun, 7 Jul 2013 02:30:04 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r672U4kS053329 for svn-soc-all@FreeBSD.org; Sun, 7 Jul 2013 02:30:04 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 7 Jul 2013 02:30:04 GMT Message-Id: <201307070230.r672U4kS053329@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254276 - soc2013/mattbw/backend/actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 02:30:04 -0000 Author: mattbw Date: Sun Jul 7 02:30:04 2013 New Revision: 254276 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254276 Log: installfiles seems to work now, except it won't tell you if a file is already installed etc. Modified: soc2013/mattbw/backend/actions/install-files.c Modified: soc2013/mattbw/backend/actions/install-files.c ============================================================================== --- soc2013/mattbw/backend/actions/install-files.c Sun Jul 7 02:28:11 2013 (r254275) +++ soc2013/mattbw/backend/actions/install-files.c Sun Jul 7 02:30:04 2013 (r254276) @@ -88,7 +88,7 @@ } else { /* TODO: event hook */ - if (open_remote_db(&db, backend) != EPKG_OK) + if (open_remote_db(&db, backend) == FALSE) goto cleanup; (void)pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); From owner-svn-soc-all@FreeBSD.ORG Sun Jul 7 08:19:39 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 06BC5C39 for ; Sun, 7 Jul 2013 08:19:39 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id DC4D7194E for ; Sun, 7 Jul 2013 08:19:38 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r678JcXN014946 for ; Sun, 7 Jul 2013 08:19:38 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r678JcGt014937 for svn-soc-all@FreeBSD.org; Sun, 7 Jul 2013 08:19:38 GMT (envelope-from dpl@FreeBSD.org) Date: Sun, 7 Jul 2013 08:19:38 GMT Message-Id: <201307070819.r678JcGt014937@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254288 - in soc2013/dpl/head: contrib/bzip2 usr.bin/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 08:19:39 -0000 Author: dpl Date: Sun Jul 7 08:19:38 2013 New Revision: 254288 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254288 Log: Done with bzip2! Starting with xz. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c soc2013/dpl/head/usr.bin/bzip2/Makefile Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Sun Jul 7 07:06:15 2013 (r254287) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Sun Jul 7 08:19:38 2013 (r254288) @@ -226,8 +226,9 @@ #define IN_FILENO fileno(inStr) #define OUT_FILENO fileno(outStr) void limitfd(int); -FILE *inStr; -FILE *outStr; +FILE *inStr; +FILE *outStr; +int cwd; #endif static void panic ( const Char* ) NORETURN; @@ -376,7 +377,6 @@ if (bzerr != BZ_OK) goto errhandler; } - BZ2_bzWriteClose64 ( &bzerr, bzf, 0, &nbytes_in_lo32, &nbytes_in_hi32, &nbytes_out_lo32, &nbytes_out_hi32 ); @@ -389,14 +389,10 @@ Int32 fd = fileno ( zStream ); if (fd < 0) goto errhandler_io; applySavedFileAttrToOutputFile ( fd ); - ret = fclose ( zStream ); outputHandleJustInCase = NULL; - if (ret == EOF) goto errhandler_io; } outputHandleJustInCase = NULL; if (ferror(stream)) goto errhandler_io; - ret = fclose ( stream ); - if (ret == EOF) goto errhandler_io; if (verbosity >= 1) { if (nbytes_in_lo32 == 0 && nbytes_in_hi32 == 0) { @@ -506,16 +502,13 @@ if (fd < 0) goto errhandler_io; applySavedFileAttrToOutputFile ( fd ); } - ret = fclose ( zStream ); - if (ret == EOF) goto errhandler_io; + if (ferror(stream)) goto errhandler_io; ret = fflush ( stream ); if (ret != 0) goto errhandler_io; if (stream != stdout) { - ret = fclose ( stream ); outputHandleJustInCase = NULL; - if (ret == EOF) goto errhandler_io; } outputHandleJustInCase = NULL; if (verbosity >= 2) fprintf ( stderr, "\n " ); @@ -574,7 +567,7 @@ Bool testStream ( FILE *zStream ) { BZFILE* bzf = NULL; - Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i; + Int32 bzerr, bzerr_dummy, nread, streamNo, i; UChar obuf[5000]; UChar unused[BZ_MAX_UNUSED]; Int32 nUnused; @@ -615,8 +608,6 @@ } if (ferror(zStream)) goto errhandler_io; - ret = fclose ( zStream ); - if (ret == EOF) goto errhandler_io; if (verbosity >= 2) fprintf ( stderr, "\n " ); return True; @@ -642,7 +633,6 @@ "file ends unexpectedly\n" ); return False; case BZ_DATA_ERROR_MAGIC: - if (zStream != stdin) fclose(zStream); if (streamNo == 1) { fprintf ( stderr, "bad magic number (file not created by bzip2)\n" ); @@ -686,6 +676,8 @@ rights = CAP_WRITE|CAP_READ|CAP_FSTAT; else if (fd == STDERR_FILENO) rights = CAP_WRITE; + else if ( fd == cwd ) + rights = CAP_UNLINKAT|CAP_LOOKUP; if (cap_rights_limit(fd, rights) < 0 && errno != ENOSYS){ fprintf ( stderr, "%s: Couldn't limit rights for descriptor %d: %s.\n", @@ -748,7 +740,7 @@ progName, outName ); if (outputHandleJustInCase != NULL) fclose ( outputHandleJustInCase ); - retVal = remove ( outName ); + retVal = unlinkat ( cwd, inName, 0 ); if (retVal != 0) fprintf ( stderr, "%s: WARNING: deletion of output file " @@ -1093,7 +1085,6 @@ { # if BZ_UNIX IntNative retVal; -/* struct utimbuf uTimBuf;*/ struct timeval fdTime[2]; fdTime[0].tv_sec = fileMetaInfo.st_atime; @@ -1101,9 +1092,6 @@ fdTime[1].tv_sec = fileMetaInfo.st_mtime; fdTime[1].tv_usec = 0; -/* uTimBuf.actime = fileMetaInfo.st_atime;*/ -/* uTimBuf.modtime = fileMetaInfo.st_mtime;*/ - printf("fd:%d\n", fd); retVal = futimes ( fd, fdTime ); ERROR_IF_NOT_ZERO ( retVal ); # endif @@ -1258,7 +1246,7 @@ } if ( srcMode == SM_F2F && fileExists ( outName ) ) { if (forceOverwrite) { - remove(outName); + unlinkat ( cwd, inName, 0 ); } else { fprintf ( stderr, "%s: Output file %s already exists.\n", progName, outName ); @@ -1355,6 +1343,7 @@ limitfd(IN_FILENO); limitfd(OUT_FILENO); limitfd(STDERR_FILENO); + limitfd(cwd); if (cap_enter() < 0 && errno != ENOSYS){ fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", progName, strerror(errno) ); @@ -1373,12 +1362,15 @@ applySavedTimeInfoToOutputFile ( OUT_FILENO ); deleteOutputOnInterrupt = False; if ( !keepInputFiles ) { - IntNative retVal = remove ( inName ); + IntNative retVal = unlinkat ( cwd, inName, 0 ); ERROR_IF_NOT_ZERO ( retVal ); } } - + deleteOutputOnInterrupt = False; + fclose(inStr); + fclose(outStr); + close(cwd); # if CAPSICUM exit(0); } @@ -1467,7 +1459,7 @@ } if ( srcMode == SM_F2F && fileExists ( outName ) ) { if (forceOverwrite) { - remove(outName); + unlinkat ( cwd, inName, 0 ); } else { fprintf ( stderr, "%s: Output file %s already exists.\n", progName, outName ); @@ -1562,6 +1554,7 @@ limitfd(IN_FILENO); limitfd(OUT_FILENO); limitfd(STDERR_FILENO); + limitfd(cwd); if (cap_enter() < 0 && errno != ENOSYS){ fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", progName, strerror(errno) ); @@ -1582,7 +1575,7 @@ applySavedTimeInfoToOutputFile ( OUT_FILENO ); deleteOutputOnInterrupt = False; if ( !keepInputFiles ) { - IntNative retVal = remove ( inName ); + IntNative retVal = unlinkat ( cwd, inName, 0 ); ERROR_IF_NOT_ZERO ( retVal ); } } @@ -1590,7 +1583,7 @@ unzFailsExist = True; deleteOutputOnInterrupt = False; if ( srcMode == SM_F2F ) { - IntNative retVal = remove ( outName ); + IntNative retVal = unlinkat ( cwd, inName, 0 ); ERROR_IF_NOT_ZERO ( retVal ); } } @@ -1607,6 +1600,9 @@ "%s: %s is not a bzip2 file.\n", progName, inName ); } + fclose(inStr); + fclose(outStr); + close(cwd); # if CAPSICUM exit(0); } @@ -2065,6 +2061,8 @@ # endif } + cwd = open ( ".", 0 ); + if (opMode == OM_Z) { if (srcMode == SM_I2O) { compress ( NULL ); Modified: soc2013/dpl/head/usr.bin/bzip2/Makefile ============================================================================== --- soc2013/dpl/head/usr.bin/bzip2/Makefile Sun Jul 7 07:06:15 2013 (r254287) +++ soc2013/dpl/head/usr.bin/bzip2/Makefile Sun Jul 7 08:19:38 2013 (r254288) @@ -45,12 +45,6 @@ ./bzip2 -d < sample1.bz2 > sample1.tst ./bzip2 -d < sample2.bz2 > sample2.tst ./bzip2 -ds < sample3.bz2 > sample3.tst - ./bzip2 -c sample1.ref sample2.ref sample3.ref > samples.rb2 - ./bzip2 -ds < samples.rb2 > total.tst - cat sample1.ref >> total - cat sample2.ref >> total - cat sample3.ref >> total - cmp total total.tst cmp sample1.bz2 sample1.rb2 cmp sample2.bz2 sample2.rb2 cmp sample3.bz2 sample3.rb2 From owner-svn-soc-all@FreeBSD.ORG Sun Jul 7 08:27:08 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C6053E79 for ; Sun, 7 Jul 2013 08:27:08 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id B84CA197D for ; Sun, 7 Jul 2013 08:27:08 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r678R8WK001782 for ; Sun, 7 Jul 2013 08:27:08 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r678R8fL001779 for svn-soc-all@FreeBSD.org; Sun, 7 Jul 2013 08:27:08 GMT (envelope-from dpl@FreeBSD.org) Date: Sun, 7 Jul 2013 08:27:08 GMT Message-Id: <201307070827.r678R8fL001779@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254289 - in soc2013/dpl/head/usr.bin: bzip2 xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 08:27:08 -0000 Author: dpl Date: Sun Jul 7 08:27:08 2013 New Revision: 254289 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254289 Log: Cleaning bzip2 Makefile. Modified: soc2013/dpl/head/usr.bin/bzip2/Makefile soc2013/dpl/head/usr.bin/xz/Makefile Modified: soc2013/dpl/head/usr.bin/bzip2/Makefile ============================================================================== --- soc2013/dpl/head/usr.bin/bzip2/Makefile Sun Jul 7 08:19:38 2013 (r254288) +++ soc2013/dpl/head/usr.bin/bzip2/Makefile Sun Jul 7 08:27:08 2013 (r254289) @@ -5,9 +5,6 @@ PROG= bzip2 CFLAGS+= -D_FILE_OFFSET_BITS=64 -#TODO: Delete this. -CFLAGS+= -fno-color-diagnostics -CFLAGS+= -Wall -Werror -g WARNS?= 3 Modified: soc2013/dpl/head/usr.bin/xz/Makefile ============================================================================== --- soc2013/dpl/head/usr.bin/xz/Makefile Sun Jul 7 08:19:38 2013 (r254288) +++ soc2013/dpl/head/usr.bin/xz/Makefile Sun Jul 7 08:27:08 2013 (r254289) @@ -41,6 +41,9 @@ CFLAGS+= -DHAVE_CONFIG_H \ -I${LZMALIBDIR} \ -I${XZDIR}/common +#TODO: Delete this. +CFLAGS+= -fno-color-diagnostics +CFLAGS+= -Wall -Werror -g DPADD= ${LIBLZMA} LDADD= -llzma From owner-svn-soc-all@FreeBSD.ORG Sun Jul 7 13:55:58 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 29D19988 for ; Sun, 7 Jul 2013 13:55:58 +0000 (UTC) (envelope-from oleksandr@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 19F6A16A9 for ; Sun, 7 Jul 2013 13:55:58 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67Dtv1Z039550 for ; Sun, 7 Jul 2013 13:55:57 GMT (envelope-from oleksandr@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r67DtvHE039533 for svn-soc-all@FreeBSD.org; Sun, 7 Jul 2013 13:55:57 GMT (envelope-from oleksandr@FreeBSD.org) Date: Sun, 7 Jul 2013 13:55:57 GMT Message-Id: <201307071355.r67DtvHE039533@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to oleksandr@FreeBSD.org using -f From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254313 - in soc2013/oleksandr/ports: . emulators emulators/virtualbox-ose-additions emulators/virtualbox-ose-additions/files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 13:55:58 -0000 Author: oleksandr Date: Sun Jul 7 13:55:56 2013 New Revision: 254313 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254313 Log: Initial add virtualbox-ose-additions port Added: soc2013/oleksandr/ports/ soc2013/oleksandr/ports/emulators/ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/Makefile soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/distinfo soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-common-VBoxGuestLib-Makefile.kmk soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-common-crOpenGL-fakedri_drv.c soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-x11-Installer-vboxclient.desktop soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd_VM_OBJECT_RENAME.c soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Runtime-r0drv-freebsd-the-freebsd-kernel.h soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/vboxguest.in soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/vboxservice.in soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/pkg-descr soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/pkg-message soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/pkg-plist Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/Makefile Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,191 @@ +# Created by: Bernhard Froehlich +# $FreeBSD: emulators/virtualbox-ose-additions/Makefile 321665 2013-06-24 06:07:53Z decke $ + +PORTNAME= virtualbox-ose +DISTVERSION= 4.2.14 +CATEGORIES= emulators kld +MASTER_SITES= http://download.virtualbox.org/virtualbox/${DISTVERSION}/ \ + http://tmp.chruetertee.ch/ \ + http://disasterarea.chruetertee.ch/ +PKGNAMESUFFIX= -additions +DISTNAME= VirtualBox-${DISTVERSION} + +MAINTAINER= vbox@FreeBSD.org +COMMENT= VirtualBox additions for FreeBSD guests + +LICENSE= GPLv2 +LICENSE_FILE= ${WRKSRC}/COPYING + +BUILD_DEPENDS= yasm:${PORTSDIR}/devel/yasm \ + as86:${PORTSDIR}/devel/dev86 \ + kmk:${PORTSDIR}/devel/kBuild + +UNIQUENAME= ${PORTNAME}${PKGNAMESUFFIX} +WRKSRC= ${WRKDIR}/VirtualBox-${PORTVERSION} +USE_RC_SUBR= vboxguest vboxservice +ONLY_FOR_ARCHS= i386 amd64 +FETCH_ARGS= -pRr +USE_BZIP2= yes +MAKE_JOBS_UNSAFE= yes + +HAS_CONFIGURE= yes +CONFIGURE_ARGS+=--with-gcc="${CC}" --with-g++="${CXX}" --nofatal \ + --disable-xpcom --disable-sdl-ttf --disable-pulse \ + --disable-alsa --disable-dbus --disable-python + +CONFLICTS= bcc-[0-9]* +CONFLICTS_INSTALL= virtualbox-ose-additions-devel-[3,4]* virtualbox-ose-[3,4]* virtualbox-ose-devel-[3,4]* virtualbox-ose-legacy-[3,4]* + +OPTIONS_DEFINE= DEBUG X11 OPENGL +OPTIONS_DEFAULT= X11 + +.include + +PLIST_SUB+= KMODDIR=${KMODDIR:C,^/,,} + +KMODDIR= /boot/modules +SRC_BASE?= /usr/src +VIDEODIR= ${PREFIX}/lib/xorg/modules/drivers +INPUTDIR= ${PREFIX}/lib/xorg/modules/input + +VBOX_BIN= ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/additions + +KMK_BUILDTYPE= release +KMK_CONFIG= VBOX_LIBPATH_X11=${LOCALBASE} +KMK_FLAGS= + +MAKE_FLAGS= SYSDIR=${SRC_BASE}/sys + +.if ${PORT_OPTIONS:MDEBUG} +KMK_FLAGS+= BUILD_TYPE=debug +KMK_BUILDTYPE= debug +MAKE_FLAGS+= DEBUG_FLAGS="-O1 -g" +PLIST_SUB+= WITH_DEBUG="" +.else +PLIST_SUB+= WITH_DEBUG="@comment " +.endif + +.if ${PORT_OPTIONS:MX11} +VBOX_WITH_X11= 1 +USE_XORG= xcursor xmu inputproto xorg-server xrandr +PLIST_SUB+= X11="" +.else +VBOX_WITH_X11= +PLIST_SUB+= X11="@comment " +.endif + +.if ${PORT_OPTIONS:MOPENGL} +USE_XORG+= xcomposite xdamage xext xfixes +USE_GL= gl +PLIST_SUB+= OPENGL="" +.else +CONFIGURE_ARGS+=--disable-opengl +PLIST_SUB+= OPENGL="@comment " +.endif + +.if ${ARCH} == i386 +KMK_ARCH= freebsd.x86 +.else +KMK_ARCH= freebsd.${ARCH} +.endif + +XSERVER_ABI:= ${XSERVER_VER:S/.//:R} + +.if !exists(${SRC_BASE}/sys/kern/bus_if.m) +IGNORE= requires kernel sources +.endif + +.include + +pre-everything:: +.if ${ARCH} == "amd64" +.if !exists(/usr/lib32/libc.so) + @${ECHO} 'Requires 32-bit libraries installed under /usr/lib32.' + @${ECHO} 'Do: cd /usr/src; make build32 install32; ldconfig -v -m -R /usr/lib32' + @${FALSE} +.endif +.endif + +post-patch: + @${ECHO} 'VBOX_ONLY_ADDITIONS = 1' > ${WRKSRC}/LocalConfig.kmk + @${ECHO} 'VBOX_WITH_X11_ADDITIONS = ${VBOX_WITH_X11}' >> ${WRKSRC}/LocalConfig.kmk + @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \ + ${WRKSRC}/Config.kmk \ + ${WRKSRC}/configure \ + ${WRKSRC}/kBuild/units/qt4.kmk \ + ${WRKSRC}/kBuild/sdks/LIBSDL.kmk \ + ${WRKSRC}/src/VBox/Additions/x11/Installer/98vboxadd-xclient \ + ${WRKSRC}/src/VBox/Additions/x11/Installer/vboxclient.desktop + @${REINPLACE_CMD} -e 's|\$$KBUILDDIR_BIN/kmk_sed|${LOCALBASE}/bin/kmk_sed|g' ${WRKSRC}/configure + +pre-build: + @${REINPLACE_CMD} -e 's|/bin/bash|/bin/sh|' \ + ${WRKSRC}/env.sh \ + ${WRKSRC}/src/VBox/Additions/freebsd/Installer/vboxguest.sh + +do-build: + cd ${WRKSRC} && ${SH} env.sh && ${KMK_CONFIG} ${LOCALBASE}/bin/kmk ${KMK_FLAGS} + cd ${VBOX_BIN}/src && make ${MAKE_FLAGS} + +do-install: + ${MKDIR} ${KMODDIR} + ${INSTALL_KLD} ${VBOX_BIN}/src/vboxguest/vboxguest.ko ${KMODDIR} +.if ${PORT_OPTIONS:MDEBUG} + ${INSTALL_KLD} ${VBOX_BIN}/src/vboxguest/vboxguest.ko.symbols ${KMODDIR} +.endif +.if ${PORT_OPTIONS:MX11} + ${INSTALL_KLD} ${VBOX_BIN}/vboxvideo.ko ${KMODDIR} +.if ${PORT_OPTIONS:MDEBUG} + ${INSTALL_KLD} ${VBOX_BIN}/vboxvideo.ko.symbols ${KMODDIR} +.endif +.endif + @/usr/sbin/kldxref ${KMODDIR} + + ${MKDIR} ${PREFIX}/etc/rc.d/ + + ${MKDIR} ${PREFIX}/sbin + ${INSTALL_PROGRAM} ${VBOX_BIN}/VBoxControl ${PREFIX}/sbin/ + ${INSTALL_PROGRAM} ${VBOX_BIN}/VBoxService ${PREFIX}/sbin/ + +.if ${PORT_OPTIONS:MX11} + ${INSTALL_PROGRAM} ${VBOX_BIN}/VBoxClient ${PREFIX}/bin/ + + ${MKDIR} ${PREFIX}/bin + ${INSTALL_SCRIPT} ${WRKSRC}/src/VBox/Additions/x11/Installer/98vboxadd-xclient \ + ${PREFIX}/bin/VBoxClient-all + + # X11 autostart + ${MKDIR} ${PREFIX}/etc/xdg/autostart/ + ${INSTALL_DATA} ${WRKSRC}/src/VBox/Additions/x11/Installer/vboxclient.desktop \ + ${PREFIX}/etc/xdg/autostart/ + + # KDE autostart + ${MKDIR} ${PREFIX}/share/autostart/ + ${INSTALL_DATA} ${WRKSRC}/src/VBox/Additions/x11/Installer/vboxclient.desktop \ + ${PREFIX}/share/autostart/ + + ${MKDIR} ${VIDEODIR} + ${INSTALL_DATA} ${VBOX_BIN}/vboxvideo_drv_${XSERVER_ABI}.so ${VIDEODIR}/vboxvideo_drv.so + + ${MKDIR} ${INPUTDIR} + ${INSTALL_DATA} ${VBOX_BIN}/vboxmouse_drv_${XSERVER_ABI}.so ${INPUTDIR}/vboxmouse_drv.so +.endif + +.if ${PORT_OPTIONS:MOPENGL} + ${MKDIR} ${PREFIX}/lib + ${INSTALL_DATA} ${VBOX_BIN}/VBoxOGL.so ${PREFIX}/lib/ + ${INSTALL_DATA} ${VBOX_BIN}/VBoxOGLarrayspu.so ${PREFIX}/lib/ + ${INSTALL_DATA} ${VBOX_BIN}/VBoxOGLcrutil.so ${PREFIX}/lib/ + ${INSTALL_DATA} ${VBOX_BIN}/VBoxOGLerrorspu.so ${PREFIX}/lib/ + ${INSTALL_DATA} ${VBOX_BIN}/VBoxOGLfeedbackspu.so ${PREFIX}/lib/ + ${INSTALL_DATA} ${VBOX_BIN}/VBoxOGLpackspu.so ${PREFIX}/lib/ + ${INSTALL_DATA} ${VBOX_BIN}/VBoxOGLpassthroughspu.so ${PREFIX}/lib/ + + ${MKDIR} ${PREFIX}/lib/dri + ${LN} -sf ${PREFIX}/lib/VBoxOGL.so ${PREFIX}/lib/dri/vboxvideo_dri.so +.endif + +post-install: + @${CAT} ${PKGMESSAGE} + +.include Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/distinfo Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,2 @@ +SHA256 (VirtualBox-4.2.14.tar.bz2) = f8f6dc19612f3c84a5c857b8e5c452b8db2cf3c8c52a678b6a00e5dd5831130d +SIZE (VirtualBox-4.2.14.tar.bz2) = 76888627 Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-common-VBoxGuestLib-Makefile.kmk ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-common-VBoxGuestLib-Makefile.kmk Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,18 @@ +--- src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk.orig 2010-10-07 11:37:10.000000000 +0200 ++++ src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk 2010-10-07 11:36:16.000000000 +0200 +@@ -140,6 +140,7 @@ + # the X server runtime instead of IPRT, for use with old servers where the + # C library is not available. + # ++ifdef VBOX_WITH_X11_ADDITIONS + VBoxGuestR3LibXFree86_TEMPLATE = VBOXGUESTR3XF86LIB + VBoxGuestR3LibXFree86_DEFS = \ + VBOX_WITH_HGCM \ +@@ -163,6 +164,7 @@ + $(VBOX_PATH_X11_XFREE_4_3)/exports/include/X11 + + VBoxGuestR3LibRuntimeXF86.cpp_CXXFLAGS = -Wno-shadow ++endif + + include $(KBUILD_PATH)/subfooter.kmk + Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,40 @@ +--- src/VBox/Additions/common/crOpenGL/Makefile.kmk.orig 2013-04-12 12:35:06.000000000 +0200 ++++ src/VBox/Additions/common/crOpenGL/Makefile.kmk 2013-05-02 23:33:26.523212251 +0200 +@@ -42,7 +42,7 @@ + + if1of ($(KBUILD_TARGET), linux solaris freebsd) + #VBoxOGL_DRI = 1 +- ifn1of ($(KBUILD_TARGET),solaris freebsd) # No DRI on Solaris yet ++ ifn1of ($(KBUILD_TARGET),solaris) # No DRI on Solaris yet + VBoxOGL_FAKEDRI = 1 + endif + +@@ -209,8 +209,13 @@ + $(PATH_STAGE_LIB)/libXfixes.so \ + $(PATH_STAGE_LIB)/libXext.so + ifdef VBoxOGL_FAKEDRI +- VBoxOGL_LIBS += \ ++ ifeq ($(KBUILD_TARGET), freebsd) ++ VBoxOGL_LIBS += \ ++ elf ++ else ++ VBoxOGL_LIBS += \ + dl ++ endif + endif + endif + ifdef VBOX_WITH_CRHGSMI +@@ -368,6 +373,13 @@ + | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$<) + $(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) ++ else ifeq ($(KBUILD_TARGET),freebsd) ++$(VBOX_PATH_CROGL_GENFILES)/freebsd_exports.c: \ ++ $(PATH_SUB_CURRENT)/FreeBSD_exports.py \ ++ $(VBOX_CROGL_API_FILES) $(PATH_SUB_CURRENT)/entrypoints.py \ ++ | $$(dir $$@) ++ $(call MSG_GENERATE,python,$@,$<) ++ $(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) + else + $(VBOX_PATH_CROGL_GENFILES)/linux_exports.c: \ + $(PATH_SUB_CURRENT)/Linux_exports.py \ Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-common-crOpenGL-fakedri_drv.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-common-crOpenGL-fakedri_drv.c Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,120 @@ +--- src/VBox/Additions/common/crOpenGL/fakedri_drv.c.orig 2012-12-19 13:25:04.000000000 -0500 ++++ src/VBox/Additions/common/crOpenGL/fakedri_drv.c 2013-01-27 17:57:04.000000000 -0500 +@@ -29,6 +29,15 @@ + #include + #include + #include ++ ++#include ++#if defined(BSD) ++#include ++#include ++#include ++#include ++#endif ++ + /** X server message type definitions. */ + typedef enum { + X_PROBED, /* Value was probed */ +@@ -50,11 +59,11 @@ + + //@todo this could be different... + #ifdef RT_ARCH_AMD64 +-# define DRI_DEFAULT_DRIVER_DIR "/usr/lib64/dri:/usr/lib/dri:/usr/lib/x86_64-linux-gnu/dri" +-# define DRI_XORG_DRV_DIR "/usr/lib/xorg/modules/drivers/" ++# define DRI_DEFAULT_DRIVER_DIR "/usr/local/lib/dri" ++# define DRI_XORG_DRV_DIR "/usr/local/lib/xorg/modules/drivers/" + #else +-# define DRI_DEFAULT_DRIVER_DIR "/usr/lib/dri:/usr/lib/i386-linux-gnu/dri" +-# define DRI_XORG_DRV_DIR "/usr/lib/xorg/modules/drivers/" ++# define DRI_DEFAULT_DRIVER_DIR "/usr/local/lib/dri" ++# define DRI_XORG_DRV_DIR "/usr/local/lib/xorg/modules/drivers/" + #endif + + #ifdef DEBUG_DRI_CALLS +@@ -209,6 +218,85 @@ + + #define FAKEDRI_JMP64_PATCH_SIZE 13 + ++#if defined(BSD) ++/* Provide basic dladdr1 flags */ ++enum { ++ RTLD_DL_SYMENT = 1 ++}; ++ ++/* Provide a minimal local version of dladdr1 */ ++static int ++dladdr1(const void *address, Dl_info *dlip, void **info, int flags) ++{ ++ static DRI_ELFSYM desym; ++ GElf_Sym sym; ++ GElf_Shdr shdr; ++ Elf *elf; ++ Elf_Scn *scn; ++ Elf_Data *data; ++ int ret, fd, count, i; ++ ++ /* Initialize variables */ ++ fd = -1; ++ elf = NULL; ++ ++ /* Call dladdr first */ ++ ret = dladdr(address, dlip); ++ if (ret == 0) goto err_exit; ++ ++ /* Check for supported flags */ ++ if (flags != RTLD_DL_SYMENT) return 1; ++ ++ /* Open shared library's ELF file */ ++ if (elf_version(EV_CURRENT) == EV_NONE) goto err_exit; ++ fd = open(dlip->dli_fname, O_RDONLY); ++ if (fd < 0) goto err_exit; ++ elf = elf_begin(fd, ELF_C_READ, NULL); ++ if (elf == NULL) goto err_exit; ++ ++ /* Find the '.dynsym' section */ ++ scn = elf_nextscn(elf, NULL); ++ while (scn != NULL) { ++ if (gelf_getshdr(scn, &shdr) == NULL) goto err_exit; ++ if (shdr.sh_type == SHT_DYNSYM) break; ++ scn = elf_nextscn(elf, scn); ++ } ++ if (scn == NULL) goto err_exit; ++ ++ /* Search for the requested symbol by name and offset */ ++ data = elf_getdata(scn, NULL); ++ count = shdr.sh_size / shdr.sh_entsize; ++ for (i = 0; i < count; i++) { ++ gelf_getsym(data, i, &sym); ++ if ((strcmp(dlip->dli_sname, ++ elf_strptr(elf, shdr.sh_link, sym.st_name)) == 0) && ++ (sym.st_value == (dlip->dli_saddr - dlip->dli_fbase))) { ++ break; ++ } ++ } ++ ++ /* Close ELF file */ ++ elf_end(elf); ++ close(fd); ++ ++ /* Return symbol entry in native format */ ++ desym.st_name = sym.st_name; ++ desym.st_info = sym.st_info; ++ desym.st_other = sym.st_other; ++ desym.st_shndx = sym.st_shndx; ++ desym.st_value = sym.st_value; ++ desym.st_size = sym.st_size; ++ *info = &desym; ++ return 1; ++ ++ /* Error handler */ ++err_exit: ++ if (elf != NULL) elf_end(elf); ++ if (fd >= 0) close(fd); ++ return 0; ++} ++#endif ++ + static void + vboxPatchMesaExport(const char* psFuncName, const void *pStart, const void *pEnd) + { Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,27 @@ +--- src/VBox/Additions/x11/Installer/98vboxadd-xclient.orig 2010-09-10 14:24:55.000000000 +0200 ++++ src/VBox/Additions/x11/Installer/98vboxadd-xclient 2010-12-29 20:42:00.000000000 +0100 +@@ -28,8 +28,8 @@ + xorgbin=Xorg + found=`which Xorg | grep "no Xorg"` + if test ! -z "$found"; then +- if test -f "/usr/X11/bin/Xorg"; then +- xorgbin=/usr/X11/bin/Xorg ++ if test -f "/usr/local/bin/Xorg"; then ++ xorgbin=/usr/local/bin/Xorg + else + exit 1 + fi +@@ -40,9 +40,9 @@ + no_display=1 + fi + +-/usr/bin/VBoxClient --clipboard +-/usr/bin/VBoxClient --checkhostversion ++/usr/local/bin/VBoxClient --clipboard ++/usr/local/bin/VBoxClient --checkhostversion + test -z "$no_display" && +- /usr/bin/VBoxClient --display ++ /usr/local/bin/VBoxClient --display + test -z "$no_display" && +- /usr/bin/VBoxClient --seamless ++ /usr/local/bin/VBoxClient --seamless Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-x11-Installer-vboxclient.desktop ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-x11-Installer-vboxclient.desktop Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,10 @@ +--- src/VBox/Additions/x11/Installer/vboxclient.desktop.orig 2009-06-12 12:34:57.000000000 +0000 ++++ src/VBox/Additions/x11/Installer/vboxclient.desktop 2011-01-13 22:07:37.000000000 +0000 +@@ -8,6 +8,6 @@ + Comment=VirtualBox User Session Services + Comment[it]=Servizi di sessione utente di VirtualBox + Comment[pl]=Usługi sesji użytkownika VirtualBox +-Exec=/usr/bin/VBoxClient-all ++Exec=/usr/local/bin/VBoxClient-all + X-GNOME-Autostart-enabled=true + X-KDE-autostart-after=panel Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,20 @@ +--- src/VBox/Additions/x11/vboxvideo/Makefile.kmk.orig 2012-10-26 18:23:35.000000000 +0200 ++++ src/VBox/Additions/x11/vboxvideo/Makefile.kmk 2012-10-28 16:54:59.074303788 +0100 +@@ -196,7 +196,7 @@ + vboxvideo_drv_15_TEMPLATE = VBOXGUESTR3XORGMOD + vboxvideo_drv_15_CFLAGS := $(vboxvideo_drv_70_CFLAGS) + vboxvideo_drv_15_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=100503000 +-if1of ($(KBUILD_TARGET), linux solaris) ++if1of ($(KBUILD_TARGET), freebsd linux solaris) + vboxvideo_drv_15_DEFS += VBOX_DRI + endif + vboxvideo_drv_15_INCS = \ +@@ -204,7 +204,7 @@ + $(VBOX_PATH_X11_ROOT)/xorg-server-1.5.3 + vboxvideo_drv_15_INCS += $(PATH_ROOT)/src/VBox/Runtime/include + vboxvideo_drv_15_SOURCES = $(vboxvideo_drv_13_SOURCES) +-if1of ($(KBUILD_TARGET), linux solaris) ++if1of ($(KBUILD_TARGET), freebsd linux solaris) + vboxvideo_drv_15_SOURCES += \ + vboxvideo_dri.c + endif Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,56 @@ +From Alan L. Cox on FreeBSD-current: + + I just glanced at the virtualbox code for a couple minutes. For + FreeBSD 9 and 10, these lock acquires are completely unnecessary, and + have been since FreeBSD 9.0. Just delete them. They may be equally + unnecessary under FreeBSD 8, but I didn't look carefully enough to + answer that question. + +[1] http://lists.freebsd.org/pipermail/freebsd-current/2012-November/037963.html +--- + src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c b/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c +index 5c90cf3..1176b51 100644 +--- src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c ++++ src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c +@@ -164,14 +164,19 @@ DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem) + { + VM_OBJECT_LOCK(pMemFreeBSD->pObject); + vm_page_t pPage = vm_page_find_least(pMemFreeBSD->pObject, 0); ++#if __FreeBSD_version < 900000 ++ /* See http://lists.freebsd.org/pipermail/freebsd-current/2012-November/037963.html */ + vm_page_lock_queues(); ++#endif + for (vm_page_t pPage = vm_page_find_least(pMemFreeBSD->pObject, 0); + pPage != NULL; + pPage = vm_page_next(pPage)) + { + vm_page_unwire(pPage, 0); + } ++#if __FreeBSD_version < 900000 + vm_page_unlock_queues(); ++#endif + VM_OBJECT_UNLOCK(pMemFreeBSD->pObject); + vm_object_deallocate(pMemFreeBSD->pObject); + break; +@@ -263,11 +268,15 @@ static int rtR0MemObjFreeBSDPhysAllocHelper(vm_object_t pObject, u_long cPages, + while (iPage-- > 0) + { + pPage = vm_page_lookup(pObject, iPage); ++#if __FreeBSD_version < 900000 + vm_page_lock_queues(); ++#endif + if (fWire) + vm_page_unwire(pPage, 0); + vm_page_free(pPage); ++#if __FreeBSD_version < 900000 + vm_page_unlock_queues(); ++#endif + } + VM_OBJECT_UNLOCK(pObject); + return rcNoMem; +-- +1.7.11.5 + Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd_VM_OBJECT_RENAME.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd_VM_OBJECT_RENAME.c Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,132 @@ +$FreeBSD: emulators/virtualbox-ose-additions/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd_VM_OBJECT_RENAME.c 317147 2013-05-02 20:54:04Z decke $ + +--- src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c 2013-03-20 19:19:36.795745576 -0700 ++++ src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c 2013-03-20 19:15:35.164791970 -0700 +@@ -162,7 +162,11 @@ + case RTR0MEMOBJTYPE_PHYS: + case RTR0MEMOBJTYPE_PHYS_NC: + { ++#if __FreeBSD_version >= 1000030 ++ VM_OBJECT_WLOCK(pMemFreeBSD->pObject); ++#else + VM_OBJECT_LOCK(pMemFreeBSD->pObject); ++#endif + vm_page_t pPage = vm_page_find_least(pMemFreeBSD->pObject, 0); + #if __FreeBSD_version < 900000 + /* See http://lists.freebsd.org/pipermail/freebsd-current/2012-November/037963.html */ +@@ -177,7 +181,12 @@ + #if __FreeBSD_version < 900000 + vm_page_unlock_queues(); + #endif ++#if __FreeBSD_version >= 1000030 ++ VM_OBJECT_WUNLOCK(pMemFreeBSD->pObject); ++#else + VM_OBJECT_UNLOCK(pMemFreeBSD->pObject); ++#endif ++ + vm_object_deallocate(pMemFreeBSD->pObject); + break; + } +@@ -205,10 +214,18 @@ + + while (cTries <= 1) + { ++#if __FreeBSD_version >= 1000030 ++ VM_OBJECT_WLOCK(pObject); ++#else + VM_OBJECT_LOCK(pObject); ++#endif + pPages = vm_page_alloc_contig(pObject, iPIndex, fFlags, cPages, 0, + VmPhysAddrHigh, uAlignment, 0, VM_MEMATTR_DEFAULT); ++#if __FreeBSD_version >= 1000030 ++ VM_OBJECT_WUNLOCK(pObject); ++#else + VM_OBJECT_UNLOCK(pObject); ++#endif + if (pPages) + break; + vm_pageout_grow_cache(cTries, 0, VmPhysAddrHigh); +@@ -228,7 +245,11 @@ + + if (!pPages) + return pPages; ++#if __FreeBSD_version >= 1000030 ++ VM_OBJECT_WLOCK(pObject); ++#else + VM_OBJECT_LOCK(pObject); ++#endif + for (vm_pindex_t iPage = 0; iPage < cPages; iPage++) + { + vm_page_t pPage = pPages + iPage; +@@ -240,7 +261,11 @@ + atomic_add_int(&cnt.v_wire_count, 1); + } + } ++#if __FreeBSD_version >= 1000030 ++ VM_OBJECT_WUNLOCK(pObject); ++#else + VM_OBJECT_UNLOCK(pObject); ++#endif + return pPages; + #endif + } +@@ -264,7 +289,11 @@ + if (!pPage) + { + /* Free all allocated pages */ ++#if __FreeBSD_version >= 1000030 ++ VM_OBJECT_WLOCK(pObject); ++#else + VM_OBJECT_LOCK(pObject); ++#endif + while (iPage-- > 0) + { + pPage = vm_page_lookup(pObject, iPage); +@@ -278,7 +307,11 @@ + vm_page_unlock_queues(); + #endif + } ++#if __FreeBSD_version >= 1000030 ++ VM_OBJECT_WUNLOCK(pObject); ++#else + VM_OBJECT_UNLOCK(pObject); ++#endif + return rcNoMem; + } + } +@@ -411,9 +444,17 @@ + if (fContiguous) + { + Assert(enmType == RTR0MEMOBJTYPE_PHYS); ++#if __FreeBSD_version >= 1000030 ++ VM_OBJECT_WLOCK(pMemFreeBSD->pObject); ++#else + VM_OBJECT_LOCK(pMemFreeBSD->pObject); ++#endif + pMemFreeBSD->Core.u.Phys.PhysBase = VM_PAGE_TO_PHYS(vm_page_find_least(pMemFreeBSD->pObject, 0)); ++#if __FreeBSD_version >= 1000030 ++ VM_OBJECT_WUNLOCK(pMemFreeBSD->pObject); ++#else + VM_OBJECT_UNLOCK(pMemFreeBSD->pObject); ++#endif + pMemFreeBSD->Core.u.Phys.fAllocated = true; + } + +@@ -823,9 +864,17 @@ + case RTR0MEMOBJTYPE_PHYS_NC: + { + RTHCPHYS addr; ++#if __FreeBSD_version >= 1000030 ++ VM_OBJECT_WLOCK(pMemFreeBSD->pObject); ++#else + VM_OBJECT_LOCK(pMemFreeBSD->pObject); ++#endif + addr = VM_PAGE_TO_PHYS(vm_page_lookup(pMemFreeBSD->pObject, iPage)); ++#if __FreeBSD_version >= 1000030 ++ VM_OBJECT_WUNLOCK(pMemFreeBSD->pObject); ++#else + VM_OBJECT_UNLOCK(pMemFreeBSD->pObject); ++#endif + return addr; + } + Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Runtime-r0drv-freebsd-the-freebsd-kernel.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-VBox-Runtime-r0drv-freebsd-the-freebsd-kernel.h Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,20 @@ +--- src/VBox/Runtime/r0drv/freebsd/the-freebsd-kernel.h.orig 2013-03-05 14:28:07.000000000 +0000 ++++ src/VBox/Runtime/r0drv/freebsd/the-freebsd-kernel.h 2013-03-28 13:10:34.000000000 +0000 +@@ -50,6 +50,9 @@ + #include + #include + #include ++#if __FreeBSD_version >= 1000030 ++#include ++#endif + #include + #include + #include +@@ -64,6 +67,7 @@ + #include + #include /* KERN_SUCCESS ++ */ + #include ++#include + #include /* vm_phys_alloc_* */ + #include /* kmem_alloc_attr */ + #include /* cnt */ Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/vboxguest.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/vboxguest.in Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,69 @@ +#!/bin/sh +# +# $FreeBSD: emulators/virtualbox-ose-additions/files/vboxguest.in 318265 2013-05-15 21:22:21Z decke $ +# + +# PROVIDE: vboxguest +# REQUIRE: FILESYSTEMS +# BEFORE: netif +# KEYWORD: nojail + +# +# Add the following lines to /etc/rc.conf.local or /etc/rc.conf +# to enable this service: +# +# vboxguest_enable (bool): Set to NO by default. +# Set it to YES to enable vboxguest on startup + +. /etc/rc.subr + +name="vboxguest" +rcvar=vboxguest_enable +start_cmd="vboxguest_start" +stop_cmd="vboxguest_stop" + +vboxguest_start() +{ + if ! kldstat -q -m pci/vboxguest; + then + if ! kldload vboxguest > /dev/null 2>&1; + then + warn "Can't load vboxguest module." + return 1 + fi + fi + if ! kldstat -q -m vgapci/vboxvideo; + then + if ! kldload vboxvideo > /dev/null 2>&1; + then + warn "Can't load vboxvideo module." + return 1 + fi + fi +} + +vboxguest_stop() +{ + if kldstat -q -m vgapci/vboxvideo; + then + if ! kldunload vboxvideo > /dev/null 2>&1; + then + warn "Can't unload vboxvideo module." + return 1 + fi + fi + if kldstat -q -m pci/vboxguest; + then + if ! kldunload vboxguest > /dev/null 2>&1; + then + warn "Can't unload vboxguest module." + return 1 + fi + fi +} + +load_rc_config $name + +: ${vboxguest_enable="NO"} + +run_rc_command "$1" Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/vboxservice.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/vboxservice.in Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,25 @@ +#!/bin/sh + +# $FreeBSD: emulators/virtualbox-ose-additions/files/vboxservice.in 300896 2012-07-14 13:54:48Z beat $ + +# PROVIDE: vboxservice +# REQUIRE: DAEMON vboxguest +# BEFORE: LOGIN +# KEYWORD: shutdown + +# Define vboxservice_enable in /etc/rc.conf[.local] to enable it. +# +# vboxservice_enable (bool): Set to "NO" by default. +# Set it to "YES" to enable VBoxService. + +. /etc/rc.subr + +name="vboxservice" +rcvar=vboxservice_enable +command="%%PREFIX%%/sbin/VBoxService" + +load_rc_config $name + +: ${vboxservice_enable="NO"} + +run_rc_command "$1" Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/pkg-descr Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,9 @@ +These additions are for installation inside a FreeBSD guest. + +VirtualBox is a family of powerful x86 virtualization products for +enterprise as well as home use. Not only is VirtualBox an extremely +feature rich, high performance product for enterprise customers, it +is also the only professional solution that is freely available as +Open Source Software under the terms of the GNU General Public License. + +WWW: http://www.virtualbox.org/ Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/pkg-message ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/pkg-message Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,21 @@ +============================================================================= + +VirtualBox Guest Additions were installed. + + +You need to enable the vboxguest startscript to load the kernel module and +vboxservice to use host time synchronization. + +vboxguest_enable="YES" +vboxservice_enable="YES" + +You also have to add all X11 users that want to use any of the additional +features (clipboard sharing, window scaling) to the wheel group. + +% pw groupmod wheel -m jerry + +Reboot the machine to load the needed kernel modules. + +For detailed informations please visit http://wiki.freebsd.org/VirtualBox + +============================================================================= Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/pkg-plist ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/pkg-plist Sun Jul 7 13:55:56 2013 (r254313) @@ -0,0 +1,31 @@ +@comment $FreeBSD: emulators/virtualbox-ose-additions/pkg-plist 318940 2013-05-24 09:47:12Z decke $ +%%X11%%bin/VBoxClient-all +%%X11%%bin/VBoxClient +%%X11%%etc/xdg/autostart/vboxclient.desktop +sbin/VBoxControl +sbin/VBoxService +%%OPENGL%%lib/VBoxOGL.so +%%OPENGL%%lib/VBoxOGLarrayspu.so +%%OPENGL%%lib/VBoxOGLcrutil.so +%%OPENGL%%lib/VBoxOGLerrorspu.so +%%OPENGL%%lib/VBoxOGLfeedbackspu.so +%%OPENGL%%lib/VBoxOGLpackspu.so +%%OPENGL%%lib/VBoxOGLpassthroughspu.so +%%OPENGL%%lib/dri/vboxvideo_dri.so +%%X11%%share/autostart/vboxclient.desktop +%%X11%%lib/xorg/modules/drivers/vboxvideo_drv.so +%%X11%%lib/xorg/modules/input/vboxmouse_drv.so +%%X11%%@dirrmtry share/autostart +%%X11%%@dirrmtry lib/xorg/modules/drivers +%%X11%%@dirrmtry lib/xorg/modules/input +%%X11%%@dirrmtry lib/xorg/modules +%%X11%%@dirrmtry lib/xorg +%%OPENGL%%@dirrmtry lib/dri +%%X11%%@dirrmtry lib +@cwd / +%%KMODDIR%%/vboxguest.ko +%%WITH_DEBUG%%%%KMODDIR%%/vboxguest.ko.symbols +%%X11%%%%KMODDIR%%/vboxvideo.ko +%%WITH_DEBUG%%%%X11%%%%KMODDIR%%/vboxvideo.ko +@exec /usr/sbin/kldxref /%%KMODDIR%% +@unexec /usr/sbin/kldxref /%%KMODDIR%% From owner-svn-soc-all@FreeBSD.ORG Sun Jul 7 14:05:09 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 01DD2A0B for ; Sun, 7 Jul 2013 14:05:09 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id E79A616DA for ; Sun, 7 Jul 2013 14:05:08 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67E58aE036750 for ; Sun, 7 Jul 2013 14:05:08 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r67E58uw036739 for svn-soc-all@FreeBSD.org; Sun, 7 Jul 2013 14:05:08 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 7 Jul 2013 14:05:08 GMT Message-Id: <201307071405.r67E58uw036739@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254322 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 14:05:09 -0000 Author: zcore Date: Sun Jul 7 14:05:08 2013 New Revision: 254322 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254322 Log: bare bone pci_ahci emulation freebsd recognize the device as an AHCI host Added: soc2013/zcore/head/usr.sbin/bhyve/ahci.h soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/Makefile Modified: soc2013/zcore/head/usr.sbin/bhyve/Makefile ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/Makefile Sun Jul 7 13:20:35 2013 (r254321) +++ soc2013/zcore/head/usr.sbin/bhyve/Makefile Sun Jul 7 14:05:08 2013 (r254322) @@ -10,7 +10,7 @@ SRCS+= ioapic.c mem.c mevent.c mptbl.c SRCS+= pci_emul.c pci_hostbridge.c pci_passthru.c pci_virtio_block.c SRCS+= pci_virtio_net.c pci_uart.c pit_8254.c pmtmr.c post.c rtc.c -SRCS+= xmsr.c spinup_ap.c +SRCS+= xmsr.c spinup_ap.c pci_ahci.c .PATH: ${.CURDIR}/../../sys/amd64/vmm SRCS+= vmm_instruction_emul.c Added: soc2013/zcore/head/usr.sbin/bhyve/ahci.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/zcore/head/usr.sbin/bhyve/ahci.h Sun Jul 7 14:05:08 2013 (r254322) @@ -0,0 +1,299 @@ +/*- + * Copyright (c) 1998 - 2008 Søren Schmidt + * Copyright (c) 2009-2012 Alexander Motin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * without modification, immediately at the beginning of the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* ATA register defines */ +#define ATA_DATA 0 /* (RW) data */ + +#define ATA_FEATURE 1 /* (W) feature */ +#define ATA_F_DMA 0x01 /* enable DMA */ +#define ATA_F_OVL 0x02 /* enable overlap */ + +#define ATA_COUNT 2 /* (W) sector count */ + +#define ATA_SECTOR 3 /* (RW) sector # */ +#define ATA_CYL_LSB 4 /* (RW) cylinder# LSB */ +#define ATA_CYL_MSB 5 /* (RW) cylinder# MSB */ +#define ATA_DRIVE 6 /* (W) Sector/Drive/Head */ +#define ATA_D_LBA 0x40 /* use LBA addressing */ +#define ATA_D_IBM 0xa0 /* 512 byte sectors, ECC */ + +#define ATA_COMMAND 7 /* (W) command */ + +#define ATA_ERROR 8 /* (R) error */ +#define ATA_E_ILI 0x01 /* illegal length */ +#define ATA_E_NM 0x02 /* no media */ +#define ATA_E_ABORT 0x04 /* command aborted */ +#define ATA_E_MCR 0x08 /* media change request */ +#define ATA_E_IDNF 0x10 /* ID not found */ +#define ATA_E_MC 0x20 /* media changed */ +#define ATA_E_UNC 0x40 /* uncorrectable data */ +#define ATA_E_ICRC 0x80 /* UDMA crc error */ +#define ATA_E_ATAPI_SENSE_MASK 0xf0 /* ATAPI sense key mask */ + +#define ATA_IREASON 9 /* (R) interrupt reason */ +#define ATA_I_CMD 0x01 /* cmd (1) | data (0) */ +#define ATA_I_IN 0x02 /* read (1) | write (0) */ +#define ATA_I_RELEASE 0x04 /* released bus (1) */ +#define ATA_I_TAGMASK 0xf8 /* tag mask */ + +#define ATA_STATUS 10 /* (R) status */ +#define ATA_ALTSTAT 11 /* (R) alternate status */ +#define ATA_S_ERROR 0x01 /* error */ +#define ATA_S_INDEX 0x02 /* index */ +#define ATA_S_CORR 0x04 /* data corrected */ +#define ATA_S_DRQ 0x08 /* data request */ +#define ATA_S_DSC 0x10 /* drive seek completed */ +#define ATA_S_SERVICE 0x10 /* drive needs service */ +#define ATA_S_DWF 0x20 /* drive write fault */ +#define ATA_S_DMA 0x20 /* DMA ready */ +#define ATA_S_READY 0x40 /* drive ready */ +#define ATA_S_BUSY 0x80 /* busy */ + +#define ATA_CONTROL 12 /* (W) control */ +#define ATA_A_IDS 0x02 /* disable interrupts */ +#define ATA_A_RESET 0x04 /* RESET controller */ +#define ATA_A_4BIT 0x08 /* 4 head bits */ +#define ATA_A_HOB 0x80 /* High Order Byte enable */ + +/* SATA register defines */ +#define ATA_SSTATUS 13 +#define ATA_SS_DET_MASK 0x0000000f +#define ATA_SS_DET_NO_DEVICE 0x00000000 +#define ATA_SS_DET_DEV_PRESENT 0x00000001 +#define ATA_SS_DET_PHY_ONLINE 0x00000003 +#define ATA_SS_DET_PHY_OFFLINE 0x00000004 + +#define ATA_SS_SPD_MASK 0x000000f0 +#define ATA_SS_SPD_NO_SPEED 0x00000000 +#define ATA_SS_SPD_GEN1 0x00000010 +#define ATA_SS_SPD_GEN2 0x00000020 +#define ATA_SS_SPD_GEN3 0x00000040 + +#define ATA_SS_IPM_MASK 0x00000f00 +#define ATA_SS_IPM_NO_DEVICE 0x00000000 +#define ATA_SS_IPM_ACTIVE 0x00000100 +#define ATA_SS_IPM_PARTIAL 0x00000200 +#define ATA_SS_IPM_SLUMBER 0x00000600 + +#define ATA_SERROR 14 +#define ATA_SE_DATA_CORRECTED 0x00000001 +#define ATA_SE_COMM_CORRECTED 0x00000002 +#define ATA_SE_DATA_ERR 0x00000100 +#define ATA_SE_COMM_ERR 0x00000200 +#define ATA_SE_PROT_ERR 0x00000400 +#define ATA_SE_HOST_ERR 0x00000800 +#define ATA_SE_PHY_CHANGED 0x00010000 +#define ATA_SE_PHY_IERROR 0x00020000 +#define ATA_SE_COMM_WAKE 0x00040000 +#define ATA_SE_DECODE_ERR 0x00080000 +#define ATA_SE_PARITY_ERR 0x00100000 +#define ATA_SE_CRC_ERR 0x00200000 +#define ATA_SE_HANDSHAKE_ERR 0x00400000 +#define ATA_SE_LINKSEQ_ERR 0x00800000 +#define ATA_SE_TRANSPORT_ERR 0x01000000 +#define ATA_SE_UNKNOWN_FIS 0x02000000 +#define ATA_SE_EXCHANGED 0x04000000 + +#define ATA_SCONTROL 15 +#define ATA_SC_DET_MASK 0x0000000f +#define ATA_SC_DET_IDLE 0x00000000 +#define ATA_SC_DET_RESET 0x00000001 +#define ATA_SC_DET_DISABLE 0x00000004 + +#define ATA_SC_SPD_MASK 0x000000f0 +#define ATA_SC_SPD_NO_SPEED 0x00000000 +#define ATA_SC_SPD_SPEED_GEN1 0x00000010 +#define ATA_SC_SPD_SPEED_GEN2 0x00000020 +#define ATA_SC_SPD_SPEED_GEN3 0x00000040 + +#define ATA_SC_IPM_MASK 0x00000f00 +#define ATA_SC_IPM_NONE 0x00000000 +#define ATA_SC_IPM_DIS_PARTIAL 0x00000100 +#define ATA_SC_IPM_DIS_SLUMBER 0x00000200 + +#define ATA_SACTIVE 16 + +#define AHCI_MAX_PORTS 32 +#define AHCI_MAX_SLOTS 32 + +/* SATA AHCI v1.0 register defines */ +#define AHCI_CAP 0x00 +#define AHCI_CAP_NPMASK 0x0000001f +#define AHCI_CAP_SXS 0x00000020 +#define AHCI_CAP_EMS 0x00000040 +#define AHCI_CAP_CCCS 0x00000080 +#define AHCI_CAP_NCS 0x00001F00 +#define AHCI_CAP_NCS_SHIFT 8 +#define AHCI_CAP_PSC 0x00002000 +#define AHCI_CAP_SSC 0x00004000 +#define AHCI_CAP_PMD 0x00008000 +#define AHCI_CAP_FBSS 0x00010000 +#define AHCI_CAP_SPM 0x00020000 +#define AHCI_CAP_SAM 0x00080000 +#define AHCI_CAP_ISS 0x00F00000 +#define AHCI_CAP_ISS_SHIFT 20 +#define AHCI_CAP_SCLO 0x01000000 +#define AHCI_CAP_SAL 0x02000000 +#define AHCI_CAP_SALP 0x04000000 +#define AHCI_CAP_SSS 0x08000000 +#define AHCI_CAP_SMPS 0x10000000 +#define AHCI_CAP_SSNTF 0x20000000 +#define AHCI_CAP_SNCQ 0x40000000 +#define AHCI_CAP_64BIT 0x80000000 + +#define AHCI_GHC 0x04 +#define AHCI_GHC_AE 0x80000000 +#define AHCI_GHC_MRSM 0x00000004 +#define AHCI_GHC_IE 0x00000002 +#define AHCI_GHC_HR 0x00000001 + +#define AHCI_IS 0x08 +#define AHCI_PI 0x0c +#define AHCI_VS 0x10 + +#define AHCI_CCCC 0x14 +#define AHCI_CCCC_TV_MASK 0xffff0000 +#define AHCI_CCCC_TV_SHIFT 16 +#define AHCI_CCCC_CC_MASK 0x0000ff00 +#define AHCI_CCCC_CC_SHIFT 8 +#define AHCI_CCCC_INT_MASK 0x000000f8 +#define AHCI_CCCC_INT_SHIFT 3 +#define AHCI_CCCC_EN 0x00000001 +#define AHCI_CCCP 0x18 + +#define AHCI_EM_LOC 0x1C +#define AHCI_EM_CTL 0x20 +#define AHCI_EM_MR 0x00000001 +#define AHCI_EM_TM 0x00000100 +#define AHCI_EM_RST 0x00000200 +#define AHCI_EM_LED 0x00010000 +#define AHCI_EM_SAFTE 0x00020000 +#define AHCI_EM_SES2 0x00040000 +#define AHCI_EM_SGPIO 0x00080000 +#define AHCI_EM_SMB 0x01000000 +#define AHCI_EM_XMT 0x02000000 +#define AHCI_EM_ALHD 0x04000000 +#define AHCI_EM_PM 0x08000000 + +#define AHCI_CAP2 0x24 +#define AHCI_CAP2_BOH 0x00000001 +#define AHCI_CAP2_NVMP 0x00000002 +#define AHCI_CAP2_APST 0x00000004 + +#define AHCI_OFFSET 0x100 +#define AHCI_STEP 0x80 + +#define AHCI_P_CLB 0x00 +#define AHCI_P_CLBU 0x04 +#define AHCI_P_FB 0x08 +#define AHCI_P_FBU 0x0c +#define AHCI_P_IS 0x10 +#define AHCI_P_IE 0x14 +#define AHCI_P_IX_DHR 0x00000001 +#define AHCI_P_IX_PS 0x00000002 +#define AHCI_P_IX_DS 0x00000004 +#define AHCI_P_IX_SDB 0x00000008 +#define AHCI_P_IX_UF 0x00000010 +#define AHCI_P_IX_DP 0x00000020 +#define AHCI_P_IX_PC 0x00000040 +#define AHCI_P_IX_MP 0x00000080 + +#define AHCI_P_IX_PRC 0x00400000 +#define AHCI_P_IX_IPM 0x00800000 +#define AHCI_P_IX_OF 0x01000000 +#define AHCI_P_IX_INF 0x04000000 +#define AHCI_P_IX_IF 0x08000000 +#define AHCI_P_IX_HBD 0x10000000 +#define AHCI_P_IX_HBF 0x20000000 +#define AHCI_P_IX_TFE 0x40000000 +#define AHCI_P_IX_CPD 0x80000000 + +#define AHCI_P_CMD 0x18 +#define AHCI_P_CMD_ST 0x00000001 +#define AHCI_P_CMD_SUD 0x00000002 +#define AHCI_P_CMD_POD 0x00000004 +#define AHCI_P_CMD_CLO 0x00000008 +#define AHCI_P_CMD_FRE 0x00000010 +#define AHCI_P_CMD_CCS_MASK 0x00001f00 +#define AHCI_P_CMD_CCS_SHIFT 8 +#define AHCI_P_CMD_ISS 0x00002000 +#define AHCI_P_CMD_FR 0x00004000 +#define AHCI_P_CMD_CR 0x00008000 +#define AHCI_P_CMD_CPS 0x00010000 +#define AHCI_P_CMD_PMA 0x00020000 +#define AHCI_P_CMD_HPCP 0x00040000 +#define AHCI_P_CMD_MPSP 0x00080000 +#define AHCI_P_CMD_CPD 0x00100000 +#define AHCI_P_CMD_ESP 0x00200000 +#define AHCI_P_CMD_FBSCP 0x00400000 +#define AHCI_P_CMD_APSTE 0x00800000 +#define AHCI_P_CMD_ATAPI 0x01000000 +#define AHCI_P_CMD_DLAE 0x02000000 +#define AHCI_P_CMD_ALPE 0x04000000 +#define AHCI_P_CMD_ASP 0x08000000 +#define AHCI_P_CMD_ICC_MASK 0xf0000000 +#define AHCI_P_CMD_NOOP 0x00000000 +#define AHCI_P_CMD_ACTIVE 0x10000000 +#define AHCI_P_CMD_PARTIAL 0x20000000 +#define AHCI_P_CMD_SLUMBER 0x60000000 + +#define AHCI_P_TFD 0x20 +#define AHCI_P_SIG 0x24 +#define AHCI_P_SSTS 0x28 +#define AHCI_P_SCTL 0x2c +#define AHCI_P_SERR 0x30 +#define AHCI_P_SACT 0x34 +#define AHCI_P_CI 0x38 +#define AHCI_P_SNTF 0x3C +#define AHCI_P_FBS 0x40 +#define AHCI_P_FBS_EN 0x00000001 +#define AHCI_P_FBS_DEC 0x00000002 +#define AHCI_P_FBS_SDE 0x00000004 +#define AHCI_P_FBS_DEV 0x00000f00 +#define AHCI_P_FBS_DEV_SHIFT 8 +#define AHCI_P_FBS_ADO 0x0000f000 +#define AHCI_P_FBS_ADO_SHIFT 12 +#define AHCI_P_FBS_DWE 0x000f0000 +#define AHCI_P_FBS_DWE_SHIFT 16 + +/* Just to be sure, if building as module. */ +#if MAXPHYS < 512 * 1024 +#undef MAXPHYS +#define MAXPHYS 512 * 1024 +#endif +/* Pessimistic prognosis on number of required S/G entries */ +#define AHCI_SG_ENTRIES (roundup(btoc(MAXPHYS) + 1, 8)) +/* Command list. 32 commands. First, 1Kbyte aligned. */ +#define AHCI_CL_OFFSET 0 +#define AHCI_CL_SIZE 32 +/* Command tables. Up to 32 commands, Each, 128byte aligned. */ +#define AHCI_CT_OFFSET (AHCI_CL_OFFSET + AHCI_CL_SIZE * AHCI_MAX_SLOTS) +#define AHCI_CT_SIZE (128 + AHCI_SG_ENTRIES * 16) +/* Total main work area. */ +#define AHCI_WORK_SIZE (AHCI_CT_OFFSET + AHCI_CT_SIZE * ch->numslots) Added: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Jul 7 14:05:08 2013 (r254322) @@ -0,0 +1,194 @@ +/*- + * Copyright (c) 2011 NetApp, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bhyverun.h" +#include "pci_emul.h" +#include "ahci.h" + +#define AHCI_REGSZ (AHCI_OFFSET+6*AHCI_STEP) + +/* + * Debug printf + */ +static int pci_ahci_debug; +#define DPRINTF(params) if (pci_ahci_debug) printf params +#define WPRINTF(params) printf params + +/* + * Per-device softc + */ +struct pci_ahci_softc { + struct pci_devinst *asc_pi; + int asc_fd; + int vbsc_lastq; +}; + +static int +pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) +{ + struct stat sbuf; + struct pci_ahci_softc *sc; + off_t size; + int fd; + int sectsz; + + if (opts == NULL) { + printf("pci_ahci: backing device required\n"); + return (1); + } + + /* + * The supplied backing file has to exist + */ + fd = open(opts, O_RDWR); + if (fd < 0) { + perror("Could not open backing file"); + return (1); + } + + if (fstat(fd, &sbuf) < 0) { + perror("Could not stat backing file"); + close(fd); + return (1); + } + + /* + * Deal with raw devices + */ + size = sbuf.st_size; + sectsz = DEV_BSIZE; + if (S_ISCHR(sbuf.st_mode)) { + if (ioctl(fd, DIOCGMEDIASIZE, &size) < 0 || + ioctl(fd, DIOCGSECTORSIZE, §sz)) { + perror("Could not fetch dev blk/sector size"); + close(fd); + return (1); + } + assert(size != 0); + assert(sectsz != 0); + } + + sc = malloc(sizeof(struct pci_ahci_softc)); + memset(sc, 0, sizeof(struct pci_ahci_softc)); + + pi->pi_arg = sc; + sc->asc_pi = pi; + sc->asc_fd = fd; + + /* Intel Cougar Point AHCI */ + pci_set_cfgdata16(pi, PCIR_DEVICE, 0x1c03); + pci_set_cfgdata16(pi, PCIR_VENDOR, 0x8086); + pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_STORAGE); + pci_set_cfgdata8(pi, PCIR_SUBCLASS, PCIS_STORAGE_SATA); + pci_set_cfgdata8(pi, PCIR_PROGIF, PCIP_STORAGE_SATA_AHCI_1_0); + + pci_emul_add_msicap(pi, 1); + + pci_emul_alloc_bar(pi, 0, PCIBAR_IO, AHCI_REGSZ); + + return (0); +} + +static void +pci_ahci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, + int baridx, uint64_t offset, int size, uint64_t value) +{ + + assert(baridx == 0); + + switch (offset) { + default: + DPRINTF(("pci_ahci: unknown i/o write offset %ld\n\r", offset)); + value = 0; + break; + } +} + +uint64_t +pci_ahci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, + int baridx, uint64_t offset, int size) +{ + uint32_t value; + + assert(baridx == 0); + + switch (offset) { + case AHCI_CAP: + assert(size == 4); + value = AHCI_CAP_64BIT | AHCI_CAP_SNCQ | AHCI_CAP_SSNTF | + AHCI_CAP_SMPS | AHCI_CAP_SSS | AHCI_CAP_SALP | + AHCI_CAP_SAL | AHCI_CAP_SCLO | (0x3 << AHCI_CAP_ISS_SHIFT)| + AHCI_CAP_PMD | AHCI_CAP_SSC | AHCI_CAP_PSC | + (0x1f << AHCI_CAP_NCS_SHIFT) | AHCI_CAP_EMS | + AHCI_CAP_SXS | 0x5; + break; + case AHCI_VS: + assert(size == 4); + value = 0x10300; + break; + case AHCI_CAP2: + assert(size == 4); + value = AHCI_CAP2_APST; + break; + default: + DPRINTF(("pci_ahci: unknown i/o read offset %ld\n\r", offset)); + value = 0; + break; + } + + return (value); +} + +struct pci_devemu pci_de_ahci = { + .pe_emu = "ahci", + .pe_init = pci_ahci_init, + .pe_barwrite = pci_ahci_write, + .pe_barread = pci_ahci_read +}; +PCI_EMUL_SET(pci_de_ahci); From owner-svn-soc-all@FreeBSD.ORG Sun Jul 7 20:48:12 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5F40EE6C for ; Sun, 7 Jul 2013 20:48:12 +0000 (UTC) (envelope-from oleksandr@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 4F6981616 for ; Sun, 7 Jul 2013 20:48:12 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67KmCjv063491 for ; Sun, 7 Jul 2013 20:48:12 GMT (envelope-from oleksandr@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r67KmCnt063481 for svn-soc-all@FreeBSD.org; Sun, 7 Jul 2013 20:48:12 GMT (envelope-from oleksandr@FreeBSD.org) Date: Sun, 7 Jul 2013 20:48:12 GMT Message-Id: <201307072048.r67KmCnt063481@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to oleksandr@FreeBSD.org using -f From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254374 - soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 20:48:12 -0000 Author: oleksandr Date: Sun Jul 7 20:48:11 2013 New Revision: 254374 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254374 Log: Add initial patch for freebsd guest additions into virtualbox-ose-additions port Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-Vbox-Additions-freebsd.kmk Added: soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-Vbox-Additions-freebsd.kmk ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/oleksandr/ports/emulators/virtualbox-ose-additions/files/patch-src-Vbox-Additions-freebsd.kmk Sun Jul 7 20:48:11 2013 (r254374) @@ -0,0 +1,11 @@ +--- src/VBox/Additions/freebsd/Makefile.kmk ++++ src/VBox/Additions/freebsd/Makefile.kmk +@@ -23,7 +23,7 @@ $(error "The FreeBSD guest additions installer can only be built on FreeBSD!") + endif + + # Include sub-makefiles. +-#include $(PATH_SUB_CURRENT)/vboxvfs/Makefile.kmk ++include $(PATH_SUB_CURRENT)/vboxvfs/Makefile.kmk + include $(PATH_SUB_CURRENT)/drm/Makefile.kmk + + # From owner-svn-soc-all@FreeBSD.ORG Sun Jul 7 23:59:19 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8C7199DC for ; Sun, 7 Jul 2013 23:59:19 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 7D45C1C36 for ; Sun, 7 Jul 2013 23:59:19 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67NxJMp011792 for ; Sun, 7 Jul 2013 23:59:19 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r67NxJOv011788 for svn-soc-all@FreeBSD.org; Sun, 7 Jul 2013 23:59:19 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 7 Jul 2013 23:59:19 GMT Message-Id: <201307072359.r67NxJOv011788@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254387 - in soc2013/mattbw/backend/bin: . getcat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 23:59:19 -0000 Author: mattbw Date: Sun Jul 7 23:59:19 2013 New Revision: 254387 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254387 Log: move getcat out of tests, make the test Warning: Object directory not changed from original /usr/home/mattbw/GSoC/backend it if necessary Added: soc2013/mattbw/backend/bin/ soc2013/mattbw/backend/bin/getcat/ soc2013/mattbw/backend/bin/getcat/Makefile soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.1 soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c Added: soc2013/mattbw/backend/bin/getcat/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/bin/getcat/Makefile Sun Jul 7 23:59:19 2013 (r254387) @@ -0,0 +1,16 @@ +# $FreeBSD$ + +PROG= pkgpk-getcat +SRCS= pkgpk-getcat.c ../../groups.c + +DESTDIR?= /usr/local +BINDIR?= /bin +MANDIR?= /man/man + +CFLAGS+= `pkgconf --cflags pkg glib-2.0` +CFLAGS+= -I/usr/local/include/PackageKit -I/usr/local/include/PackageKit/backend +CFLAGS+= -I../../ +CFLAGS+= -DPK_COMPILATION +LDFLAGS+= `pkgconf --libs pkg glib-2.0` -lpackagekit-glib2 + +.include Added: soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.1 Sun Jul 7 23:59:19 2013 (r254387) @@ -0,0 +1,53 @@ +.\" Copyright (C) 2013 Matt Windsor +.\" +.\" Licensed under the GNU General Public License Version 2 +.\" +.\" This program is free software; you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation; either version 2 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more files. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program; if not, write to the Free Software +.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +.\"----------------------------------------------------------------------------- +.Dd July 7, 2013 +.Dt pkgpk-getcat 1 +.Os +.\"----------------------------------------------------------------------------- +.Sh NAME +.Nm pkgpk-getcat +.Nd return PackageKit category for a pkgng port origin +.\"----------------------------------------------------------------------------- +.Sh SYNOPSIS +.Nm +.Ar origin +.\"----------------------------------------------------------------------------- +.Sh DESCRIPTION +.Nm +is a debug utility for investigating the mapping between ports directories and +PackageKit categories as part of the PackageKit pkgng backend. +It returns the descriptive name of the category that matches the directory of +the port origin given on the command line. +.Pp +.Ar origin +is expected to be a package origin, that is a port category directory followed +by a slash and then a port name. For the purposes of +.Nm +the actual port/package name may be empty, but the slash must always exist. +.Pp +The result is always written on one line to standard output. +.\"----------------------------------------------------------------------------- +.Sh AUTHORS +.An Matt Windsor Aq mattbw@FreeBSD.org +.\"----------------------------------------------------------------------------- +.Sh BUGS +If the backend cannot find a match for a port directory, it will return +.Ql unknown +instead. This includes the case in which a directory has been supplied without +a trailing slash. Added: soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c Sun Jul 7 23:59:19 2013 (r254387) @@ -0,0 +1,51 @@ +/*- + * + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* + * Gets the group name of a pkgng origin, eg 'ports-mgmt/pkg' -> 'admin-tools'. + */ +const char *USAGE = "usage: %s origin\n"; + +#include + +#include +#include "pkg.h" +#include "pk-backend.h" + +#include "groups.h" + + +int +main(int argc, char **argv) +{ + int ret; + + ret = 0; + if (argc != 2) { + ret = 1; + fprintf(stderr, USAGE, argv[0]); + } else { + printf("%s\n", + pk_group_enum_to_string(group_from_origin(argv[1]))); + } + + return ret; +} From owner-svn-soc-all@FreeBSD.ORG Mon Jul 8 01:05:22 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id EEC3E72A for ; Mon, 8 Jul 2013 01:05:22 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id DED111E7C for ; Mon, 8 Jul 2013 01:05:22 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6815MR3000704 for ; Mon, 8 Jul 2013 01:05:22 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6815MSY000699 for svn-soc-all@FreeBSD.org; Mon, 8 Jul 2013 01:05:22 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 8 Jul 2013 01:05:22 GMT Message-Id: <201307080105.r6815MSY000699@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254391 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 01:05:23 -0000 Author: mattbw Date: Mon Jul 8 01:05:22 2013 New Revision: 254391 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254391 Log: add explanatory comment Modified: soc2013/mattbw/backend/query_match.c Modified: soc2013/mattbw/backend/query_match.c ============================================================================== --- soc2013/mattbw/backend/query_match.c Mon Jul 8 00:57:12 2013 (r254390) +++ soc2013/mattbw/backend/query_match.c Mon Jul 8 01:05:22 2013 (r254391) @@ -43,7 +43,7 @@ return query_do(backend, load_flags, emitter, - PKG_JOBS_INSTALL, + PKG_JOBS_INSTALL, /* <-- does not matter what goes here */ NULL, query_find_match); } From owner-svn-soc-all@FreeBSD.ORG Mon Jul 8 01:06:44 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 652FC74C for ; Mon, 8 Jul 2013 01:06:44 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 55BD61E86 for ; Mon, 8 Jul 2013 01:06:44 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6816ivW016660 for ; Mon, 8 Jul 2013 01:06:44 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6816iZM016650 for svn-soc-all@FreeBSD.org; Mon, 8 Jul 2013 01:06:44 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 8 Jul 2013 01:06:44 GMT Message-Id: <201307080106.r6816iZM016650@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254392 - in soc2013/mattbw/tests: all-ports-dirs-mapped get-details-output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 01:06:44 -0000 Author: mattbw Date: Mon Jul 8 01:06:44 2013 New Revision: 254392 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254392 Log: add new test, remove getcat and slightly mod getdetails test Added: soc2013/mattbw/tests/all-ports-dirs-mapped/ soc2013/mattbw/tests/all-ports-dirs-mapped/test.sh (contents, props changed) soc2013/mattbw/tests/get-details-output/test-pkgs Deleted: soc2013/mattbw/tests/get-details-output/Makefile soc2013/mattbw/tests/get-details-output/getcat.1 soc2013/mattbw/tests/get-details-output/getcat.c Modified: soc2013/mattbw/tests/get-details-output/test-pkg.sh Added: soc2013/mattbw/tests/all-ports-dirs-mapped/test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/all-ports-dirs-mapped/test.sh Mon Jul 8 01:06:44 2013 (r254392) @@ -0,0 +1,47 @@ +#!/bin/sh + +################################################################################ +# Tests to make sure all ports directories have a corresponding PackageKit +# category mapped, using getcat. +# +# Usage: ./test +# (You may need to make/install any programs listed below) + +################################################################################ +# Programs used in this test (relative paths will require make-ing, names +# imply external program installation). + +CMD_GETCAT_DIR=../../backend/bin/getcat/ +CMD_GETCAT="${CMD_GETCAT_DIR}pkgpk-getcat" + +( cd "${CMD_GETCAT_DIR}"; make ) +if [ $? -ne 0 ] +then + echo "couldn't make getcat" + exit 2 +fi + +# Quick and dirty way of getting all ports directories with the / required for +# getcat to work; assume all required ports directories are lowercase and all +# other directories have at least one uppercase character. +PORTS_DIRS=`ls -1F /usr/ports | grep '/$' | grep -v ".*[A-Z].*"` + +# Test to make sure getcat retrieves "unknown" for silly ports dirs +GROUP=`${CMD_GETCAT} wombatwombatwombat` +if [ "${GROUP}" != "unknown" ] +then + echo "test failed, did not return unknown for bad ports dir" + exit 1 +fi + +for DIR in ${PORTS_DIRS} +do + GROUP=`${CMD_GETCAT} ${DIR}` + if [ -n "${GROUP}" ] && [ "${GROUP}" != "unknown" ] + then + echo "${DIR} -> ${GROUP}" + else + echo "test failed on ${DIR}" + exit 1 + fi +done Modified: soc2013/mattbw/tests/get-details-output/test-pkg.sh ============================================================================== --- soc2013/mattbw/tests/get-details-output/test-pkg.sh Mon Jul 8 01:05:22 2013 (r254391) +++ soc2013/mattbw/tests/get-details-output/test-pkg.sh Mon Jul 8 01:06:44 2013 (r254392) @@ -8,10 +8,28 @@ # # Usage: ./test-pkg [PACKAGE] [PK_REPO] # or ./test.sh (runs this over a set of packages) +# (You may need to make/install any programs listed below) # # TODO: Specific version/arch requirements in the PackageID ################################################################################ +# Programs used in this test (relative paths will require make-ing, names +# imply external program installation). +CMD_PKG=pkg +CMD_PKCON=pkcon + +CMD_GETCAT_DIR=../../backend/bin/getcat/ +CMD_GETCAT="${CMD_GETCAT_DIR}pkgpk-getcat" + +( cd "${CMD_GETCAT_DIR}"; make ) +if [ $? -ne 0 ] +then + echo "couldn't make getcat" + exit 2 +fi + + +################################################################################ # Retrieve the arguments. if [ $# -gt 0 ] @@ -53,12 +71,12 @@ if [ ${TRY_LOCAL} -gt 0 ] then # Does the package exist locally? - TEST=`eval pkg query ${ECOND} \"%n\"` + TEST=`eval ${CMD_PKG} query ${ECOND} \"%n\"` if [ -n "${TEST}" ] then FOUND=1 TRY_REMOTE=0 - QTYPE="pkg query" + QTYPE="${CMD_PKG} query" fi fi if [ ${TRY_REMOTE} -gt 0 ] @@ -68,7 +86,7 @@ if [ -n "${TEST}" ] then FOUND=1 - QTYPE="pkg rquery ${REPO}" + QTYPE="${CMD_PKG} rquery ${REPO}" fi fi PKGCMD="${QTYPE} ${ECOND}" @@ -78,7 +96,7 @@ PK_ID="${PACKAGE};;;${PK_REPO}" echo "testing with package ${PACKAGE}" echo " pkg invocation: ${PKGCMD} ..." -echo " pkcon invocation: pkcon get-details ${PK_ID}" +echo " pkcon invocation: ${CMD_PKCON} get-details ${PK_ID}" ################################################################################ # Infer data not available from a query string but used in PackageKit. @@ -86,8 +104,6 @@ # Get the expected ABI through some invasive inspection of the pkg config dump ARCH="`pkg -vv | grep ABI | sed 's/ *ABI: *//'`" -CMD_GETCAT="./getcat" - # Get the PackageKit group of the package ORIGIN="`eval ${PKGCMD} \"%o\"`" GROUP="`${CMD_GETCAT} ${ORIGIN}`" @@ -117,7 +133,8 @@ PKCON_FILE="${PACKAGE}-pkcon" eval ${PKGCMD} \""${FMT}"\" > "${PKG_FILE}" -pkcon get-details "${PK_ID}" | awk -f "strip_messages.awk" > "${PKCON_FILE}" +${CMD_PKCON} get-details "${PK_ID}" | + awk -f "strip_messages.awk" > "${PKCON_FILE}" ################################################################################ # Diff the results. Added: soc2013/mattbw/tests/get-details-output/test-pkgs ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/get-details-output/test-pkgs Mon Jul 8 01:06:44 2013 (r254392) @@ -0,0 +1,11 @@ +pkg +pkg installed +pkg packagesite +wine +wine installed +wine packagesite +asciidoc +asciidoc installed +asciidoc packagesite +gnu-unifont +gnu-unifont packagesite From owner-svn-soc-all@FreeBSD.ORG Mon Jul 8 01:22:57 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8006FCA9 for ; Mon, 8 Jul 2013 01:22:57 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 715101F17 for ; Mon, 8 Jul 2013 01:22:57 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r681Mvwf070314 for ; Mon, 8 Jul 2013 01:22:57 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r681MvrI070305 for svn-soc-all@FreeBSD.org; Mon, 8 Jul 2013 01:22:57 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 8 Jul 2013 01:22:57 GMT Message-Id: <201307080122.r681MvrI070305@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254393 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 01:22:57 -0000 Author: mattbw Date: Mon Jul 8 01:22:56 2013 New Revision: 254393 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254393 Log: eventual filters support Modified: soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/query.c Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Mon Jul 8 01:06:44 2013 (r254392) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Mon Jul 8 01:22:56 2013 (r254393) @@ -115,6 +115,7 @@ /* TODO: support more filters */ return pk_bitfield_from_enums(PK_FILTER_ENUM_INSTALLED, + PK_FILTER_ENUM_NOT_INSTALLED, -1); } Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Mon Jul 8 01:06:44 2013 (r254392) +++ soc2013/mattbw/backend/query.c Mon Jul 8 01:22:56 2013 (r254393) @@ -77,6 +77,7 @@ gboolean try_local; gboolean try_remote; int match; + PkBitfield filters; const char *name; gchar *match_id; struct pkg *match_pkg; @@ -102,6 +103,13 @@ try_remote = (q->local_repo == FALSE); } + /* Apply filters, if any */ + filters = pk_backend_get_uint(q->backend, "filters"); + if (pk_bitfield_contain(filters, PK_FILTER_ENUM_INSTALLED)) + try_remote = FALSE; + if (pk_bitfield_contain(filters, PK_FILTER_ENUM_NOT_INSTALLED)) + try_local = FALSE; + /* Try a local search first, if applicable. */ it = (try_local ? pkgdb_query(db, name, match) : NULL); if (it != NULL) From owner-svn-soc-all@FreeBSD.ORG Mon Jul 8 06:55:07 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4174CBE6 for ; Mon, 8 Jul 2013 06:55:07 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 2395E1BB9 for ; Mon, 8 Jul 2013 06:55:07 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r686t7NB090738 for ; Mon, 8 Jul 2013 06:55:07 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r686t6f4090728 for svn-soc-all@FreeBSD.org; Mon, 8 Jul 2013 06:55:06 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 8 Jul 2013 06:55:06 GMT Message-Id: <201307080655.r686t6f4090728@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254404 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 06:55:07 -0000 Author: mattbw Date: Mon Jul 8 06:55:06 2013 New Revision: 254404 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254404 Log: (in progress) even more changing around ready for resolve Added: soc2013/mattbw/backend/actions/resolve.c Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/actions.h soc2013/mattbw/backend/actions/install-files.c soc2013/mattbw/backend/db.c soc2013/mattbw/backend/db.h soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/query.c soc2013/mattbw/backend/query.h Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Mon Jul 8 05:58:09 2013 (r254403) +++ soc2013/mattbw/backend/Makefile Mon Jul 8 06:55:06 2013 (r254404) @@ -16,7 +16,8 @@ actions/get-files.c \ actions/get-repo-list.c \ actions/install-files.c \ - actions/install-packages.c + actions/install-packages.c \ + actions/resolve.c LIBDIR= /usr/local/lib/packagekit-backend Modified: soc2013/mattbw/backend/actions/actions.h ============================================================================== --- soc2013/mattbw/backend/actions/actions.h Mon Jul 8 05:58:09 2013 (r254403) +++ soc2013/mattbw/backend/actions/actions.h Mon Jul 8 06:55:06 2013 (r254404) @@ -33,6 +33,7 @@ gboolean get_repo_list_thread(PkBackend *backend); gboolean install_files_thread(PkBackend *backend); gboolean install_packages_thread(PkBackend *backend); +gboolean resolve_thread(PkBackend *backend); gboolean simulate_install_files_thread(PkBackend *backend); gboolean simulate_install_packages_thread(PkBackend *backend); Modified: soc2013/mattbw/backend/actions/install-files.c ============================================================================== --- soc2013/mattbw/backend/actions/install-files.c Mon Jul 8 05:58:09 2013 (r254403) +++ soc2013/mattbw/backend/actions/install-files.c Mon Jul 8 06:55:06 2013 (r254404) @@ -22,7 +22,7 @@ #include "../pk-backend.h" #include "pkg.h" -#include "../db.h" /* open_remote_db */ +#include "../db.h" /* db_open_remote */ #include "../hash_traverse.h" /* HASH_FOR */ #include "../pkgutils.h" /* pkgutils_... */ #include "../query_match.h" /* query_match_... */ @@ -88,7 +88,7 @@ } else { /* TODO: event hook */ - if (open_remote_db(&db, backend) == FALSE) + if (db_open_remote(&db, backend) == FALSE) goto cleanup; (void)pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); Added: soc2013/mattbw/backend/actions/resolve.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/resolve.c Mon Jul 8 06:55:06 2013 (r254404) @@ -0,0 +1,83 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "../pk-backend.h" +#include "pkg.h" + +#include "../db.h" /* db_open_remote */ +#include "actions.h" /* Prototype */ + +static gboolean resolve_id(struct pkgdb *db, PkBackend *backend, gchar *id); +static gboolean resolve_name(struct pkgdb *db, PkBackend *backend, gchar *name); + +/* + * Resolves a package identifier, which may be a full PackageID or a package + * name, to a package that is promptly emitted. + */ +gboolean +resolve_thread(PkBackend *backend) +{ + gboolean success; + struct pkgdb *db; + gchar **package_ids; + + success = TRUE; + + package_ids = pk_backend_get_strv(backend, "package_ids"); + + db = NULL; + if (db_open_remote(&db, backend) == TRUE) { + gchar **id_p; + + for (id_p = package_ids; *id_p != NULL && success; id_p++) { + if (pk_package_id_check(*id_p) == TRUE) + success = resolve_id(db, backend, *id_p); + else + success = resolve_name(db, backend, *id_p); + } + } else + success = FALSE; + + pk_backend_finished(backend); + return success; +} + +static gboolean +resolve_id(struct pkgdb *db, PkBackend *backend, gchar *id) +{ + + /* TODO: implement */ + (void)db; + (void)backend; + (void)id; + return FALSE; +} + +static gboolean +resolve_name(struct pkgdb *db, PkBackend *backend, gchar *name) +{ + + /* TODO: implement */ + (void)db; + (void)backend; + (void)name; + return FALSE; +} + Modified: soc2013/mattbw/backend/db.c ============================================================================== --- soc2013/mattbw/backend/db.c Mon Jul 8 05:58:09 2013 (r254403) +++ soc2013/mattbw/backend/db.c Mon Jul 8 06:55:06 2013 (r254404) @@ -43,7 +43,7 @@ * "pk_backend_initialize" and before "pk_backend_destroy". */ gboolean -open_remote_db(struct pkgdb **db_p, PkBackend *backend) +db_open_remote(struct pkgdb **db_p, PkBackend *backend) { gboolean success; Modified: soc2013/mattbw/backend/db.h ============================================================================== --- soc2013/mattbw/backend/db.h Mon Jul 8 05:58:09 2013 (r254403) +++ soc2013/mattbw/backend/db.h Mon Jul 8 06:55:06 2013 (r254404) @@ -26,6 +26,6 @@ #include "pk-backend.h" /* PkBackend */ #include "pkg.h" /* struct pkgdb */ -gboolean open_remote_db(struct pkgdb **db, PkBackend *backend); +gboolean db_open_remote(struct pkgdb **db, PkBackend *backend); -#endif /* !_PKGNG_BACKEND_DETAILS_H_ */ +#endif /* !_PKGNG_BACKEND_DB_H_ */ Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Mon Jul 8 05:58:09 2013 (r254403) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Mon Jul 8 06:55:06 2013 (r254404) @@ -172,6 +172,15 @@ } void +pk_backend_resolve(PkBackend *backend, PkBitfield filters, gchar **package_ids) +{ + + INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ + INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + pk_backend_thread_create(backend, resolve_thread); +} + +void pk_backend_simulate_install_files(PkBackend *backend, gchar **full_paths) { Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Mon Jul 8 05:58:09 2013 (r254403) +++ soc2013/mattbw/backend/query.c Mon Jul 8 06:55:06 2013 (r254404) @@ -25,7 +25,7 @@ #include "query.h" /* Prototypes */ -#include "db.h" /* open_remote_db */ +#include "db.h" /* db_open_remote */ #include "hash_traverse.h" /* HASH_FOR */ #include "utils.h" /* string_match */ #include "pkgutils.h" /* pkgutils_... */ @@ -168,29 +168,31 @@ (void)pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); + /* + * We're using length/index instead of incrementing the pointer to NULL + * so that we can infer the progress bar percentage. + */ package_ids = pk_backend_get_strv(backend, "package_ids"); len = g_strv_length(package_ids); db = NULL; q = NULL; - no_error_yet = open_remote_db(&db, backend); + no_error_yet = db_open_remote(&db, backend); pk_backend_set_percentage(backend, 0); for (i = 0; i < len && no_error_yet; i++) { - no_error_yet = query_init(package_ids[i], + no_error_yet = query_do_single(package_ids[i], backend, db, load_flags, emitter, job_type, job_emitter, - &q); - if (no_error_yet == TRUE) - no_error_yet = body(q); + body); pk_backend_set_percentage(backend, ((i * 100) / len)); } - query_free(q); + pkgdb_close(db); pk_backend_finished(backend); @@ -199,6 +201,41 @@ } /* + * Runs a query over one PackageID. + * + * This provides the emitting function with a query structure ready to run, but + * does not do any backend housekeeping. + */ +gboolean +query_do_single(gchar *package_id, + PkBackend *backend, + struct pkgdb *db, + unsigned int load_flags, + emit_ptr emitter, + pkg_jobs_t job_type, + job_emit_ptr job_emitter, + query_body_ptr body) +{ + gboolean success; + struct query *q; + + q = NULL; + success = query_init(package_id, + backend, + db, + load_flags, + emitter, + job_type, + job_emitter, + &q); + if (success) + success = body(q); + + query_free(q); + return success; +} + +/* * For adapting an emitter function into one that solves and applies a job. */ gboolean Modified: soc2013/mattbw/backend/query.h ============================================================================== --- soc2013/mattbw/backend/query.h Mon Jul 8 05:58:09 2013 (r254403) +++ soc2013/mattbw/backend/query.h Mon Jul 8 06:55:06 2013 (r254404) @@ -33,6 +33,7 @@ PkBackend *query_backend(struct query *q); gboolean query_do(PkBackend *backend, unsigned int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, query_body_ptr body); +gboolean query_do_single(gchar *package_id, PkBackend *backend, struct pkgdb *db, unsigned int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, query_body_ptr body); gboolean query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q); gboolean query_find_match(struct query *q); gboolean query_init(const gchar *id, PkBackend *backend, struct pkgdb *db, unsigned int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, struct query **q_p); From owner-svn-soc-all@FreeBSD.ORG Mon Jul 8 07:12:21 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 11B5FED0 for ; Mon, 8 Jul 2013 07:12:21 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 02E011C4D for ; Mon, 8 Jul 2013 07:12:21 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r687CKeK068916 for ; Mon, 8 Jul 2013 07:12:20 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r687CKCK068912 for svn-soc-all@FreeBSD.org; Mon, 8 Jul 2013 07:12:20 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 8 Jul 2013 07:12:20 GMT Message-Id: <201307080712.r687CKCK068912@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254407 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 07:12:21 -0000 Author: mattbw Date: Mon Jul 8 07:12:20 2013 New Revision: 254407 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254407 Log: (in-progress) create new datatypes to streamline query target passing Modified: soc2013/mattbw/backend/query.c soc2013/mattbw/backend/query.h soc2013/mattbw/backend/query_match.c Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Mon Jul 8 06:12:38 2013 (r254406) +++ soc2013/mattbw/backend/query.c Mon Jul 8 07:12:20 2013 (r254407) @@ -43,10 +43,7 @@ gboolean any_repo; gboolean local_repo; - /* Query result routing */ - emit_ptr emitter; - job_emit_ptr job_emitter; - pkg_jobs_t job_type; + struct query_target *t; }; static gboolean match_id_in_it(struct pkgdb_it *it, struct query *q, struct pkg @@ -129,9 +126,12 @@ * Assume any error is due to not finding packages. At time of * writing this is true, but may change. */ - if (success == TRUE) - q->emitter(match_pkg, match_id, q); - else + if (success == TRUE) { + if (q->t->type == QUERY_EMIT) + q->t->data.emit.f(match_pkg, match_id, q); + else if (q->t->type == QUERY_JOB) + query_emit_to_job(match_pkg, match_id, q); + } else pk_backend_error_code(q->backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found"); @@ -151,12 +151,7 @@ * It also *finishes* the backend job. */ gboolean -query_do(PkBackend *backend, - unsigned int load_flags, - emit_ptr emitter, - pkg_jobs_t job_type, - job_emit_ptr job_emitter, - query_body_ptr body) +query_do(PkBackend *backend, struct query_target *t, query_body_ptr body) { gboolean no_error_yet; guint i; @@ -185,10 +180,7 @@ no_error_yet = query_do_single(package_ids[i], backend, db, - load_flags, - emitter, - job_type, - job_emitter, + t, body); pk_backend_set_percentage(backend, ((i * 100) / len)); } @@ -210,24 +202,14 @@ query_do_single(gchar *package_id, PkBackend *backend, struct pkgdb *db, - unsigned int load_flags, - emit_ptr emitter, - pkg_jobs_t job_type, - job_emit_ptr job_emitter, + struct query_target *t, query_body_ptr body) { gboolean success; struct query *q; q = NULL; - success = query_init(package_id, - backend, - db, - load_flags, - emitter, - job_type, - job_emitter, - &q); + success = query_init(package_id, backend, db, t, &q); if (success) success = body(q); @@ -255,7 +237,7 @@ backend = query_backend(q); - if (pkg_jobs_new(&jobs, q->job_type, q->db) != EPKG_OK) { + if (pkg_jobs_new(&jobs, q->t->data.job.type, q->db) != EPKG_OK) { (void)pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "could not init pkg_jobs"); @@ -273,7 +255,7 @@ "could not add to job"); goto cleanup; } - success = q->job_emitter(jobs, q); + success = q->t->data.job.f(jobs, q); cleanup: pkg_jobs_free(jobs); @@ -287,14 +269,10 @@ query_init(const gchar *id, PkBackend *backend, struct pkgdb *db, - unsigned int load_flags, - emit_ptr emitter, - pkg_jobs_t job_type, - job_emit_ptr job_emitter, + struct query_target *t, struct query **q_p) { gboolean success; - gboolean loading_files; struct query *q; q = *q_p; @@ -304,11 +282,8 @@ query_free_contents(q); q->backend = backend; - q->load_flags = load_flags; q->db = db; - q->emitter = emitter; - q->job_type = job_type; - q->job_emitter = job_emitter; + q->t = t; success = split_id(id, &(q->strv), @@ -341,13 +316,18 @@ * Stop pkg from catching fire if we try to load files from * non-installed packages. */ - loading_files = (load_flags & PKG_LOAD_FILES) ? TRUE : FALSE; - if (q->local_repo == FALSE && loading_files) { - pk_backend_error_code(backend, - PK_ERROR_ENUM_CANNOT_GET_FILELIST, - "cannot get files for remote package"); - success = FALSE; - goto cleanup; + if (q->t->type == QUERY_EMIT) { + gboolean loading_files; + + loading_files = (q->t->data.emit.load_flags & + PKG_LOAD_FILES) ? TRUE : FALSE; + if (q->local_repo == FALSE && loading_files) { + pk_backend_error_code(backend, + PK_ERROR_ENUM_CANNOT_GET_FILELIST, + "cannot get files for remote package"); + success = FALSE; + goto cleanup; + } } cleanup: if (success == FALSE) { @@ -382,7 +362,11 @@ *match_pkg_p = NULL; *match_id_p = NULL; - load_flags = q->load_flags; + + if (q->t->type == QUERY_EMIT) + load_flags = q->t->data.emit.load_flags; + else + load_flags = PKG_LOAD_BASIC; for (HASH_FOR(err, pkgdb_it_next, it, match_pkg_p, load_flags)) if (try_id_match(*match_pkg_p, q, match_id_p) == TRUE) Modified: soc2013/mattbw/backend/query.h ============================================================================== --- soc2013/mattbw/backend/query.h Mon Jul 8 06:12:38 2013 (r254406) +++ soc2013/mattbw/backend/query.h Mon Jul 8 07:12:20 2013 (r254407) @@ -31,12 +31,31 @@ typedef gboolean (*job_emit_ptr) (struct pkg_jobs *jobs, struct query *q); typedef gboolean (*query_body_ptr) (struct query *q); +enum query_type { + QUERY_EMIT, + QUERY_JOB +}; + +struct query_target { + enum query_type type; + union { + struct { + int load_flags; + emit_ptr f; + } emit; + struct { + pkg_jobs_t type; + job_emit_ptr f; + } job; + } data; +}; + PkBackend *query_backend(struct query *q); -gboolean query_do(PkBackend *backend, unsigned int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, query_body_ptr body); -gboolean query_do_single(gchar *package_id, PkBackend *backend, struct pkgdb *db, unsigned int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, query_body_ptr body); +gboolean query_do(PkBackend *backend, struct query_target *t, query_body_ptr body); +gboolean query_do_single(gchar *package_id, PkBackend *backend, struct pkgdb *db, struct query_target *t, query_body_ptr body); gboolean query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q); gboolean query_find_match(struct query *q); -gboolean query_init(const gchar *id, PkBackend *backend, struct pkgdb *db, unsigned int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, struct query **q_p); +gboolean query_init(const gchar *id, PkBackend *backend, struct pkgdb *db, struct query_target *t, struct query **q_p); void query_free(struct query *q); #endif /* !_PKGNG_BACKEND_QUERY_H_ */ Modified: soc2013/mattbw/backend/query_match.c ============================================================================== --- soc2013/mattbw/backend/query_match.c Mon Jul 8 06:12:38 2013 (r254406) +++ soc2013/mattbw/backend/query_match.c Mon Jul 8 07:12:20 2013 (r254407) @@ -39,13 +39,13 @@ query_match_id_to_emitter(PkBackend *backend, unsigned int load_flags, emit_ptr emitter) { + struct query_target t; - return query_do(backend, - load_flags, - emitter, - PKG_JOBS_INSTALL, /* <-- does not matter what goes here */ - NULL, - query_find_match); + t.type = QUERY_EMIT; + t.data.emit.load_flags = load_flags; + t.data.emit.f = emitter; + + return query_do(backend, &t, query_find_match); } /* @@ -57,11 +57,11 @@ query_match_id_to_job(PkBackend *backend, pkg_jobs_t type, job_emit_ptr emitter) { + struct query_target t; + + t.type = QUERY_JOB; + t.data.job.type = type; + t.data.job.f = emitter; - return query_do(backend, - PKG_LOAD_BASIC, /* <-- does not matter what goes here */ - query_emit_to_job, - type, - emitter, - query_find_match); + return query_do(backend, &t, query_find_match); } From owner-svn-soc-all@FreeBSD.ORG Mon Jul 8 11:55:22 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4876A2CF for ; Mon, 8 Jul 2013 11:55:22 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 2C7DB19C8 for ; Mon, 8 Jul 2013 11:55:22 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r68BtMRl042465 for ; Mon, 8 Jul 2013 11:55:22 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r68BtLlK042448 for svn-soc-all@FreeBSD.org; Mon, 8 Jul 2013 11:55:21 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 8 Jul 2013 11:55:21 GMT Message-Id: <201307081155.r68BtLlK042448@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254408 - in soc2013/mattbw/backend: . actions query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 11:55:22 -0000 Author: mattbw Date: Mon Jul 8 11:55:21 2013 New Revision: 254408 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254408 Log: so many query changes while FreeBSD.org was down... Added: soc2013/mattbw/backend/query/ soc2013/mattbw/backend/query/core.c - copied, changed from r254407, soc2013/mattbw/backend/query.c soc2013/mattbw/backend/query/core.h - copied, changed from r254407, soc2013/mattbw/backend/query.h soc2013/mattbw/backend/query/do.c soc2013/mattbw/backend/query/do.h soc2013/mattbw/backend/query/match.c soc2013/mattbw/backend/query/match.h Replaced: soc2013/mattbw/backend/query.h Deleted: soc2013/mattbw/backend/query.c soc2013/mattbw/backend/query_match.c soc2013/mattbw/backend/query_match.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/get-details.c soc2013/mattbw/backend/actions/get-files.c soc2013/mattbw/backend/actions/get-repo-list.c soc2013/mattbw/backend/actions/install-files.c soc2013/mattbw/backend/actions/install-packages.c soc2013/mattbw/backend/actions/resolve.c soc2013/mattbw/backend/utils.h Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Mon Jul 8 07:12:20 2013 (r254407) +++ soc2013/mattbw/backend/Makefile Mon Jul 8 11:55:21 2013 (r254408) @@ -8,8 +8,6 @@ groups.c \ licenses.c \ pkgutils.c \ - query.c \ - query_match.c \ utils.c SRCS+= \ actions/get-details.c \ @@ -19,6 +17,11 @@ actions/install-packages.c \ actions/resolve.c +SRCS+= \ + query/core.c \ + query/do.c \ + query/match.c + LIBDIR= /usr/local/lib/packagekit-backend PKGS= pkg gio-2.0 gio-unix-2.0 Modified: soc2013/mattbw/backend/actions/get-details.c ============================================================================== --- soc2013/mattbw/backend/actions/get-details.c Mon Jul 8 07:12:20 2013 (r254407) +++ soc2013/mattbw/backend/actions/get-details.c Mon Jul 8 11:55:21 2013 (r254408) @@ -23,8 +23,8 @@ #include "pkg.h" #include "../groups.h" /* group_from_origin */ -#include "../query_match.h" /* query_match_... */ #include "../licenses.h" /* license_from_pkg */ +#include "../query.h" /* query_... */ #include "actions.h" /* get_details_thread prototype */ @@ -39,8 +39,11 @@ gboolean get_details_thread(PkBackend *backend) { + gboolean success; - return query_match_id_to_emitter(backend, LOAD_FLAGS, emit); + success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit); + pk_backend_finished(backend); + return success; } /* @@ -49,25 +52,31 @@ static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q) { + gboolean success; const char *description; const char *origin; const char *www; int64_t flatsize; + query_set_percentage(q, 0); + /* Information not already part of the PackageID */ description = origin = www = NULL; flatsize = 0; pkg_get(pkg, - PKG_DESC, &description, - PKG_FLATSIZE, &flatsize, - PKG_ORIGIN, &origin, - PKG_WWW, &www); - - return pk_backend_details(query_backend(q), - id, - license_name_from_pkg(pkg), - group_from_origin(origin), - description, - www, - flatsize); + PKG_DESC, &description, + PKG_FLATSIZE, &flatsize, + PKG_ORIGIN, &origin, + PKG_WWW, &www); + + success = pk_backend_details(query_backend(q), + id, + license_name_from_pkg(pkg), + group_from_origin(origin), + description, + www, + flatsize); + + query_set_percentage(q, 100); + return success; } Modified: soc2013/mattbw/backend/actions/get-files.c ============================================================================== --- soc2013/mattbw/backend/actions/get-files.c Mon Jul 8 07:12:20 2013 (r254407) +++ soc2013/mattbw/backend/actions/get-files.c Mon Jul 8 11:55:21 2013 (r254408) @@ -26,8 +26,8 @@ #include "../groups.h" /* group_from_origin */ #include "../hash_traverse.h" /* HASH_FOR */ -#include "../query_match.h" /* query_match_... */ #include "../licenses.h" /* license_from_pkg */ +#include "../query.h" /* query_... */ #include "actions.h" /* get_files_thread prototype */ @@ -43,9 +43,13 @@ gboolean get_files_thread(PkBackend *backend) { + gboolean success; (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - return query_match_id_to_emitter(backend, LOAD_FLAGS, emit); + success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit); + + (void)pk_backend_finished(backend); + return success; } /* @@ -59,6 +63,8 @@ struct pkg_file *file; struct sbuf *sb; + query_set_percentage(q, 0); + success = FALSE; file = NULL; @@ -86,5 +92,6 @@ } sbuf_delete(sb); + query_set_percentage(q, 100); return success; } Modified: soc2013/mattbw/backend/actions/get-repo-list.c ============================================================================== --- soc2013/mattbw/backend/actions/get-repo-list.c Mon Jul 8 07:12:20 2013 (r254407) +++ soc2013/mattbw/backend/actions/get-repo-list.c Mon Jul 8 11:55:21 2013 (r254408) @@ -38,8 +38,7 @@ repo = NULL; (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - (void)pk_backend_set_percentage(backend, - PK_BACKEND_PERCENTAGE_INVALID); + (void)pk_backend_set_percentage(backend, 0); for (HASH_FOR(err, pkg_repos, &repo)) pk_backend_repo_detail(backend, @@ -47,6 +46,7 @@ pkg_repo_name(repo), pkg_repo_enabled(repo)); + (void)pk_backend_set_percentage(backend, 100); (void)pk_backend_finished(backend); return (err == EPKG_END ? TRUE : FALSE); Modified: soc2013/mattbw/backend/actions/install-files.c ============================================================================== --- soc2013/mattbw/backend/actions/install-files.c Mon Jul 8 07:12:20 2013 (r254407) +++ soc2013/mattbw/backend/actions/install-files.c Mon Jul 8 11:55:21 2013 (r254408) @@ -25,7 +25,6 @@ #include "../db.h" /* db_open_remote */ #include "../hash_traverse.h" /* HASH_FOR */ #include "../pkgutils.h" /* pkgutils_... */ -#include "../query_match.h" /* query_match_... */ #include "../utils.h" /* INTENTIONALLY_IGNORE */ #include "actions.h" /* install_files_thread prototype */ Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Mon Jul 8 07:12:20 2013 (r254407) +++ soc2013/mattbw/backend/actions/install-packages.c Mon Jul 8 11:55:21 2013 (r254408) @@ -24,16 +24,14 @@ #include "../hash_traverse.h" /* HASH_FOR */ #include "../pkgutils.h" /* pkgutils_... */ -#include "../query_match.h" /* query_match_... */ +#include "../query.h" /* query_... */ #include "../utils.h" /* INTENTIONALLY_IGNORE */ #include "actions.h" /* install_packages_thread prototype */ -static gboolean do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate); -static gboolean do_install_solved_job(struct pkg_jobs *jobs, PkBackend *backend, gboolean simulate); -static gboolean do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend); static gboolean job(struct pkg_jobs *jobs, struct query *q); static gboolean sim_job(struct pkg_jobs *jobs, struct query *q); +static gboolean solve_job(struct query *q, struct pkg_jobs *jobs); static int install_event_cb(void *backend_v, struct pkg_event *event); @@ -44,9 +42,13 @@ gboolean install_packages_thread(PkBackend *backend) { + gboolean success; + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, job); - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - return query_match_id_to_job(backend, PKG_JOBS_INSTALL, job); + (void)pk_backend_finished(backend); + return success; } /* @@ -56,107 +58,107 @@ gboolean simulate_install_packages_thread(PkBackend *backend) { + gboolean success; + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, sim_job); - return query_match_id_to_job(backend, PKG_JOBS_INSTALL, sim_job); + (void)pk_backend_finished(backend); + return success; } /* - * Installs (or pretends to install) an unsolved installation job. + * Tries to process the given solved installation jobs. */ static gboolean -do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate) +job(struct pkg_jobs *jobs, struct query *q) { gboolean success; PkBackend *backend; success = FALSE; backend = query_backend(q); + query_set_percentage(q, 0); - pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); - if (pkg_jobs_solve(jobs) != EPKG_OK) - pk_backend_error_code(backend, - PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, - "could not solve the job"); - else if (pkg_jobs_count(jobs) == 0) + if (solve_job(q, jobs) == FALSE) + goto cleanup; + + pkg_event_register(install_event_cb, backend); + + pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); + if (pkg_jobs_apply(jobs) != EPKG_OK) { pk_backend_error_code(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "job contains no packages"); - else - success = do_install_solved_job(jobs, backend, simulate); + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, + "job failed"); + goto cleanup; + } + success = TRUE; +cleanup: + pkg_event_register(NULL, NULL); + query_set_percentage(q, 100); return success; } /* - * Installs (or pretends to install) a fully solved installation job. + * Tries to simulate processing the given installation jobs. */ static gboolean -do_install_solved_job(struct pkg_jobs *jobs, - PkBackend *backend, - gboolean simulate) +sim_job(struct pkg_jobs *jobs, struct query *q) { gboolean success; + PkBackend *backend; struct pkg *pkg; - success = TRUE; + backend = query_backend(q); + success = FALSE; + query_set_percentage(q, 0); + + if (solve_job(q, jobs) == FALSE) + goto cleanup; + + pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); pkg = NULL; while (pkg_jobs(jobs, &pkg) == EPKG_OK) pkgutils_emit(pkg, backend, pkgutils_pkg_install_state(pkg)); - if (simulate == FALSE) - success = do_install_solved_job_real(jobs, backend); + success = TRUE; +cleanup: + query_set_percentage(q, 100); return success; } /* - * Actually installs a fully solved installation job. + * Solves a job and ensures it has packages available. */ static gboolean -do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend) +solve_job(struct query *q, struct pkg_jobs *jobs) { gboolean success; + PkBackend *backend; success = FALSE; + backend = query_backend(q); - pkg_event_register(install_event_cb, backend); - - pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); - if (pkg_jobs_apply(jobs) == EPKG_OK) - success = TRUE; - else + pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); + if (pkg_jobs_solve(jobs) != EPKG_OK) pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, - "job failed"); - - pkg_event_register(NULL, NULL); + PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, + "could not solve the job"); + else if (pkg_jobs_count(jobs) == 0) + pk_backend_error_code(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "job contains no packages"); + else + success = TRUE; return success; } /* - * Tries to process the given solved installation jobs. - */ -static gboolean -job(struct pkg_jobs *jobs, struct query *q) -{ - - return do_install_packages(jobs, q, FALSE); -} - -/* - * Tries to simulate processing the given installation jobs. - */ -static gboolean -sim_job(struct pkg_jobs *jobs, struct query *q) -{ - - return do_install_packages(jobs, q, TRUE); -} - -/* * Event handler for events emitted by pkg during an installation. */ static int @@ -199,9 +201,15 @@ PK_INFO_ENUM_FINISHED); break; case PKG_EVENT_ERROR: + /* + * This is sometimes used for nonfatal errors, so we can't + * throw an error code here + */ +#if 0 pk_backend_error_code(backend, PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, event->e_pkg_error.msg); +#endif break; case PKG_EVENT_FILE_MISMATCH: pk_backend_error_code(backend, Modified: soc2013/mattbw/backend/actions/resolve.c ============================================================================== --- soc2013/mattbw/backend/actions/resolve.c Mon Jul 8 07:12:20 2013 (r254407) +++ soc2013/mattbw/backend/actions/resolve.c Mon Jul 8 11:55:21 2013 (r254408) @@ -22,6 +22,7 @@ #include "pkg.h" #include "../db.h" /* db_open_remote */ +#include "../query.h" /* query_* */ #include "actions.h" /* Prototype */ static gboolean resolve_id(struct pkgdb *db, PkBackend *backend, gchar *id); @@ -55,6 +56,7 @@ } else success = FALSE; + pkgdb_close(db); pk_backend_finished(backend); return success; } @@ -64,6 +66,15 @@ { /* TODO: implement */ + + /*struct query_target t; + + t.type = QUERY_EMIT; + t.data.emit.load_flags = load_flags; + t.data.emit.f = emitter; + + return query_do(backend, &t, query_find_match);*/ + (void)db; (void)backend; (void)id; Added: soc2013/mattbw/backend/query.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/query.h Mon Jul 8 11:55:21 2013 (r254408) @@ -0,0 +1,29 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _PKGNG_BACKEND_QUERY_H_ +#define _PKGNG_BACKEND_QUERY_H_ + +/* Meta-header for the public interfaces to the query system. */ + +#include "query/do.h" /* query_do_... */ +#include "query/match.h" /* query_match_... */ + +#endif /* !_PKGNG_BACKEND_QUERY_H_ */ Copied and modified: soc2013/mattbw/backend/query/core.c (from r254407, soc2013/mattbw/backend/query.c) ============================================================================== --- soc2013/mattbw/backend/query.c Mon Jul 8 07:12:20 2013 (r254407, copy source) +++ soc2013/mattbw/backend/query/core.c Mon Jul 8 11:55:21 2013 (r254408) @@ -20,38 +20,52 @@ #include #include -#include "pk-backend.h" +#include "../pk-backend.h" #include "pkg.h" -#include "query.h" /* Prototypes */ -#include "db.h" /* db_open_remote */ -#include "hash_traverse.h" /* HASH_FOR */ -#include "utils.h" /* string_match */ -#include "pkgutils.h" /* pkgutils_... */ +#include "../db.h" /* db_open_remote */ +#include "../hash_traverse.h" /* HASH_FOR */ +#include "../utils.h" /* string_match */ +#include "../pkgutils.h" /* pkgutils_... */ +#include "core.h" /* Prototypes */ + +enum repo_type { + REPO_INVALID, + REPO_ANY, + REPO_LOCAL, + REPO_REMOTE +}; -struct query { - int load_flags; +struct query_unpacked_source { + gboolean skip_id_match; const gchar *name; const gchar *version; const gchar *arch; const gchar *data; gchar **strv; +}; + +struct query { PkBackend *backend; struct pkgdb *db; - gboolean any_repo; - gboolean local_repo; + struct query_unpacked_source *su; + enum repo_type rtype; + + struct query_source *s; struct query_target *t; }; -static gboolean match_id_in_it(struct pkgdb_it *it, struct query *q, struct pkg -**match_pkg_p, gchar **match_id_p); -static gboolean try_id_match(struct pkg *pkg, struct query *q, gchar **match_id); +static enum repo_type type_of_repo_name(const char *name); +static gboolean can_remote_iterate(struct query *q); +static gchar *match_pkg(struct pkg *pkg, struct query *q); static int jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg); static int jobs_repo_from_query(struct pkg_jobs *jobs, struct query *q); -static void query_free_contents(struct query *q); +static struct pkg *match_iterator(struct pkgdb_it *it, struct query *q, gchar **match_id_p); +static struct query_unpacked_source *init_unpacked_source(PkBackend *backend, struct query_source *s); +static void free_unpacked_source(struct query_unpacked_source **su_p); /* Returns the backend stored inside the struct query. */ PkBackend * @@ -77,28 +91,24 @@ PkBitfield filters; const char *name; gchar *match_id; - struct pkg *match_pkg; + struct pkg *pkg; struct pkgdb *db; struct pkgdb_it *it; success = FALSE; match = MATCH_EXACT; match_id = NULL; - match_pkg = NULL; + pkg = NULL; db = q->db; - name = q->name; + name = q->su->name; /* * If we're not given a specific repository in the PackageID, we want * to try searching locally first and then remotely; otherwise which * database we query depends on the repository we have been given. */ - if (q->any_repo == TRUE) - try_local = try_remote = TRUE; - else { - try_local = (q->local_repo == TRUE); - try_remote = (q->local_repo == FALSE); - } + try_local = (q->rtype != REPO_REMOTE); + try_remote = (q->rtype != REPO_LOCAL); /* Apply filters, if any */ filters = pk_backend_get_uint(q->backend, "filters"); @@ -110,110 +120,33 @@ /* Try a local search first, if applicable. */ it = (try_local ? pkgdb_query(db, name, match) : NULL); if (it != NULL) - success = match_id_in_it(it, q, &match_pkg, &match_id); + pkg = match_iterator(it, q, &match_id); pkgdb_it_free(it); - if (success == TRUE) + /* No point trying remote if we got a local match */ + if (pkg != NULL) try_remote = FALSE; /* Next, try a remote search, again only if applicable. */ - it = (try_remote ? pkgdb_rquery(db, name, match, q->data) : NULL); - if (it != NULL) - success = match_id_in_it(it, q, &match_pkg, &match_id); + it = (try_remote ? pkgdb_rquery(db, name, match, q->su->data) : NULL); + if (it != NULL && can_remote_iterate(q)) + pkg = match_iterator(it, q, &match_id); pkgdb_it_free(it); - /* - * Assume any error is due to not finding packages. At time of - * writing this is true, but may change. - */ - if (success == TRUE) { - if (q->t->type == QUERY_EMIT) - q->t->data.emit.f(match_pkg, match_id, q); - else if (q->t->type == QUERY_JOB) - query_emit_to_job(match_pkg, match_id, q); - } else + if (pkg == NULL) pk_backend_error_code(q->backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found"); - - pkg_free(match_pkg); - g_free(match_id); - - return success; -} - -/* - * Iterates a query function over all PackageIDs provided for this job. - * - * This provides each iterating function call with a query structure ready to - * run and updates the percentage after each iteration. - * - * It also *finishes* the backend job. - */ -gboolean -query_do(PkBackend *backend, struct query_target *t, query_body_ptr body) -{ - gboolean no_error_yet; - guint i; - guint len; - struct pkgdb *db; - struct query *q; - gchar **package_ids; - - (void)pk_backend_set_percentage(backend, - PK_BACKEND_PERCENTAGE_INVALID); - - /* - * We're using length/index instead of incrementing the pointer to NULL - * so that we can infer the progress bar percentage. - */ - package_ids = pk_backend_get_strv(backend, "package_ids"); - len = g_strv_length(package_ids); - - db = NULL; - q = NULL; - - no_error_yet = db_open_remote(&db, backend); - - pk_backend_set_percentage(backend, 0); - for (i = 0; i < len && no_error_yet; i++) { - no_error_yet = query_do_single(package_ids[i], - backend, - db, - t, - body); - pk_backend_set_percentage(backend, ((i * 100) / len)); + else { + if (q->t->type == QUERY_EMIT) + success = q->t->data.emit.f(pkg, match_id, q); + else if (q->t->type == QUERY_JOB) + success = query_emit_to_job(pkg, match_id, q); } - pkgdb_close(db); - - pk_backend_finished(backend); - - return no_error_yet; -} - -/* - * Runs a query over one PackageID. - * - * This provides the emitting function with a query structure ready to run, but - * does not do any backend housekeeping. - */ -gboolean -query_do_single(gchar *package_id, - PkBackend *backend, - struct pkgdb *db, - struct query_target *t, - query_body_ptr body) -{ - gboolean success; - struct query *q; - - q = NULL; - success = query_init(package_id, backend, db, t, &q); - if (success) - success = body(q); + pkg_free(pkg); + g_free(match_id); - query_free(q); return success; } @@ -262,145 +195,193 @@ return success; } +/* + * Runs an assembled query. + */ +gboolean +query_run(struct query *q) +{ + return q->s->body(q); +} -/* Creates a struct query for the given backend and target ID. */ -gboolean -query_init(const gchar *id, - PkBackend *backend, +/* + * Creates a struct query for the given backend, database, source and target. + * + * Usually you'll want to use "query_do" instead of calling this directly. + */ +struct query * +query_init(PkBackend *backend, struct pkgdb *db, - struct query_target *t, - struct query **q_p) + struct query_source *s, + struct query_target *t) { gboolean success; struct query *q; - q = *q_p; - if (q == NULL) - q = g_new0(struct query, 1); - else - query_free_contents(q); + success = FALSE; + q = calloc(1, sizeof(struct query)); + if (q == NULL) { + ERR(backend, PK_ERROR_ENUM_OOM, "couldn't allocate query"); + goto cleanup; + } q->backend = backend; q->db = db; + q->s = s; q->t = t; - success = split_id(id, - &(q->strv), - &(q->name), - &(q->version), - &(q->arch), - &(q->data)); - if (success == FALSE) { - pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_ID_INVALID, - "invalid package id"); + q->su = init_unpacked_source(backend, s); + if (q->su == NULL) goto cleanup; - } - /* - * Check the repository to make sure it's sane, and populate the repo - * type flags in the state for later consumption. - */ - if (q->data == NULL) - q->any_repo = TRUE; - else if (strcmp(q->data, "installed") == 0) - q->local_repo = TRUE; - else if (pkg_repo_find_ident(q->data) == NULL) { - pk_backend_error_code(backend, - PK_ERROR_ENUM_REPO_NOT_FOUND, - "no such repository"); - success = FALSE; + + q->rtype = type_of_repo_name(q->su->data); + if (q->rtype == REPO_INVALID) { + ERR(backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "no such repo"); goto cleanup; } - /* - * Stop pkg from catching fire if we try to load files from - * non-installed packages. - */ - if (q->t->type == QUERY_EMIT) { - gboolean loading_files; + success = TRUE; - loading_files = (q->t->data.emit.load_flags & - PKG_LOAD_FILES) ? TRUE : FALSE; - if (q->local_repo == FALSE && loading_files) { - pk_backend_error_code(backend, - PK_ERROR_ENUM_CANNOT_GET_FILELIST, - "cannot get files for remote package"); - success = FALSE; - goto cleanup; - } - } cleanup: - if (success == FALSE) { - query_free(q); - q = NULL; - } - *q_p = q; - return success; + if (success == FALSE) + query_free(&q); + + return q; } /* Deallocates a struct query and any contents it owns. */ void -query_free(struct query *q) +query_free(struct query **q_p) { + struct query *q; + + q = (q_p == NULL ? NULL : *q_p); if (q != NULL) { - query_free_contents(q); - g_free(q); + /* + * The database, source and target structures are owned by + * the creator and not freed here. + */ + + if (q->su != NULL) + free_unpacked_source(&(q->su)); + + free(q); + *q_p = NULL; } } -static gboolean -match_id_in_it(struct pkgdb_it *it, - struct query *q, - struct pkg **match_pkg_p, - gchar **match_id_p) +/* + * Updates the PackageKit percentage to reflect progress on this query. If + * this query is part of a subquery, then the percentage will be scaled + * appropriately. + */ +void +query_set_percentage(struct query *q, unsigned char percent) { - int err; - int load_flags; + guint scaled_percent; - /* TODO: Filters */ + if (percent == PK_BACKEND_PERCENTAGE_INVALID) + scaled_percent = PK_BACKEND_PERCENTAGE_INVALID; + else { + if (percent > 100) + percent = 100; - *match_pkg_p = NULL; - *match_id_p = NULL; + scaled_percent = (((100 * q->s->position) + + (percent * (q->s->position + 1))) / (q->s->total)); + } - if (q->t->type == QUERY_EMIT) - load_flags = q->t->data.emit.load_flags; - else - load_flags = PKG_LOAD_BASIC; + (void)pk_backend_set_percentage(q->backend, scaled_percent); +} - for (HASH_FOR(err, pkgdb_it_next, it, match_pkg_p, load_flags)) - if (try_id_match(*match_pkg_p, q, match_id_p) == TRUE) - break; +/* Finds the type of the given PackageKit repository name. */ +static enum repo_type +type_of_repo_name(const char *name) +{ + enum repo_type rtype; + + if (name == NULL) + rtype = REPO_ANY; + else if (strcmp(name, "installed") == 0) + rtype = REPO_LOCAL; + else if (pkg_repo_find_ident(name) != NULL) + rtype = REPO_REMOTE; + else + rtype = REPO_INVALID; - return (err == EPKG_OK && *match_id_p != NULL) ? TRUE : FALSE; + return rtype; } +/* + * Checks to see if trying to do a remote package iteration with this query + * could spell disaster. + */ static gboolean -try_id_match(struct pkg *pkg, struct query *q, char **match_id) +can_remote_iterate(struct query *q) +{ + gboolean sane; + + /* Innocent until proven guilty */ + sane = TRUE; + + /* + * Stop pkg from catching fire if we try to load files from + * non-installed packages. + */ + if (q->t->type == QUERY_EMIT) { + int loading_files; + + loading_files = (q->t->data.emit.load_flags & PKG_LOAD_FILES); + if (loading_files) { + ERR(q->backend, + PK_ERROR_ENUM_CANNOT_GET_FILELIST, + "cannot get files for remote package"); + sane = FALSE; + } + } + return sane; +} + +/* + * Checks whether a candidate package matches any constraints provided by the + * query and, if so, returns its full PackageID; otherwise NULL. + */ +static gchar * +match_pkg(struct pkg *pkg, struct query *q) { gboolean matches; int i; + gchar *match_id; const gchar **pkg_id_bits; pkg_id_bits = g_new0(const gchar *, 4); - g_free(*match_id); - *match_id = pkgutils_pkg_to_id_through(pkg, pkg_id_bits); + match_id = pkgutils_pkg_to_id_through(pkg, pkg_id_bits); - /* - * Succeed if this package's PackageID fields match the original - * PackageID. Of course, the original ID might have missing fields - * (NULLs), so we treat a comparison involving one as a success. This - * means using our "weak strcmp" instead of normal strcmp or even - * g_strcmp0. - */ - for (matches = TRUE, i = PK_PACKAGE_ID_NAME; - matches == TRUE && i <= PK_PACKAGE_ID_DATA; - i++) - matches = string_match((q->strv)[i], pkg_id_bits[i]); + if (q->su->skip_id_match == TRUE) + matches = TRUE; + else { + /* + * Succeed if this package's PackageID fields match the + * original PackageID. Of course, the original ID might have + * missing fields (NULLs), so we treat a comparison involving + * one as a success. This means using our "weak strcmp" + * instead of normal strcmp or even g_strcmp0. + */ + for (matches = TRUE, i = PK_PACKAGE_ID_NAME; + matches == TRUE && i <= PK_PACKAGE_ID_DATA; + i++) + matches = string_match((q->su->strv)[i], + pkg_id_bits[i]); + } g_free(pkg_id_bits); - return matches; + + if (matches == FALSE) { + g_free(match_id); + match_id = NULL; + } + return match_id; } /* Adds a single package to a jobs structure. */ @@ -420,21 +401,109 @@ { int err; - if (q->data == NULL) + if (q->su->data == NULL) err = EPKG_OK; else - err = pkg_jobs_set_repository(jobs, q->data); + err = pkg_jobs_set_repository(jobs, q->su->data); return err; } -/* Frees the owned contents of a struct query, but not the struct itself. */ +/* + * Tries to find a query-matching package in a database iterator. Returns the + * package if one matches, or NULL; if match_id_p is non-null, its full + * PackageID will be emitted there. + */ +static struct pkg * +match_iterator(struct pkgdb_it *it, struct query *q, gchar **match_id_p) +{ + int load_flags; + gchar *match_id; + struct pkg *pkg; + + if (q->t->type == QUERY_EMIT) + load_flags = q->t->data.emit.load_flags; + else + load_flags = PKG_LOAD_BASIC; + + match_id = NULL; + pkg = NULL; + while (pkgdb_it_next(it, &pkg, load_flags) == EPKG_OK) { + match_id = match_pkg(pkg, q); + /* Did it match? */ + if (match_id != NULL) + break; + } + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Mon Jul 8 12:06:18 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5D7C3FD5 for ; Mon, 8 Jul 2013 12:06:18 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 3FEA61BF4 for ; Mon, 8 Jul 2013 12:06:18 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r68C6Id1095179 for ; Mon, 8 Jul 2013 12:06:18 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r68C6IXv095157 for svn-soc-all@FreeBSD.org; Mon, 8 Jul 2013 12:06:18 GMT (envelope-from dpl@FreeBSD.org) Date: Mon, 8 Jul 2013 12:06:18 GMT Message-Id: <201307081206.r68C6IXv095157@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254411 - in soc2013/dpl/head/contrib: bzip2 xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 12:06:18 -0000 Author: dpl Date: Mon Jul 8 12:06:17 2013 New Revision: 254411 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254411 Log: Added code to be able to compress anywhere. (Not working) Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c soc2013/dpl/head/contrib/xz/src/xz/coder.c soc2013/dpl/head/contrib/xz/src/xz/file_io.c soc2013/dpl/head/contrib/xz/src/xz/file_io.h soc2013/dpl/head/contrib/xz/src/xz/private.h Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Mon Jul 8 11:29:59 2013 (r254410) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Mon Jul 8 12:06:17 2013 (r254411) @@ -91,9 +91,8 @@ # ifdef __FreeBSD__ # include # if __FreeBSD_version >= 900041 -# define CAPSICUM 1 +# define CAPSICUM # include -# include # include # include # endif @@ -222,13 +221,14 @@ FILE *outputHandleJustInCase; Int32 workFactor; -#if CAPSICUM +#ifdef CAPSICUM #define IN_FILENO fileno(inStr) #define OUT_FILENO fileno(outStr) void limitfd(int); +const Char * getdir(Char* file); FILE *inStr; FILE *outStr; -int cwd; +int cwd; /* Where is the file (fd) */ #endif static void panic ( const Char* ) NORETURN; @@ -663,7 +663,7 @@ if (v > exitValue) exitValue = v; } -#if CAPSICUM +#ifdef CAPSICUM /*---------------------------------------------*/ void limitfd(int fd) @@ -686,6 +686,22 @@ exit(exitValue); } } + + +/*---------------------------------------------*/ +const Char * +getdir(Char *file) +{ + Char * slashPos; + Char * ret; + + slashPos = strrchr(file, (int)'/'); + if ( slashPos == 0 ) + return( "." ); + ret = strndup( file, (slashPos - file + 1) ); + return(ret); + +} #endif /*---------------------------------------------*/ @@ -1168,7 +1184,7 @@ static void compress ( Char *name ) { -#if CAPSICUM +#ifdef CAPSICUM pid_t forkpid; #elif FILE *inStr; @@ -1329,7 +1345,7 @@ break; } -# if CAPSICUM +# ifdef CAPSICUM /* Fork and compress in sandbox. */ if ( (forkpid = fork()) == -1 ){ fprintf ( stderr, "%s: Couldn't fork: %s.\n", progName, strerror(errno) ); @@ -1362,6 +1378,7 @@ applySavedTimeInfoToOutputFile ( OUT_FILENO ); deleteOutputOnInterrupt = False; if ( !keepInputFiles ) { + printf("unlinkat( %d, %s, 0);\n", cwd, inName); IntNative retVal = unlinkat ( cwd, inName, 0 ); ERROR_IF_NOT_ZERO ( retVal ); } @@ -1371,7 +1388,7 @@ fclose(inStr); fclose(outStr); close(cwd); -# if CAPSICUM +# ifdef CAPSICUM exit(0); } # endif @@ -1381,7 +1398,7 @@ static void uncompress ( Char *name ) { -#if CAPSICUM +#ifdef CAPSICUM pid_t forkpid; #elif FILE *inStr; @@ -1540,7 +1557,7 @@ } -# if CAPSICUM +# ifdef CAPSICUM /* Fork and compress in sandbox. */ if ( (forkpid = fork()) == -1 ){ fprintf ( stderr, "%s: Couldn't fork: %s.\n", progName, strerror(errno) ); @@ -1603,7 +1620,7 @@ fclose(inStr); fclose(outStr); close(cwd); -# if CAPSICUM +# ifdef CAPSICUM exit(0); } # endif @@ -2061,8 +2078,6 @@ # endif } - cwd = open ( ".", 0 ); - if (opMode == OM_Z) { if (srcMode == SM_I2O) { compress ( NULL ); @@ -2072,6 +2087,9 @@ if (ISFLAG("--")) { decode = False; continue; } if (aa->name[0] == '-' && decode) continue; numFilesProcessed++; +# ifdef CAPSICUM + cwd = open ( getdir(aa->name) , O_DIRECTORY ); +# endif compress ( aa->name ); } } @@ -2088,6 +2106,9 @@ if (ISFLAG("--")) { decode = False; continue; } if (aa->name[0] == '-' && decode) continue; numFilesProcessed++; +# ifdef CAPSICUM + cwd = open ( getdir(aa->name) , 0 ); +# endif uncompress ( aa->name ); } } Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/coder.c Mon Jul 8 11:29:59 2013 (r254410) +++ soc2013/dpl/head/contrib/xz/src/xz/coder.c Mon Jul 8 12:06:17 2013 (r254411) @@ -641,6 +641,9 @@ // Don't open the destination file when --test // is used. if (opt_mode == MODE_TEST || !io_open_dest(pair)) { +# ifdef CAPSICUM + limitfd(pair); +# endif // Initialize the progress indicator. const uint64_t in_size = pair->src_st.st_size <= 0 Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.c Mon Jul 8 11:29:59 2013 (r254410) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.c Mon Jul 8 12:06:17 2013 (r254411) @@ -955,3 +955,15 @@ return io_write_buf(pair, buf->u8, size); } + +#if CAPSICUM +extern void +limitfd(struct file_pair *pair) +{ + cap_rights_t rights = 0; + + + + return; +} +#endif \ No newline at end of file Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.h Mon Jul 8 11:29:59 2013 (r254410) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.h Mon Jul 8 12:06:17 2013 (r254411) @@ -127,3 +127,11 @@ /// \return On success, zero is returned. On error, -1 is returned /// and error message printed. extern bool io_write(file_pair *pair, const io_buf *buf, size_t size); + + +#ifdef CAPSICUM +/// \brief Limits fd using FreeBSD's Capsicum framework. +/// +/// \param fd File descriptor to limit. +extern void limitfd(struct file_pair* pair); +#endif \ No newline at end of file Modified: soc2013/dpl/head/contrib/xz/src/xz/private.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/private.h Mon Jul 8 11:29:59 2013 (r254410) +++ soc2013/dpl/head/contrib/xz/src/xz/private.h Mon Jul 8 12:06:17 2013 (r254411) @@ -27,6 +27,14 @@ #include "tuklib_exit.h" #include "tuklib_mbstr.h" +#ifdef __FreeBSD__ +# include +# if __FreeBSD_version >= 900041 +# define CAPSICUM +# include +# endif +#endif + #if defined(_WIN32) && !defined(__CYGWIN__) # define WIN32_LEAN_AND_MEAN # include From owner-svn-soc-all@FreeBSD.ORG Mon Jul 8 12:27:18 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 55420C03 for ; Mon, 8 Jul 2013 12:27:18 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 366971DE4 for ; Mon, 8 Jul 2013 12:27:18 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r68CRINo092868 for ; Mon, 8 Jul 2013 12:27:18 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r68CRI4m092860 for svn-soc-all@FreeBSD.org; Mon, 8 Jul 2013 12:27:18 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 8 Jul 2013 12:27:18 GMT Message-Id: <201307081227.r68CRI4m092860@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254412 - in soc2013/mattbw/backend: . actions query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 12:27:18 -0000 Author: mattbw Date: Mon Jul 8 12:27:17 2013 New Revision: 254412 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254412 Log: resolve implemented, mostly, some version quirkiness Modified: soc2013/mattbw/backend/actions/resolve.c soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/pkgutils.h soc2013/mattbw/backend/query/core.c soc2013/mattbw/backend/query/core.h soc2013/mattbw/backend/query/do.c soc2013/mattbw/backend/query/match.c Modified: soc2013/mattbw/backend/actions/resolve.c ============================================================================== --- soc2013/mattbw/backend/actions/resolve.c Mon Jul 8 12:06:17 2013 (r254411) +++ soc2013/mattbw/backend/actions/resolve.c Mon Jul 8 12:27:17 2013 (r254412) @@ -22,11 +22,12 @@ #include "pkg.h" #include "../db.h" /* db_open_remote */ +#include "../pkgutils.h" /* pkgutils_* */ #include "../query.h" /* query_* */ +#include "../utils.h" /* INTENTIONALLY_IGNORE */ #include "actions.h" /* Prototype */ -static gboolean resolve_id(struct pkgdb *db, PkBackend *backend, gchar *id); -static gboolean resolve_name(struct pkgdb *db, PkBackend *backend, gchar *name); +static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q); /* * Resolves a package identifier, which may be a full PackageID or a package @@ -36,59 +37,31 @@ resolve_thread(PkBackend *backend) { gboolean success; - struct pkgdb *db; - gchar **package_ids; + struct query_source s; + struct query_target t; - success = TRUE; + s.type = QUERY_BACKEND_MIXED; + t.type = QUERY_EMIT; + t.data.emit.load_flags = PKG_LOAD_BASIC; + t.data.emit.f = emit; - package_ids = pk_backend_get_strv(backend, "package_ids"); + success = query_do(backend, &s, &t); - db = NULL; - if (db_open_remote(&db, backend) == TRUE) { - gchar **id_p; - - for (id_p = package_ids; *id_p != NULL && success; id_p++) { - if (pk_package_id_check(*id_p) == TRUE) - success = resolve_id(db, backend, *id_p); - else - success = resolve_name(db, backend, *id_p); - } - } else - success = FALSE; - - pkgdb_close(db); - pk_backend_finished(backend); + (void)pk_backend_finished(backend); return success; } static gboolean -resolve_id(struct pkgdb *db, PkBackend *backend, gchar *id) +emit(struct pkg *pkg, const gchar *id, struct query *q) { + PkBackend *backend; - /* TODO: implement */ - - /*struct query_target t; - - t.type = QUERY_EMIT; - t.data.emit.load_flags = load_flags; - t.data.emit.f = emitter; - - return query_do(backend, &t, query_find_match);*/ + INTENTIONALLY_IGNORE(id); + backend = query_backend(q); - (void)db; - (void)backend; - (void)id; - return FALSE; -} + query_set_percentage(q, 0); + pkgutils_emit(pkg, backend, pkgutils_pkg_current_state(pkg)); + query_set_percentage(q, 100); -static gboolean -resolve_name(struct pkgdb *db, PkBackend *backend, gchar *name) -{ - - /* TODO: implement */ - (void)db; - (void)backend; - (void)name; - return FALSE; + return TRUE; } - Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Mon Jul 8 12:06:17 2013 (r254411) +++ soc2013/mattbw/backend/pkgutils.c Mon Jul 8 12:27:17 2013 (r254412) @@ -28,6 +28,17 @@ static const char *repo_of_remote(struct pkg *pkg); /* + * Infers the correct PkInfoEnum to emit for this package for its current state. + */ +PkInfoEnum +pkgutils_pkg_current_state(struct pkg *pkg) +{ + + return (pkg_type(pkg) == PKG_INSTALLED ? + PK_INFO_ENUM_INSTALLED : PK_INFO_ENUM_AVAILABLE); +} + +/* * Infers the correct PkInfoEnum to emit for this package if it is being * installed, mainly from its current installation information. */ Modified: soc2013/mattbw/backend/pkgutils.h ============================================================================== --- soc2013/mattbw/backend/pkgutils.h Mon Jul 8 12:06:17 2013 (r254411) +++ soc2013/mattbw/backend/pkgutils.h Mon Jul 8 12:27:17 2013 (r254412) @@ -25,6 +25,7 @@ #include "pk-backend.h" #include "pkg.h" +PkInfoEnum pkgutils_pkg_current_state(struct pkg *pkg); PkInfoEnum pkgutils_pkg_install_state(struct pkg *pkg); const char *pkgutils_pk_repo_of(struct pkg *pkg); gchar *pkgutils_pkg_to_id(struct pkg *pkg); Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Mon Jul 8 12:06:17 2013 (r254411) +++ soc2013/mattbw/backend/query/core.c Mon Jul 8 12:27:17 2013 (r254412) @@ -76,13 +76,55 @@ } /* - * Performs a package database query against a (potentially partial) - * PackageID, retrieving the matched package and its full PackageID. - * - * The exact type of query depends on the repository given. + * For adapting an emitter function into one that solves and applies a job. */ gboolean -query_find_match(struct query *q) +query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q) +{ + gboolean success; + struct pkg_jobs *jobs; + PkBackend *backend; + + INTENTIONALLY_IGNORE(id); + + success = FALSE; + jobs = NULL; + + if (q == NULL) + goto cleanup; + + backend = query_backend(q); + + if (pkg_jobs_new(&jobs, q->t->data.job.type, q->db) != EPKG_OK) { + (void)pk_backend_error_code(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not init pkg_jobs"); + goto cleanup; + } + if (jobs_repo_from_query(jobs, q) != EPKG_OK) { + (void)pk_backend_error_code(backend, + PK_ERROR_ENUM_REPO_NOT_FOUND, + "could not set repo"); + goto cleanup; + } + if (jobs_add_pkg(jobs, MATCH_EXACT, pkg) != EPKG_OK) { + (void)pk_backend_error_code(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not add to job"); + goto cleanup; + } + success = q->t->data.job.f(jobs, q); + +cleanup: + pkg_jobs_free(jobs); + return success; +} + +/* + * Runs an assembled query. + */ +gboolean +query_run(struct query *q) { gboolean success; gboolean try_local; @@ -151,61 +193,6 @@ } /* - * For adapting an emitter function into one that solves and applies a job. - */ -gboolean -query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q) -{ - gboolean success; - struct pkg_jobs *jobs; - PkBackend *backend; - - INTENTIONALLY_IGNORE(id); - - success = FALSE; - jobs = NULL; - - if (q == NULL) - goto cleanup; - - backend = query_backend(q); - - if (pkg_jobs_new(&jobs, q->t->data.job.type, q->db) != EPKG_OK) { - (void)pk_backend_error_code(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "could not init pkg_jobs"); - goto cleanup; - } - if (jobs_repo_from_query(jobs, q) != EPKG_OK) { - (void)pk_backend_error_code(backend, - PK_ERROR_ENUM_REPO_NOT_FOUND, - "could not set repo"); - goto cleanup; - } - if (jobs_add_pkg(jobs, MATCH_EXACT, pkg) != EPKG_OK) { - (void)pk_backend_error_code(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "could not add to job"); - goto cleanup; - } - success = q->t->data.job.f(jobs, q); - -cleanup: - pkg_jobs_free(jobs); - return success; -} - -/* - * Runs an assembled query. - */ -gboolean -query_run(struct query *q) -{ - - return q->s->body(q); -} - -/* * Creates a struct query for the given backend, database, source and target. * * Usually you'll want to use "query_do" instead of calling this directly. Modified: soc2013/mattbw/backend/query/core.h ============================================================================== --- soc2013/mattbw/backend/query/core.h Mon Jul 8 12:06:17 2013 (r254411) +++ soc2013/mattbw/backend/query/core.h Mon Jul 8 12:27:17 2013 (r254412) @@ -34,7 +34,8 @@ enum query_source_type { QUERY_SINGLE_ID, QUERY_SINGLE_NAME, - QUERY_BACKEND_IDS + QUERY_BACKEND_IDS, + QUERY_BACKEND_MIXED }; enum query_target_type { @@ -73,7 +74,6 @@ PkBackend *query_backend(struct query *q); gboolean query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q); -gboolean query_find_match(struct query *q); gboolean query_run(struct query *q); struct query *query_init(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t); void query_free(struct query **q_p); Modified: soc2013/mattbw/backend/query/do.c ============================================================================== --- soc2013/mattbw/backend/query/do.c Mon Jul 8 12:06:17 2013 (r254411) +++ soc2013/mattbw/backend/query/do.c Mon Jul 8 12:27:17 2013 (r254412) @@ -49,6 +49,7 @@ if (db_open_remote(&db, backend) == TRUE) { switch (s->type) { case QUERY_BACKEND_IDS: + case QUERY_BACKEND_MIXED: success = do_backend_ids(backend, db, s, t); break; case QUERY_SINGLE_NAME: @@ -81,15 +82,20 @@ success = TRUE; package_ids = pk_backend_get_strv(backend, "package_ids"); - new_s.type = QUERY_SINGLE_ID; new_s.total = g_strv_length(package_ids); - new_s.body = s->body; for (new_s.position = 0; new_s.position < new_s.total && success; (new_s.position)++) { new_s.data.single = package_ids[new_s.position]; + /* Treat non-PackageIDs as pkgng package names, if allowed */ + if (s->type == QUERY_BACKEND_IDS || + pk_package_id_check(new_s.data.single) == TRUE) + new_s.type = QUERY_SINGLE_ID; + else + new_s.type = QUERY_SINGLE_NAME; + success = do_single(backend, db, &new_s, t); } Modified: soc2013/mattbw/backend/query/match.c ============================================================================== --- soc2013/mattbw/backend/query/match.c Mon Jul 8 12:06:17 2013 (r254411) +++ soc2013/mattbw/backend/query/match.c Mon Jul 8 12:27:17 2013 (r254412) @@ -45,7 +45,6 @@ struct query_target t; s.type = QUERY_BACKEND_IDS; - s.body = query_find_match; t.type = QUERY_EMIT; t.data.emit.load_flags = load_flags; @@ -67,7 +66,6 @@ struct query_target t; s.type = QUERY_BACKEND_IDS; - s.body = query_find_match; t.type = QUERY_JOB; t.data.job.type = type; From owner-svn-soc-all@FreeBSD.ORG Mon Jul 8 16:30:22 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4CFF8E04 for ; Mon, 8 Jul 2013 16:30:22 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 3D1591BA6 for ; Mon, 8 Jul 2013 16:30:22 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r68GUMnS024245 for ; Mon, 8 Jul 2013 16:30:22 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r68GUM5f024235 for svn-soc-all@FreeBSD.org; Mon, 8 Jul 2013 16:30:22 GMT (envelope-from dpl@FreeBSD.org) Date: Mon, 8 Jul 2013 16:30:22 GMT Message-Id: <201307081630.r68GUM5f024235@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254421 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 16:30:22 -0000 Author: dpl Date: Mon Jul 8 16:30:21 2013 New Revision: 254421 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254421 Log: Make bzip2 work with any file anywhere. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Mon Jul 8 15:59:11 2013 (r254420) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Mon Jul 8 16:30:21 2013 (r254421) @@ -226,6 +226,7 @@ #define OUT_FILENO fileno(outStr) void limitfd(int); const Char * getdir(Char* file); +const Char * getfilename(Char* file); FILE *inStr; FILE *outStr; int cwd; /* Where is the file (fd) */ @@ -698,7 +699,31 @@ slashPos = strrchr(file, (int)'/'); if ( slashPos == 0 ) return( "." ); - ret = strndup( file, (slashPos - file + 1) ); + if ( (ret = strndup( file, (slashPos - file + 1)) ) == NULL){ + setExit(1); + exit(exitValue); + } + return(ret); + +} + + +/*---------------------------------------------*/ +const Char * +getfilename(Char *file) +{ + Char * slashPos; + Char * ret; + int slashIndex; + + slashPos = strrchr(file, (int)'/'); + if ( slashPos == 0 ) + return( file ); + slashIndex = slashPos - file; + if ( (ret = strndup( slashPos + 1, (strlen(file) - slashIndex) )) == NULL){ + setExit(1); + exit(exitValue); + } return(ret); } @@ -756,7 +781,7 @@ progName, outName ); if (outputHandleJustInCase != NULL) fclose ( outputHandleJustInCase ); - retVal = unlinkat ( cwd, inName, 0 ); + retVal = unlinkat ( cwd, getfilename(inName), 0 ); if (retVal != 0) fprintf ( stderr, "%s: WARNING: deletion of output file " @@ -1262,7 +1287,7 @@ } if ( srcMode == SM_F2F && fileExists ( outName ) ) { if (forceOverwrite) { - unlinkat ( cwd, inName, 0 ); + unlinkat ( cwd, getfilename(inName), 0 ); } else { fprintf ( stderr, "%s: Output file %s already exists.\n", progName, outName ); @@ -1378,8 +1403,7 @@ applySavedTimeInfoToOutputFile ( OUT_FILENO ); deleteOutputOnInterrupt = False; if ( !keepInputFiles ) { - printf("unlinkat( %d, %s, 0);\n", cwd, inName); - IntNative retVal = unlinkat ( cwd, inName, 0 ); + IntNative retVal = unlinkat ( cwd, getfilename(inName), 0 ); ERROR_IF_NOT_ZERO ( retVal ); } } @@ -1476,7 +1500,7 @@ } if ( srcMode == SM_F2F && fileExists ( outName ) ) { if (forceOverwrite) { - unlinkat ( cwd, inName, 0 ); + unlinkat ( cwd, getfilename(inName), 0 ); } else { fprintf ( stderr, "%s: Output file %s already exists.\n", progName, outName ); @@ -1592,7 +1616,7 @@ applySavedTimeInfoToOutputFile ( OUT_FILENO ); deleteOutputOnInterrupt = False; if ( !keepInputFiles ) { - IntNative retVal = unlinkat ( cwd, inName, 0 ); + IntNative retVal = unlinkat ( cwd, getfilename(inName), 0 ); ERROR_IF_NOT_ZERO ( retVal ); } } @@ -1600,7 +1624,7 @@ unzFailsExist = True; deleteOutputOnInterrupt = False; if ( srcMode == SM_F2F ) { - IntNative retVal = unlinkat ( cwd, inName, 0 ); + IntNative retVal = unlinkat ( cwd, getfilename(inName), 0 ); ERROR_IF_NOT_ZERO ( retVal ); } } From owner-svn-soc-all@FreeBSD.ORG Mon Jul 8 21:47:32 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CA648F9C for ; Mon, 8 Jul 2013 21:47:32 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id BA8C51AFA for ; Mon, 8 Jul 2013 21:47:32 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r68LlWps033428 for ; Mon, 8 Jul 2013 21:47:32 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r68LlWuv033426 for svn-soc-all@FreeBSD.org; Mon, 8 Jul 2013 21:47:32 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 8 Jul 2013 21:47:32 GMT Message-Id: <201307082147.r68LlWuv033426@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254429 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 21:47:32 -0000 Author: mattbw Date: Mon Jul 8 21:47:32 2013 New Revision: 254429 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254429 Log: remove useless backend mains Added: soc2013/mattbw/backend/actions/.indent.pro Deleted: soc2013/mattbw/backend/pk-backend-dummy-089.c soc2013/mattbw/backend/pk-backend-dummy.c Added: soc2013/mattbw/backend/actions/.indent.pro ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/.indent.pro Mon Jul 8 21:47:32 2013 (r254429) @@ -0,0 +1,6 @@ +-TPkBackend +-Tgchar +-Tgboolean +-sob +-nlp +-ci4 From owner-svn-soc-all@FreeBSD.ORG Mon Jul 8 21:54:52 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4F2201D3 for ; Mon, 8 Jul 2013 21:54:52 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 3F34D1B31 for ; Mon, 8 Jul 2013 21:54:52 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r68Lsq5Q037621 for ; Mon, 8 Jul 2013 21:54:52 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r68Lsq49037611 for svn-soc-all@FreeBSD.org; Mon, 8 Jul 2013 21:54:52 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 8 Jul 2013 21:54:52 GMT Message-Id: <201307082154.r68Lsq49037611@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254430 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jul 2013 21:54:52 -0000 Author: mattbw Date: Mon Jul 8 21:54:51 2013 New Revision: 254430 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254430 Log: rename actions files to match their C action names Added: soc2013/mattbw/backend/actions.h - copied, changed from r254404, soc2013/mattbw/backend/actions/actions.h soc2013/mattbw/backend/actions/get_details.c - copied, changed from r254408, soc2013/mattbw/backend/actions/get-details.c soc2013/mattbw/backend/actions/get_files.c - copied, changed from r254408, soc2013/mattbw/backend/actions/get-files.c soc2013/mattbw/backend/actions/get_repo_list.c - copied, changed from r254408, soc2013/mattbw/backend/actions/get-repo-list.c soc2013/mattbw/backend/actions/install_files.c - copied, changed from r254408, soc2013/mattbw/backend/actions/install-files.c soc2013/mattbw/backend/actions/install_packages.c - copied, changed from r254408, soc2013/mattbw/backend/actions/install-packages.c Deleted: soc2013/mattbw/backend/actions/actions.h soc2013/mattbw/backend/actions/get-details.c soc2013/mattbw/backend/actions/get-files.c soc2013/mattbw/backend/actions/get-repo-list.c soc2013/mattbw/backend/actions/install-files.c soc2013/mattbw/backend/actions/install-packages.c Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/resolve.c soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Mon Jul 8 21:47:32 2013 (r254429) +++ soc2013/mattbw/backend/Makefile Mon Jul 8 21:54:51 2013 (r254430) @@ -10,11 +10,11 @@ pkgutils.c \ utils.c SRCS+= \ - actions/get-details.c \ - actions/get-files.c \ - actions/get-repo-list.c \ - actions/install-files.c \ - actions/install-packages.c \ + actions/get_details.c \ + actions/get_files.c \ + actions/get_repo_list.c \ + actions/install_files.c \ + actions/install_packages.c \ actions/resolve.c SRCS+= \ Copied and modified: soc2013/mattbw/backend/actions.h (from r254404, soc2013/mattbw/backend/actions/actions.h) ============================================================================== --- soc2013/mattbw/backend/actions/actions.h Mon Jul 8 06:55:06 2013 (r254404, copy source) +++ soc2013/mattbw/backend/actions.h Mon Jul 8 21:54:51 2013 (r254430) @@ -22,7 +22,7 @@ #define _PKGNG_BACKEND_ACTIONS_H_ #include /* gboolean */ -#include "../pk-backend.h" /* PkBackend */ +#include "pk-backend.h" /* PkBackend */ /* * Each thread is implemented in its namesake C file, except simulations Copied and modified: soc2013/mattbw/backend/actions/get_details.c (from r254408, soc2013/mattbw/backend/actions/get-details.c) ============================================================================== --- soc2013/mattbw/backend/actions/get-details.c Mon Jul 8 11:55:21 2013 (r254408, copy source) +++ soc2013/mattbw/backend/actions/get_details.c Mon Jul 8 21:54:51 2013 (r254430) @@ -26,7 +26,7 @@ #include "../licenses.h" /* license_from_pkg */ #include "../query.h" /* query_... */ -#include "actions.h" /* get_details_thread prototype */ +#include "../actions.h" /* get_details_thread prototype */ static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_LICENSES; Copied and modified: soc2013/mattbw/backend/actions/get_files.c (from r254408, soc2013/mattbw/backend/actions/get-files.c) ============================================================================== --- soc2013/mattbw/backend/actions/get-files.c Mon Jul 8 11:55:21 2013 (r254408, copy source) +++ soc2013/mattbw/backend/actions/get_files.c Mon Jul 8 21:54:51 2013 (r254430) @@ -29,9 +29,8 @@ #include "../licenses.h" /* license_from_pkg */ #include "../query.h" /* query_... */ -#include "actions.h" /* get_files_thread prototype */ +#include "../actions.h" /* get_files_thread prototype */ -static const int FILE_NAME_STEP = 10; static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_FILES; static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q); Copied and modified: soc2013/mattbw/backend/actions/get_repo_list.c (from r254408, soc2013/mattbw/backend/actions/get-repo-list.c) ============================================================================== --- soc2013/mattbw/backend/actions/get-repo-list.c Mon Jul 8 11:55:21 2013 (r254408, copy source) +++ soc2013/mattbw/backend/actions/get_repo_list.c Mon Jul 8 21:54:51 2013 (r254430) @@ -23,7 +23,7 @@ #include "pkg.h" #include "../hash_traverse.h" /* HASH_FOR */ -#include "actions.h" /* get_repo_list_thread prototype */ +#include "../actions.h" /* get_repo_list_thread prototype */ /* * The thread that performs a GetRepoList operation. Should be invoked by the @@ -42,9 +42,9 @@ for (HASH_FOR(err, pkg_repos, &repo)) pk_backend_repo_detail(backend, - pkg_repo_ident(repo), - pkg_repo_name(repo), - pkg_repo_enabled(repo)); + pkg_repo_ident(repo), + pkg_repo_name(repo), + pkg_repo_enabled(repo)); (void)pk_backend_set_percentage(backend, 100); (void)pk_backend_finished(backend); Copied and modified: soc2013/mattbw/backend/actions/install_files.c (from r254408, soc2013/mattbw/backend/actions/install-files.c) ============================================================================== --- soc2013/mattbw/backend/actions/install-files.c Mon Jul 8 11:55:21 2013 (r254408, copy source) +++ soc2013/mattbw/backend/actions/install_files.c Mon Jul 8 21:54:51 2013 (r254430) @@ -27,7 +27,7 @@ #include "../pkgutils.h" /* pkgutils_... */ #include "../utils.h" /* INTENTIONALLY_IGNORE */ -#include "actions.h" /* install_files_thread prototype */ +#include "../actions.h" /* install_files_thread prototype */ static gboolean do_file(const gchar *path, PkBackend *backend, gboolean simulate); static gboolean do_files(PkBackend *backend, gboolean simulate); Copied and modified: soc2013/mattbw/backend/actions/install_packages.c (from r254408, soc2013/mattbw/backend/actions/install-packages.c) ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Mon Jul 8 11:55:21 2013 (r254408, copy source) +++ soc2013/mattbw/backend/actions/install_packages.c Mon Jul 8 21:54:51 2013 (r254430) @@ -27,14 +27,13 @@ #include "../query.h" /* query_... */ #include "../utils.h" /* INTENTIONALLY_IGNORE */ -#include "actions.h" /* install_packages_thread prototype */ +#include "../actions.h" /* install_packages_thread prototype */ static gboolean job(struct pkg_jobs *jobs, struct query *q); static gboolean sim_job(struct pkg_jobs *jobs, struct query *q); static gboolean solve_job(struct query *q, struct pkg_jobs *jobs); static int install_event_cb(void *backend_v, struct pkg_event *event); - /* * The thread that performs an InstallPackages operation. Should be invoked * by the pk_backend_install_packages hook. Modified: soc2013/mattbw/backend/actions/resolve.c ============================================================================== --- soc2013/mattbw/backend/actions/resolve.c Mon Jul 8 21:47:32 2013 (r254429) +++ soc2013/mattbw/backend/actions/resolve.c Mon Jul 8 21:54:51 2013 (r254430) @@ -25,7 +25,7 @@ #include "../pkgutils.h" /* pkgutils_* */ #include "../query.h" /* query_* */ #include "../utils.h" /* INTENTIONALLY_IGNORE */ -#include "actions.h" /* Prototype */ +#include "../actions.h" /* Prototype */ static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q); Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Mon Jul 8 21:47:32 2013 (r254429) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Mon Jul 8 21:54:51 2013 (r254430) @@ -29,7 +29,7 @@ #include "utils.h" /* INTENTIONALLY_IGNORE */ #include "groups.h" /* available_groups */ -#include "actions/actions.h" /* Actions threads */ +#include "actions.h" /* Actions threads */ /** * pk_backend_initialize: From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 00:59:34 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0F619233 for ; Tue, 9 Jul 2013 00:59:34 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id F2DA019CC for ; Tue, 9 Jul 2013 00:59:33 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r690xXR0071285 for ; Tue, 9 Jul 2013 00:59:33 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r690xXRZ071275 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 00:59:33 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 9 Jul 2013 00:59:33 GMT Message-Id: <201307090059.r690xXRZ071275@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254434 - in soc2013/mattbw/backend: . actions query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 00:59:34 -0000 Author: mattbw Date: Tue Jul 9 00:59:33 2013 New Revision: 254434 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254434 Log: remove some unnecessary bloat in queries, also apparently I forgot to commit my search work Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions.h soc2013/mattbw/backend/actions/get_details.c soc2013/mattbw/backend/actions/resolve.c soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/pkgutils.h soc2013/mattbw/backend/query/core.c soc2013/mattbw/backend/query/match.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Mon Jul 8 21:25:12 2013 (r254433) +++ soc2013/mattbw/backend/Makefile Tue Jul 9 00:59:33 2013 (r254434) @@ -15,7 +15,8 @@ actions/get_repo_list.c \ actions/install_files.c \ actions/install_packages.c \ - actions/resolve.c + actions/resolve.c \ + actions/search_names.c SRCS+= \ query/core.c \ Modified: soc2013/mattbw/backend/actions.h ============================================================================== --- soc2013/mattbw/backend/actions.h Mon Jul 8 21:25:12 2013 (r254433) +++ soc2013/mattbw/backend/actions.h Tue Jul 9 00:59:33 2013 (r254434) @@ -34,6 +34,7 @@ gboolean install_files_thread(PkBackend *backend); gboolean install_packages_thread(PkBackend *backend); gboolean resolve_thread(PkBackend *backend); +gboolean search_names_thread(PkBackend *backend); gboolean simulate_install_files_thread(PkBackend *backend); gboolean simulate_install_packages_thread(PkBackend *backend); Modified: soc2013/mattbw/backend/actions/get_details.c ============================================================================== --- soc2013/mattbw/backend/actions/get_details.c Mon Jul 8 21:25:12 2013 (r254433) +++ soc2013/mattbw/backend/actions/get_details.c Tue Jul 9 00:59:33 2013 (r254434) @@ -25,7 +25,6 @@ #include "../groups.h" /* group_from_origin */ #include "../licenses.h" /* license_from_pkg */ #include "../query.h" /* query_... */ - #include "../actions.h" /* get_details_thread prototype */ static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_LICENSES; Modified: soc2013/mattbw/backend/actions/resolve.c ============================================================================== --- soc2013/mattbw/backend/actions/resolve.c Mon Jul 8 21:25:12 2013 (r254433) +++ soc2013/mattbw/backend/actions/resolve.c Tue Jul 9 00:59:33 2013 (r254434) @@ -25,7 +25,7 @@ #include "../pkgutils.h" /* pkgutils_* */ #include "../query.h" /* query_* */ #include "../utils.h" /* INTENTIONALLY_IGNORE */ -#include "../actions.h" /* Prototype */ +#include "../actions.h" /* resolve_thread prototype */ static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q); Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Mon Jul 8 21:25:12 2013 (r254433) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Tue Jul 9 00:59:33 2013 (r254434) @@ -181,6 +181,16 @@ } void +pk_backend_search_names(PkBackend *backend, PkBitfield filters, gchar **values) +{ + + INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ + pk_backend_set_strv(backend, "values", values); + pk_backend_thread_create(backend, search_names_thread); +} + + +void pk_backend_simulate_install_files(PkBackend *backend, gchar **full_paths) { Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Mon Jul 8 21:25:12 2013 (r254433) +++ soc2013/mattbw/backend/pkgutils.c Tue Jul 9 00:59:33 2013 (r254434) @@ -102,23 +102,6 @@ } /* - * Emits a package through the backend with the given info enum. - */ -void -pkgutils_emit(struct pkg *pkg, PkBackend *backend, PkInfoEnum info) -{ - char *comment; - gchar *id; - - comment = id = NULL; - - pkg_get(pkg, PKG_COMMENT, &comment); - id = pkgutils_pkg_to_id(pkg); - pk_backend_package(backend, info, id, comment); - g_free(id); -} - -/* * Converts a package to a PackageID. */ gchar * @@ -165,6 +148,47 @@ } /* + * Emits a package through the backend with the given info enum. + */ +void +pkgutils_emit(struct pkg *pkg, PkBackend *backend, PkInfoEnum info) +{ + char *comment; + gchar *id; + + comment = id = NULL; + + pkg_get(pkg, PKG_COMMENT, &comment); + id = pkgutils_pkg_to_id(pkg); + pk_backend_package(backend, info, id, comment); + g_free(id); +} + +/* + * Emits a package if it satisfies the given filter set. + */ +void +pkgutils_emit_filtered(struct pkg *pkg, PkBackend *backend, PkBitfield filters, + PkInfoEnum info) +{ + gboolean should_emit; + + should_emit = TRUE; + + if (pkg_type(pkg) == PKG_INSTALLED) + should_emit = pk_bitfield_contain(filters, + PK_FILTER_ENUM_NOT_INSTALLED) ? FALSE : should_emit; + else + should_emit = pk_bitfield_contain(filters, + PK_FILTER_ENUM_INSTALLED) ? FALSE : should_emit; + + /* TODO: more filters? */ + + if (should_emit) + pkgutils_emit(pkg, backend, info); +} + +/* * Gets the PackageKit repository name for the (remote) package. * * Currently this is actually the pkgng repository ident. This might change. Modified: soc2013/mattbw/backend/pkgutils.h ============================================================================== --- soc2013/mattbw/backend/pkgutils.h Mon Jul 8 21:25:12 2013 (r254433) +++ soc2013/mattbw/backend/pkgutils.h Tue Jul 9 00:59:33 2013 (r254434) @@ -31,5 +31,6 @@ gchar *pkgutils_pkg_to_id(struct pkg *pkg); gchar *pkgutils_pkg_to_id_through(struct pkg *pkg, const gchar **strv); void pkgutils_emit(struct pkg *pkg, PkBackend *backend, PkInfoEnum info); +void pkgutils_emit_filtered(struct pkg *pkg, PkBackend *backend, PkBitfield filters, PkInfoEnum info); #endif /* !_PKGNG_BACKEND_PKGUTILS_H_ */ Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Mon Jul 8 21:25:12 2013 (r254433) +++ soc2013/mattbw/backend/query/core.c Tue Jul 9 00:59:33 2013 (r254434) @@ -37,20 +37,11 @@ REPO_REMOTE }; -struct query_unpacked_source { - gboolean skip_id_match; - const gchar *name; - const gchar *version; - const gchar *arch; - const gchar *data; - gchar **strv; -}; - struct query { PkBackend *backend; struct pkgdb *db; - struct query_unpacked_source *su; + gchar **id_strv; enum repo_type rtype; @@ -61,11 +52,11 @@ static enum repo_type type_of_repo_name(const char *name); static gboolean can_remote_iterate(struct query *q); static gchar *match_pkg(struct pkg *pkg, struct query *q); +static const gchar *query_repo(struct query *q); +static gchar **init_unpack_source(PkBackend *backend, struct query_source *s); static int jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg); static int jobs_repo_from_query(struct pkg_jobs *jobs, struct query *q); static struct pkg *match_iterator(struct pkgdb_it *it, struct query *q, gchar **match_id_p); -static struct query_unpacked_source *init_unpacked_source(PkBackend *backend, struct query_source *s); -static void free_unpacked_source(struct query_unpacked_source **su_p); /* Returns the backend stored inside the struct query. */ PkBackend * @@ -132,6 +123,7 @@ int match; PkBitfield filters; const char *name; + const char *repo; gchar *match_id; struct pkg *pkg; struct pkgdb *db; @@ -142,7 +134,8 @@ match_id = NULL; pkg = NULL; db = q->db; - name = q->su->name; + name = q->id_strv[PK_PACKAGE_ID_NAME]; + repo = query_repo(q); /* * If we're not given a specific repository in the PackageID, we want @@ -170,7 +163,7 @@ try_remote = FALSE; /* Next, try a remote search, again only if applicable. */ - it = (try_remote ? pkgdb_rquery(db, name, match, q->su->data) : NULL); + it = (try_remote ? pkgdb_rquery(db, name, match, repo) : NULL); if (it != NULL && can_remote_iterate(q)) pkg = match_iterator(it, q, &match_id); pkgdb_it_free(it); @@ -218,11 +211,11 @@ q->s = s; q->t = t; - q->su = init_unpacked_source(backend, s); - if (q->su == NULL) + q->id_strv = init_unpack_source(backend, s); + if (q->id_strv == NULL) goto cleanup; - q->rtype = type_of_repo_name(q->su->data); + q->rtype = type_of_repo_name(q->id_strv[PK_PACKAGE_ID_DATA]); if (q->rtype == REPO_INVALID) { ERR(backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "no such repo"); goto cleanup; @@ -250,8 +243,8 @@ * the creator and not freed here. */ - if (q->su != NULL) - free_unpacked_source(&(q->su)); + if (q->id_strv != NULL) + g_strfreev(q->id_strv); free(q); *q_p = NULL; @@ -287,7 +280,8 @@ { enum repo_type rtype; - if (name == NULL) + /* Null or empty implies no specific repository */ + if (name == NULL || name[0] == '\0') rtype = REPO_ANY; else if (strcmp(name, "installed") == 0) rtype = REPO_LOCAL; @@ -315,16 +309,12 @@ * Stop pkg from catching fire if we try to load files from * non-installed packages. */ - if (q->t->type == QUERY_EMIT) { - int loading_files; - - loading_files = (q->t->data.emit.load_flags & PKG_LOAD_FILES); - if (loading_files) { - ERR(q->backend, - PK_ERROR_ENUM_CANNOT_GET_FILELIST, - "cannot get files for remote package"); - sane = FALSE; - } + if (q->t->type == QUERY_EMIT && + (q->t->data.emit.load_flags & PKG_LOAD_FILES)) { + ERR(q->backend, + PK_ERROR_ENUM_CANNOT_GET_FILELIST, + "cannot get files for remote package"); + sane = FALSE; } return sane; } @@ -345,7 +335,8 @@ match_id = pkgutils_pkg_to_id_through(pkg, pkg_id_bits); - if (q->su->skip_id_match == TRUE) + /* No need to do a PackageID match if we're looking for a name. */ + if (q->s->type == QUERY_SINGLE_NAME) matches = TRUE; else { /* @@ -358,7 +349,7 @@ for (matches = TRUE, i = PK_PACKAGE_ID_NAME; matches == TRUE && i <= PK_PACKAGE_ID_DATA; i++) - matches = string_match((q->su->strv)[i], + matches = string_match((q->id_strv)[i], pkg_id_bits[i]); } @@ -371,6 +362,16 @@ return match_id; } +/* Retrieves the repository for the query, or NULL if none is specified. */ +static const gchar * +query_repo(struct query *q) +{ + const gchar *repo; + + repo = q->id_strv[PK_PACKAGE_ID_DATA]; + return ((repo == NULL || repo[0] == '\0') ? NULL : repo); +} + /* Adds a single package to a jobs structure. */ static int jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg) @@ -387,11 +388,13 @@ jobs_repo_from_query(struct pkg_jobs *jobs, struct query *q) { int err; + gchar *repo; - if (q->su->data == NULL) + repo = q->id_strv[PK_PACKAGE_ID_DATA]; + if (repo == NULL || repo[0] == '\0') err = EPKG_OK; else - err = pkg_jobs_set_repository(jobs, q->su->data); + err = pkg_jobs_set_repository(jobs, repo); return err; } @@ -432,65 +435,34 @@ } /* Unpacks a query source into name/version/arch/data pointers. */ -static struct query_unpacked_source * -init_unpacked_source(PkBackend *backend, struct query_source *s) +static gchar ** +init_unpack_source(PkBackend *backend, struct query_source *s) { - struct query_unpacked_source *su; - gboolean success; - - success = FALSE; + gchar **id_strv; - su = calloc(1, sizeof(struct query_unpacked_source)); - if (su == NULL) - (void)pk_backend_error_code(backend, - PK_ERROR_ENUM_OOM, - "couldn't allocate unpacked source"); - else if (s->type == QUERY_SINGLE_NAME) { + id_strv = NULL; + if (s->type == QUERY_SINGLE_NAME) { /* - * Expecting the string to be of the form "name" or - * "name-version", no way to check which yet. + * Make a snake-oil ID vector; we won't be doing rigid checking + * against it so it doesn't matter that the version might be in + * the name column etc. */ - su->skip_id_match = TRUE; - su->name = s->data.single; + id_strv = g_new0(gchar *, 5); - success = TRUE; + id_strv[PK_PACKAGE_ID_NAME] = g_strdup(s->data.single); + id_strv[PK_PACKAGE_ID_VERSION] = g_strdup(""); + id_strv[PK_PACKAGE_ID_ARCH] = g_strdup(""); + id_strv[PK_PACKAGE_ID_DATA] = g_strdup(""); } else if (s->type == QUERY_SINGLE_ID) { - su->skip_id_match = FALSE; - - success = split_id(s->data.single, - &(su->strv), - &(su->name), - &(su->version), - &(su->arch), - &(su->data)); - if (success == FALSE) + id_strv = pk_package_id_split(s->data.single); + if (id_strv == NULL) (void)pk_backend_error_code(backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id"); } else (void)pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "query_init_unpack_source given silly source type"); - - if (success == FALSE) - free_unpacked_source(&su); - - return su; -} - -/* Frees an unpacked source and all its owned contents. */ -static void -free_unpacked_source(struct query_unpacked_source **su_p) -{ - struct query_unpacked_source *su; + "init_unpack_source given silly source type"); - su = (su_p == NULL ? NULL : *su_p); - if (su != NULL) { - /* This should free the other split ID pointer targets. */ - if (su->strv != NULL) - g_strfreev(su->strv); - - free(su); - *su_p = NULL; - } + return id_strv; } Modified: soc2013/mattbw/backend/query/match.c ============================================================================== --- soc2013/mattbw/backend/query/match.c Mon Jul 8 21:25:12 2013 (r254433) +++ soc2013/mattbw/backend/query/match.c Tue Jul 9 00:59:33 2013 (r254434) @@ -18,15 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include #include "../pk-backend.h" -#include "pkg.h" - -#include "../db.h" /* open_remote_db */ -#include "../hash_traverse.h" /* HASH_FOR */ -#include "../utils.h" /* string_match */ -#include "../pkgutils.h" /* pkgutils_... */ #include "core.h" /* query_... */ #include "do.h" /* query_do... */ From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 04:51:40 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 927F17C4 for ; Tue, 9 Jul 2013 04:51:40 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 837EB179B for ; Tue, 9 Jul 2013 04:51:40 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r694peTK036409 for ; Tue, 9 Jul 2013 04:51:40 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r694pesP036301 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 04:51:40 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 9 Jul 2013 04:51:40 GMT Message-Id: <201307090451.r694pesP036301@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254441 - in soc2013/mattbw/backend: . actions query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 04:51:40 -0000 Author: mattbw Date: Tue Jul 9 04:51:38 2013 New Revision: 254441 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254441 Log: banish variadic macros Deleted: soc2013/mattbw/backend/hash_traverse.h Modified: soc2013/mattbw/backend/.indent.pro soc2013/mattbw/backend/actions/.indent.pro soc2013/mattbw/backend/actions/get_details.c soc2013/mattbw/backend/actions/get_files.c soc2013/mattbw/backend/actions/get_repo_list.c soc2013/mattbw/backend/actions/install_files.c soc2013/mattbw/backend/actions/install_packages.c soc2013/mattbw/backend/actions/resolve.c soc2013/mattbw/backend/db.c soc2013/mattbw/backend/db.h soc2013/mattbw/backend/licenses.c soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/query/core.c soc2013/mattbw/backend/query/core.h soc2013/mattbw/backend/query/do.c soc2013/mattbw/backend/query/do.h soc2013/mattbw/backend/query/match.c soc2013/mattbw/backend/query/match.h soc2013/mattbw/backend/utils.h Modified: soc2013/mattbw/backend/.indent.pro ============================================================================== --- soc2013/mattbw/backend/.indent.pro Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/.indent.pro Tue Jul 9 04:51:38 2013 (r254441) @@ -1,6 +1,7 @@ -TPkBackend -Tgchar -Tgboolean +-Tbool -sob -nlp -ci4 Modified: soc2013/mattbw/backend/actions/.indent.pro ============================================================================== --- soc2013/mattbw/backend/actions/.indent.pro Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/actions/.indent.pro Tue Jul 9 04:51:38 2013 (r254441) @@ -1,6 +1,7 @@ -TPkBackend -Tgchar -Tgboolean +-Tbool -sob -nlp -ci4 Modified: soc2013/mattbw/backend/actions/get_details.c ============================================================================== --- soc2013/mattbw/backend/actions/get_details.c Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/actions/get_details.c Tue Jul 9 04:51:38 2013 (r254441) @@ -19,6 +19,7 @@ */ #include +#include #include "../pk-backend.h" #include "pkg.h" @@ -29,7 +30,7 @@ static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_LICENSES; -static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q); +static bool emit(struct pkg *pkg, const gchar *id, struct query *q); /* * The thread that performs a GetDetails operation. Should be invoked by the @@ -38,20 +39,20 @@ gboolean get_details_thread(PkBackend *backend) { - gboolean success; + bool success; success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit); pk_backend_finished(backend); - return success; + return success ? TRUE : FALSE; } /* * Emits the given package's details. To be used as an iterating function. */ -static gboolean +static bool emit(struct pkg *pkg, const gchar *id, struct query *q) { - gboolean success; + bool success; const char *description; const char *origin; const char *www; @@ -74,7 +75,7 @@ group_from_origin(origin), description, www, - flatsize); + flatsize) == TRUE; query_set_percentage(q, 100); return success; Modified: soc2013/mattbw/backend/actions/get_files.c ============================================================================== --- soc2013/mattbw/backend/actions/get_files.c Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/actions/get_files.c Tue Jul 9 04:51:38 2013 (r254441) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #include #include @@ -25,7 +26,6 @@ #include "pkg.h" #include "../groups.h" /* group_from_origin */ -#include "../hash_traverse.h" /* HASH_FOR */ #include "../licenses.h" /* license_from_pkg */ #include "../query.h" /* query_... */ @@ -33,7 +33,7 @@ static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_FILES; -static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q); +static bool emit(struct pkg *pkg, const gchar *id, struct query *q); /* * The thread that performs a GetDetails operation. Should be invoked by the @@ -48,23 +48,22 @@ success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit); (void)pk_backend_finished(backend); - return success; + return success ? TRUE : FALSE; } /* * Emits the given package's files. To be used as an iterating function. */ -static gboolean +static bool emit(struct pkg *pkg, const gchar *id, struct query *q) { - gboolean success; - int err; + bool success; struct pkg_file *file; struct sbuf *sb; query_set_percentage(q, 0); - success = FALSE; + success = false; file = NULL; /* @@ -72,7 +71,7 @@ * rid of the initial ; later. */ sb = sbuf_new_auto(); - for (HASH_FOR(err, pkg_files, pkg, &file)) + while (pkg_files(pkg, &file) == EPKG_OK) sbuf_printf(sb, ";%s", pkg_file_path(file)); if (sbuf_finish(sb) != 0) @@ -87,7 +86,8 @@ if (filenames[0] == ';') filenames++; - success = pk_backend_files(query_backend(q), id, filenames); + success = (pk_backend_files(query_backend(q), id, filenames) == + TRUE); } sbuf_delete(sb); Modified: soc2013/mattbw/backend/actions/get_repo_list.c ============================================================================== --- soc2013/mattbw/backend/actions/get_repo_list.c Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/actions/get_repo_list.c Tue Jul 9 04:51:38 2013 (r254441) @@ -22,7 +22,6 @@ #include "../pk-backend.h" #include "pkg.h" -#include "../hash_traverse.h" /* HASH_FOR */ #include "../actions.h" /* get_repo_list_thread prototype */ /* @@ -32,15 +31,13 @@ gboolean get_repo_list_thread(PkBackend *backend) { - int err; struct pkg_repo *repo; - repo = NULL; - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); (void)pk_backend_set_percentage(backend, 0); - for (HASH_FOR(err, pkg_repos, &repo)) + repo = NULL; + while (pkg_repos(&repo) == EPKG_OK) pk_backend_repo_detail(backend, pkg_repo_ident(repo), pkg_repo_name(repo), @@ -49,5 +46,5 @@ (void)pk_backend_set_percentage(backend, 100); (void)pk_backend_finished(backend); - return (err == EPKG_END ? TRUE : FALSE); + return TRUE; } Modified: soc2013/mattbw/backend/actions/install_files.c ============================================================================== --- soc2013/mattbw/backend/actions/install_files.c Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/actions/install_files.c Tue Jul 9 04:51:38 2013 (r254441) @@ -23,7 +23,6 @@ #include "pkg.h" #include "../db.h" /* db_open_remote */ -#include "../hash_traverse.h" /* HASH_FOR */ #include "../pkgutils.h" /* pkgutils_... */ #include "../utils.h" /* INTENTIONALLY_IGNORE */ Modified: soc2013/mattbw/backend/actions/install_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install_packages.c Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/actions/install_packages.c Tue Jul 9 04:51:38 2013 (r254441) @@ -22,16 +22,15 @@ #include "../pk-backend.h" #include "pkg.h" -#include "../hash_traverse.h" /* HASH_FOR */ #include "../pkgutils.h" /* pkgutils_... */ #include "../query.h" /* query_... */ #include "../utils.h" /* INTENTIONALLY_IGNORE */ #include "../actions.h" /* install_packages_thread prototype */ -static gboolean job(struct pkg_jobs *jobs, struct query *q); -static gboolean sim_job(struct pkg_jobs *jobs, struct query *q); -static gboolean solve_job(struct query *q, struct pkg_jobs *jobs); +static bool job (struct pkg_jobs *jobs, struct query *q); +static bool sim_job(struct pkg_jobs *jobs, struct query *q); +static bool solve_job(struct query *q, struct pkg_jobs *jobs); static int install_event_cb(void *backend_v, struct pkg_event *event); /* @@ -41,13 +40,13 @@ gboolean install_packages_thread(PkBackend *backend) { - gboolean success; + bool success; (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, job); (void)pk_backend_finished(backend); - return success; + return success ? TRUE : FALSE; } /* @@ -57,29 +56,29 @@ gboolean simulate_install_packages_thread(PkBackend *backend) { - gboolean success; + bool success; (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, sim_job); (void)pk_backend_finished(backend); - return success; + return success ? TRUE : FALSE; } /* * Tries to process the given solved installation jobs. */ -static gboolean +static bool job(struct pkg_jobs *jobs, struct query *q) { - gboolean success; + bool success; PkBackend *backend; - success = FALSE; + success = false; backend = query_backend(q); query_set_percentage(q, 0); - if (solve_job(q, jobs) == FALSE) + if (solve_job(q, jobs) == false) goto cleanup; pkg_event_register(install_event_cb, backend); @@ -91,7 +90,7 @@ "job failed"); goto cleanup; } - success = TRUE; + success = true; cleanup: pkg_event_register(NULL, NULL); @@ -102,18 +101,18 @@ /* * Tries to simulate processing the given installation jobs. */ -static gboolean +static bool sim_job(struct pkg_jobs *jobs, struct query *q) { - gboolean success; + bool success; PkBackend *backend; struct pkg *pkg; backend = query_backend(q); - success = FALSE; + success = false; query_set_percentage(q, 0); - if (solve_job(q, jobs) == FALSE) + if (solve_job(q, jobs) == false) goto cleanup; pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); @@ -123,7 +122,7 @@ backend, pkgutils_pkg_install_state(pkg)); - success = TRUE; + success = true; cleanup: query_set_percentage(q, 100); @@ -133,26 +132,26 @@ /* * Solves a job and ensures it has packages available. */ -static gboolean +static bool solve_job(struct query *q, struct pkg_jobs *jobs) { - gboolean success; + bool success; PkBackend *backend; - success = FALSE; + success = false; backend = query_backend(q); pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); if (pkg_jobs_solve(jobs) != EPKG_OK) - pk_backend_error_code(backend, + (void)pk_backend_error_code(backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "could not solve the job"); else if (pkg_jobs_count(jobs) == 0) - pk_backend_error_code(backend, + (void)pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "job contains no packages"); else - success = TRUE; + success = true; return success; } Modified: soc2013/mattbw/backend/actions/resolve.c ============================================================================== --- soc2013/mattbw/backend/actions/resolve.c Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/actions/resolve.c Tue Jul 9 04:51:38 2013 (r254441) @@ -27,7 +27,7 @@ #include "../utils.h" /* INTENTIONALLY_IGNORE */ #include "../actions.h" /* resolve_thread prototype */ -static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q); +static bool emit(struct pkg *pkg, const gchar *id, struct query *q); /* * Resolves a package identifier, which may be a full PackageID or a package @@ -48,10 +48,10 @@ success = query_do(backend, &s, &t); (void)pk_backend_finished(backend); - return success; + return success ? TRUE : FALSE; } -static gboolean +static bool emit(struct pkg *pkg, const gchar *id, struct query *q) { PkBackend *backend; @@ -63,5 +63,5 @@ pkgutils_emit(pkg, backend, pkgutils_pkg_current_state(pkg)); query_set_percentage(q, 100); - return TRUE; + return true; } Modified: soc2013/mattbw/backend/db.c ============================================================================== --- soc2013/mattbw/backend/db.c Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/db.c Tue Jul 9 04:51:38 2013 (r254441) @@ -42,12 +42,12 @@ * This must be called during the lifetime of "backend", eg after * "pk_backend_initialize" and before "pk_backend_destroy". */ -gboolean +bool db_open_remote(struct pkgdb **db_p, PkBackend *backend) { - gboolean success; + bool success; - success = FALSE; + success = false; (void)pk_backend_set_status(backend, PK_STATUS_ENUM_WAITING_FOR_AUTH); if (pkgdb_access(ACCESS_MODE, ACCESS_DB) != EPKG_OK) { @@ -70,7 +70,7 @@ goto cleanup; } (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); - success = TRUE; + success = true; cleanup: return success; Modified: soc2013/mattbw/backend/db.h ============================================================================== --- soc2013/mattbw/backend/db.h Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/db.h Tue Jul 9 04:51:38 2013 (r254441) @@ -22,10 +22,10 @@ #ifndef _PKGNG_BACKEND_DB_H_ #define _PKGNG_BACKEND_DB_H_ -#include /* gboolean */ +#include /* bool */ #include "pk-backend.h" /* PkBackend */ #include "pkg.h" /* struct pkgdb */ -gboolean db_open_remote(struct pkgdb **db, PkBackend *backend); +bool db_open_remote(struct pkgdb **db, PkBackend *backend); #endif /* !_PKGNG_BACKEND_DB_H_ */ Modified: soc2013/mattbw/backend/licenses.c ============================================================================== --- soc2013/mattbw/backend/licenses.c Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/licenses.c Tue Jul 9 04:51:38 2013 (r254441) @@ -24,7 +24,6 @@ #include "pkg.h" /* struct pkg, etc */ #include "pk-backend.h" /* PkLicenseEnum, PK_* */ -#include "hash_traverse.h" /* HASH_FOR */ #include "licenses.h" /* prototypes */ /* @@ -35,7 +34,6 @@ license_name_from_pkg(struct pkg *pkg) { /* TODO: handle conjunctions and disjunctions */ - int err; int sb_err; lic_t logic; char *license_dup; @@ -60,7 +58,7 @@ /* Join all the licenses together with the logic word above. */ lic = NULL; sb = sbuf_new_auto(); - for (HASH_FOR(err, pkg_licenses, pkg, &lic)) { + while (pkg_licenses(pkg, &lic) == EPKG_OK) { sbuf_cat(sb, logic_str); sbuf_cat(sb, pkg_license_name(lic)); } Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Tue Jul 9 04:51:38 2013 (r254441) @@ -96,7 +96,7 @@ { INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ - pk_backend_thread_create(backend, get_details_thread); + (void)pk_backend_thread_create(backend, get_details_thread); } void @@ -104,7 +104,7 @@ { INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ - pk_backend_thread_create(backend, get_files_thread); + (void)pk_backend_thread_create(backend, get_files_thread); } PkBitfield @@ -148,7 +148,7 @@ { INTENTIONALLY_IGNORE(filters); /* not yet supported */ - pk_backend_thread_create(backend, get_repo_list_thread); + (void)pk_backend_thread_create(backend, get_repo_list_thread); } void @@ -158,7 +158,7 @@ INTENTIONALLY_IGNORE(only_trusted); /* not yet supported */ INTENTIONALLY_IGNORE(full_paths); /* retrieved from backend */ - pk_backend_thread_create(backend, install_files_thread); + (void)pk_backend_thread_create(backend, install_files_thread); } void @@ -168,25 +168,25 @@ INTENTIONALLY_IGNORE(only_trusted); /* not yet supported */ INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ - pk_backend_thread_create(backend, install_packages_thread); + (void)pk_backend_thread_create(backend, install_packages_thread); } void pk_backend_resolve(PkBackend *backend, PkBitfield filters, gchar **package_ids) { - INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ + INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ - pk_backend_thread_create(backend, resolve_thread); + (void)pk_backend_thread_create(backend, resolve_thread); } void pk_backend_search_names(PkBackend *backend, PkBitfield filters, gchar **values) { - INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ - pk_backend_set_strv(backend, "values", values); - pk_backend_thread_create(backend, search_names_thread); + INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ + (void)pk_backend_set_strv(backend, "values", values); + (void)pk_backend_thread_create(backend, search_names_thread); } @@ -195,7 +195,7 @@ { INTENTIONALLY_IGNORE(full_paths); /* retrieved from backend */ - pk_backend_thread_create(backend, simulate_install_files_thread); + (void)pk_backend_thread_create(backend, simulate_install_files_thread); } void @@ -203,5 +203,6 @@ { INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ - pk_backend_thread_create(backend, simulate_install_packages_thread); + (void)pk_backend_thread_create(backend, + simulate_install_packages_thread); } Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/query/core.c Tue Jul 9 04:51:38 2013 (r254441) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #include #include #include "../pk-backend.h" @@ -25,7 +26,6 @@ #include "../db.h" /* db_open_remote */ -#include "../hash_traverse.h" /* HASH_FOR */ #include "../utils.h" /* string_match */ #include "../pkgutils.h" /* pkgutils_... */ #include "core.h" /* Prototypes */ @@ -41,7 +41,7 @@ PkBackend *backend; struct pkgdb *db; - gchar **id_strv; + gchar **id_strv; enum repo_type rtype; @@ -50,7 +50,7 @@ }; static enum repo_type type_of_repo_name(const char *name); -static gboolean can_remote_iterate(struct query *q); +static bool can_remote_iterate(struct query *q); static gchar *match_pkg(struct pkg *pkg, struct query *q); static const gchar *query_repo(struct query *q); static gchar **init_unpack_source(PkBackend *backend, struct query_source *s); @@ -69,16 +69,16 @@ /* * For adapting an emitter function into one that solves and applies a job. */ -gboolean +bool query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q) { - gboolean success; + bool success; struct pkg_jobs *jobs; PkBackend *backend; INTENTIONALLY_IGNORE(id); - success = FALSE; + success = false; jobs = NULL; if (q == NULL) @@ -114,12 +114,12 @@ /* * Runs an assembled query. */ -gboolean +bool query_run(struct query *q) { - gboolean success; - gboolean try_local; - gboolean try_remote; + bool success; + bool try_local; + bool try_remote; int match; PkBitfield filters; const char *name; @@ -129,7 +129,7 @@ struct pkgdb *db; struct pkgdb_it *it; - success = FALSE; + success = false; match = MATCH_EXACT; match_id = NULL; pkg = NULL; @@ -148,9 +148,9 @@ /* Apply filters, if any */ filters = pk_backend_get_uint(q->backend, "filters"); if (pk_bitfield_contain(filters, PK_FILTER_ENUM_INSTALLED)) - try_remote = FALSE; + try_remote = false; if (pk_bitfield_contain(filters, PK_FILTER_ENUM_NOT_INSTALLED)) - try_local = FALSE; + try_local = false; /* Try a local search first, if applicable. */ it = (try_local ? pkgdb_query(db, name, match) : NULL); @@ -160,7 +160,7 @@ /* No point trying remote if we got a local match */ if (pkg != NULL) - try_remote = FALSE; + try_remote = false; /* Next, try a remote search, again only if applicable. */ it = (try_remote ? pkgdb_rquery(db, name, match, repo) : NULL); @@ -196,10 +196,10 @@ struct query_source *s, struct query_target *t) { - gboolean success; + bool success; struct query *q; - success = FALSE; + success = false; q = calloc(1, sizeof(struct query)); if (q == NULL) { @@ -220,10 +220,10 @@ ERR(backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "no such repo"); goto cleanup; } - success = TRUE; + success = true; cleanup: - if (success == FALSE) + if (success == false) query_free(&q); return q; @@ -297,13 +297,13 @@ * Checks to see if trying to do a remote package iteration with this query * could spell disaster. */ -static gboolean +static bool can_remote_iterate(struct query *q) { - gboolean sane; + bool sane; /* Innocent until proven guilty */ - sane = TRUE; + sane = true; /* * Stop pkg from catching fire if we try to load files from @@ -314,7 +314,7 @@ ERR(q->backend, PK_ERROR_ENUM_CANNOT_GET_FILELIST, "cannot get files for remote package"); - sane = FALSE; + sane = false; } return sane; } @@ -326,7 +326,7 @@ static gchar * match_pkg(struct pkg *pkg, struct query *q) { - gboolean matches; + bool matches; int i; gchar *match_id; const gchar **pkg_id_bits; @@ -337,7 +337,7 @@ /* No need to do a PackageID match if we're looking for a name. */ if (q->s->type == QUERY_SINGLE_NAME) - matches = TRUE; + matches = true; else { /* * Succeed if this package's PackageID fields match the @@ -346,8 +346,8 @@ * one as a success. This means using our "weak strcmp" * instead of normal strcmp or even g_strcmp0. */ - for (matches = TRUE, i = PK_PACKAGE_ID_NAME; - matches == TRUE && i <= PK_PACKAGE_ID_DATA; + for (matches = true, i = PK_PACKAGE_ID_NAME; + matches == true && i <= PK_PACKAGE_ID_DATA; i++) matches = string_match((q->id_strv)[i], pkg_id_bits[i]); @@ -355,7 +355,7 @@ g_free(pkg_id_bits); - if (matches == FALSE) { + if (matches == false) { g_free(match_id); match_id = NULL; } @@ -366,7 +366,7 @@ static const gchar * query_repo(struct query *q) { - const gchar *repo; + const gchar *repo; repo = q->id_strv[PK_PACKAGE_ID_DATA]; return ((repo == NULL || repo[0] == '\0') ? NULL : repo); @@ -388,7 +388,7 @@ jobs_repo_from_query(struct pkg_jobs *jobs, struct query *q) { int err; - gchar *repo; + gchar *repo; repo = q->id_strv[PK_PACKAGE_ID_DATA]; if (repo == NULL || repo[0] == '\0') @@ -435,17 +435,17 @@ } /* Unpacks a query source into name/version/arch/data pointers. */ -static gchar ** +static gchar ** init_unpack_source(PkBackend *backend, struct query_source *s) { - gchar **id_strv; + gchar **id_strv; id_strv = NULL; if (s->type == QUERY_SINGLE_NAME) { /* - * Make a snake-oil ID vector; we won't be doing rigid checking - * against it so it doesn't matter that the version might be in - * the name column etc. + * Make a snake-oil ID vector; we won't be doing rigid + * checking against it so it doesn't matter that the version + * might be in the name column etc. */ id_strv = g_new0(gchar *, 5); Modified: soc2013/mattbw/backend/query/core.h ============================================================================== --- soc2013/mattbw/backend/query/core.h Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/query/core.h Tue Jul 9 04:51:38 2013 (r254441) @@ -27,9 +27,9 @@ struct query; -typedef gboolean (*emit_ptr) (struct pkg *pkg, const gchar *id, struct query *q); -typedef gboolean (*job_emit_ptr) (struct pkg_jobs *jobs, struct query *q); -typedef gboolean (*query_body_ptr) (struct query *q); +typedef bool (*emit_ptr) (struct pkg *pkg, const gchar *id, struct query *q); +typedef bool (*job_emit_ptr) (struct pkg_jobs *jobs, struct query *q); +typedef bool (*query_body_ptr) (struct query *q); enum query_source_type { QUERY_SINGLE_ID, @@ -47,14 +47,14 @@ struct query_source { enum query_source_type type; union { - gchar *single; - } data; + gchar *single; + } data; - query_body_ptr body; + query_body_ptr body; /* Information about this query's position in a set of subqueries. */ - unsigned int position; - unsigned int total; + unsigned int position; + unsigned int total; }; /* Holds information about where the result of a query should go. */ @@ -62,19 +62,19 @@ enum query_target_type type; union { struct { - unsigned int load_flags; - emit_ptr f; - } emit; + unsigned int load_flags; + emit_ptr f; + } emit; struct { - pkg_jobs_t type; - job_emit_ptr f; - } job; - } data; + pkg_jobs_t type; + job_emit_ptr f; + } job; + } data; }; PkBackend *query_backend(struct query *q); -gboolean query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q); -gboolean query_run(struct query *q); +bool query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q); +bool query_run (struct query *q); struct query *query_init(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t); void query_free(struct query **q_p); void query_set_percentage(struct query *q, unsigned char percent); Modified: soc2013/mattbw/backend/query/do.c ============================================================================== --- soc2013/mattbw/backend/query/do.c Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/query/do.c Tue Jul 9 04:51:38 2013 (r254441) @@ -31,22 +31,22 @@ #include "do.h" /* query_do_... */ #include "core.h" /* query_... */ -static gboolean do_single(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t); -static gboolean do_backend_ids(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t); +static bool do_single(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t); +static bool do_backend_ids(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t); /* * Given information about a query's source and target, creates and runs it. */ -gboolean +bool query_do(PkBackend *backend, struct query_source *s, struct query_target *t) { - gboolean success; + bool success; struct pkgdb *db; db = NULL; - success = FALSE; + success = false; - if (db_open_remote(&db, backend) == TRUE) { + if (db_open_remote(&db, backend)) { switch (s->type) { case QUERY_BACKEND_IDS: case QUERY_BACKEND_MIXED: @@ -57,7 +57,7 @@ success = do_single(backend, db, s, t); break; default: - success = FALSE; + success = false; break; } } @@ -69,17 +69,17 @@ * Performs a query whose source is the set of PackageIDs stored in the * backend. */ -static gboolean +static bool do_backend_ids(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t) { - gboolean success; + bool success; gchar **package_ids; struct query_source new_s; /* Cheat by running a separate single-ID query for each ID. */ - success = TRUE; + success = true; package_ids = pk_backend_get_strv(backend, "package_ids"); new_s.total = g_strv_length(package_ids); @@ -105,15 +105,15 @@ /* * Performs a query whose source is a single PackageID or name. */ -static gboolean +static bool do_single(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t) { - gboolean success; + bool success; struct query *q; q = query_init(backend, db, s, t); - success = q == NULL ? FALSE : query_run(q); + success = q == NULL ? false : query_run(q); query_free(&q); return success; Modified: soc2013/mattbw/backend/query/do.h ============================================================================== --- soc2013/mattbw/backend/query/do.h Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/query/do.h Tue Jul 9 04:51:38 2013 (r254441) @@ -21,12 +21,12 @@ #ifndef _PKGNG_BACKEND_QUERY_DO_H_ #define _PKGNG_BACKEND_QUERY_DO_H_ -#include +#include #include "../pk-backend.h" #include "pkg.h" #include "core.h" /* struct query_... */ -gboolean query_do(PkBackend *backend, struct query_source *s, struct query_target *t); +bool query_do (PkBackend *backend, struct query_source *s, struct query_target *t); #endif /* !_PKGNG_BACKEND_QUERY_DO_H_ */ Modified: soc2013/mattbw/backend/query/match.c ============================================================================== --- soc2013/mattbw/backend/query/match.c Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/query/match.c Tue Jul 9 04:51:38 2013 (r254441) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #include "../pk-backend.h" #include "core.h" /* query_... */ @@ -29,7 +30,7 @@ * Runs a query over the PackageIDs selected in the backend that sends the * first match to an emitting function. */ -gboolean +bool query_match_id_to_emitter(PkBackend *backend, unsigned int load_flags, emit_ptr emitter) { @@ -50,7 +51,7 @@ * first match into a job of the given type and hands it to a function for * solving and applying. */ -gboolean +bool query_match_id_to_job(PkBackend *backend, pkg_jobs_t type, job_emit_ptr emitter) { Modified: soc2013/mattbw/backend/query/match.h ============================================================================== --- soc2013/mattbw/backend/query/match.h Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/query/match.h Tue Jul 9 04:51:38 2013 (r254441) @@ -21,13 +21,13 @@ #ifndef _PKGNG_BACKEND_QUERY_MATCH_H_ #define _PKGNG_BACKEND_QUERY_MATCH_H_ -#include +#include #include "../pk-backend.h" #include "pkg.h" #include "core.h" /* *_ptr */ -gboolean query_match_id_to_emitter(PkBackend *backend, unsigned int load_flags, emit_ptr emitter); -gboolean query_match_id_to_job(PkBackend *backend, pkg_jobs_t type, job_emit_ptr job_emitter); +bool query_match_id_to_emitter(PkBackend *backend, unsigned int load_flags, emit_ptr emitter); +bool query_match_id_to_job(PkBackend *backend, pkg_jobs_t type, job_emit_ptr job_emitter); #endif /* !_PKGNG_BACKEND_QUERY_MATCH_H_ */ Modified: soc2013/mattbw/backend/utils.h ============================================================================== --- soc2013/mattbw/backend/utils.h Tue Jul 9 03:00:06 2013 (r254440) +++ soc2013/mattbw/backend/utils.h Tue Jul 9 04:51:38 2013 (r254441) @@ -25,7 +25,8 @@ #include /* gboolean */ #define INTENTIONALLY_IGNORE(x) (void)(x) -#define ERR(...) (void) pk_backend_error_code(__VA_ARGS__) +#define ERR(backend, type, msg) \ + (void) pk_backend_error_code((backend), (type), (msg)) const char *null_if_empty(const char *in); gboolean From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 05:06:47 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 20BBB9AD for ; Tue, 9 Jul 2013 05:06:47 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 03F8117F4 for ; Tue, 9 Jul 2013 05:06:47 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6956kMB093791 for ; Tue, 9 Jul 2013 05:06:46 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6956kUX093770 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 05:06:46 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 9 Jul 2013 05:06:46 GMT Message-Id: <201307090506.r6956kUX093770@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254442 - in soc2013/mattbw/backend: . actions query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 05:06:47 -0000 Author: mattbw Date: Tue Jul 9 05:06:46 2013 New Revision: 254442 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254442 Log: some silencing of splint warnings Modified: soc2013/mattbw/backend/actions/get_details.c soc2013/mattbw/backend/actions/get_repo_list.c soc2013/mattbw/backend/actions/install_files.c soc2013/mattbw/backend/actions/install_packages.c soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/query/core.c Modified: soc2013/mattbw/backend/actions/get_details.c ============================================================================== --- soc2013/mattbw/backend/actions/get_details.c Tue Jul 9 04:51:38 2013 (r254441) +++ soc2013/mattbw/backend/actions/get_details.c Tue Jul 9 05:06:46 2013 (r254442) @@ -42,7 +42,7 @@ bool success; success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit); - pk_backend_finished(backend); + (void)pk_backend_finished(backend); return success ? TRUE : FALSE; } Modified: soc2013/mattbw/backend/actions/get_repo_list.c ============================================================================== --- soc2013/mattbw/backend/actions/get_repo_list.c Tue Jul 9 04:51:38 2013 (r254441) +++ soc2013/mattbw/backend/actions/get_repo_list.c Tue Jul 9 05:06:46 2013 (r254442) @@ -38,7 +38,7 @@ repo = NULL; while (pkg_repos(&repo) == EPKG_OK) - pk_backend_repo_detail(backend, + (void)pk_backend_repo_detail(backend, pkg_repo_ident(repo), pkg_repo_name(repo), pkg_repo_enabled(repo)); Modified: soc2013/mattbw/backend/actions/install_files.c ============================================================================== --- soc2013/mattbw/backend/actions/install_files.c Tue Jul 9 04:51:38 2013 (r254441) +++ soc2013/mattbw/backend/actions/install_files.c Tue Jul 9 05:06:46 2013 (r254442) @@ -75,7 +75,7 @@ (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); if (pkg_open(&pkg, path, keys, PKG_FLAG_NONE) != EPKG_OK) { - (void)pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_PACKAGE_CORRUPT, "could not open file"); goto cleanup; @@ -92,7 +92,7 @@ (void)pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); if (pkg_add(db, path, PKG_FLAG_NONE, keys) != EPKG_OK) { - (void)pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, "could not install file"); goto cleanup; @@ -122,11 +122,11 @@ paths = pk_backend_get_strv(backend, "full_paths"); if (paths == NULL) - (void)pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "could not get path vector"); else if (*paths == NULL) - (void)pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "path vector is empty"); else { @@ -138,6 +138,6 @@ success = do_file(*p, backend, simulate); } - pk_backend_finished(backend); + (void)pk_backend_finished(backend); return success; } Modified: soc2013/mattbw/backend/actions/install_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install_packages.c Tue Jul 9 04:51:38 2013 (r254441) +++ soc2013/mattbw/backend/actions/install_packages.c Tue Jul 9 05:06:46 2013 (r254442) @@ -24,7 +24,7 @@ #include "../pkgutils.h" /* pkgutils_... */ #include "../query.h" /* query_... */ -#include "../utils.h" /* INTENTIONALLY_IGNORE */ +#include "../utils.h" /* INTENTIONALLY_IGNORE, ERR */ #include "../actions.h" /* install_packages_thread prototype */ @@ -83,9 +83,9 @@ pkg_event_register(install_event_cb, backend); - pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); if (pkg_jobs_apply(jobs) != EPKG_OK) { - pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, "job failed"); goto cleanup; @@ -115,7 +115,7 @@ if (solve_job(q, jobs) == false) goto cleanup; - pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); pkg = NULL; while (pkg_jobs(jobs, &pkg) == EPKG_OK) pkgutils_emit(pkg, @@ -141,13 +141,13 @@ success = false; backend = query_backend(q); - pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); if (pkg_jobs_solve(jobs) != EPKG_OK) - (void)pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "could not solve the job"); else if (pkg_jobs_count(jobs) == 0) - (void)pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "job contains no packages"); else @@ -204,18 +204,18 @@ * throw an error code here */ #if 0 - pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, event->e_pkg_error.msg); #endif break; case PKG_EVENT_FILE_MISMATCH: - pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_PACKAGE_CORRUPT, pkg_file_path(event->e_file_mismatch.file)); break; case PKG_EVENT_NOT_FOUND: - pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, event->e_not_found.pkg_name); default: Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Tue Jul 9 04:51:38 2013 (r254441) +++ soc2013/mattbw/backend/pkgutils.c Tue Jul 9 05:06:46 2013 (r254442) @@ -108,10 +108,10 @@ pkgutils_pkg_to_id(struct pkg *pkg) { gchar *id; - const gchar **id_bits; + const char **id_bits; /* Make sure the initial string vector's pointers are all NULL */ - id_bits = calloc(4, sizeof(const gchar *)); + id_bits = calloc(4, sizeof(const char *)); /* * This is split through an intermediate function so the same code @@ -131,7 +131,7 @@ * they should be NULL). */ gchar * -pkgutils_pkg_to_id_through(struct pkg *pkg, const gchar **strv) +pkgutils_pkg_to_id_through(struct pkg *pkg, const char **strv) { pkg_get(pkg, @@ -160,7 +160,7 @@ pkg_get(pkg, PKG_COMMENT, &comment); id = pkgutils_pkg_to_id(pkg); - pk_backend_package(backend, info, id, comment); + (void)pk_backend_package(backend, info, id, comment); g_free(id); } Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Tue Jul 9 04:51:38 2013 (r254441) +++ soc2013/mattbw/backend/query/core.c Tue Jul 9 05:06:46 2013 (r254442) @@ -87,19 +87,19 @@ backend = query_backend(q); if (pkg_jobs_new(&jobs, q->t->data.job.type, q->db) != EPKG_OK) { - (void)pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "could not init pkg_jobs"); goto cleanup; } if (jobs_repo_from_query(jobs, q) != EPKG_OK) { - (void)pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "could not set repo"); goto cleanup; } if (jobs_add_pkg(jobs, MATCH_EXACT, pkg) != EPKG_OK) { - (void)pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "could not add to job"); goto cleanup; @@ -169,7 +169,7 @@ pkgdb_it_free(it); if (pkg == NULL) - pk_backend_error_code(q->backend, + ERR(q->backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found"); else { @@ -329,9 +329,9 @@ bool matches; int i; gchar *match_id; - const gchar **pkg_id_bits; + const char **pkg_id_bits; - pkg_id_bits = g_new0(const gchar *, 4); + pkg_id_bits = calloc(4, sizeof(const char *)); match_id = pkgutils_pkg_to_id_through(pkg, pkg_id_bits); @@ -353,7 +353,7 @@ pkg_id_bits[i]); } - g_free(pkg_id_bits); + free(pkg_id_bits); if (matches == false) { g_free(match_id); @@ -407,7 +407,7 @@ static struct pkg * match_iterator(struct pkgdb_it *it, struct query *q, gchar **match_id_p) { - int load_flags; + unsigned int load_flags; gchar *match_id; struct pkg *pkg; @@ -447,7 +447,7 @@ * checking against it so it doesn't matter that the version * might be in the name column etc. */ - id_strv = g_new0(gchar *, 5); + id_strv = g_malloc0_n(5, (gsize)sizeof(gchar *)); id_strv[PK_PACKAGE_ID_NAME] = g_strdup(s->data.single); id_strv[PK_PACKAGE_ID_VERSION] = g_strdup(""); @@ -456,11 +456,11 @@ } else if (s->type == QUERY_SINGLE_ID) { id_strv = pk_package_id_split(s->data.single); if (id_strv == NULL) - (void)pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id"); } else - (void)pk_backend_error_code(backend, + ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "init_unpack_source given silly source type"); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 05:13:16 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3BAD5A12 for ; Tue, 9 Jul 2013 05:13:16 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 12C321826 for ; Tue, 9 Jul 2013 05:13:16 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r695DFxX085220 for ; Tue, 9 Jul 2013 05:13:15 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r695DF71085216 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 05:13:15 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 9 Jul 2013 05:13:15 GMT Message-Id: <201307090513.r695DF71085216@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254443 - in soc2013/mattbw/backend: . query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 05:13:16 -0000 Author: mattbw Date: Tue Jul 9 05:13:15 2013 New Revision: 254443 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254443 Log: some more splint tidying Modified: soc2013/mattbw/backend/licenses.c soc2013/mattbw/backend/query/core.h soc2013/mattbw/backend/query/match.c Modified: soc2013/mattbw/backend/licenses.c ============================================================================== --- soc2013/mattbw/backend/licenses.c Tue Jul 9 05:06:46 2013 (r254442) +++ soc2013/mattbw/backend/licenses.c Tue Jul 9 05:13:15 2013 (r254443) @@ -59,14 +59,14 @@ lic = NULL; sb = sbuf_new_auto(); while (pkg_licenses(pkg, &lic) == EPKG_OK) { - sbuf_cat(sb, logic_str); - sbuf_cat(sb, pkg_license_name(lic)); + (void)sbuf_cat(sb, logic_str); + (void)sbuf_cat(sb, pkg_license_name(lic)); } /* Stop the following code from bombing if there was no license * available. */ if (sbuf_len(sb) == 0) - sbuf_cat(sb, logic_str); + (void)sbuf_cat(sb, logic_str); sb_err = sbuf_finish(sb); /* Make sure that we remove the initial logic string instance! */ Modified: soc2013/mattbw/backend/query/core.h ============================================================================== --- soc2013/mattbw/backend/query/core.h Tue Jul 9 05:06:46 2013 (r254442) +++ soc2013/mattbw/backend/query/core.h Tue Jul 9 05:13:15 2013 (r254443) @@ -21,7 +21,7 @@ #ifndef _PKGNG_BACKEND_QUERY_CORE_H_ #define _PKGNG_BACKEND_QUERY_CORE_H_ -#include +#include #include "../pk-backend.h" #include "pkg.h" @@ -47,11 +47,10 @@ struct query_source { enum query_source_type type; union { + bool unused; gchar *single; } data; - query_body_ptr body; - /* Information about this query's position in a set of subqueries. */ unsigned int position; unsigned int total; Modified: soc2013/mattbw/backend/query/match.c ============================================================================== --- soc2013/mattbw/backend/query/match.c Tue Jul 9 05:06:46 2013 (r254442) +++ soc2013/mattbw/backend/query/match.c Tue Jul 9 05:13:15 2013 (r254443) @@ -37,11 +37,14 @@ struct query_source s; struct query_target t; + s.data.unused = true; + s.position = 0; + s.total = 1; s.type = QUERY_BACKEND_IDS; - t.type = QUERY_EMIT; - t.data.emit.load_flags = load_flags; t.data.emit.f = emitter; + t.data.emit.load_flags = load_flags; + t.type = QUERY_EMIT; return query_do(backend, &s, &t); } @@ -58,11 +61,14 @@ struct query_source s; struct query_target t; + s.data.unused = true; + s.position = 0; + s.total = 1; s.type = QUERY_BACKEND_IDS; - t.type = QUERY_JOB; - t.data.job.type = type; t.data.job.f = emitter; + t.data.job.type = type; + t.type = QUERY_JOB; return query_do(backend, &s, &t); } From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 05:19:58 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 80B21A8E for ; Tue, 9 Jul 2013 05:19:58 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 639B91856 for ; Tue, 9 Jul 2013 05:19:58 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r695JwZp092687 for ; Tue, 9 Jul 2013 05:19:58 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r695Jw00092682 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 05:19:58 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 9 Jul 2013 05:19:58 GMT Message-Id: <201307090519.r695Jw00092682@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254444 - in soc2013/mattbw/backend: . actions query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 05:19:58 -0000 Author: mattbw Date: Tue Jul 9 05:19:57 2013 New Revision: 254444 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254444 Log: change db_open_remote to return a pointer directly Modified: soc2013/mattbw/backend/actions/install_files.c soc2013/mattbw/backend/db.c soc2013/mattbw/backend/db.h soc2013/mattbw/backend/query/do.c Modified: soc2013/mattbw/backend/actions/install_files.c ============================================================================== --- soc2013/mattbw/backend/actions/install_files.c Tue Jul 9 05:13:15 2013 (r254443) +++ soc2013/mattbw/backend/actions/install_files.c Tue Jul 9 05:19:57 2013 (r254444) @@ -86,7 +86,8 @@ } else { /* TODO: event hook */ - if (db_open_remote(&db, backend) == FALSE) + db = db_open_remote(backend); + if (db == NULL) goto cleanup; (void)pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); Modified: soc2013/mattbw/backend/db.c ============================================================================== --- soc2013/mattbw/backend/db.c Tue Jul 9 05:13:15 2013 (r254443) +++ soc2013/mattbw/backend/db.c Tue Jul 9 05:19:57 2013 (r254444) @@ -28,9 +28,9 @@ #include "utils.h" /* null_if_empty, split_id */ static const unsigned int ACCESS_MODE = (unsigned int)(PKGDB_MODE_READ | - PKGDB_MODE_WRITE); + PKGDB_MODE_WRITE); static const unsigned int ACCESS_DB = (unsigned int)(PKGDB_DB_LOCAL | - PKGDB_DB_REPO); + PKGDB_DB_REPO); /* * Opens a pkgdb ready for remote operations. This will always return TRUE if @@ -42,36 +42,44 @@ * This must be called during the lifetime of "backend", eg after * "pk_backend_initialize" and before "pk_backend_destroy". */ -bool -db_open_remote(struct pkgdb **db_p, PkBackend *backend) +struct pkgdb * +db_open_remote(PkBackend *backend) { bool success; + struct pkgdb *db; - success = false; + success = FALSE; + db = NULL; (void)pk_backend_set_status(backend, PK_STATUS_ENUM_WAITING_FOR_AUTH); if (pkgdb_access(ACCESS_MODE, ACCESS_DB) != EPKG_OK) { (void)pk_backend_error_code(backend, - PK_ERROR_ENUM_NOT_AUTHORIZED, - "cannot access database"); + PK_ERROR_ENUM_NOT_AUTHORIZED, + "cannot access database"); goto cleanup; } (void)pk_backend_set_status(backend, PK_STATUS_ENUM_WAITING_FOR_LOCK); - if (pkgdb_open(db_p, PKGDB_REMOTE) != EPKG_OK) { + if (pkgdb_open(&db, PKGDB_REMOTE) != EPKG_OK) { (void)pk_backend_error_code(backend, - PK_ERROR_ENUM_CANNOT_GET_LOCK, - "cannot open database"); + PK_ERROR_ENUM_CANNOT_GET_LOCK, + "cannot open database"); goto cleanup; } - if (*db_p == NULL) { + if (db == NULL) { (void)pk_backend_error_code(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "pkgdb_open gave us a null pointer"); + PK_ERROR_ENUM_INTERNAL_ERROR, + "pkgdb_open gave us a null pointer"); goto cleanup; } (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); + success = true; cleanup: - return success; + if (success == false) { + pkgdb_close(db); + db = NULL; + } + + return db; } Modified: soc2013/mattbw/backend/db.h ============================================================================== --- soc2013/mattbw/backend/db.h Tue Jul 9 05:13:15 2013 (r254443) +++ soc2013/mattbw/backend/db.h Tue Jul 9 05:19:57 2013 (r254444) @@ -22,10 +22,9 @@ #ifndef _PKGNG_BACKEND_DB_H_ #define _PKGNG_BACKEND_DB_H_ -#include /* bool */ #include "pk-backend.h" /* PkBackend */ #include "pkg.h" /* struct pkgdb */ -bool db_open_remote(struct pkgdb **db, PkBackend *backend); +struct pkgdb* db_open_remote(PkBackend *backend); #endif /* !_PKGNG_BACKEND_DB_H_ */ Modified: soc2013/mattbw/backend/query/do.c ============================================================================== --- soc2013/mattbw/backend/query/do.c Tue Jul 9 05:13:15 2013 (r254443) +++ soc2013/mattbw/backend/query/do.c Tue Jul 9 05:19:57 2013 (r254444) @@ -43,10 +43,10 @@ bool success; struct pkgdb *db; - db = NULL; success = false; - if (db_open_remote(&db, backend)) { + db = db_open_remote(backend); + if (db != NULL) { switch (s->type) { case QUERY_BACKEND_IDS: case QUERY_BACKEND_MIXED: From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 05:35:36 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CB44FC43 for ; Tue, 9 Jul 2013 05:35:36 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id BBF6618CF for ; Tue, 9 Jul 2013 05:35:36 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r695ZaZo062826 for ; Tue, 9 Jul 2013 05:35:36 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r695ZaYr062807 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 05:35:36 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 9 Jul 2013 05:35:36 GMT Message-Id: <201307090535.r695ZaYr062807@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254445 - in soc2013/mattbw/backend: . query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 05:35:36 -0000 Author: mattbw Date: Tue Jul 9 05:35:36 2013 New Revision: 254445 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254445 Log: even more static analysis cleanup Modified: soc2013/mattbw/backend/db.h soc2013/mattbw/backend/query/core.c soc2013/mattbw/backend/query/core.h soc2013/mattbw/backend/query/do.c soc2013/mattbw/backend/utils.c soc2013/mattbw/backend/utils.h Modified: soc2013/mattbw/backend/db.h ============================================================================== --- soc2013/mattbw/backend/db.h Tue Jul 9 05:19:57 2013 (r254444) +++ soc2013/mattbw/backend/db.h Tue Jul 9 05:35:36 2013 (r254445) @@ -25,6 +25,6 @@ #include "pk-backend.h" /* PkBackend */ #include "pkg.h" /* struct pkgdb */ -struct pkgdb* db_open_remote(PkBackend *backend); +struct pkgdb *db_open_remote(PkBackend *backend); #endif /* !_PKGNG_BACKEND_DB_H_ */ Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Tue Jul 9 05:19:57 2013 (r254444) +++ soc2013/mattbw/backend/query/core.c Tue Jul 9 05:35:36 2013 (r254445) @@ -49,68 +49,16 @@ struct query_target *t; }; -static enum repo_type type_of_repo_name(const char *name); static bool can_remote_iterate(struct query *q); -static gchar *match_pkg(struct pkg *pkg, struct query *q); +static bool emit_to_job(struct pkg *pkg, struct query *q); static const gchar *query_repo(struct query *q); +static enum repo_type type_of_repo_name(const char *name); +static gchar *match_pkg(struct pkg *pkg, struct query *q); static gchar **init_unpack_source(PkBackend *backend, struct query_source *s); static int jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg); static int jobs_repo_from_query(struct pkg_jobs *jobs, struct query *q); static struct pkg *match_iterator(struct pkgdb_it *it, struct query *q, gchar **match_id_p); -/* Returns the backend stored inside the struct query. */ -PkBackend * -query_backend(struct query *q) -{ - - return (q == NULL ? NULL : q->backend); -} - -/* - * For adapting an emitter function into one that solves and applies a job. - */ -bool -query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q) -{ - bool success; - struct pkg_jobs *jobs; - PkBackend *backend; - - INTENTIONALLY_IGNORE(id); - - success = false; - jobs = NULL; - - if (q == NULL) - goto cleanup; - - backend = query_backend(q); - - if (pkg_jobs_new(&jobs, q->t->data.job.type, q->db) != EPKG_OK) { - ERR(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "could not init pkg_jobs"); - goto cleanup; - } - if (jobs_repo_from_query(jobs, q) != EPKG_OK) { - ERR(backend, - PK_ERROR_ENUM_REPO_NOT_FOUND, - "could not set repo"); - goto cleanup; - } - if (jobs_add_pkg(jobs, MATCH_EXACT, pkg) != EPKG_OK) { - ERR(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "could not add to job"); - goto cleanup; - } - success = q->t->data.job.f(jobs, q); - -cleanup: - pkg_jobs_free(jobs); - return success; -} - /* * Runs an assembled query. */ @@ -176,7 +124,7 @@ if (q->t->type == QUERY_EMIT) success = q->t->data.emit.f(pkg, match_id, q); else if (q->t->type == QUERY_JOB) - success = query_emit_to_job(pkg, match_id, q); + success = emit_to_job(pkg, q); } pkg_free(pkg); @@ -185,6 +133,14 @@ return success; } +/* Returns the backend stored inside the struct query. */ +PkBackend * +query_backend(struct query *q) +{ + + return (q == NULL ? NULL : q->backend); +} + /* * Creates a struct query for the given backend, database, source and target. * @@ -274,30 +230,12 @@ (void)pk_backend_set_percentage(q->backend, scaled_percent); } -/* Finds the type of the given PackageKit repository name. */ -static enum repo_type -type_of_repo_name(const char *name) -{ - enum repo_type rtype; - - /* Null or empty implies no specific repository */ - if (name == NULL || name[0] == '\0') - rtype = REPO_ANY; - else if (strcmp(name, "installed") == 0) - rtype = REPO_LOCAL; - else if (pkg_repo_find_ident(name) != NULL) - rtype = REPO_REMOTE; - else - rtype = REPO_INVALID; - - return rtype; -} /* * Checks to see if trying to do a remote package iteration with this query * could spell disaster. */ -static bool +static bool can_remote_iterate(struct query *q) { bool sane; @@ -320,6 +258,68 @@ } /* + * For adapting an emitter function into one that solves and applies a job. + */ +static bool +emit_to_job(struct pkg *pkg, struct query *q) +{ + bool success; + struct pkg_jobs *jobs; + PkBackend *backend; + + success = false; + jobs = NULL; + + if (q == NULL) + goto cleanup; + + backend = query_backend(q); + + if (pkg_jobs_new(&jobs, q->t->data.job.type, q->db) != EPKG_OK) { + ERR(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not init pkg_jobs"); + goto cleanup; + } + if (jobs_repo_from_query(jobs, q) != EPKG_OK) { + ERR(backend, + PK_ERROR_ENUM_REPO_NOT_FOUND, + "could not set repo"); + goto cleanup; + } + if (jobs_add_pkg(jobs, MATCH_EXACT, pkg) != EPKG_OK) { + ERR(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not add to job"); + goto cleanup; + } + success = q->t->data.job.f(jobs, q); + +cleanup: + pkg_jobs_free(jobs); + return success; +} + +/* Finds the type of the given PackageKit repository name. */ +static enum repo_type +type_of_repo_name(const char *name) +{ + enum repo_type rtype; + + /* Null or empty implies no specific repository */ + if (name == NULL || name[0] == '\0') + rtype = REPO_ANY; + else if (strcmp(name, "installed") == 0) + rtype = REPO_LOCAL; + else if (pkg_repo_find_ident(name) != NULL) + rtype = REPO_REMOTE; + else + rtype = REPO_INVALID; + + return rtype; +} + +/* * Checks whether a candidate package matches any constraints provided by the * query and, if so, returns its full PackageID; otherwise NULL. */ @@ -347,7 +347,7 @@ * instead of normal strcmp or even g_strcmp0. */ for (matches = true, i = PK_PACKAGE_ID_NAME; - matches == true && i <= PK_PACKAGE_ID_DATA; + matches && i <= PK_PACKAGE_ID_DATA; i++) matches = string_match((q->id_strv)[i], pkg_id_bits[i]); @@ -447,7 +447,7 @@ * checking against it so it doesn't matter that the version * might be in the name column etc. */ - id_strv = g_malloc0_n(5, (gsize)sizeof(gchar *)); + id_strv = g_malloc0_n(5, (gsize) sizeof(gchar *)); id_strv[PK_PACKAGE_ID_NAME] = g_strdup(s->data.single); id_strv[PK_PACKAGE_ID_VERSION] = g_strdup(""); Modified: soc2013/mattbw/backend/query/core.h ============================================================================== --- soc2013/mattbw/backend/query/core.h Tue Jul 9 05:19:57 2013 (r254444) +++ soc2013/mattbw/backend/query/core.h Tue Jul 9 05:35:36 2013 (r254445) @@ -72,7 +72,6 @@ }; PkBackend *query_backend(struct query *q); -bool query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q); bool query_run (struct query *q); struct query *query_init(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t); void query_free(struct query **q_p); Modified: soc2013/mattbw/backend/query/do.c ============================================================================== --- soc2013/mattbw/backend/query/do.c Tue Jul 9 05:19:57 2013 (r254444) +++ soc2013/mattbw/backend/query/do.c Tue Jul 9 05:35:36 2013 (r254445) @@ -60,8 +60,10 @@ success = false; break; } + + pkgdb_close(db); } - pkgdb_close(db); + return success; } Modified: soc2013/mattbw/backend/utils.c ============================================================================== --- soc2013/mattbw/backend/utils.c Tue Jul 9 05:19:57 2013 (r254444) +++ soc2013/mattbw/backend/utils.c Tue Jul 9 05:35:36 2013 (r254445) @@ -1,5 +1,4 @@ /*- - * * Copyright (C) 2013 Matt Windsor * * Licensed under the GNU General Public License Version 2 @@ -29,69 +28,21 @@ #include "utils.h" /* prototypes */ /* - * If the input pointer points to a string that is empty, return the null - * pointer; else pass through the pointer unmolested. - * - * This does NOT free anything! - */ -const char * -null_if_empty(const char *in) -{ - return (in != NULL && strlen(in) == 0) ? NULL : in; -} - -/* - * Splits a PackageID into its constituent parts, and returns both the split - * string vector (to be freed with g_strfreev later) and four pointers to its - * constituents (or NULL where they are empty strings). - * - * Returns FALSE on failure. - */ -gboolean -split_id(const char *id, - char ***strv_p, - const char **name_p, - const char **version_p, - const char **arch_p, - const char **data_p) -{ - int success; - char **strv; - - success = FALSE; - strv = pk_package_id_split(id); - if (strv != NULL) { - /* - * Make really really REALLY sure that the PackageID fields - * either have sensible data in them, or are NULL. - */ - *name_p = null_if_empty(strv[PK_PACKAGE_ID_NAME]); - *version_p = null_if_empty(strv[PK_PACKAGE_ID_VERSION]); - *arch_p = null_if_empty(strv[PK_PACKAGE_ID_ARCH]); - *data_p = null_if_empty(strv[PK_PACKAGE_ID_DATA]); - - *strv_p = strv; - success = TRUE; - } - return success; -} - -/* * Checks two strings with strcmp and emits TRUE if they match. If either * string is NULL or empty, emit TRUE as well (this is so that missing * PackageID elements trigger matches). */ -gboolean +bool string_match(const char *left, const char *right) { - int result; + bool result; if (left == NULL || right == NULL) - result = TRUE; + result = true; else if (*left == '\0' || *right == '\0') - result = TRUE; + result = true; else - result = (strcmp(left, right) == 0 ? TRUE : FALSE); + result = (strcmp(left, right) == 0); return result; } Modified: soc2013/mattbw/backend/utils.h ============================================================================== --- soc2013/mattbw/backend/utils.h Tue Jul 9 05:19:57 2013 (r254444) +++ soc2013/mattbw/backend/utils.h Tue Jul 9 05:35:36 2013 (r254445) @@ -1,5 +1,4 @@ /*- - * * Copyright (C) 2013 Matt Windsor * * Licensed under the GNU General Public License Version 2 @@ -22,20 +21,12 @@ #ifndef _PKGNG_BACKEND_UTILS_H_ #define _PKGNG_BACKEND_UTILS_H_ -#include /* gboolean */ +#include /* bool */ #define INTENTIONALLY_IGNORE(x) (void)(x) #define ERR(backend, type, msg) \ (void) pk_backend_error_code((backend), (type), (msg)) -const char *null_if_empty(const char *in); -gboolean -split_id(const char *id, - char ***strv_p, - const char **name_p, - const char **version_p, - const char **arch_p, - const char **data_p); -gboolean string_match(const char *left, const char *right); +bool string_match(const char *left, const char *right); #endif /* !_PKGNG_BACKEND_DETAILS_H_ */ From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 05:39:11 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3802FDA1 for ; Tue, 9 Jul 2013 05:39:11 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 2AB4818E2 for ; Tue, 9 Jul 2013 05:39:11 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r695dBpX012448 for ; Tue, 9 Jul 2013 05:39:11 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r695dBR2012445 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 05:39:11 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 9 Jul 2013 05:39:11 GMT Message-Id: <201307090539.r695dBR2012445@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254446 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 05:39:11 -0000 Author: mattbw Date: Tue Jul 9 05:39:10 2013 New Revision: 254446 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254446 Log: even more static analysis cleanup Modified: soc2013/mattbw/backend/groups.c Modified: soc2013/mattbw/backend/groups.c ============================================================================== --- soc2013/mattbw/backend/groups.c Tue Jul 9 05:35:36 2013 (r254445) +++ soc2013/mattbw/backend/groups.c Tue Jul 9 05:39:10 2013 (r254446) @@ -27,10 +27,10 @@ #include "groups.h" /* prototypes */ #include "mappings.h" /* mapping macros */ -const char ORIGIN_SEPARATOR = '/'; +static const char ORIGIN_SEPARATOR = '/'; struct group_mapping { - const char *key; + const char /* @null@ */ *key; PkGroupEnum group; }; @@ -131,10 +131,10 @@ /* Maps from port/origin directories to PackageKit groups. */ PkGroupEnum -group_from_port_dir(const char *port_dir) +group_from_port_dir( /* @null@ */ const char *port_dir) { struct group_mapping *result; - + MAPPING_FIND(port_dir, &result, group_mappings); return result->group; } From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 07:08:54 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 7E0EA2FC for ; Tue, 9 Jul 2013 07:08:54 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 62A271C44 for ; Tue, 9 Jul 2013 07:08:54 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6978sMW091691 for ; Tue, 9 Jul 2013 07:08:54 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6978sgl091684 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 07:08:54 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 9 Jul 2013 07:08:54 GMT Message-Id: <201307090708.r6978sgl091684@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254449 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 07:08:54 -0000 Author: dpl Date: Tue Jul 9 07:08:54 2013 New Revision: 254449 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254449 Log: Final touches with bzip2. It now works on any directory. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Tue Jul 9 06:51:41 2013 (r254448) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Tue Jul 9 07:08:54 2013 (r254449) @@ -92,6 +92,7 @@ # include # if __FreeBSD_version >= 900041 # define CAPSICUM +# include # include # include # include @@ -225,11 +226,9 @@ #define IN_FILENO fileno(inStr) #define OUT_FILENO fileno(outStr) void limitfd(int); -const Char * getdir(Char* file); -const Char * getfilename(Char* file); FILE *inStr; FILE *outStr; -int cwd; /* Where is the file (fd) */ +int cwd; /* Dir where is the file */ #endif static void panic ( const Char* ) NORETURN; @@ -687,46 +686,6 @@ exit(exitValue); } } - - -/*---------------------------------------------*/ -const Char * -getdir(Char *file) -{ - Char * slashPos; - Char * ret; - - slashPos = strrchr(file, (int)'/'); - if ( slashPos == 0 ) - return( "." ); - if ( (ret = strndup( file, (slashPos - file + 1)) ) == NULL){ - setExit(1); - exit(exitValue); - } - return(ret); - -} - - -/*---------------------------------------------*/ -const Char * -getfilename(Char *file) -{ - Char * slashPos; - Char * ret; - int slashIndex; - - slashPos = strrchr(file, (int)'/'); - if ( slashPos == 0 ) - return( file ); - slashIndex = slashPos - file; - if ( (ret = strndup( slashPos + 1, (strlen(file) - slashIndex) )) == NULL){ - setExit(1); - exit(exitValue); - } - return(ret); - -} #endif /*---------------------------------------------*/ @@ -781,7 +740,7 @@ progName, outName ); if (outputHandleJustInCase != NULL) fclose ( outputHandleJustInCase ); - retVal = unlinkat ( cwd, getfilename(inName), 0 ); + retVal = unlinkat ( cwd, basename(inName), 0 ); if (retVal != 0) fprintf ( stderr, "%s: WARNING: deletion of output file " @@ -1287,7 +1246,7 @@ } if ( srcMode == SM_F2F && fileExists ( outName ) ) { if (forceOverwrite) { - unlinkat ( cwd, getfilename(inName), 0 ); + unlinkat ( cwd, basename(inName), 0 ); } else { fprintf ( stderr, "%s: Output file %s already exists.\n", progName, outName ); @@ -1403,7 +1362,7 @@ applySavedTimeInfoToOutputFile ( OUT_FILENO ); deleteOutputOnInterrupt = False; if ( !keepInputFiles ) { - IntNative retVal = unlinkat ( cwd, getfilename(inName), 0 ); + IntNative retVal = unlinkat ( cwd, basename(inName), 0 ); ERROR_IF_NOT_ZERO ( retVal ); } } @@ -1500,7 +1459,7 @@ } if ( srcMode == SM_F2F && fileExists ( outName ) ) { if (forceOverwrite) { - unlinkat ( cwd, getfilename(inName), 0 ); + unlinkat ( cwd, basename(inName), 0 ); } else { fprintf ( stderr, "%s: Output file %s already exists.\n", progName, outName ); @@ -1616,7 +1575,7 @@ applySavedTimeInfoToOutputFile ( OUT_FILENO ); deleteOutputOnInterrupt = False; if ( !keepInputFiles ) { - IntNative retVal = unlinkat ( cwd, getfilename(inName), 0 ); + IntNative retVal = unlinkat ( cwd, basename(inName), 0 ); ERROR_IF_NOT_ZERO ( retVal ); } } @@ -1624,7 +1583,7 @@ unzFailsExist = True; deleteOutputOnInterrupt = False; if ( srcMode == SM_F2F ) { - IntNative retVal = unlinkat ( cwd, getfilename(inName), 0 ); + IntNative retVal = unlinkat ( cwd, basename(inName), 0 ); ERROR_IF_NOT_ZERO ( retVal ); } } @@ -2112,7 +2071,7 @@ if (aa->name[0] == '-' && decode) continue; numFilesProcessed++; # ifdef CAPSICUM - cwd = open ( getdir(aa->name) , O_DIRECTORY ); + cwd = open ( dirname(aa->name) , O_DIRECTORY ); # endif compress ( aa->name ); } @@ -2131,7 +2090,7 @@ if (aa->name[0] == '-' && decode) continue; numFilesProcessed++; # ifdef CAPSICUM - cwd = open ( getdir(aa->name) , 0 ); + cwd = open ( dirname(aa->name) , 0 ); # endif uncompress ( aa->name ); } From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 07:10:46 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2533E3AA for ; Tue, 9 Jul 2013 07:10:46 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 16BA11C5C for ; Tue, 9 Jul 2013 07:10:46 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r697AjpJ016292 for ; Tue, 9 Jul 2013 07:10:45 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r697Ajsx016282 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 07:10:45 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 9 Jul 2013 07:10:45 GMT Message-Id: <201307090710.r697Ajsx016282@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254450 - soc2013/dpl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 07:10:46 -0000 Author: dpl Date: Tue Jul 9 07:10:45 2013 New Revision: 254450 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254450 Log: This file will hold my own functions and notes when porting applications to Capsicum. Added: soc2013/dpl/functions.c Added: soc2013/dpl/functions.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/functions.c Tue Jul 9 07:10:45 2013 (r254450) @@ -0,0 +1,46 @@ +void +limitfd(int fd) +{ + cap_rights_t rights; + + if (fd == OUT_FILENO) + rights = CAP_READ|CAP_FSTAT|CAP_WRITE|CAP_FCHMOD|CAP_FCHOWN|CAP_FUTIMES; + else if (fd == IN_FILENO) + rights = CAP_WRITE|CAP_READ|CAP_FSTAT; + else if (fd == STDERR_FILENO) + rights = CAP_WRITE; + else if ( fd == cwd ) + rights = CAP_UNLINKAT|CAP_LOOKUP; + + if (cap_rights_limit(fd, rights) < 0 && errno != ENOSYS){ + fprintf ( stderr, "%s: Couldn't limit rights for descriptor %d: %s.\n", + progName, fd, strerror(errno)); + setExit(1); + exit(exitValue); + } +} + +extern void +cap_init() +{ + if (cap_rights_limit(STDIN_FILENO, CAP_READ) < 0 && errno != ENOSYS){ + message_error("%d: %s", STDIN_FILENO, strerror(errno)); + exit(E_ERROR); + } + + if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ + message_error("%d: %s", STDOUT_FILENO, strerror(errno)); + exit(E_ERROR); + } + + if (cap_rights_limit(STDERR_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ + message_error("%d: %s", STDERR_FILENO, strerror(errno)); + exit(E_ERROR); + } + + if (cap_enter() < 0 && errno != ENOSYS){ + message_error("cap_enter: %s", strerror(errno)); + exit(E_ERROR); + } + return; +} \ No newline at end of file From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 07:13:20 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B734963A for ; Tue, 9 Jul 2013 07:13:20 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A9CD01C86 for ; Tue, 9 Jul 2013 07:13:20 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r697DKnY029137 for ; Tue, 9 Jul 2013 07:13:20 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r697DK2n029135 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 07:13:20 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 9 Jul 2013 07:13:20 GMT Message-Id: <201307090713.r697DK2n029135@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254451 - soc2013/dpl/head/usr.bin/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 07:13:20 -0000 Author: dpl Date: Tue Jul 9 07:13:20 2013 New Revision: 254451 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254451 Log: Added a simple test target. Modified: soc2013/dpl/head/usr.bin/xz/Makefile Modified: soc2013/dpl/head/usr.bin/xz/Makefile ============================================================================== --- soc2013/dpl/head/usr.bin/xz/Makefile Tue Jul 9 07:10:45 2013 (r254450) +++ soc2013/dpl/head/usr.bin/xz/Makefile Tue Jul 9 07:13:20 2013 (r254451) @@ -48,4 +48,14 @@ DPADD= ${LIBLZMA} LDADD= -llzma +CLEANFILES+= testfile testfile.xz ktrace.out + +test: xz + -@rm testfile + -@rm testfile.xz + @echo one > testfile + -@ktrace -i ./xz testfile; \ + if [ $$? -ne 0 ]; \ + then kdump; \ + fi; .include From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 07:15:59 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 71AFD755 for ; Tue, 9 Jul 2013 07:15:59 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 49BAB1C9E for ; Tue, 9 Jul 2013 07:15:59 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r697FxNB030321 for ; Tue, 9 Jul 2013 07:15:59 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r697FxxE030319 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 07:15:59 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 9 Jul 2013 07:15:59 GMT Message-Id: <201307090715.r697FxxE030319@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254452 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 07:15:59 -0000 Author: dpl Date: Tue Jul 9 07:15:59 2013 New Revision: 254452 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254452 Log: Added functions to enter capability mode, and limitfds. Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.c Tue Jul 9 07:13:20 2013 (r254451) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.c Tue Jul 9 07:15:59 2013 (r254452) @@ -604,6 +604,7 @@ free(pair->dest_name); return true; } + limitfd(pair); } // If this really fails... well, we have a safe fallback. @@ -956,14 +957,49 @@ return io_write_buf(pair, buf->u8, size); } -#if CAPSICUM +#if defined(CAPSICUM) extern void -limitfd(struct file_pair *pair) +limitfd(file_pair *pair) { cap_rights_t rights = 0; - + rights |= CAP_READ; + if (cap_rights_limit(pair->src_fd, rights) < 0 && errno != ENOSYS){ + message_error("%s: %s", pair->src_name, strerror(errno)); + exit(E_ERROR); + } + rights |= CAP_WRITE|CAP_FSTAT|CAP_FCHOWN; + rights |= CAP_FCHMOD|CAP_FUTIMES; + if (cap_rights_limit(pair->dest_fd, rights) < 0 && errno != ENOSYS){ + message_error("%s: %s", pair->dest_name, strerror(errno)); + exit(E_ERROR); + } return; } -#endif \ No newline at end of file + +extern void +cap_init(void) +{ + if (cap_rights_limit(STDIN_FILENO, CAP_READ) < 0 && errno != ENOSYS){ + message_error("%d: %s", STDIN_FILENO, strerror(errno)); + exit(E_ERROR); + } + + if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ + message_error("%d: %s", STDOUT_FILENO, strerror(errno)); + exit(E_ERROR); + } + + if (cap_rights_limit(STDERR_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ + message_error("%d: %s", STDERR_FILENO, strerror(errno)); + exit(E_ERROR); + } + + if (cap_enter() < 0 && errno != ENOSYS){ + message_error("cap_enter: %s", strerror(errno)); + exit(E_ERROR); + } + return; +} +#endif From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 07:17:30 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1B8A6771 for ; Tue, 9 Jul 2013 07:17:30 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 0DC981CA5 for ; Tue, 9 Jul 2013 07:17:30 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r697HTem030759 for ; Tue, 9 Jul 2013 07:17:29 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r697HT5i030757 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 07:17:29 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 9 Jul 2013 07:17:29 GMT Message-Id: <201307090717.r697HT5i030757@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254453 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 07:17:30 -0000 Author: dpl Date: Tue Jul 9 07:17:29 2013 New Revision: 254453 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254453 Log: Enter capability mode after opening the files. Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/main.c Tue Jul 9 07:15:59 2013 (r254452) +++ soc2013/dpl/head/contrib/xz/src/xz/main.c Tue Jul 9 07:17:29 2013 (r254453) @@ -210,6 +210,10 @@ void (*run)(const char *filename) = opt_mode == MODE_LIST ? &list_file : &coder_run; +#if defined(CAPSICUM) // + cap_init(); +#endif + // Process the files given on the command line. Note that if no names // were given, args_parse() gave us a fake "-" filename. for (size_t i = 0; i < args.arg_count && !user_abort; ++i) { @@ -244,7 +248,7 @@ } // Do the actual compression or decompression. - run(args.arg_names[i]); + (args.arg_names[i]); } // If --files or --files0 was used, process the filenames from the From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 07:29:26 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0A561CFB for ; Tue, 9 Jul 2013 07:29:26 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id E106A1D3B for ; Tue, 9 Jul 2013 07:29:25 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r697TPBH038846 for ; Tue, 9 Jul 2013 07:29:25 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r697TP8N038834 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 07:29:25 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 9 Jul 2013 07:29:25 GMT Message-Id: <201307090729.r697TP8N038834@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254454 - in soc2013/mattbw/backend: . actions query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 07:29:26 -0000 Author: mattbw Date: Tue Jul 9 07:29:25 2013 New Revision: 254454 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254454 Log: more cleanup mainly to allow -Weverything -Wno-system-includes to work Modified: soc2013/mattbw/backend/.indent.pro soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/get_details.c soc2013/mattbw/backend/actions/install_packages.c soc2013/mattbw/backend/groups.c soc2013/mattbw/backend/groups.h soc2013/mattbw/backend/licenses.c soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/query/core.c soc2013/mattbw/backend/query/do.c soc2013/mattbw/backend/utils.h Modified: soc2013/mattbw/backend/.indent.pro ============================================================================== --- soc2013/mattbw/backend/.indent.pro Tue Jul 9 07:17:29 2013 (r254453) +++ soc2013/mattbw/backend/.indent.pro Tue Jul 9 07:29:25 2013 (r254454) @@ -1,3 +1,5 @@ +-TPkBitfield +-TPkGroupEnum -TPkBackend -Tgchar -Tgboolean Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Tue Jul 9 07:17:29 2013 (r254453) +++ soc2013/mattbw/backend/Makefile Tue Jul 9 07:29:25 2013 (r254454) @@ -33,13 +33,19 @@ .if USE_PK_PKGCONF PKGS+= packagekit-glib2 .else -CFLAGS+= -I/usr/local/include/PackageKit -I/usr/local/include/PackageKit/backend +CFLAGS+= -isystem/usr/local/include/PackageKit -isystem/usr/local/include/PackageKit/backend LDFLAGS+= -L/usr/local/lib -lpackagekit-glib2 .endif CFLAGS+= `pkg-config --cflags ${PKGS}` CFLAGS+= -DPK_COMPILATION LDFLAGS+= `pkg-config --libs ${PKGS}` -CSTD?= c99 +CSTD?= c11 + +# NOTE: remove this before finishing +CFLAGS+= --pedantic -Weverything -Werror -Wno-system-headers \ + -isystem /usr/local/include/glib-2.0 \ + -isystem /usr/local/include \ + -isystem /usr/include .include Modified: soc2013/mattbw/backend/actions/get_details.c ============================================================================== --- soc2013/mattbw/backend/actions/get_details.c Tue Jul 9 07:17:29 2013 (r254453) +++ soc2013/mattbw/backend/actions/get_details.c Tue Jul 9 07:29:25 2013 (r254454) @@ -20,6 +20,7 @@ #include #include +#include #include "../pk-backend.h" #include "pkg.h" @@ -57,6 +58,7 @@ const char *origin; const char *www; int64_t flatsize; + guint flatsize_u; query_set_percentage(q, 0); @@ -69,13 +71,15 @@ PKG_ORIGIN, &origin, PKG_WWW, &www); + flatsize_u = (guint)CLAMP(flatsize, 0, G_MAXUINT); + success = pk_backend_details(query_backend(q), id, license_name_from_pkg(pkg), group_from_origin(origin), description, www, - flatsize) == TRUE; + flatsize_u) == TRUE; query_set_percentage(q, 100); return success; Modified: soc2013/mattbw/backend/actions/install_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install_packages.c Tue Jul 9 07:17:29 2013 (r254453) +++ soc2013/mattbw/backend/actions/install_packages.c Tue Jul 9 07:29:25 2013 (r254454) @@ -68,7 +68,7 @@ /* * Tries to process the given solved installation jobs. */ -static bool +static bool job(struct pkg_jobs *jobs, struct query *q) { bool success; @@ -101,7 +101,7 @@ /* * Tries to simulate processing the given installation jobs. */ -static bool +static bool sim_job(struct pkg_jobs *jobs, struct query *q) { bool success; @@ -132,7 +132,7 @@ /* * Solves a job and ensures it has packages available. */ -static bool +static bool solve_job(struct query *q, struct pkg_jobs *jobs) { bool success; @@ -157,7 +157,8 @@ } /* - * Event handler for events emitted by pkg during an installation. + * Event handler for events emitted by pkg during an installation. TODO: Many + * of these events are unhandled or deficiently handled. */ static int install_event_cb(void *backend_v, struct pkg_event *event) @@ -166,9 +167,9 @@ backend = (PkBackend *)backend_v; - /* TODO: percentage bar */ switch (event->type) { case PKG_EVENT_INSTALL_BEGIN: + STATUS(backend, PK_STATUS_ENUM_INSTALL); pkgutils_emit(event->e_install_begin.pkg, backend, PK_INFO_ENUM_INSTALLING); @@ -179,6 +180,7 @@ PK_INFO_ENUM_FINISHED); break; case PKG_EVENT_DEINSTALL_BEGIN: + STATUS(backend, PK_STATUS_ENUM_REMOVE); pkgutils_emit(event->e_deinstall_begin.pkg, backend, PK_INFO_ENUM_REMOVING); @@ -189,6 +191,7 @@ PK_INFO_ENUM_FINISHED); break; case PKG_EVENT_UPGRADE_BEGIN: + STATUS(backend, PK_STATUS_ENUM_UPDATE); pkgutils_emit(event->e_upgrade_begin.pkg, backend, PK_INFO_ENUM_UPDATING); @@ -198,29 +201,56 @@ backend, PK_INFO_ENUM_FINISHED); break; + case PKG_EVENT_FETCHING: + STATUS(backend, PK_STATUS_ENUM_DOWNLOAD); + break; + case PKG_EVENT_INTEGRITYCHECK_BEGIN: + case PKG_EVENT_INTEGRITYCHECK_FINISHED: + /* Unimplemented */ + break; + case PKG_EVENT_INTEGRITYCHECK_CONFLICT: + ERR(backend, + PK_ERROR_ENUM_PACKAGE_CORRUPT, + event->e_integrity_conflict.pkg_name); + break; + case PKG_EVENT_NEWPKGVERSION: + case PKG_EVENT_NOTICE: + case PKG_EVENT_INCREMENTAL_UPDATE: + /* Unimplemented */ + break; case PKG_EVENT_ERROR: /* * This is sometimes used for nonfatal errors, so we can't - * throw an error code here + * throw an error code here. */ -#if 0 - ERR(backend, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, - event->e_pkg_error.msg); -#endif + break; + case PKG_EVENT_ERRNO: + case PKG_EVENT_ARCHIVE_COMP_UNSUP: + case PKG_EVENT_ALREADY_INSTALLED: + case PKG_EVENT_FAILED_CKSUM: + case PKG_EVENT_CREATE_DB_ERROR: + case PKG_EVENT_LOCKED: + case PKG_EVENT_REQUIRED: + case PKG_EVENT_MISSING_DEP: + case PKG_EVENT_NOREMOTEDB: + case PKG_EVENT_NOLOCALDB: + /* Unimplemented */ break; case PKG_EVENT_FILE_MISMATCH: ERR(backend, PK_ERROR_ENUM_PACKAGE_CORRUPT, pkg_file_path(event->e_file_mismatch.file)); break; + case PKG_EVENT_DEVELOPER_MODE: + case PKG_EVENT_PLUGIN_ERRNO: + case PKG_EVENT_PLUGIN_ERROR: + case PKG_EVENT_PLUGIN_INFO: + /* Unimplemented */ + break; case PKG_EVENT_NOT_FOUND: ERR(backend, PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, event->e_not_found.pkg_name); - default: - /* Do nothing for unrecognised events */ - break; } return EPKG_OK; Modified: soc2013/mattbw/backend/groups.c ============================================================================== --- soc2013/mattbw/backend/groups.c Tue Jul 9 07:17:29 2013 (r254453) +++ soc2013/mattbw/backend/groups.c Tue Jul 9 07:29:25 2013 (r254454) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include /* assert */ #include /* NULL */ #include /* strchr, strdup */ @@ -25,12 +26,11 @@ #include "pk-backend.h" /* PkGroupEnum, PK_* */ #include "groups.h" /* prototypes */ -#include "mappings.h" /* mapping macros */ -static const char ORIGIN_SEPARATOR = '/'; +static const char ORIGIN_SEPARATOR = '/'; struct group_mapping { - const char /* @null@ */ *key; + const char *key; PkGroupEnum group; }; @@ -112,9 +112,11 @@ {"x11-toolkits", PK_GROUP_ENUM_DESKTOP_OTHER}, {"x11-wm", PK_GROUP_ENUM_DESKTOP_OTHER}, /* Default (for new/unspecified ports directories) */ - {NULL, PK_GROUP_ENUM_UNKNOWN} + {"", PK_GROUP_ENUM_UNKNOWN} }; +static PkGroupEnum group_from_port_dir(const char *port_dir); + /* Reports the PackageKit groups available on this backend as a bitfield. */ PkBitfield available_groups(void) @@ -123,30 +125,23 @@ PkBitfield bits; bits = 0; - for (i = 0; group_mappings[i].key != NULL; i++) + for (i = 0; group_mappings[i].key[0] != '\0'; i++) pk_bitfield_add(bits, group_mappings[i].group); return bits; } -/* Maps from port/origin directories to PackageKit groups. */ -PkGroupEnum -group_from_port_dir( /* @null@ */ const char *port_dir) -{ - struct group_mapping *result; - - MAPPING_FIND(port_dir, &result, group_mappings); - return result->group; -} - /* Maps from package origins to PackageKit groups. */ PkGroupEnum group_from_origin(const char *origin) { + size_t len; char *dir; char *sep; PkGroupEnum group; + assert(origin != NULL); + /* Find the separation between dir and port name */ sep = strchr(origin, ORIGIN_SEPARATOR); @@ -156,10 +151,25 @@ * origin start and the separator mark the port directory name we * want to use. */ - dir = (sep == NULL ? NULL : strndup(origin, sep - origin)); + len = (size_t) (sep == NULL ? 0 : sep - origin); + dir = strndup(origin, len); group = group_from_port_dir(dir); - if (dir) - free(dir); + free(dir); return group; } + +/* Maps from port/origin directories to PackageKit groups. */ +static PkGroupEnum +group_from_port_dir(const char *port_dir) +{ + struct group_mapping *result; + + assert(port_dir != NULL); + + for (result = group_mappings; + result->key[0] != '\0' && strcmp(result->key, port_dir) != 0; + result++); + + return result->group; +} Modified: soc2013/mattbw/backend/groups.h ============================================================================== --- soc2013/mattbw/backend/groups.h Tue Jul 9 07:17:29 2013 (r254453) +++ soc2013/mattbw/backend/groups.h Tue Jul 9 07:29:25 2013 (r254454) @@ -25,6 +25,5 @@ PkBitfield available_groups(void); PkGroupEnum group_from_origin(const char *origin); -PkGroupEnum group_from_port_dir(const char *port_dir); #endif /* _PKGNG_BACKEND_GROUPS_H_ */ Modified: soc2013/mattbw/backend/licenses.c ============================================================================== --- soc2013/mattbw/backend/licenses.c Tue Jul 9 07:17:29 2013 (r254453) +++ soc2013/mattbw/backend/licenses.c Tue Jul 9 07:29:25 2013 (r254454) @@ -50,7 +50,7 @@ case LICENSE_AND: logic_str = " and "; break; - default: + case LICENSE_SINGLE: logic_str = " "; break; } Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Tue Jul 9 07:17:29 2013 (r254453) +++ soc2013/mattbw/backend/pkgutils.c Tue Jul 9 07:29:25 2013 (r254454) @@ -67,9 +67,6 @@ case PKG_UPGRADE: info = PK_INFO_ENUM_UPDATING; break; - default: - /* Stick with the above default. */ - break; } } return info; @@ -84,6 +81,7 @@ const char *repo; switch (pkg_type(pkg)) { + case PKG_OLD_FILE: case PKG_FILE: repo = "local"; break; @@ -93,7 +91,7 @@ case PKG_REMOTE: repo = repo_of_remote(pkg); break; - default: + case PKG_NONE: repo = "unknown"; break; } Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Tue Jul 9 07:17:29 2013 (r254453) +++ soc2013/mattbw/backend/query/core.c Tue Jul 9 07:29:25 2013 (r254454) @@ -68,7 +68,7 @@ bool success; bool try_local; bool try_remote; - int match; + match_t match; PkBitfield filters; const char *name; const char *repo; Modified: soc2013/mattbw/backend/query/do.c ============================================================================== --- soc2013/mattbw/backend/query/do.c Tue Jul 9 07:17:29 2013 (r254453) +++ soc2013/mattbw/backend/query/do.c Tue Jul 9 07:29:25 2013 (r254454) @@ -56,9 +56,6 @@ case QUERY_SINGLE_ID: success = do_single(backend, db, s, t); break; - default: - success = false; - break; } pkgdb_close(db); Modified: soc2013/mattbw/backend/utils.h ============================================================================== --- soc2013/mattbw/backend/utils.h Tue Jul 9 07:17:29 2013 (r254453) +++ soc2013/mattbw/backend/utils.h Tue Jul 9 07:29:25 2013 (r254454) @@ -24,8 +24,10 @@ #include /* bool */ #define INTENTIONALLY_IGNORE(x) (void)(x) +#define STATUS(backend, status) \ + (void)pk_backend_set_status((backend), (status)) #define ERR(backend, type, msg) \ - (void) pk_backend_error_code((backend), (type), (msg)) + (void)pk_backend_error_code((backend), (type), (msg)) bool string_match(const char *left, const char *right); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 07:32:48 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1614AFCD for ; Tue, 9 Jul 2013 07:32:48 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 080261D90 for ; Tue, 9 Jul 2013 07:32:48 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r697Wlxd073618 for ; Tue, 9 Jul 2013 07:32:47 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r697WlmP073613 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 07:32:47 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 9 Jul 2013 07:32:47 GMT Message-Id: <201307090732.r697WlmP073613@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254455 - soc2013/mattbw/backend/query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 07:32:48 -0000 Author: mattbw Date: Tue Jul 9 07:32:47 2013 New Revision: 254455 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254455 Log: use C11 anonymous unions Modified: soc2013/mattbw/backend/query/core.c soc2013/mattbw/backend/query/core.h soc2013/mattbw/backend/query/do.c soc2013/mattbw/backend/query/match.c Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Tue Jul 9 07:29:25 2013 (r254454) +++ soc2013/mattbw/backend/query/core.c Tue Jul 9 07:32:47 2013 (r254455) @@ -122,7 +122,7 @@ "package not found"); else { if (q->t->type == QUERY_EMIT) - success = q->t->data.emit.f(pkg, match_id, q); + success = q->t->emit.f(pkg, match_id, q); else if (q->t->type == QUERY_JOB) success = emit_to_job(pkg, q); } @@ -248,7 +248,7 @@ * non-installed packages. */ if (q->t->type == QUERY_EMIT && - (q->t->data.emit.load_flags & PKG_LOAD_FILES)) { + (q->t->emit.load_flags & PKG_LOAD_FILES)) { ERR(q->backend, PK_ERROR_ENUM_CANNOT_GET_FILELIST, "cannot get files for remote package"); @@ -275,7 +275,7 @@ backend = query_backend(q); - if (pkg_jobs_new(&jobs, q->t->data.job.type, q->db) != EPKG_OK) { + if (pkg_jobs_new(&jobs, q->t->job.type, q->db) != EPKG_OK) { ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "could not init pkg_jobs"); @@ -293,7 +293,7 @@ "could not add to job"); goto cleanup; } - success = q->t->data.job.f(jobs, q); + success = q->t->job.f(jobs, q); cleanup: pkg_jobs_free(jobs); @@ -412,7 +412,7 @@ struct pkg *pkg; if (q->t->type == QUERY_EMIT) - load_flags = q->t->data.emit.load_flags; + load_flags = q->t->emit.load_flags; else load_flags = PKG_LOAD_BASIC; @@ -449,12 +449,12 @@ */ id_strv = g_malloc0_n(5, (gsize) sizeof(gchar *)); - id_strv[PK_PACKAGE_ID_NAME] = g_strdup(s->data.single); + id_strv[PK_PACKAGE_ID_NAME] = g_strdup(s->single); id_strv[PK_PACKAGE_ID_VERSION] = g_strdup(""); id_strv[PK_PACKAGE_ID_ARCH] = g_strdup(""); id_strv[PK_PACKAGE_ID_DATA] = g_strdup(""); } else if (s->type == QUERY_SINGLE_ID) { - id_strv = pk_package_id_split(s->data.single); + id_strv = pk_package_id_split(s->single); if (id_strv == NULL) ERR(backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, Modified: soc2013/mattbw/backend/query/core.h ============================================================================== --- soc2013/mattbw/backend/query/core.h Tue Jul 9 07:29:25 2013 (r254454) +++ soc2013/mattbw/backend/query/core.h Tue Jul 9 07:32:47 2013 (r254455) @@ -49,7 +49,7 @@ union { bool unused; gchar *single; - } data; + }; /* Information about this query's position in a set of subqueries. */ unsigned int position; @@ -68,7 +68,7 @@ pkg_jobs_t type; job_emit_ptr f; } job; - } data; + }; }; PkBackend *query_backend(struct query *q); Modified: soc2013/mattbw/backend/query/do.c ============================================================================== --- soc2013/mattbw/backend/query/do.c Tue Jul 9 07:29:25 2013 (r254454) +++ soc2013/mattbw/backend/query/do.c Tue Jul 9 07:32:47 2013 (r254455) @@ -86,11 +86,11 @@ for (new_s.position = 0; new_s.position < new_s.total && success; (new_s.position)++) { - new_s.data.single = package_ids[new_s.position]; + new_s.single = package_ids[new_s.position]; /* Treat non-PackageIDs as pkgng package names, if allowed */ if (s->type == QUERY_BACKEND_IDS || - pk_package_id_check(new_s.data.single) == TRUE) + pk_package_id_check(new_s.single) == TRUE) new_s.type = QUERY_SINGLE_ID; else new_s.type = QUERY_SINGLE_NAME; Modified: soc2013/mattbw/backend/query/match.c ============================================================================== --- soc2013/mattbw/backend/query/match.c Tue Jul 9 07:29:25 2013 (r254454) +++ soc2013/mattbw/backend/query/match.c Tue Jul 9 07:32:47 2013 (r254455) @@ -37,13 +37,13 @@ struct query_source s; struct query_target t; - s.data.unused = true; + s.unused = true; s.position = 0; s.total = 1; s.type = QUERY_BACKEND_IDS; - t.data.emit.f = emitter; - t.data.emit.load_flags = load_flags; + t.emit.f = emitter; + t.emit.load_flags = load_flags; t.type = QUERY_EMIT; return query_do(backend, &s, &t); @@ -61,13 +61,13 @@ struct query_source s; struct query_target t; - s.data.unused = true; + s.unused = true; s.position = 0; s.total = 1; s.type = QUERY_BACKEND_IDS; - t.data.job.f = emitter; - t.data.job.type = type; + t.job.f = emitter; + t.job.type = type; t.type = QUERY_JOB; return query_do(backend, &s, &t); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 07:41:25 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 70C333CC for ; Tue, 9 Jul 2013 07:41:25 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 62A521E06 for ; Tue, 9 Jul 2013 07:41:25 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r697fPbl080225 for ; Tue, 9 Jul 2013 07:41:25 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r697fPos080222 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 07:41:25 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 9 Jul 2013 07:41:25 GMT Message-Id: <201307090741.r697fPos080222@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254456 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 07:41:25 -0000 Author: dpl Date: Tue Jul 9 07:41:25 2013 New Revision: 254456 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254456 Log: Adhere to local preprocessor style. Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c soc2013/dpl/head/contrib/xz/src/xz/file_io.h Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/coder.c Tue Jul 9 07:32:47 2013 (r254455) +++ soc2013/dpl/head/contrib/xz/src/xz/coder.c Tue Jul 9 07:41:25 2013 (r254456) @@ -641,9 +641,9 @@ // Don't open the destination file when --test // is used. if (opt_mode == MODE_TEST || !io_open_dest(pair)) { -# ifdef CAPSICUM +# if defined(CAPSICUM) // limitfd(pair); -# endif +# endif // Initialize the progress indicator. const uint64_t in_size = pair->src_st.st_size <= 0 Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.h Tue Jul 9 07:32:47 2013 (r254455) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.h Tue Jul 9 07:41:25 2013 (r254456) @@ -129,9 +129,12 @@ extern bool io_write(file_pair *pair, const io_buf *buf, size_t size); -#ifdef CAPSICUM +#if defined(CAPSICUM) /// \brief Limits fd using FreeBSD's Capsicum framework. /// /// \param fd File descriptor to limit. -extern void limitfd(struct file_pair* pair); -#endif \ No newline at end of file +extern void limitfd(file_pair *pair); + +/// \brief Enters Capability mode, and limit stdin, stdout & stderr. +extern void cap_init(void); +#endif From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 10:00:21 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A970FD6E for ; Tue, 9 Jul 2013 10:00:21 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 81840168D for ; Tue, 9 Jul 2013 10:00:21 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r69A0L7q052380 for ; Tue, 9 Jul 2013 10:00:21 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r69A0LTo052364 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 10:00:21 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 9 Jul 2013 10:00:21 GMT Message-Id: <201307091000.r69A0LTo052364@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254487 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 10:00:21 -0000 Author: mattbw Date: Tue Jul 9 10:00:21 2013 New Revision: 254487 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254487 Log: report packages already installed as installed when searching Modified: soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/pkgutils.h Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Tue Jul 9 09:59:46 2013 (r254486) +++ soc2013/mattbw/backend/pkgutils.c Tue Jul 9 10:00:21 2013 (r254487) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #include #include #include "pk-backend.h" @@ -33,9 +34,19 @@ PkInfoEnum pkgutils_pkg_current_state(struct pkg *pkg) { + PkInfoEnum info; + + /* If the package is local, then it's installed. If it is remote, then + * it is installed if it is the same version as an installed package, + * and available if it is not. + */ + if ((pkg_type(pkg) == PKG_INSTALLED) || + pkgutils_pkg_install_state(pkg) == PK_INFO_ENUM_REINSTALLING) + info = PK_INFO_ENUM_INSTALLED; + else + info = PK_INFO_ENUM_AVAILABLE; - return (pkg_type(pkg) == PKG_INSTALLED ? - PK_INFO_ENUM_INSTALLED : PK_INFO_ENUM_AVAILABLE); + return info; } /* @@ -146,6 +157,31 @@ } /* + * Adds any old version of the given package to itself as PKG_OLD_VERSION. + */ +void +pkgutils_add_old_version(struct pkgdb *db, struct pkg *pkg) +{ + const char *origin; + struct pkg *pkg2; + + origin = NULL; + pkg_get(pkg, PKG_ORIGIN, &origin); + + pkg2 = NULL; + if (pkg_try_installed(db, origin, &pkg2, PKG_LOAD_BASIC) == EPKG_OK) { + const char *version; + + assert(pkg2 != NULL); + + pkg_get(pkg2, PKG_VERSION, &version); + pkg_set(pkg, PKG_OLD_VERSION, version); + + pkg_free(pkg2); + } +} + +/* * Emits a package through the backend with the given info enum. */ void @@ -173,7 +209,7 @@ should_emit = TRUE; - if (pkg_type(pkg) == PKG_INSTALLED) + if (pkgutils_pkg_current_state(pkg) == PK_INFO_ENUM_INSTALLED) should_emit = pk_bitfield_contain(filters, PK_FILTER_ENUM_NOT_INSTALLED) ? FALSE : should_emit; else Modified: soc2013/mattbw/backend/pkgutils.h ============================================================================== --- soc2013/mattbw/backend/pkgutils.h Tue Jul 9 09:59:46 2013 (r254486) +++ soc2013/mattbw/backend/pkgutils.h Tue Jul 9 10:00:21 2013 (r254487) @@ -30,6 +30,7 @@ const char *pkgutils_pk_repo_of(struct pkg *pkg); gchar *pkgutils_pkg_to_id(struct pkg *pkg); gchar *pkgutils_pkg_to_id_through(struct pkg *pkg, const gchar **strv); +void pkgutils_add_old_version(struct pkgdb *db, struct pkg *pkg); void pkgutils_emit(struct pkg *pkg, PkBackend *backend, PkInfoEnum info); void pkgutils_emit_filtered(struct pkg *pkg, PkBackend *backend, PkBitfield filters, PkInfoEnum info); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 10:16:38 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 528791E0 for ; Tue, 9 Jul 2013 10:16:38 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 44CBD1730 for ; Tue, 9 Jul 2013 10:16:38 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r69AGcv5017661 for ; Tue, 9 Jul 2013 10:16:38 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r69AGcmm017659 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 10:16:38 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 9 Jul 2013 10:16:38 GMT Message-Id: <201307091016.r69AGcmm017659@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254488 - soc2013/mattbw/backend/query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 10:16:38 -0000 Author: mattbw Date: Tue Jul 9 10:16:38 2013 New Revision: 254488 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254488 Log: hopefully fix horrendously broken percentage code Modified: soc2013/mattbw/backend/query/core.c Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Tue Jul 9 10:00:21 2013 (r254487) +++ soc2013/mattbw/backend/query/core.c Tue Jul 9 10:16:38 2013 (r254488) @@ -223,14 +223,13 @@ if (percent > 100) percent = 100; - scaled_percent = (((100 * q->s->position) + - (percent * (q->s->position + 1))) / (q->s->total)); + scaled_percent = (((100 * q->s->position) + percent) / + (q->s->total)); } (void)pk_backend_set_percentage(q->backend, scaled_percent); } - /* * Checks to see if trying to do a remote package iteration with this query * could spell disaster. From owner-svn-soc-all@FreeBSD.ORG Tue Jul 9 18:31:51 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C3B09DD1 for ; Tue, 9 Jul 2013 18:31:51 +0000 (UTC) (envelope-from ambarisha@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A570E12A6 for ; Tue, 9 Jul 2013 18:31:51 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r69IVpe4031547 for ; Tue, 9 Jul 2013 18:31:51 GMT (envelope-from ambarisha@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r69IVpIH031532 for svn-soc-all@FreeBSD.org; Tue, 9 Jul 2013 18:31:51 GMT (envelope-from ambarisha@FreeBSD.org) Date: Tue, 9 Jul 2013 18:31:51 GMT Message-Id: <201307091831.r69IVpIH031532@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ambarisha@FreeBSD.org using -f From: ambarisha@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254504 - in soc2013/ambarisha/head/usr.bin: dmget dms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 18:31:51 -0000 Author: ambarisha Date: Tue Jul 9 18:31:50 2013 New Revision: 254504 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254504 Log: DMS server first commit Added: soc2013/ambarisha/head/usr.bin/dmget/dm.h soc2013/ambarisha/head/usr.bin/dmget/utils.c soc2013/ambarisha/head/usr.bin/dms/ soc2013/ambarisha/head/usr.bin/dms/Makefile soc2013/ambarisha/head/usr.bin/dms/dm.h soc2013/ambarisha/head/usr.bin/dms/dms.c soc2013/ambarisha/head/usr.bin/dms/dms.h soc2013/ambarisha/head/usr.bin/dms/list.c soc2013/ambarisha/head/usr.bin/dms/list.h soc2013/ambarisha/head/usr.bin/dms/utils.c soc2013/ambarisha/head/usr.bin/dms/worker.c Modified: soc2013/ambarisha/head/usr.bin/dmget/Makefile soc2013/ambarisha/head/usr.bin/dmget/dmget.c soc2013/ambarisha/head/usr.bin/dmget/dmget.h soc2013/ambarisha/head/usr.bin/dmget/fetch.c Modified: soc2013/ambarisha/head/usr.bin/dmget/Makefile ============================================================================== --- soc2013/ambarisha/head/usr.bin/dmget/Makefile Tue Jul 9 15:20:46 2013 (r254503) +++ soc2013/ambarisha/head/usr.bin/dmget/Makefile Tue Jul 9 18:31:50 2013 (r254504) @@ -2,7 +2,7 @@ .include -SRCS= fetch.c dmget.c +SRCS= fetch.c utils.c dmget.c PROG= dmget CSTD?= c99 .if ${MK_OPENSSL} != "no" Added: soc2013/ambarisha/head/usr.bin/dmget/dm.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/ambarisha/head/usr.bin/dmget/dm.h Tue Jul 9 18:31:50 2013 (r254504) @@ -0,0 +1,59 @@ +#ifndef _DM_H +#define _DM_H + +#include +#include + +#include +#include + +/* TODO : Fix the path, make sure the perms on it are good */ +#define DMS_UDS_PATH "/tmp/dms.uds" + +struct dmres { +}; + +struct dmreq { + int v_level; + int family; + long ftp_timeout; + long http_timeout; + off_t B_size; + off_t S_size; + long T_secs; + long flags; + +#define A_FLAG (1 << 0) +#define F_FLAG (1 << 1) +#define O_STDOUT (1 << 2) +#define R_FLAG (1 << 3) +#define U_FLAG (1 << 4) +#define d_FLAG (1 << 5) +#define i_FLAG (1 << 6) +#define l_FLAG (1 << 7) +#define m_FLAG (1 << 8) +#define n_FLAG (1 << 9) +#define p_FLAG (1 << 10) +#define r_FLAG (1 << 11) +#define s_FLAG (1 << 12) + + char *i_filename; + char *URL; + char *path; +}; + +struct msg { + char op; + int len; + char *buf; +}; + +#define DMREQ 1 +#define DMRESP 2 +#define DMSTATREQ 3 +#define DMSTATRESP 4 +#define DMAUTHREQ 5 +#define DMAUTHRESP 6 +#define DMSIG 7 + +#endif /* _DMCLIENT_H */ Modified: soc2013/ambarisha/head/usr.bin/dmget/dmget.c ============================================================================== --- soc2013/ambarisha/head/usr.bin/dmget/dmget.c Tue Jul 9 15:20:46 2013 (r254503) +++ soc2013/ambarisha/head/usr.bin/dmget/dmget.c Tue Jul 9 18:31:50 2013 (r254504) @@ -1,4 +1,3 @@ - #include #include #include @@ -9,7 +8,9 @@ #include +#include "dm.h" #include "dmget.h" + auth_t dmAuthMethod; int dmTimeout; int dmRestartCalls; @@ -17,8 +18,11 @@ int dmLastErrCode; char dmLastErrString[MAXERRSTRING]; +static int dms; +static int sigint; + static void * -safe_malloc(size_t size) +Malloc(size_t size) { void *ptr = malloc(size); if (ptr == NULL) { @@ -27,170 +31,155 @@ return ptr; } -static char -mk_dmflags(void) -{ - char flags = 0; - if (dmRestartCalls != 0) - flags |= DM_RESTART_CALLS; - if (dmDebug != 0) - flags |= DM_DEBUG; - - return flags; -} - static int -mk_reqbuf(struct url *u, char **reqbuf, char op) +mk_reqbuf(struct dmreq dmreq, char **reqbuf, char op) { int bufsize = 0; + printf("mk_reqbuf() : Starting\n"); - bufsize += sizeof(bufsize); // Buffer size - bufsize += 1; // Opcode - bufsize += sizeof(struct url) - 4; // Struct url - doc pointer - bufsize += strlen(u->doc) + 1; // Url document name - bufsize += sizeof(dmTimeout); // Timeout - - *reqbuf = (char *) safe_malloc(bufsize); + bufsize += sizeof(bufsize); // Buffer size + bufsize += 1; // Opcode + bufsize += sizeof(struct dmreq) - (3 * sizeof(char*)); // fix sizeof(dmreq) + bufsize += strlen(dmreq.i_filename) + 1; // + bufsize += strlen(dmreq.URL) + 1; + bufsize += strlen(dmreq.path) + 1; + *reqbuf = (char *) Malloc(bufsize); + int i = 0; - + memcpy(*reqbuf, &(bufsize), sizeof(bufsize)); i += sizeof(bufsize); + + *(*reqbuf+i) = op; + i++; + + memcpy(*reqbuf + i, &(dmreq.v_level), sizeof(sizeof(dmreq.v_level))); + i += sizeof(dmreq.v_level); + + memcpy(*reqbuf + i, &(dmreq.family), sizeof(dmreq.family)); + i += sizeof(dmreq.family); + + memcpy(*reqbuf + i, &(dmreq.ftp_timeout), sizeof(dmreq.ftp_timeout)); + i += sizeof(dmreq.ftp_timeout); + + memcpy(*reqbuf + i, &(dmreq.http_timeout), sizeof(dmreq.http_timeout)); + i += sizeof(dmreq.http_timeout); + + memcpy(*reqbuf + i, &(dmreq.B_size), sizeof(dmreq.B_size)); + i += sizeof(dmreq.B_size); + + memcpy(*reqbuf + i, &(dmreq.S_size), sizeof(dmreq.S_size)); + i += sizeof(dmreq.S_size); + + memcpy(*reqbuf + i, &(dmreq.T_secs), sizeof(dmreq.T_secs)); + i += sizeof(dmreq.T_secs); + + memcpy(*reqbuf + i, &(dmreq.flags), sizeof(dmreq.flags)); + i += sizeof(dmreq.flags); - reqbuf[i++] = op; - - memcpy(*reqbuf + i, u->scheme, sizeof(u->scheme)); - i += sizeof(u->scheme); - - memcpy(*reqbuf + i, u->user, sizeof(u->user)); - i += sizeof(u->user); - - memcpy(*reqbuf + i, u->pwd, sizeof(u->pwd)); - i += sizeof(u->pwd); - - memcpy(*reqbuf + i, u->host, sizeof(u->host)); - i += sizeof(u->host); - - memcpy(*reqbuf + i, &(u->offset), sizeof(u->offset)); - i += sizeof(u->offset); - - memcpy(*reqbuf + i, &(u->length), sizeof(u->length)); - i += sizeof(u->length); - - memcpy(*reqbuf + i, &(u->ims_time), sizeof(u->ims_time)); - i += sizeof(u->ims_time); - - memcpy(*reqbuf + i, &dmTimeout, sizeof(dmTimeout)); - i += sizeof(dmTimeout); - - char dmFlags = mk_dmflags(); - memcpy(*reqbuf + i, &dmFlags, sizeof(dmFlags)); - i += sizeof(dmFlags); - - strcpy(*reqbuf + i, u->doc); - //Assert i == bufsize - strlen(doc) - 1 + strcpy(*reqbuf + i, dmreq.i_filename); + i += strlen(dmreq.i_filename) + 1; + + strcpy(*reqbuf + i, dmreq.URL); + i += strlen(dmreq.URL) + 1; + + strcpy(*reqbuf + i, dmreq.path); + i += strlen(dmreq.path) + 1; return bufsize; } static int -send_request(int sock, struct url *u) +send_request(int sock, struct dmreq dmreq) { char *reqbuf; - int bufsize = mk_reqbuf(u, &reqbuf, 0); - int err = write(sock, reqbuf, bufsize); - if (err == -1) { - perror("send_request write():"); - } + int bufsize = mk_reqbuf(dmreq, &reqbuf, DMREQ); + int err = Write(sock, reqbuf, bufsize); free(reqbuf); return (err); } static int -parse_rcvbuf(char *rcvbuf, int bufsize, struct dmres *dmres) +keep_reading(int sock, char *buf, int size) { - return 0; + int err = read(sock, buf, size); + while (err == -1 && errno == EINTR && sigint == 0) { + err = read(sock, buf, size); + } + + if (err == -1) + perror("read():"); + + return err; } static int recv_response(int sock, struct dmres *dmres) { int bufsize; - int kbytes = read(sock, &bufsize, sizeof(bufsize)); - if (kbytes == -1) { - perror("recv_response read():"); - } + keep_reading(sock, &bufsize, sizeof(bufsize)); + bufsize -= sizeof(bufsize); - char *rcvbuf = (char *) safe_malloc(bufsize); - - kbytes = read(sock, &rcvbuf, bufsize); + char *buf = (char *) Malloc(bufsize); + keep_reading(sock, buf, bufsize); - return (parse_rcvbuf(rcvbuf, bufsize, dmres)); + /* TODO: Check the error code in the response and set the + dmLastErrCode & dmLastErrString values */ } -FILE * -dmXGet(struct url *u, struct url_stat *us, const char *flags) +int +dm_request(struct dmreq dmreq) { - int udsock = socket(AF_UNIX, SOCK_STREAM, 0); + dms = socket(AF_UNIX, SOCK_STREAM, 0); struct sockaddr_un dms_addr; dms_addr.sun_family = AF_UNIX; strncpy(dms_addr.sun_path, DMS_UDS_PATH, sizeof(dms_addr.sun_path)); + int err = Connect(dms, (struct sockaddr *) &dms_addr, sizeof(dms_addr)); + + send_request(dms, dmreq); - int err = connect(udsock, (struct sockaddr *) &dms_addr, sizeof(dms_addr)); - if (err == -1) { - if (err == ENOENT) { - /* The DMS server process doesn't exist so start one */ - } else { - perror("dmXGet connect():"); - /* There was some error trying to connect to dms */ - } - } + struct dmres dmres; + recv_response(dms, &dmres); +} - err = send_request(udsock, u); - if (err == -1) { - perror("send_request :"); - } +static int +send_msg(int socket, struct msg msg) +{ + int bufsize = sizeof(bufsize); // Buffer size + bufsize += 1; // Op + bufsize += msg.len; // Signal number - struct dmres dmres; - for (;;) { - err = recv_response(udsock, &dmres); + char *sndbuf = (char *) Malloc(bufsize); + + int i = 0; + memcpy(sndbuf + i, &bufsize, sizeof(bufsize)); + i += sizeof(bufsize); - if (err == -1){ - perror("dmXGet read():"); - dmLastErrCode = errno; - strcpy(dmLastErrString, strerror(errno)); - return (NULL); - } - - if (dmres.op == DM_COMPLETE) { - FILE *savedf = fopen(dmres.fname, "r"); - if (savedf == NULL) { - dmLastErrCode = errno; - strcpy(dmLastErrString, strerror(errno)); - } - return (savedf); - } else if (dmres.op == DM_AUTH_REQ) { - err = dmAuthMethod(u); - if (err == -1) { - /* do what libfetch does when auth fails */ - } - send_request(udsock, u); - continue; - } else { - /* Received error code in response */ - } - } + *(sndbuf + i) = msg.op; + i++; + + memcpy(sndbuf + i, msg.buf, msg.len); + i += msg.len; - return (NULL); + int nbytes = Write(socket, sndbuf, bufsize); + free(sndbuf); + + return (nbytes); } -int -dmStat(struct url *u, struct url_stat *us, const char *flags) +void +dm_sighandler(int signal) { - us->size = -1; - us->mtime = 0; // Epoch - us->atime = us->mtime; + struct msg msg; + msg.op = DMSIG; + msg.buf = &signal; + msg.len = sizeof(signal); + send_msg(dms, msg); - return (-1); + if (signal == SIGINT) { + close(dms); + exit(2); + } } Modified: soc2013/ambarisha/head/usr.bin/dmget/dmget.h ============================================================================== --- soc2013/ambarisha/head/usr.bin/dmget/dmget.h Tue Jul 9 15:20:46 2013 (r254503) +++ soc2013/ambarisha/head/usr.bin/dmget/dmget.h Tue Jul 9 18:31:50 2013 (r254504) @@ -7,36 +7,16 @@ #include #include -/* TODO : Fix the path, make sure the perms on it are good */ -#define DMS_UDS_PATH "/tmp/dms.uds" +#include "dm.h" -#define DM_COMPLETE 1 -#define DM_AUTH_REQ 2 - - -struct dmres { - int op; - char fname[]; -}; - -#define DM_RESTART_CALLS 1 -#define DM_DEBUG 2 - -/* Authentication */ -extern auth_t dmAuthMethod; - -/* Last error code */ extern int dmLastErrCode; -#define MAXERRSTRING 256 -extern char dmLastErrString[MAXERRSTRING]; - -/* I/O timeout */ -extern int dmTimeout; - -/* Restart interrupted syscalls */ extern int dmRestartCalls; +extern char dmLastErrString[]; + +typedef int (*auth_t)(struct url *); +extern auth_t dmAuthMethod; -/* Extra verbosity */ -extern int dmDebug; +int dm_request(struct dmreq); +void dm_sighandler(int sig); #endif /* _DMCLIENT_H */ Modified: soc2013/ambarisha/head/usr.bin/dmget/fetch.c ============================================================================== --- soc2013/ambarisha/head/usr.bin/dmget/fetch.c Tue Jul 9 15:20:46 2013 (r254503) +++ soc2013/ambarisha/head/usr.bin/dmget/fetch.c Tue Jul 9 18:31:50 2013 (r254504) @@ -48,6 +48,7 @@ #include #include "dmget.h" +#include "dm.h" #define MINBUFSIZE 4096 #define TIMEOUT 120 @@ -95,26 +96,6 @@ static long http_timeout = TIMEOUT;/* default timeout for HTTP transfers */ static char *buf; /* transfer buffer */ - -/* - * Signal handler - */ -static void -sig_handler(int sig) -{ - switch (sig) { - case SIGALRM: - sigalrm = 1; - break; - case SIGINFO: - siginfo = 1; - break; - case SIGINT: - sigint = 1; - break; - } -} - struct xferstat { char name[64]; struct timeval start; /* start of transfer */ @@ -127,6 +108,9 @@ }; /* + * Signal handler + */ +/* * Compute and display ETA */ static const char * @@ -236,52 +220,6 @@ } /* - * Initialize the transfer statistics - */ -static void -stat_start(struct xferstat *xs, const char *name, off_t size, off_t offset) -{ - snprintf(xs->name, sizeof xs->name, "%s", name); - gettimeofday(&xs->start, NULL); - xs->last.tv_sec = xs->last.tv_usec = 0; - xs->size = size; - xs->offset = offset; - xs->rcvd = offset; - xs->lastrcvd = offset; - if (v_tty && v_level > 0) - stat_display(xs, 1); - else if (v_level > 0) - fprintf(stderr, "%-46s", xs->name); -} - -/* - * Update the transfer statistics - */ -static void -stat_update(struct xferstat *xs, off_t rcvd) -{ - xs->rcvd = rcvd; - if (v_tty && v_level > 0) - stat_display(xs, 0); -} - -/* - * Finalize the transfer statistics - */ -static void -stat_end(struct xferstat *xs) -{ - gettimeofday(&xs->last, NULL); - if (v_tty && v_level > 0) { - stat_display(xs, 2); - putc('\n', stderr); - } else if (v_level > 0) { - fprintf(stderr, " %s %s\n", - stat_bytes(xs->size), stat_bps(xs)); - } -} - -/* * Ask the user for authentication details */ static int @@ -328,444 +266,37 @@ static int fetch(char *URL, const char *path) { - struct url *url; - struct url_stat us; - struct stat sb, nsb; - struct xferstat xs; - FILE *f, *of; - size_t size, readcnt, wr; - off_t count; - char flags[8]; - const char *slash; - char *tmppath; - int r; - unsigned timeout; - char *ptr; - - f = of = NULL; - tmppath = NULL; - - timeout = 0; - *flags = 0; - count = 0; - - /* set verbosity level */ - if (v_level > 1) - strcat(flags, "v"); - if (v_level > 2) - dmDebug = 1; - - /* parse URL */ - url = NULL; - if (*URL == '\0') { - warnx("empty URL"); - goto failure; - } - if ((url = fetchParseURL(URL)) == NULL) { - warnx("%s: parse error", URL); - goto failure; - } - - /* if no scheme was specified, take a guess */ - if (!*url->scheme) { - if (!*url->host) - strcpy(url->scheme, SCHEME_FILE); - else if (strncasecmp(url->host, "ftp.", 4) == 0) - strcpy(url->scheme, SCHEME_FTP); - else if (strncasecmp(url->host, "www.", 4) == 0) - strcpy(url->scheme, SCHEME_HTTP); - } - - /* common flags */ - switch (family) { - case PF_INET: - strcat(flags, "4"); - break; - case PF_INET6: - strcat(flags, "6"); - break; - } - - /* FTP specific flags */ - if (strcmp(url->scheme, SCHEME_FTP) == 0) { - if (p_flag) - strcat(flags, "p"); - if (d_flag) - strcat(flags, "d"); - if (U_flag) - strcat(flags, "l"); - timeout = T_secs ? T_secs : ftp_timeout; - } - - /* HTTP specific flags */ - if (strcmp(url->scheme, SCHEME_HTTP) == 0 || - strcmp(url->scheme, SCHEME_HTTPS) == 0) { - if (d_flag) - strcat(flags, "d"); - if (A_flag) - strcat(flags, "A"); - timeout = T_secs ? T_secs : http_timeout; - if (i_flag) { - if (stat(i_filename, &sb)) { - warn("%s: stat()", i_filename); - goto failure; - } - url->ims_time = sb.st_mtime; - strcat(flags, "i"); - } - } - - /* set the protocol timeout. */ - dmTimeout = timeout; + struct dmreq dmreq; + dmreq.v_level = v_level; + dmreq.family = family; + dmreq.ftp_timeout = ftp_timeout; + dmreq.http_timeout = http_timeout; + dmreq.B_size = B_size; + dmreq.S_size = S_size; + dmreq.URL = URL; + printf("URL = %s\n", dmreq.URL); + dmreq.path = path; + dmreq.T_secs = T_secs; + + if (i_flag) dmreq.i_filename = i_filename; + else dmreq.i_filename = ""; + + dmreq.flags = 0; + if (A_flag != 0) dmreq.flags |= A_FLAG; + if (F_flag != 0) dmreq.flags |= F_FLAG; + if (R_flag != 0) dmreq.flags |= R_FLAG; + if (U_flag != 0) dmreq.flags |= U_FLAG; + if (d_flag != 0) dmreq.flags |= d_FLAG; + if (i_flag != 0) dmreq.flags |= i_FLAG; + if (l_flag != 0) dmreq.flags |= l_FLAG; + if (m_flag != 0) dmreq.flags |= m_FLAG; + if (n_flag != 0) dmreq.flags |= n_FLAG; + if (p_flag != 0) dmreq.flags |= p_FLAG; + if (r_flag != 0) dmreq.flags |= r_FLAG; + if (s_flag != 0) dmreq.flags |= s_FLAG; + if (o_stdout != 0) dmreq.flags |= O_STDOUT; - /* just print size */ - if (s_flag) { - if (timeout) - alarm(timeout); - r = dmStat(url, &us, flags); - if (timeout) - alarm(0); - if (sigalrm || sigint) - goto signal; - if (r == -1) { - warnx("%s", dmLastErrString); - goto failure; - } - if (us.size == -1) - printf("Unknown\n"); - else - printf("%jd\n", (intmax_t)us.size); - goto success; - } - - /* - * If the -r flag was specified, we have to compare the local - * and remote files, so we should really do a dmStat() - * first, but I know of at least one HTTP server that only - * sends the content size in response to GET requests, and - * leaves it out of replies to HEAD requests. Also, in the - * (frequent) case that the local and remote files match but - * the local file is truncated, we have sufficient information - * before the compare to issue a correct request. Therefore, - * we always issue a GET request as if we were sure the local - * file was a truncated copy of the remote file; we can drop - * the connection later if we change our minds. - */ - sb.st_size = -1; - if (!o_stdout) { - r = stat(path, &sb); - if (r == 0 && r_flag && S_ISREG(sb.st_mode)) { - url->offset = sb.st_size; - } else if (r == -1 || !S_ISREG(sb.st_mode)) { - /* - * Whatever value sb.st_size has now is either - * wrong (if stat(2) failed) or irrelevant (if the - * path does not refer to a regular file) - */ - sb.st_size = -1; - } - if (r == -1 && errno != ENOENT) { - warnx("%s: stat()", path); - goto failure; - } - } - - /* start the transfer */ - if (timeout) - alarm(timeout); - f = dmXGet(url, &us, flags); - if (timeout) - alarm(0); - if (sigalrm || sigint) - goto signal; - if (f == NULL) { - warnx("%s: %s", URL, dmLastErrString); - if (i_flag && strcmp(url->scheme, SCHEME_HTTP) == 0 - && dmLastErrCode == FETCH_OK - && strcmp(dmLastErrString, "Not Modified") == 0) { - /* HTTP Not Modified Response, return OK. */ - r = 0; - goto done; - } else - goto failure; - } - if (sigint) - goto signal; - - /* check that size is as expected */ - if (S_size) { - if (us.size == -1) { - warnx("%s: size unknown", URL); - } else if (us.size != S_size) { - warnx("%s: size mismatch: expected %jd, actual %jd", - URL, (intmax_t)S_size, (intmax_t)us.size); - goto failure; - } - } - - /* symlink instead of copy */ - if (l_flag && strcmp(url->scheme, "file") == 0 && !o_stdout) { - if (symlink(url->doc, path) == -1) { - warn("%s: symlink()", path); - goto failure; - } - goto success; - } - - if (us.size == -1 && !o_stdout && v_level > 0) - warnx("%s: size of remote file is not known", URL); - if (v_level > 1) { - if (sb.st_size != -1) - fprintf(stderr, "local size / mtime: %jd / %ld\n", - (intmax_t)sb.st_size, (long)sb.st_mtime); - if (us.size != -1) - fprintf(stderr, "remote size / mtime: %jd / %ld\n", - (intmax_t)us.size, (long)us.mtime); - } - - /* open output file */ - if (o_stdout) { - /* output to stdout */ - of = stdout; - } else if (r_flag && sb.st_size != -1) { - /* resume mode, local file exists */ - if (!F_flag && us.mtime && sb.st_mtime != us.mtime) { - /* no match! have to refetch */ - fclose(f); - /* if precious, warn the user and give up */ - if (R_flag) { - warnx("%s: local modification time " - "does not match remote", path); - goto failure_keep; - } - } else if (url->offset > sb.st_size) { - /* gap between what we asked for and what we got */ - warnx("%s: gap in resume mode", URL); - fclose(of); - of = NULL; - /* picked up again later */ - } else if (us.size != -1) { - if (us.size == sb.st_size) - /* nothing to do */ - goto success; - if (sb.st_size > us.size) { - /* local file too long! */ - warnx("%s: local file (%jd bytes) is longer " - "than remote file (%jd bytes)", path, - (intmax_t)sb.st_size, (intmax_t)us.size); - goto failure; - } - /* we got it, open local file */ - if ((of = fopen(path, "r+")) == NULL) { - warn("%s: fopen()", path); - goto failure; - } - /* check that it didn't move under our feet */ - if (fstat(fileno(of), &nsb) == -1) { - /* can't happen! */ - warn("%s: fstat()", path); - goto failure; - } - if (nsb.st_dev != sb.st_dev || - nsb.st_ino != nsb.st_ino || - nsb.st_size != sb.st_size) { - warnx("%s: file has changed", URL); - fclose(of); - of = NULL; - sb = nsb; - /* picked up again later */ - } - } - /* seek to where we left off */ - if (of != NULL && fseeko(of, url->offset, SEEK_SET) != 0) { - warn("%s: fseeko()", path); - fclose(of); - of = NULL; - /* picked up again later */ - } - } else if (m_flag && sb.st_size != -1) { - /* mirror mode, local file exists */ - if (sb.st_size == us.size && sb.st_mtime == us.mtime) - goto success; - } - - if (of == NULL) { - /* - * We don't yet have an output file; either this is a - * vanilla run with no special flags, or the local and - * remote files didn't match. - */ - - if (url->offset > 0) { - /* - * We tried to restart a transfer, but for - * some reason gave up - so we have to restart - * from scratch if we want the whole file - */ - url->offset = 0; - if ((f = dmXGet(url, &us, flags)) == NULL) { - warnx("%s: %s", URL, dmLastErrString); - goto failure; - } - if (sigint) - goto signal; - } - - /* construct a temp file name */ - if (sb.st_size != -1 && S_ISREG(sb.st_mode)) { - if ((slash = strrchr(path, '/')) == NULL) - slash = path; - else - ++slash; - asprintf(&tmppath, "%.*s.dm.XXXXXX.%s", - (int)(slash - path), path, slash); - if (tmppath != NULL) { - if (mkstemps(tmppath, strlen(slash) + 1) == -1) { - warn("%s: mkstemps()", path); - goto failure; - } - of = fopen(tmppath, "w"); - chown(tmppath, sb.st_uid, sb.st_gid); - chmod(tmppath, sb.st_mode & ALLPERMS); - } - } - if (of == NULL) - of = fopen(path, "w"); - if (of == NULL) { - warn("%s: open()", path); - goto failure; - } - } - count = url->offset; - - /* start the counter */ - stat_start(&xs, path, us.size, count); - - sigalrm = siginfo = sigint = 0; - - /* suck in the data */ - signal(SIGINFO, sig_handler); - while (!sigint) { - if (us.size != -1 && us.size - count < B_size && - us.size - count >= 0) - size = us.size - count; - else - size = B_size; - if (siginfo) { - stat_end(&xs); - siginfo = 0; - } - - if (size == 0) - break; - - if ((readcnt = fread(buf, 1, size, f)) < size) { - if (ferror(f) && errno == EINTR && !sigint) - clearerr(f); - else if (readcnt == 0) - break; - } - - stat_update(&xs, count += readcnt); - for (ptr = buf; readcnt > 0; ptr += wr, readcnt -= wr) - if ((wr = fwrite(ptr, 1, readcnt, of)) < readcnt) { - if (ferror(of) && errno == EINTR && !sigint) - clearerr(of); - else - break; - } - if (readcnt != 0) - break; - } - if (!sigalrm) - sigalrm = ferror(f) && errno == ETIMEDOUT; - signal(SIGINFO, SIG_DFL); - - stat_end(&xs); - - /* - * If the transfer timed out or was interrupted, we still want to - * set the mtime in case the file is not removed (-r or -R) and - * the user later restarts the transfer. - */ - signal: - /* set mtime of local file */ - if (!n_flag && us.mtime && !o_stdout && of != NULL && - (stat(path, &sb) != -1) && sb.st_mode & S_IFREG) { - struct timeval tv[2]; - - fflush(of); - tv[0].tv_sec = (long)(us.atime ? us.atime : us.mtime); - tv[1].tv_sec = (long)us.mtime; - tv[0].tv_usec = tv[1].tv_usec = 0; - if (utimes(tmppath ? tmppath : path, tv)) - warn("%s: utimes()", tmppath ? tmppath : path); - } - - /* timed out or interrupted? */ - if (sigalrm) - warnx("transfer timed out"); - if (sigint) { - warnx("transfer interrupted"); - goto failure; - } - - /* timeout / interrupt before connection completley established? */ - if (f == NULL) - goto failure; - - if (!sigalrm) { - /* check the status of our files */ - if (ferror(f)) - warn("%s", URL); - if (ferror(of)) - warn("%s", path); - if (ferror(f) || ferror(of)) - goto failure; - } - - /* did the transfer complete normally? */ - if (us.size != -1 && count < us.size) { - warnx("%s appears to be truncated: %jd/%jd bytes", - path, (intmax_t)count, (intmax_t)us.size); - goto failure_keep; - } - - /* - * If the transfer timed out and we didn't know how much to - * expect, assume the worst (i.e. we didn't get all of it) - */ - if (sigalrm && us.size == -1) { - warnx("%s may be truncated", path); - goto failure_keep; - } - - success: - r = 0; - if (tmppath != NULL && rename(tmppath, path) == -1) { - warn("%s: rename()", path); - goto failure_keep; - } - goto done; - failure: - if (of && of != stdout && !R_flag && !r_flag) - if (stat(path, &sb) != -1 && (sb.st_mode & S_IFREG)) - unlink(tmppath ? tmppath : path); - if (R_flag && tmppath != NULL && sb.st_size == -1) - rename(tmppath, path); /* ignore errors here */ - failure_keep: - r = -1; - goto done; - done: - if (f) - fclose(f); - if (of && of != stdout) - fclose(of); - if (url) - fetchFreeURL(url); - if (tmppath != NULL) - free(tmppath); - return (r); + return (dm_request(dmreq)); } static void *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Wed Jul 10 06:20:18 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4D25049C for ; Wed, 10 Jul 2013 06:20:18 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 313E816CE for ; Wed, 10 Jul 2013 06:20:18 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6A6KHg5026796 for ; Wed, 10 Jul 2013 06:20:17 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6A6KHfj026674 for svn-soc-all@FreeBSD.org; Wed, 10 Jul 2013 06:20:17 GMT (envelope-from mattbw@FreeBSD.org) Date: Wed, 10 Jul 2013 06:20:17 GMT Message-Id: <201307100620.r6A6KHfj026674@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254537 - in soc2013/mattbw/backend: . actions bin bin/catregex bin/getcat query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 06:20:18 -0000 Author: mattbw Date: Wed Jul 10 06:20:16 2013 New Revision: 254537 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254537 Log: gratituous amounts of group-matcher changing in prep for SearchGroups; group mappings are for now specified in a text file and awked into a C array Added: soc2013/mattbw/backend/bin/Makefile soc2013/mattbw/backend/bin/catregex/ soc2013/mattbw/backend/bin/catregex/.indent.pro soc2013/mattbw/backend/bin/catregex/Makefile soc2013/mattbw/backend/bin/catregex/pkgpk-catregex.1 soc2013/mattbw/backend/bin/catregex/pkgpk-catregex.c soc2013/mattbw/backend/bin/getcat/.indent.pro soc2013/mattbw/backend/group.c - copied, changed from r254454, soc2013/mattbw/backend/groups.c soc2013/mattbw/backend/group.h - copied, changed from r254454, soc2013/mattbw/backend/groups.h soc2013/mattbw/backend/group_map.awk (contents, props changed) soc2013/mattbw/backend/group_map.h soc2013/mattbw/backend/groups soc2013/mattbw/backend/query/.indent.pro Deleted: soc2013/mattbw/backend/groups.c soc2013/mattbw/backend/groups.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/get_details.c soc2013/mattbw/backend/actions/get_files.c soc2013/mattbw/backend/actions/resolve.c soc2013/mattbw/backend/bin/getcat/Makefile soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Wed Jul 10 04:59:10 2013 (r254536) +++ soc2013/mattbw/backend/Makefile Wed Jul 10 06:20:16 2013 (r254537) @@ -5,7 +5,8 @@ SRCS= pk-backend-pkgng.c SRCS+= \ db.c \ - groups.c \ + group_map.c \ + group.c \ licenses.c \ pkgutils.c \ utils.c @@ -42,10 +43,7 @@ LDFLAGS+= `pkg-config --libs ${PKGS}` CSTD?= c11 -# NOTE: remove this before finishing -CFLAGS+= --pedantic -Weverything -Werror -Wno-system-headers \ - -isystem /usr/local/include/glib-2.0 \ - -isystem /usr/local/include \ - -isystem /usr/include +group_map.c: groups group_map.awk + sort groups | awk -f group_map.awk > group_map.c .include Modified: soc2013/mattbw/backend/actions/get_details.c ============================================================================== --- soc2013/mattbw/backend/actions/get_details.c Wed Jul 10 04:59:10 2013 (r254536) +++ soc2013/mattbw/backend/actions/get_details.c Wed Jul 10 06:20:16 2013 (r254537) @@ -24,7 +24,7 @@ #include "../pk-backend.h" #include "pkg.h" -#include "../groups.h" /* group_from_origin */ +#include "../group.h" /* group_from_origin */ #include "../licenses.h" /* license_from_pkg */ #include "../query.h" /* query_... */ #include "../actions.h" /* get_details_thread prototype */ Modified: soc2013/mattbw/backend/actions/get_files.c ============================================================================== --- soc2013/mattbw/backend/actions/get_files.c Wed Jul 10 04:59:10 2013 (r254536) +++ soc2013/mattbw/backend/actions/get_files.c Wed Jul 10 06:20:16 2013 (r254537) @@ -25,8 +25,6 @@ #include "../pk-backend.h" #include "pkg.h" -#include "../groups.h" /* group_from_origin */ -#include "../licenses.h" /* license_from_pkg */ #include "../query.h" /* query_... */ #include "../actions.h" /* get_files_thread prototype */ Modified: soc2013/mattbw/backend/actions/resolve.c ============================================================================== --- soc2013/mattbw/backend/actions/resolve.c Wed Jul 10 04:59:10 2013 (r254536) +++ soc2013/mattbw/backend/actions/resolve.c Wed Jul 10 06:20:16 2013 (r254537) @@ -42,8 +42,8 @@ s.type = QUERY_BACKEND_MIXED; t.type = QUERY_EMIT; - t.data.emit.load_flags = PKG_LOAD_BASIC; - t.data.emit.f = emit; + t.emit.load_flags = PKG_LOAD_BASIC; + t.emit.f = emit; success = query_do(backend, &s, &t); Added: soc2013/mattbw/backend/bin/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/bin/Makefile Wed Jul 10 06:20:16 2013 (r254537) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +SUBDIR= \ + getcat \ + catregex + +.include Added: soc2013/mattbw/backend/bin/catregex/.indent.pro ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/bin/catregex/.indent.pro Wed Jul 10 06:20:16 2013 (r254537) @@ -0,0 +1,9 @@ +-TPkBitfield +-TPkGroupEnum +-TPkBackend +-Tgchar +-Tgboolean +-Tbool +-sob +-nlp +-ci4 Added: soc2013/mattbw/backend/bin/catregex/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/bin/catregex/Makefile Wed Jul 10 06:20:16 2013 (r254537) @@ -0,0 +1,16 @@ +# $FreeBSD$ + +PROG= pkgpk-catregex +SRCS= pkgpk-catregex.c ../../group.c ../../group_map.c + +DESTDIR?= /usr/local +BINDIR?= /bin +MANDIR?= /man/man + +CFLAGS+= `pkgconf --cflags pkg glib-2.0` +CFLAGS+= -I/usr/local/include/PackageKit -I/usr/local/include/PackageKit/backend +CFLAGS+= -I../../ +CFLAGS+= -DPK_COMPILATION +LDFLAGS+= `pkgconf --libs pkg glib-2.0` -lpackagekit-glib2 + +.include Added: soc2013/mattbw/backend/bin/catregex/pkgpk-catregex.1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/bin/catregex/pkgpk-catregex.1 Wed Jul 10 06:20:16 2013 (r254537) @@ -0,0 +1,49 @@ +.\" Copyright (C) 2013 Matt Windsor +.\" +.\" Licensed under the GNU General Public License Version 2 +.\" +.\" This program is free software; you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation; either version 2 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more files. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program; if not, write to the Free Software +.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +.\"----------------------------------------------------------------------------- +.Dd July 10, 2013 +.Dt pkgpk-catregex 1 +.Os +.\"----------------------------------------------------------------------------- +.Sh NAME +.Nm pkgpk-catregex +.Nd create origin matching regular expression for given PackageKit groups +.\"----------------------------------------------------------------------------- +.Sh SYNOPSIS +.Nm +.Ar group ... +.\"----------------------------------------------------------------------------- +.Sh DESCRIPTION +.Nm +is a debug utility for investigating the mapping between ports directories and +PackageKit groups as part of the PackageKit pkgng backend. +It returns an Extended Regular Expression that will match any port origins that +are inside any of the categories specified on the command line. +.Pp +Each +.Ar group +is expected to be the local name of a PackageKit group; the groups available +can be investigated by utilities such as pkcon. +.Pp +The result is always written on one line to standard output. +.\"----------------------------------------------------------------------------- +.Sh AUTHORS +.An Matt Windsor Aq mattbw@FreeBSD.org +.\"----------------------------------------------------------------------------- +.Sh BUGS +Probably. Added: soc2013/mattbw/backend/bin/catregex/pkgpk-catregex.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/bin/catregex/pkgpk-catregex.c Wed Jul 10 06:20:16 2013 (r254537) @@ -0,0 +1,76 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* + * Given the names of PackageKit groups, this programme prints out an + * Extended Regular Expression matching all dir/name style package origins in + * those groups. + */ +#define USAGE "usage: %s group ...\n" + +#include /* calloc, free */ +#include /* printf, fprintf */ +#include "pk-backend.h" /* PkGroupEnum, pk_group_enum_to_string */ +#include "group.h" /* group_list_to_origin_regex */ + +int +main(int argc, char **argv) +{ + int i; + int ret; + unsigned int groupc; + char *regex; + PkGroupEnum *groupv; + + ret = 0; + + /* Did we get any groups? */ + if (argc == 1) { + ret = 1; + fprintf(stderr, USAGE, argv[0]); + goto cleanup; + } + + groupc = (unsigned int)(argc - 1); + groupv = calloc(groupc, sizeof(PkGroupEnum)); + if (groupv == NULL) { + ret = 1; + fprintf(stderr, "out of mem!\n"); + goto cleanup; + } + + /* Find the group enums from their names */ + for (i = 1; i < argc; i++) + groupv[i - 1] = pk_group_enum_from_string(argv[i]); + + /* Now build the regex */ + regex = group_list_to_origin_regex(groupc, groupv); + if (regex == NULL) { + ret = 1; + fprintf (stderr, "passed null pointer to regex!\n"); + goto cleanup; + } + + printf("%s\n", regex); + free(regex); + +cleanup: + return ret; +} Added: soc2013/mattbw/backend/bin/getcat/.indent.pro ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/bin/getcat/.indent.pro Wed Jul 10 06:20:16 2013 (r254537) @@ -0,0 +1,9 @@ +-TPkBitfield +-TPkGroupEnum +-TPkBackend +-Tgchar +-Tgboolean +-Tbool +-sob +-nlp +-ci4 Modified: soc2013/mattbw/backend/bin/getcat/Makefile ============================================================================== --- soc2013/mattbw/backend/bin/getcat/Makefile Wed Jul 10 04:59:10 2013 (r254536) +++ soc2013/mattbw/backend/bin/getcat/Makefile Wed Jul 10 06:20:16 2013 (r254537) @@ -1,7 +1,7 @@ # $FreeBSD$ PROG= pkgpk-getcat -SRCS= pkgpk-getcat.c ../../groups.c +SRCS= pkgpk-getcat.c ../../group.c ../../group_map.c DESTDIR?= /usr/local BINDIR?= /bin Modified: soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c ============================================================================== --- soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c Wed Jul 10 04:59:10 2013 (r254536) +++ soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c Wed Jul 10 06:20:16 2013 (r254537) @@ -1,5 +1,4 @@ /*- - * * Copyright (C) 2013 Matt Windsor * * Licensed under the GNU General Public License Version 2 @@ -20,18 +19,17 @@ */ /* - * Gets the group name of a pkgng origin, eg 'ports-mgmt/pkg' -> 'admin-tools'. + * Gets the group name of a pkgng origin, eg 'ports-mgmt/pkg' -> + * 'admin-tools'. */ -const char *USAGE = "usage: %s origin\n"; +#define USAGE "usage: %s origin\n" #include -#include #include "pkg.h" #include "pk-backend.h" -#include "groups.h" - +#include "group.h" int main(int argc, char **argv) @@ -42,10 +40,9 @@ if (argc != 2) { ret = 1; fprintf(stderr, USAGE, argv[0]); - } else { + } else printf("%s\n", - pk_group_enum_to_string(group_from_origin(argv[1]))); - } + pk_group_enum_to_string(group_from_origin(argv[1]))); return ret; } Copied and modified: soc2013/mattbw/backend/group.c (from r254454, soc2013/mattbw/backend/groups.c) ============================================================================== --- soc2013/mattbw/backend/groups.c Tue Jul 9 07:29:25 2013 (r254454, copy source) +++ soc2013/mattbw/backend/group.c Wed Jul 10 06:20:16 2013 (r254537) @@ -19,119 +19,38 @@ */ #include /* assert */ +#include /* bool, true, false */ #include /* NULL */ #include /* strchr, strdup */ +#include /* struct sbuf, sbuf_... */ #include "glib.h" /* g_strcmp0 */ -#include "pk-backend.h" /* PkGroupEnum, PK_* */ +#include "pk-backend.h" /* PkGroupEnum, PK_... */ -#include "groups.h" /* prototypes */ +#include "group_map.h" /* group_mappings */ +#include "group.h" /* group_... */ static const char ORIGIN_SEPARATOR = '/'; -struct group_mapping { - const char *key; - PkGroupEnum group; -}; - -/* - * Mappings between ports directories (as in the first part of PKG_ORIGIN) - * and PackageKit enums. - * - * Some of these mappings are a bit iffy, peer review would be greatly - * appreciated. - * - * These should ALWAYS be in ASCIIbetical order of ports directories. This is - * in case anything relies on this property when searching this list (for - * example binary searching) - */ -static struct group_mapping group_mappings[] = { - {"accessibility", PK_GROUP_ENUM_ACCESSIBILITY}, - {"arabic", PK_GROUP_ENUM_LOCALIZATION}, - {"archivers", PK_GROUP_ENUM_ACCESSORIES}, - {"astro", PK_GROUP_ENUM_SCIENCE}, - {"audio", PK_GROUP_ENUM_MULTIMEDIA}, - {"benchmarks", PK_GROUP_ENUM_PROGRAMMING}, - {"biology", PK_GROUP_ENUM_SCIENCE}, - {"cad", PK_GROUP_ENUM_SCIENCE}, /* dubious */ - {"chinese", PK_GROUP_ENUM_LOCALIZATION}, - {"comms", PK_GROUP_ENUM_COMMUNICATION}, - {"converters", PK_GROUP_ENUM_ACCESSORIES}, /* dubious */ - {"databases", PK_GROUP_ENUM_SERVERS}, /* dubious */ - {"deskutils", PK_GROUP_ENUM_ACCESSORIES}, - {"devel", PK_GROUP_ENUM_PROGRAMMING}, - {"distfiles", PK_GROUP_ENUM_OTHER}, /* ?? */ - {"dns", PK_GROUP_ENUM_NETWORK}, - {"editors", PK_GROUP_ENUM_OFFICE}, /* dubious */ - {"emulators", PK_GROUP_ENUM_OTHER}, /* ?? */ - {"finance", PK_GROUP_ENUM_OFFICE}, /* dubious */ - {"french", PK_GROUP_ENUM_LOCALIZATION}, - {"ftp", PK_GROUP_ENUM_NETWORK}, - {"games", PK_GROUP_ENUM_GAMES}, - {"german", PK_GROUP_ENUM_LOCALIZATION}, - {"graphics", PK_GROUP_ENUM_GRAPHICS}, - {"hebrew", PK_GROUP_ENUM_LOCALIZATION}, - {"hungarian", PK_GROUP_ENUM_LOCALIZATION}, - {"irc", PK_GROUP_ENUM_COMMUNICATION}, - {"japanese", PK_GROUP_ENUM_LOCALIZATION}, - {"java", PK_GROUP_ENUM_PROGRAMMING}, - {"korean", PK_GROUP_ENUM_LOCALIZATION}, - {"lang", PK_GROUP_ENUM_PROGRAMMING}, - {"mail", PK_GROUP_ENUM_COMMUNICATION}, - {"math", PK_GROUP_ENUM_SCIENCE}, - {"misc", PK_GROUP_ENUM_OTHER}, - {"multimedia", PK_GROUP_ENUM_MULTIMEDIA}, - {"net", PK_GROUP_ENUM_NETWORK}, - {"net-im", PK_GROUP_ENUM_COMMUNICATION}, - {"net-mgmt", PK_GROUP_ENUM_NETWORK}, - {"net-p2p", PK_GROUP_ENUM_NETWORK}, /* possibly COMMUNICATION */ - {"news", PK_GROUP_ENUM_COMMUNICATION}, /* ?? */ - {"packages", PK_GROUP_ENUM_OTHER}, /* ?? */ - {"palm", PK_GROUP_ENUM_OTHER}, - {"polish", PK_GROUP_ENUM_LOCALIZATION}, - {"ports-mgmt", PK_GROUP_ENUM_ADMIN_TOOLS}, /* dubious? */ - {"portuguese", PK_GROUP_ENUM_LOCALIZATION}, - {"print", PK_GROUP_ENUM_OFFICE}, /* dubious */ - {"russian", PK_GROUP_ENUM_LOCALIZATION}, - {"science", PK_GROUP_ENUM_SCIENCE}, - {"security", PK_GROUP_ENUM_SECURITY}, - {"shells", PK_GROUP_ENUM_ACCESSORIES}, /* dubious */ - {"sysutils", PK_GROUP_ENUM_ADMIN_TOOLS}, - {"textproc", PK_GROUP_ENUM_PUBLISHING}, /* dubious */ - {"ukrainian", PK_GROUP_ENUM_LOCALIZATION}, - {"vietnamese", PK_GROUP_ENUM_LOCALIZATION}, - {"www", PK_GROUP_ENUM_NETWORK}, /* could be COMMUNICATION? prob. not */ - /* Some of the X directories could be better classified possibly */ - {"x11", PK_GROUP_ENUM_DESKTOP_OTHER}, - {"x11-clocks", PK_GROUP_ENUM_DESKTOP_OTHER}, - {"x11-drivers", PK_GROUP_ENUM_DESKTOP_OTHER}, - {"x11-fm", PK_GROUP_ENUM_DESKTOP_OTHER}, - {"x11-fonts", PK_GROUP_ENUM_FONTS}, - {"x11-servers", PK_GROUP_ENUM_DESKTOP_OTHER}, - {"x11-themes", PK_GROUP_ENUM_DESKTOP_OTHER}, - {"x11-toolkits", PK_GROUP_ENUM_DESKTOP_OTHER}, - {"x11-wm", PK_GROUP_ENUM_DESKTOP_OTHER}, - /* Default (for new/unspecified ports directories) */ - {"", PK_GROUP_ENUM_UNKNOWN} -}; - static PkGroupEnum group_from_port_dir(const char *port_dir); /* Reports the PackageKit groups available on this backend as a bitfield. */ PkBitfield -available_groups(void) +group_bitfield(void) { - int i; + const struct group_mapping *map; PkBitfield bits; bits = 0; - for (i = 0; group_mappings[i].key[0] != '\0'; i++) - pk_bitfield_add(bits, group_mappings[i].group); + for (map = group_mappings; map->key[0] != '\0'; map++) + pk_bitfield_add(bits, map->group); return bits; } -/* Maps from package origins to PackageKit groups. */ +/* + * Maps from package origins to PackageKit groups. + */ PkGroupEnum group_from_origin(const char *origin) { @@ -159,11 +78,65 @@ return group; } -/* Maps from port/origin directories to PackageKit groups. */ +/* + * Constructs an Extended Regular Expression matching any package origins + * that lie within the given group. The regex should be freed using free(3). + */ +char * +group_list_to_origin_regex(unsigned int groupc, PkGroupEnum *groupv) +{ + char *regex; + struct sbuf *sb; + + regex = NULL; + sb = sbuf_new_auto(); + if (sb != NULL) { + bool at_least_one; + unsigned int i; + const struct group_mapping *map; + + at_least_one = false; + + /* (group1|group2|group3|...)/.* */ + (void)sbuf_putc(sb, '('); + + /* Quadratic time, any improvements welcomed */ + for (map = group_mappings; map->key[0] != '\0'; map++) { + for (i = 0; i < groupc; i++) { + if (map->group == groupv[i]) { + if (at_least_one) + (void)sbuf_putc(sb, '|'); + + (void)sbuf_cat(sb, map->key); + + at_least_one = true; + } + } + } + + (void)sbuf_cat(sb, ")/.*"); + + /* + * Invalidate the regex if there were no matching groups. + */ + if (at_least_one == false) + (void)sbuf_clear(sb); + + if (sbuf_finish(sb) == 0) + regex = strdup(sbuf_data(sb)); + + sbuf_delete(sb); + } + return regex; +} + +/* + * Maps from port/origin directories to PackageKit groups. + */ static PkGroupEnum group_from_port_dir(const char *port_dir) { - struct group_mapping *result; + const struct group_mapping *result; assert(port_dir != NULL); Copied and modified: soc2013/mattbw/backend/group.h (from r254454, soc2013/mattbw/backend/groups.h) ============================================================================== --- soc2013/mattbw/backend/groups.h Tue Jul 9 07:29:25 2013 (r254454, copy source) +++ soc2013/mattbw/backend/group.h Wed Jul 10 06:20:16 2013 (r254537) @@ -23,7 +23,8 @@ #include "pk-backend.h" -PkBitfield available_groups(void); +PkBitfield group_bitfield(void); PkGroupEnum group_from_origin(const char *origin); +char * group_list_to_origin_regex(unsigned int groupc, PkGroupEnum *groupv); #endif /* _PKGNG_BACKEND_GROUPS_H_ */ Added: soc2013/mattbw/backend/group_map.awk ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/group_map.awk Wed Jul 10 06:20:16 2013 (r254537) @@ -0,0 +1,17 @@ +#! /usr/bin/awk -f +BEGIN { + print "/* Auto-generated, do not edit directly. Edit 'groups' instead */" + print "#include \"group_map.h\"" + print "const struct group_mapping group_mappings[] = {" +} +{ + sub("#.*$", "", $0); + if (length($0) > 0) { + print "\t{\"" $1 "\", " $2 "},"; + MAP[tolower($1)] = toupper($2); + } +} +END { + print "\t{\"\", PK_GROUP_ENUM_UNKNOWN}"; + print "};"; +} Added: soc2013/mattbw/backend/group_map.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/group_map.h Wed Jul 10 06:20:16 2013 (r254537) @@ -0,0 +1,33 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _PKGNG_BACKEND_GROUP_MAP_H_ +#define _PKGNG_BACKEND_GROUP_MAP_H_ + +#include "pk-backend.h" + +struct group_mapping { + const char *key; + PkGroupEnum group; +}; + +extern const struct group_mapping group_mappings[]; + +#endif /* _PKGNG_BACKEND_GROUP_MAP_H_ */ Added: soc2013/mattbw/backend/groups ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/groups Wed Jul 10 06:20:16 2013 (r254537) @@ -0,0 +1,75 @@ +# $FreeBSD$ +# Mapping from ports directories to PackageKit group enums. +# (See /usr/local/include/PackageKit/packagekit-glib2/pk-enum.h) +# +# This file does not have to be in alphabetical order, but it would help. +# It will be processed into group-map.c during a make. +# +# '#' starts a line comment as usual; any form of whitespace can separate the +# port directory from its group enum. + +# Port dir Group enum Comments +accessibility PK_GROUP_ENUM_ACCESSIBILITY +arabic PK_GROUP_ENUM_LOCALIZATION +archivers PK_GROUP_ENUM_ACCESSORIES +astro PK_GROUP_ENUM_SCIENCE +audio PK_GROUP_ENUM_MULTIMEDIA +benchmarks PK_GROUP_ENUM_PROGRAMMING +biology PK_GROUP_ENUM_SCIENCE +cad PK_GROUP_ENUM_SCIENCE # dubious +chinese PK_GROUP_ENUM_LOCALIZATION +comms PK_GROUP_ENUM_COMMUNICATION +converters PK_GROUP_ENUM_ACCESSORIES # dubious +databases PK_GROUP_ENUM_SERVERS # dubious +deskutils PK_GROUP_ENUM_ACCESSORIES +devel PK_GROUP_ENUM_PROGRAMMING +distfiles PK_GROUP_ENUM_OTHER # ?? +dns PK_GROUP_ENUM_NETWORK +editors PK_GROUP_ENUM_OFFICE # dubious +emulators PK_GROUP_ENUM_OTHER # ?? +finance PK_GROUP_ENUM_OFFICE # dubious +french PK_GROUP_ENUM_LOCALIZATION +ftp PK_GROUP_ENUM_NETWORK +games PK_GROUP_ENUM_GAMES +german PK_GROUP_ENUM_LOCALIZATION +graphics PK_GROUP_ENUM_GRAPHICS +hebrew PK_GROUP_ENUM_LOCALIZATION +hungarian PK_GROUP_ENUM_LOCALIZATION +irc PK_GROUP_ENUM_COMMUNICATION +japanese PK_GROUP_ENUM_LOCALIZATION +java PK_GROUP_ENUM_PROGRAMMING +korean PK_GROUP_ENUM_LOCALIZATION +lang PK_GROUP_ENUM_PROGRAMMING +mail PK_GROUP_ENUM_COMMUNICATION +math PK_GROUP_ENUM_SCIENCE +misc PK_GROUP_ENUM_OTHER +multimedia PK_GROUP_ENUM_MULTIMEDIA +net PK_GROUP_ENUM_NETWORK +net-im PK_GROUP_ENUM_COMMUNICATION +net-mgmt PK_GROUP_ENUM_NETWORK +net-p2p PK_GROUP_ENUM_NETWORK # possibly COMMUNICATION +news PK_GROUP_ENUM_COMMUNICATION # ?? +packages PK_GROUP_ENUM_OTHER # ?? +palm PK_GROUP_ENUM_OTHER +polish PK_GROUP_ENUM_LOCALIZATION +ports-mgmt PK_GROUP_ENUM_ADMIN_TOOLS # dubious? +portuguese PK_GROUP_ENUM_LOCALIZATION +print PK_GROUP_ENUM_OFFICE # dubious +russian PK_GROUP_ENUM_LOCALIZATION +science PK_GROUP_ENUM_SCIENCE +security PK_GROUP_ENUM_SECURITY +shells PK_GROUP_ENUM_ACCESSORIES # dubious +sysutils PK_GROUP_ENUM_ADMIN_TOOLS +textproc PK_GROUP_ENUM_PUBLISHING # dubious +ukrainian PK_GROUP_ENUM_LOCALIZATION +vietnamese PK_GROUP_ENUM_LOCALIZATION +www PK_GROUP_ENUM_NETWORK # could be COMMUNICATION +x11 PK_GROUP_ENUM_DESKTOP_OTHER +x11-clocks PK_GROUP_ENUM_DESKTOP_OTHER +x11-drivers PK_GROUP_ENUM_DESKTOP_OTHER +x11-fm PK_GROUP_ENUM_DESKTOP_OTHER +x11-fonts PK_GROUP_ENUM_FONTS +x11-servers PK_GROUP_ENUM_DESKTOP_OTHER +x11-themes PK_GROUP_ENUM_DESKTOP_OTHER +x11-toolkits PK_GROUP_ENUM_DESKTOP_OTHER +x11-wm PK_GROUP_ENUM_DESKTOP_OTHER Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Wed Jul 10 04:59:10 2013 (r254536) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Wed Jul 10 06:20:16 2013 (r254537) @@ -28,12 +28,9 @@ #include "pkg.h" #include "utils.h" /* INTENTIONALLY_IGNORE */ -#include "groups.h" /* available_groups */ +#include "group.h" /* group_bitfield */ #include "actions.h" /* Actions threads */ -/** - * pk_backend_initialize: - */ void pk_backend_initialize(PkBackend *backend) { @@ -49,9 +46,6 @@ "could not initialise pkg"); } -/** - * pk_backend_destroy: - */ void pk_backend_destroy(PkBackend *backend) { @@ -124,7 +118,7 @@ { INTENTIONALLY_IGNORE(backend); - return available_groups(); + return group_bitfield(); } gchar * Added: soc2013/mattbw/backend/query/.indent.pro ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/query/.indent.pro Wed Jul 10 06:20:16 2013 (r254537) @@ -0,0 +1,7 @@ +-TPkBackend +-Tgchar +-Tgboolean +-Tbool +-sob +-nlp +-ci4 From owner-svn-soc-all@FreeBSD.ORG Wed Jul 10 11:04:26 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 54ECAAD6 for ; Wed, 10 Jul 2013 11:04:26 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 2D3D51478 for ; Wed, 10 Jul 2013 11:04:26 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AB4Q6W077495 for ; Wed, 10 Jul 2013 11:04:26 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6AB4QIZ077484 for svn-soc-all@FreeBSD.org; Wed, 10 Jul 2013 11:04:26 GMT (envelope-from mattbw@FreeBSD.org) Date: Wed, 10 Jul 2013 11:04:26 GMT Message-Id: <201307101104.r6AB4QIZ077484@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254554 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 11:04:26 -0000 Author: mattbw Date: Wed Jul 10 11:04:25 2013 New Revision: 254554 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254554 Log: implement search_groups Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions.h soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Wed Jul 10 10:57:09 2013 (r254553) +++ soc2013/mattbw/backend/Makefile Wed Jul 10 11:04:25 2013 (r254554) @@ -17,6 +17,7 @@ actions/install_files.c \ actions/install_packages.c \ actions/resolve.c \ + actions/search_groups.c \ actions/search_names.c SRCS+= \ Modified: soc2013/mattbw/backend/actions.h ============================================================================== --- soc2013/mattbw/backend/actions.h Wed Jul 10 10:57:09 2013 (r254553) +++ soc2013/mattbw/backend/actions.h Wed Jul 10 11:04:25 2013 (r254554) @@ -34,6 +34,7 @@ gboolean install_files_thread(PkBackend *backend); gboolean install_packages_thread(PkBackend *backend); gboolean resolve_thread(PkBackend *backend); +gboolean search_groups_thread(PkBackend *backend); gboolean search_names_thread(PkBackend *backend); gboolean simulate_install_files_thread(PkBackend *backend); gboolean simulate_install_packages_thread(PkBackend *backend); Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Wed Jul 10 10:57:09 2013 (r254553) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Wed Jul 10 11:04:25 2013 (r254554) @@ -175,6 +175,15 @@ } void +pk_backend_search_groups(PkBackend *backend, PkBitfield filters, gchar **values) +{ + + INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ + (void)pk_backend_set_strv(backend, "values", values); + (void)pk_backend_thread_create(backend, search_groups_thread); +} + +void pk_backend_search_names(PkBackend *backend, PkBitfield filters, gchar **values) { @@ -183,7 +192,6 @@ (void)pk_backend_thread_create(backend, search_names_thread); } - void pk_backend_simulate_install_files(PkBackend *backend, gchar **full_paths) { From owner-svn-soc-all@FreeBSD.ORG Wed Jul 10 15:13:13 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 56D10A0C for ; Wed, 10 Jul 2013 15:13:13 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 495651604 for ; Wed, 10 Jul 2013 15:13:13 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AFDDeK041653 for ; Wed, 10 Jul 2013 15:13:13 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6AFDDfO041649 for svn-soc-all@FreeBSD.org; Wed, 10 Jul 2013 15:13:13 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 10 Jul 2013 15:13:13 GMT Message-Id: <201307101513.r6AFDDfO041649@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254563 - soc2013/dpl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 15:13:13 -0000 Author: dpl Date: Wed Jul 10 15:13:13 2013 New Revision: 254563 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254563 Log: Adding function passing functions. Modified: soc2013/dpl/functions.c Modified: soc2013/dpl/functions.c ============================================================================== --- soc2013/dpl/functions.c Wed Jul 10 14:16:39 2013 (r254562) +++ soc2013/dpl/functions.c Wed Jul 10 15:13:13 2013 (r254563) @@ -43,4 +43,67 @@ exit(E_ERROR); } return; +} + +#define DATALEN CMSG_LEN(sizeof(int)) + +int +sendfd(int s, int fd) +{ + printf("sendfd sending: %d\n", fd); + struct msghdr msg; + struct cmsghdr *cmsg; + struct iovec io[1]; + char buf[1] = { "!" }; + int ret; + + io[0].iov_base = buf; + io[0].iov_len = 1; + + if( (cmsg = malloc(DATALEN)) == NULL ) + return -1; + + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iov = io; + msg.msg_iovlen = 1; + msg.msg_control =cmsg; + msg.msg_controllen = DATALEN; + + cmsg->cmsg_len = DATALEN; + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + *(int *)CMSG_DATA(cmsg) = fd; + if( (ret = sendmsg(s, &msg, 0)) <= 0) + return -1; + free(cmsg); + return 0; +} + +int +recvfd(int s) +{ + int fd; + struct msghdr msg; + struct cmsghdr cmsg; + char buf[1] = { "!" }; + struct iovec io[1]; + + io[0].iov_base = buf; + io[0].iov_len = 1; + + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iov = io; + msg.msg_iovlen = 1; + msg.msg_control = &cmsg; + msg.msg_controllen = DATALEN; + + cmsg.cmsg_len = DATALEN; + cmsg.cmsg_level = SOL_SOCKET; + cmsg.cmsg_type = SCM_RIGHTS; + if(recvmsg(s, &msg, 0) < 0) + return -1; + fd = *(int *)CMSG_DATA(&cmsg); + return 0; } \ No newline at end of file From owner-svn-soc-all@FreeBSD.ORG Wed Jul 10 15:14:23 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 65D4CA3F for ; Wed, 10 Jul 2013 15:14:23 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 584131614 for ; Wed, 10 Jul 2013 15:14:23 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AFENoo049793 for ; Wed, 10 Jul 2013 15:14:23 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6AFENEx049779 for svn-soc-all@FreeBSD.org; Wed, 10 Jul 2013 15:14:23 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 10 Jul 2013 15:14:23 GMT Message-Id: <201307101514.r6AFENEx049779@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254564 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 15:14:23 -0000 Author: dpl Date: Wed Jul 10 15:14:23 2013 New Revision: 254564 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254564 Log: Adhere to the preprocessor style. Modified: soc2013/dpl/head/contrib/xz/src/xz/private.h Modified: soc2013/dpl/head/contrib/xz/src/xz/private.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/private.h Wed Jul 10 15:13:13 2013 (r254563) +++ soc2013/dpl/head/contrib/xz/src/xz/private.h Wed Jul 10 15:14:23 2013 (r254564) @@ -27,7 +27,7 @@ #include "tuklib_exit.h" #include "tuklib_mbstr.h" -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) # include # if __FreeBSD_version >= 900041 # define CAPSICUM From owner-svn-soc-all@FreeBSD.ORG Wed Jul 10 15:17:22 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4ABA2BF4 for ; Wed, 10 Jul 2013 15:17:22 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 3CD5E165D for ; Wed, 10 Jul 2013 15:17:22 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AFHMtM086315 for ; Wed, 10 Jul 2013 15:17:22 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6AFHM8E086310 for svn-soc-all@FreeBSD.org; Wed, 10 Jul 2013 15:17:22 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 10 Jul 2013 15:17:22 GMT Message-Id: <201307101517.r6AFHM8E086310@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254565 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 15:17:22 -0000 Author: dpl Date: Wed Jul 10 15:17:22 2013 New Revision: 254565 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254565 Log: Adhere to preprocessor style, and save to make some code changes. Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/coder.c Wed Jul 10 15:14:23 2013 (r254564) +++ soc2013/dpl/head/contrib/xz/src/xz/coder.c Wed Jul 10 15:17:22 2013 (r254565) @@ -12,7 +12,6 @@ #include "private.h" - /// Return value type for coder_init(). enum coder_init_ret { CODER_INIT_NORMAL, @@ -641,9 +640,9 @@ // Don't open the destination file when --test // is used. if (opt_mode == MODE_TEST || !io_open_dest(pair)) { -# if defined(CAPSICUM) // +#if defined(CAPSICUM) limitfd(pair); -# endif +#endif // Initialize the progress indicator. const uint64_t in_size = pair->src_st.st_size <= 0 @@ -666,4 +665,6 @@ io_close(pair, success); return; + + } From owner-svn-soc-all@FreeBSD.ORG Wed Jul 10 15:18:45 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8FE52C35 for ; Wed, 10 Jul 2013 15:18:45 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 8213F166D for ; Wed, 10 Jul 2013 15:18:45 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AFIjM9007606 for ; Wed, 10 Jul 2013 15:18:45 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6AFIjgD007600 for svn-soc-all@FreeBSD.org; Wed, 10 Jul 2013 15:18:45 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 10 Jul 2013 15:18:45 GMT Message-Id: <201307101518.r6AFIjgD007600@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254566 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 15:18:45 -0000 Author: dpl Date: Wed Jul 10 15:18:45 2013 New Revision: 254566 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254566 Log: Limit std fds. Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.c Wed Jul 10 15:17:22 2013 (r254565) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.c Wed Jul 10 15:18:45 2013 (r254566) @@ -604,7 +604,9 @@ free(pair->dest_name); return true; } +#if defined(CAPSICUM) limitfd(pair); +#endif } // If this really fails... well, we have a safe fallback. @@ -981,16 +983,29 @@ extern void cap_init(void) { - if (cap_rights_limit(STDIN_FILENO, CAP_READ) < 0 && errno != ENOSYS){ + cap_rights_t *rights; + + if( cap_rights_get(STDIN_FILENO, rights) < 0) { message_error("%d: %s", STDIN_FILENO, strerror(errno)); exit(E_ERROR); + } else if (*rights == 0) { + if (cap_rights_limit(STDIN_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ + message_error("%d: %s", STDIN_FILENO, strerror(errno)); + exit(E_ERROR); + } } - if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ + if( cap_rights_get(STDOUT_FILENO, rights) < 0) { message_error("%d: %s", STDOUT_FILENO, strerror(errno)); exit(E_ERROR); + } else if (*rights == 0) { + if (cap_rights_limit(STDOUT_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ + message_error("%d: %s", STDOUT_FILENO, strerror(errno)); + exit(E_ERROR); + } } + if (cap_rights_limit(STDERR_FILENO, CAP_WRITE) < 0 && errno != ENOSYS){ message_error("%d: %s", STDERR_FILENO, strerror(errno)); exit(E_ERROR); @@ -1000,6 +1015,7 @@ message_error("cap_enter: %s", strerror(errno)); exit(E_ERROR); } + return; } #endif From owner-svn-soc-all@FreeBSD.ORG Wed Jul 10 15:22:43 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 664C0F34 for ; Wed, 10 Jul 2013 15:22:43 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 5843016C1 for ; Wed, 10 Jul 2013 15:22:43 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AFMhvm090122 for ; Wed, 10 Jul 2013 15:22:43 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6AFMhvs090117 for svn-soc-all@FreeBSD.org; Wed, 10 Jul 2013 15:22:43 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 10 Jul 2013 15:22:43 GMT Message-Id: <201307101522.r6AFMhvs090117@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254567 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 15:22:43 -0000 Author: dpl Date: Wed Jul 10 15:22:43 2013 New Revision: 254567 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254567 Log: Declaration of a pointer to struct that will be used in future changes. Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.h Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.h Wed Jul 10 15:18:45 2013 (r254566) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.h Wed Jul 10 15:22:43 2013 (r254567) @@ -63,6 +63,8 @@ } file_pair; +/// All the opened files. +file_pair *all_pairs; /// \brief Initialize the I/O module extern void io_init(void); @@ -128,13 +130,12 @@ /// and error message printed. extern bool io_write(file_pair *pair, const io_buf *buf, size_t size); - #if defined(CAPSICUM) /// \brief Limits fd using FreeBSD's Capsicum framework. /// /// \param fd File descriptor to limit. extern void limitfd(file_pair *pair); -/// \brief Enters Capability mode, and limit stdin, stdout & stderr. +/// \brief Enters Capability mode, and limit basic fds. extern void cap_init(void); #endif From owner-svn-soc-all@FreeBSD.ORG Wed Jul 10 15:23:54 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A8ECBE5 for ; Wed, 10 Jul 2013 15:23:54 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 9B1B016D9 for ; Wed, 10 Jul 2013 15:23:54 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AFNsLI004168 for ; Wed, 10 Jul 2013 15:23:54 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6AFNscj004163 for svn-soc-all@FreeBSD.org; Wed, 10 Jul 2013 15:23:54 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 10 Jul 2013 15:23:54 GMT Message-Id: <201307101523.r6AFNscj004163@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254568 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 15:23:54 -0000 Author: dpl Date: Wed Jul 10 15:23:54 2013 New Revision: 254568 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254568 Log: A silly error got corrected. Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/main.c Wed Jul 10 15:22:43 2013 (r254567) +++ soc2013/dpl/head/contrib/xz/src/xz/main.c Wed Jul 10 15:23:54 2013 (r254568) @@ -210,10 +210,6 @@ void (*run)(const char *filename) = opt_mode == MODE_LIST ? &list_file : &coder_run; -#if defined(CAPSICUM) // - cap_init(); -#endif - // Process the files given on the command line. Note that if no names // were given, args_parse() gave us a fake "-" filename. for (size_t i = 0; i < args.arg_count && !user_abort; ++i) { @@ -246,11 +242,11 @@ // handling the special case of stdin. args.arg_names[i] = (char *)stdin_filename; } - - // Do the actual compression or decompression. - (args.arg_names[i]); } + // Do the actual compression or decompression. + run(args.arg_names); + // If --files or --files0 was used, process the filenames from the // given file or stdin. Note that here we don't consider "-" to // indicate stdin like we do with the command line arguments. From owner-svn-soc-all@FreeBSD.ORG Wed Jul 10 15:37:59 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8F2C1755 for ; Wed, 10 Jul 2013 15:37:59 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 811371802 for ; Wed, 10 Jul 2013 15:37:59 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AFbxlP097806 for ; Wed, 10 Jul 2013 15:37:59 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6AFbxbZ097801 for svn-soc-all@FreeBSD.org; Wed, 10 Jul 2013 15:37:59 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 10 Jul 2013 15:37:59 GMT Message-Id: <201307101537.r6AFbxbZ097801@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254569 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 15:37:59 -0000 Author: dpl Date: Wed Jul 10 15:37:59 2013 New Revision: 254569 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254569 Log: We don't need this here. We will just declare the array dynamically when we know the number of files to use. Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.h Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.h Wed Jul 10 15:23:54 2013 (r254568) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.h Wed Jul 10 15:37:59 2013 (r254569) @@ -63,8 +63,6 @@ } file_pair; -/// All the opened files. -file_pair *all_pairs; /// \brief Initialize the I/O module extern void io_init(void); From owner-svn-soc-all@FreeBSD.ORG Wed Jul 10 21:28:47 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D09F887A for ; Wed, 10 Jul 2013 21:28:47 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A23DA1CBD for ; Wed, 10 Jul 2013 21:28:47 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6ALSlDm098338 for ; Wed, 10 Jul 2013 21:28:47 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6ALSlRC098334 for svn-soc-all@FreeBSD.org; Wed, 10 Jul 2013 21:28:47 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 10 Jul 2013 21:28:47 GMT Message-Id: <201307102128.r6ALSlRC098334@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254583 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 21:28:47 -0000 Author: dpl Date: Wed Jul 10 21:28:47 2013 New Revision: 254583 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254583 Log: Start changing coder_run to handle all the files needed so that we can call cap_init() after opening everything. Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c soc2013/dpl/head/contrib/xz/src/xz/coder.h soc2013/dpl/head/contrib/xz/src/xz/main.c Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/coder.c Wed Jul 10 20:56:04 2013 (r254582) +++ soc2013/dpl/head/contrib/xz/src/xz/coder.c Wed Jul 10 21:28:47 2013 (r254583) @@ -609,8 +609,9 @@ extern void -coder_run(const char *filename) +coder_run(const char *filename[], int files) { + file_pair all_files // Set and possibly print the filename for the progress message. message_filename(filename); Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/coder.h Wed Jul 10 20:56:04 2013 (r254582) +++ soc2013/dpl/head/contrib/xz/src/xz/coder.h Wed Jul 10 21:28:47 2013 (r254583) @@ -58,4 +58,4 @@ extern void coder_set_compression_settings(void); /// Compress or decompress the given file -extern void coder_run(const char *filename); +extern void coder_run(const char *filename[], int files); Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/main.c Wed Jul 10 20:56:04 2013 (r254582) +++ soc2013/dpl/head/contrib/xz/src/xz/main.c Wed Jul 10 21:28:47 2013 (r254583) @@ -142,6 +142,8 @@ int main(int argc, char **argv) { + int files = 0; + #if defined(_WIN32) && !defined(__CYGWIN__) InitializeCriticalSection(&exit_status_cs); #endif @@ -241,11 +243,10 @@ // string and the code still knows that it is // handling the special case of stdin. args.arg_names[i] = (char *)stdin_filename; + files++; } } - - // Do the actual compression or decompression. - run(args.arg_names); + run(args.arg_names, files); // If --files or --files0 was used, process the filenames from the // given file or stdin. Note that here we don't consider "-" to From owner-svn-soc-all@FreeBSD.ORG Thu Jul 11 03:59:03 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9B452D18 for ; Thu, 11 Jul 2013 03:59:03 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 7F48B1E8E for ; Thu, 11 Jul 2013 03:59:03 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B3x3CE025240 for ; Thu, 11 Jul 2013 03:59:03 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6B3x39R025236 for svn-soc-all@FreeBSD.org; Thu, 11 Jul 2013 03:59:03 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 11 Jul 2013 03:59:03 GMT Message-Id: <201307110359.r6B3x39R025236@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254592 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 03:59:03 -0000 Author: mattbw Date: Thu Jul 11 03:59:02 2013 New Revision: 254592 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254592 Log: attempt to use first category instead of port directory for package groups Modified: soc2013/mattbw/backend/actions/get_details.c soc2013/mattbw/backend/group.c soc2013/mattbw/backend/group.h Modified: soc2013/mattbw/backend/actions/get_details.c ============================================================================== --- soc2013/mattbw/backend/actions/get_details.c Thu Jul 11 02:10:23 2013 (r254591) +++ soc2013/mattbw/backend/actions/get_details.c Thu Jul 11 03:59:02 2013 (r254592) @@ -55,7 +55,6 @@ { bool success; const char *description; - const char *origin; const char *www; int64_t flatsize; guint flatsize_u; @@ -63,12 +62,11 @@ query_set_percentage(q, 0); /* Information not already part of the PackageID */ - description = origin = www = NULL; + description = www = NULL; flatsize = 0; pkg_get(pkg, PKG_DESC, &description, PKG_FLATSIZE, &flatsize, - PKG_ORIGIN, &origin, PKG_WWW, &www); flatsize_u = (guint)CLAMP(flatsize, 0, G_MAXUINT); @@ -76,7 +74,7 @@ success = pk_backend_details(query_backend(q), id, license_name_from_pkg(pkg), - group_from_origin(origin), + group_of_pkg(pkg), description, www, flatsize_u) == TRUE; Modified: soc2013/mattbw/backend/group.c ============================================================================== --- soc2013/mattbw/backend/group.c Thu Jul 11 02:10:23 2013 (r254591) +++ soc2013/mattbw/backend/group.c Thu Jul 11 03:59:02 2013 (r254592) @@ -21,11 +21,11 @@ #include /* assert */ #include /* bool, true, false */ #include /* NULL */ -#include /* strchr, strdup */ +#include /* strchr, strcmp, strdup */ #include /* struct sbuf, sbuf_... */ -#include "glib.h" /* g_strcmp0 */ #include "pk-backend.h" /* PkGroupEnum, PK_... */ +#include "pkg.h" /* pkg_... */ #include "group_map.h" /* group_mappings */ #include "group.h" /* group_... */ @@ -66,7 +66,7 @@ /* * Is this a valid origin (did it have a separator)? If not, we want - * the default group. If so, then the number of chars between the + * the default group. If so, then the number of chars between the * origin start and the separator mark the port directory name we * want to use. */ @@ -79,6 +79,42 @@ } /* + * Maps from packages to PackageKit groups. PKG_LOAD_CATEGORIES must have been + * set whilst loading the package for this to work properly. + */ +PkGroupEnum +group_of_pkg(struct pkg *pkg) +{ + PkGroupEnum group; + struct pkg_category *category; + + assert(pkg != NULL); + + /* Default failure state group. */ + group = PK_GROUP_ENUM_UNKNOWN; + + /* Take the first category only. */ + category = NULL; + if (pkg_categories(pkg, &category) == EPKG_OK) { + assert(category != NULL); + + group = group_from_port_dir(pkg_category_name(category)); + } else { + const char *origin; + + /* Fallback to checking the origin. */ + origin = NULL; + if (pkg_get(pkg, PKG_ORIGIN, &origin) == EPKG_OK) { + assert(origin != NULL); + + group = group_from_origin(origin); + } + } + + return group; +} + +/* * Constructs an Extended Regular Expression matching any package origins * that lie within the given group. The regex should be freed using free(3). */ Modified: soc2013/mattbw/backend/group.h ============================================================================== --- soc2013/mattbw/backend/group.h Thu Jul 11 02:10:23 2013 (r254591) +++ soc2013/mattbw/backend/group.h Thu Jul 11 03:59:02 2013 (r254592) @@ -22,9 +22,11 @@ #define _PKGNG_BACKEND_GROUPS_H_ #include "pk-backend.h" +#include "pkg.h" PkBitfield group_bitfield(void); PkGroupEnum group_from_origin(const char *origin); +PkGroupEnum group_of_pkg(struct pkg *pkg); char * group_list_to_origin_regex(unsigned int groupc, PkGroupEnum *groupv); #endif /* _PKGNG_BACKEND_GROUPS_H_ */ From owner-svn-soc-all@FreeBSD.ORG Thu Jul 11 04:01:45 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 47991E27 for ; Thu, 11 Jul 2013 04:01:45 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 39EC41EA5 for ; Thu, 11 Jul 2013 04:01:45 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B41iMZ069706 for ; Thu, 11 Jul 2013 04:01:44 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6B41iB1069695 for svn-soc-all@FreeBSD.org; Thu, 11 Jul 2013 04:01:44 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 11 Jul 2013 04:01:44 GMT Message-Id: <201307110401.r6B41iB1069695@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254597 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 04:01:45 -0000 Author: mattbw Date: Thu Jul 11 04:01:44 2013 New Revision: 254597 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254597 Log: also use origin mapping if categories exist but could not be mapped Modified: soc2013/mattbw/backend/group.c Modified: soc2013/mattbw/backend/group.c ============================================================================== --- soc2013/mattbw/backend/group.c Thu Jul 11 03:57:53 2013 (r254596) +++ soc2013/mattbw/backend/group.c Thu Jul 11 04:01:44 2013 (r254597) @@ -99,10 +99,12 @@ assert(category != NULL); group = group_from_port_dir(pkg_category_name(category)); - } else { + } + + /* Fallback to checking the origin if category mapping failed. */ + if (group == PK_GROUP_ENUM_UNKNOWN) { const char *origin; - /* Fallback to checking the origin. */ origin = NULL; if (pkg_get(pkg, PKG_ORIGIN, &origin) == EPKG_OK) { assert(origin != NULL); From owner-svn-soc-all@FreeBSD.ORG Thu Jul 11 07:11:48 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C39B082B for ; Thu, 11 Jul 2013 07:11:48 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A449E16E5 for ; Thu, 11 Jul 2013 07:11:48 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B7BmmK012038 for ; Thu, 11 Jul 2013 07:11:48 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6B7Bmrk012034 for svn-soc-all@FreeBSD.org; Thu, 11 Jul 2013 07:11:48 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 11 Jul 2013 07:11:48 GMT Message-Id: <201307110711.r6B7Bmrk012034@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254608 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 07:11:48 -0000 Author: mattbw Date: Thu Jul 11 07:11:48 2013 New Revision: 254608 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254608 Log: use bsearch for finding group mapping Modified: soc2013/mattbw/backend/group.c soc2013/mattbw/backend/group_map.awk soc2013/mattbw/backend/group_map.h Modified: soc2013/mattbw/backend/group.c ============================================================================== --- soc2013/mattbw/backend/group.c Thu Jul 11 06:48:53 2013 (r254607) +++ soc2013/mattbw/backend/group.c Thu Jul 11 07:11:48 2013 (r254608) @@ -32,18 +32,19 @@ static const char ORIGIN_SEPARATOR = '/'; +static int map_compare(const void *key, const void *mapping); static PkGroupEnum group_from_port_dir(const char *port_dir); /* Reports the PackageKit groups available on this backend as a bitfield. */ PkBitfield group_bitfield(void) { - const struct group_mapping *map; + size_t i; PkBitfield bits; bits = 0; - for (map = group_mappings; map->key[0] != '\0'; map++) - pk_bitfield_add(bits, map->group); + for (i = 0; i < num_group_mappings; i++) + pk_bitfield_add(bits, group_mappings[i].group); return bits; } @@ -79,13 +80,13 @@ } /* - * Maps from packages to PackageKit groups. PKG_LOAD_CATEGORIES must have been - * set whilst loading the package for this to work properly. + * Maps from packages to PackageKit groups. PKG_LOAD_CATEGORIES must have + * been set whilst loading the package for this to work properly. */ PkGroupEnum group_of_pkg(struct pkg *pkg) { - PkGroupEnum group; + PkGroupEnum group; struct pkg_category *category; assert(pkg != NULL); @@ -100,11 +101,10 @@ group = group_from_port_dir(pkg_category_name(category)); } - - /* Fallback to checking the origin if category mapping failed. */ + /* Fall back to checking the origin if category mapping failed. */ if (group == PK_GROUP_ENUM_UNKNOWN) { - const char *origin; - + const char *origin; + origin = NULL; if (pkg_get(pkg, PKG_ORIGIN, &origin) == EPKG_OK) { assert(origin != NULL); @@ -112,7 +112,6 @@ group = group_from_origin(origin); } } - return group; } @@ -168,6 +167,13 @@ return regex; } +static int +map_compare(const void *key, const void *mapping) +{ + return strcmp((const char *)key, + ((const struct group_mapping *)mapping)->key); +} + /* * Maps from port/origin directories to PackageKit groups. */ @@ -178,9 +184,10 @@ assert(port_dir != NULL); - for (result = group_mappings; - result->key[0] != '\0' && strcmp(result->key, port_dir) != 0; - result++); - - return result->group; + result = bsearch(port_dir, + group_mappings, + num_group_mappings, + sizeof(struct group_mapping), + map_compare); + return (result == NULL ? PK_GROUP_ENUM_UNKNOWN : result->group); } Modified: soc2013/mattbw/backend/group_map.awk ============================================================================== --- soc2013/mattbw/backend/group_map.awk Thu Jul 11 06:48:53 2013 (r254607) +++ soc2013/mattbw/backend/group_map.awk Thu Jul 11 07:11:48 2013 (r254608) @@ -3,15 +3,16 @@ print "/* Auto-generated, do not edit directly. Edit 'groups' instead */" print "#include \"group_map.h\"" print "const struct group_mapping group_mappings[] = {" + COUNT = 0; } { sub("#.*$", "", $0); if (length($0) > 0) { print "\t{\"" $1 "\", " $2 "},"; - MAP[tolower($1)] = toupper($2); + COUNT++; } } END { - print "\t{\"\", PK_GROUP_ENUM_UNKNOWN}"; print "};"; + print "const size_t num_group_mappings = " COUNT ";"; } Modified: soc2013/mattbw/backend/group_map.h ============================================================================== --- soc2013/mattbw/backend/group_map.h Thu Jul 11 06:48:53 2013 (r254607) +++ soc2013/mattbw/backend/group_map.h Thu Jul 11 07:11:48 2013 (r254608) @@ -29,5 +29,6 @@ }; extern const struct group_mapping group_mappings[]; +extern const size_t num_group_mappings; #endif /* _PKGNG_BACKEND_GROUP_MAP_H_ */ From owner-svn-soc-all@FreeBSD.ORG Thu Jul 11 08:56:49 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C7B56E5A for ; Thu, 11 Jul 2013 08:56:49 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id B89371BDC for ; Thu, 11 Jul 2013 08:56:49 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6B8un6s018251 for ; Thu, 11 Jul 2013 08:56:49 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6B8unpO018243 for svn-soc-all@FreeBSD.org; Thu, 11 Jul 2013 08:56:49 GMT (envelope-from dpl@FreeBSD.org) Date: Thu, 11 Jul 2013 08:56:49 GMT Message-Id: <201307110856.r6B8unpO018243@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254611 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 08:56:49 -0000 Author: dpl Date: Thu Jul 11 08:56:49 2013 New Revision: 254611 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254611 Log: Prepare everything to write io_files_open(). Which will open all the files as needed, and limit them. The compressing/decompressing functions will accept file_pair as arguments instead (instead of opening files and doing the stuff). Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c soc2013/dpl/head/contrib/xz/src/xz/coder.h soc2013/dpl/head/contrib/xz/src/xz/file_io.c soc2013/dpl/head/contrib/xz/src/xz/file_io.h soc2013/dpl/head/contrib/xz/src/xz/list.c soc2013/dpl/head/contrib/xz/src/xz/main.c Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/coder.c Thu Jul 11 07:17:03 2013 (r254610) +++ soc2013/dpl/head/contrib/xz/src/xz/coder.c Thu Jul 11 08:56:49 2013 (r254611) @@ -609,9 +609,8 @@ extern void -coder_run(const char *filename[], int files) +coder_run(const char *filename) { - file_pair all_files // Set and possibly print the filename for the progress message. message_filename(filename); @@ -641,9 +640,6 @@ // Don't open the destination file when --test // is used. if (opt_mode == MODE_TEST || !io_open_dest(pair)) { -#if defined(CAPSICUM) - limitfd(pair); -#endif // Initialize the progress indicator. const uint64_t in_size = pair->src_st.st_size <= 0 Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/coder.h Thu Jul 11 07:17:03 2013 (r254610) +++ soc2013/dpl/head/contrib/xz/src/xz/coder.h Thu Jul 11 08:56:49 2013 (r254611) @@ -58,4 +58,4 @@ extern void coder_set_compression_settings(void); /// Compress or decompress the given file -extern void coder_run(const char *filename[], int files); +extern void coder_run(const char *filename); Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.c Thu Jul 11 07:17:03 2013 (r254610) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.c Thu Jul 11 08:56:49 2013 (r254611) @@ -604,9 +604,6 @@ free(pair->dest_name); return true; } -#if defined(CAPSICUM) - limitfd(pair); -#endif } // If this really fails... well, we have a safe fallback. @@ -959,6 +956,12 @@ return io_write_buf(pair, buf->u8, size); } +extern file_pair +io_open_files(char *filenames[], int files) +{ + return; +} + #if defined(CAPSICUM) extern void limitfd(file_pair *pair) Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/file_io.h Thu Jul 11 07:17:03 2013 (r254610) +++ soc2013/dpl/head/contrib/xz/src/xz/file_io.h Thu Jul 11 08:56:49 2013 (r254611) @@ -128,6 +128,16 @@ /// and error message printed. extern bool io_write(file_pair *pair, const io_buf *buf, size_t size); + +/// \brief Open all the files as needed. +/// +/// \param filenames Array containing all the filenames to be open. +/// \param files Number of files to open. +/// +/// \return Returns an array of file_pairs. +extern file_pair io_open_files(char *filenames[], int files); + + #if defined(CAPSICUM) /// \brief Limits fd using FreeBSD's Capsicum framework. /// Modified: soc2013/dpl/head/contrib/xz/src/xz/list.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/list.c Thu Jul 11 07:17:03 2013 (r254610) +++ soc2013/dpl/head/contrib/xz/src/xz/list.c Thu Jul 11 08:56:49 2013 (r254611) @@ -1059,16 +1059,20 @@ extern void list_file(const char *filename) { + int i; + if (opt_format != FORMAT_XZ && opt_format != FORMAT_AUTO) message_fatal(_("--list works only on .xz files " "(--format=xz or --format=auto)")); + for ( i = 0; i < files; i++) { + message_filename(filename); if (filename == stdin_filename) { message_error(_("--list does not support reading from " "standard input")); - return; + continue; } // Unset opt_stdout so that io_open_src() won't accept special files. @@ -1077,7 +1081,7 @@ opt_force = true; file_pair *pair = io_open_src(filename); if (pair == NULL) - return; + continue; xz_file_info xfi = XZ_FILE_INFO_INIT; if (!parse_indexes(&xfi, pair)) { Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/main.c Thu Jul 11 07:17:03 2013 (r254610) +++ soc2013/dpl/head/contrib/xz/src/xz/main.c Thu Jul 11 08:56:49 2013 (r254611) @@ -208,7 +208,8 @@ signals_init(); // coder_run() handles compression, decompression, and testing. - // list_file() is for --list. + // list_file() is for --list. + // We have to limit both functions with Capsicum. void (*run)(const char *filename) = opt_mode == MODE_LIST ? &list_file : &coder_run; @@ -244,9 +245,12 @@ // handling the special case of stdin. args.arg_names[i] = (char *)stdin_filename; files++; + +/* // Do the actual compression/decompression.*/ +/* run(args.arg_names[i]);*/ } } - run(args.arg_names, files); + // If --files or --files0 was used, process the filenames from the // given file or stdin. Note that here we don't consider "-" to From owner-svn-soc-all@FreeBSD.ORG Thu Jul 11 13:56:52 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7AC51D03 for ; Thu, 11 Jul 2013 13:56:52 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 6AF1F1F03 for ; Thu, 11 Jul 2013 13:56:52 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BDuq9R086178 for ; Thu, 11 Jul 2013 13:56:52 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6BDuqAn086176 for svn-soc-all@FreeBSD.org; Thu, 11 Jul 2013 13:56:52 GMT (envelope-from jmuniz@FreeBSD.org) Date: Thu, 11 Jul 2013 13:56:52 GMT Message-Id: <201307111356.r6BDuqAn086176@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254625 - soc2013/jmuniz/PackageKit-Setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 13:56:52 -0000 Author: jmuniz Date: Thu Jul 11 13:56:52 2013 New Revision: 254625 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254625 Log: Corrected the usage of the sed command, fixing the bug that wiped out the configuration file when it should have updated it. Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter ============================================================================== --- soc2013/jmuniz/PackageKit-Setter/pk-setter Thu Jul 11 12:53:13 2013 (r254624) +++ soc2013/jmuniz/PackageKit-Setter/pk-setter Thu Jul 11 13:56:52 2013 (r254625) @@ -92,7 +92,7 @@ # Ask PackageKit to quietly close as soon as it can gdbus call --system --dest org.freedestop.PackageKit --object-path /org/freedestop/PackageKit --method org.freedestop.PackageKit.SuggestDaemonQuit >/dev/null # Find the first instance of "DefaultBackend" in the configuration file and edit it - sed "s/DefaultBackend=.*/DefaultBackend=$2/" ${PK_PREFIX}etc/PackageKit/PackageKit.conf > ${PK_PREFIX}etc/PackageKit/PackageKit.conf + sed -i .old "s/DefaultBackend=.*/DefaultBackend=$2/" ${PK_PREFIX}etc/PackageKit/PackageKit.conf # Sync the disks to make sure the configuration file is updated sync # Silently start PackageKit From owner-svn-soc-all@FreeBSD.ORG Thu Jul 11 13:58:35 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 75BB4D43 for ; Thu, 11 Jul 2013 13:58:35 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 4EAA81F1C for ; Thu, 11 Jul 2013 13:58:35 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BDwZ9x086494 for ; Thu, 11 Jul 2013 13:58:35 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6BDwZxC086493 for svn-soc-all@FreeBSD.org; Thu, 11 Jul 2013 13:58:35 GMT (envelope-from jmuniz@FreeBSD.org) Date: Thu, 11 Jul 2013 13:58:35 GMT Message-Id: <201307111358.r6BDwZxC086493@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254626 - soc2013/jmuniz/PackageKit-Setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 13:58:35 -0000 Author: jmuniz Date: Thu Jul 11 13:58:35 2013 New Revision: 254626 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254626 Log: Created an archive to distribute pk-setter for ports collection. Added: soc2013/jmuniz/PackageKit-Setter/packagekit-setter-latest.txz (contents, props changed) Added: soc2013/jmuniz/PackageKit-Setter/packagekit-setter-latest.txz ============================================================================== Binary file. No diff available. From owner-svn-soc-all@FreeBSD.ORG Thu Jul 11 14:00:06 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CE148DB4 for ; Thu, 11 Jul 2013 14:00:06 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A7B441F38 for ; Thu, 11 Jul 2013 14:00:06 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BE064j089772 for ; Thu, 11 Jul 2013 14:00:06 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6BE06Us089758 for svn-soc-all@FreeBSD.org; Thu, 11 Jul 2013 14:00:06 GMT (envelope-from jmuniz@FreeBSD.org) Date: Thu, 11 Jul 2013 14:00:06 GMT Message-Id: <201307111400.r6BE06Us089758@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254627 - soc2013/jmuniz/PackageKit-Setter/packagekit-setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 14:00:06 -0000 Author: jmuniz Date: Thu Jul 11 14:00:06 2013 New Revision: 254627 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254627 Log: Added initial ports collection files for packagekit-setter. Added: soc2013/jmuniz/PackageKit-Setter/packagekit-setter/ soc2013/jmuniz/PackageKit-Setter/packagekit-setter/Makefile soc2013/jmuniz/PackageKit-Setter/packagekit-setter/distinfo soc2013/jmuniz/PackageKit-Setter/packagekit-setter/pkg-descr Added: soc2013/jmuniz/PackageKit-Setter/packagekit-setter/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/PackageKit-Setter/packagekit-setter/Makefile Thu Jul 11 14:00:06 2013 (r254627) @@ -0,0 +1,25 @@ +# Created by: Justin Edward Muniz +# +# $FreeBSD$ + +PORTNAME= packagekit-setter +PORTVERSION= 1.0 +CATEGORIES= ports-mgmt sysutils +MASTER_SITES= http://socsvn.freebsd.org/socsvn/soc2013/jmuniz/PackageKit-Setter/ +DISTNAME= packagekit-setter-latest +EXTRACT_SUFX= .txz + +MAINTAINER= jmuniz@FreeBSD.org +COMMENT= Back end setting utility for PackageKit + +LICENSE= GPLv2 +LICENSE_FILE= ${WRKDIR}/COPYING + +LIB_DEPENDS= packagekit-glib2:${PORTSDIR}/ports-mgmt/packagekit + +PLIST_FILES= bin/pk-setter + +post-install: + ${INSTALL_SCRIPT} ${WRKDIR}/pk-setter ${PREFIX}/bin/pk-setter + +.include Added: soc2013/jmuniz/PackageKit-Setter/packagekit-setter/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/PackageKit-Setter/packagekit-setter/distinfo Thu Jul 11 14:00:06 2013 (r254627) @@ -0,0 +1,2 @@ +SHA256 (packagekit-setter-latest.txz) = 7c9833c080ad26aa5e36010ea521d33bfc4d82e8d0820b389c097d42d1f6e2f0 +SIZE (packagekit-setter-latest.txz) = 8368 Added: soc2013/jmuniz/PackageKit-Setter/packagekit-setter/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/PackageKit-Setter/packagekit-setter/pkg-descr Thu Jul 11 14:00:06 2013 (r254627) @@ -0,0 +1,4 @@ +PackageKit-Setter is a script to quickly and easily identify available +PackageKit back ends, and select which to use. + +WWW: http://wiki.freebsd.org/SummerOfCode2013/pkgQtGtk From owner-svn-soc-all@FreeBSD.ORG Thu Jul 11 14:06:12 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AD15FE83 for ; Thu, 11 Jul 2013 14:06:12 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 9CC001F70 for ; Thu, 11 Jul 2013 14:06:12 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BE6Crw094677 for ; Thu, 11 Jul 2013 14:06:12 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6BE6C4P094671 for svn-soc-all@FreeBSD.org; Thu, 11 Jul 2013 14:06:12 GMT (envelope-from jmuniz@FreeBSD.org) Date: Thu, 11 Jul 2013 14:06:12 GMT Message-Id: <201307111406.r6BE6C4P094671@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254628 - soc2013/jmuniz/PackageKit-Setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 14:06:12 -0000 Author: jmuniz Date: Thu Jul 11 14:06:12 2013 New Revision: 254628 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254628 Log: Added GPL license file to packagekit-setter source folder. Added: soc2013/jmuniz/PackageKit-Setter/COPYING Added: soc2013/jmuniz/PackageKit-Setter/COPYING ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/jmuniz/PackageKit-Setter/COPYING Thu Jul 11 14:06:12 2013 (r254628) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. From owner-svn-soc-all@FreeBSD.ORG Thu Jul 11 14:58:27 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9FA38C53 for ; Thu, 11 Jul 2013 14:58:27 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 91A6D1231 for ; Thu, 11 Jul 2013 14:58:27 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BEwR4D027334 for ; Thu, 11 Jul 2013 14:58:27 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6BEwR3K027332 for svn-soc-all@FreeBSD.org; Thu, 11 Jul 2013 14:58:27 GMT (envelope-from jmuniz@FreeBSD.org) Date: Thu, 11 Jul 2013 14:58:27 GMT Message-Id: <201307111458.r6BEwR3K027332@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254629 - soc2013/jmuniz/PackageKit-Setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 14:58:27 -0000 Author: jmuniz Date: Thu Jul 11 14:58:27 2013 New Revision: 254629 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254629 Log: Fixed mispelling of desktop in the gdbus call, pk-setter now seems to function flawlessly. Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter ============================================================================== --- soc2013/jmuniz/PackageKit-Setter/pk-setter Thu Jul 11 14:06:12 2013 (r254628) +++ soc2013/jmuniz/PackageKit-Setter/pk-setter Thu Jul 11 14:58:27 2013 (r254629) @@ -90,7 +90,7 @@ # If the provided backend is valid *" $2 "*) # Ask PackageKit to quietly close as soon as it can - gdbus call --system --dest org.freedestop.PackageKit --object-path /org/freedestop/PackageKit --method org.freedestop.PackageKit.SuggestDaemonQuit >/dev/null + gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --method org.freedesktop.PackageKit.SuggestDaemonQuit >/dev/null # Find the first instance of "DefaultBackend" in the configuration file and edit it sed -i .old "s/DefaultBackend=.*/DefaultBackend=$2/" ${PK_PREFIX}etc/PackageKit/PackageKit.conf # Sync the disks to make sure the configuration file is updated From owner-svn-soc-all@FreeBSD.ORG Fri Jul 12 17:47:09 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 35FBF887 for ; Fri, 12 Jul 2013 17:47:09 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 275241287 for ; Fri, 12 Jul 2013 17:47:09 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CHl9ad092530 for ; Fri, 12 Jul 2013 17:47:09 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6CHl9TZ092525 for svn-soc-all@FreeBSD.org; Fri, 12 Jul 2013 17:47:09 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 12 Jul 2013 17:47:09 GMT Message-Id: <201307121747.r6CHl9TZ092525@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254696 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 17:47:09 -0000 Author: mattbw Date: Fri Jul 12 17:47:08 2013 New Revision: 254696 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254696 Log: fix segfault with search group; search functions now use common search function. Added: soc2013/mattbw/backend/search.c soc2013/mattbw/backend/search.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/group.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Fri Jul 12 16:41:58 2013 (r254695) +++ soc2013/mattbw/backend/Makefile Fri Jul 12 17:47:08 2013 (r254696) @@ -9,6 +9,7 @@ group.c \ licenses.c \ pkgutils.c \ + search.c \ utils.c SRCS+= \ actions/get_details.c \ Modified: soc2013/mattbw/backend/group.c ============================================================================== --- soc2013/mattbw/backend/group.c Fri Jul 12 16:41:58 2013 (r254695) +++ soc2013/mattbw/backend/group.c Fri Jul 12 17:47:08 2013 (r254696) @@ -130,7 +130,7 @@ if (sb != NULL) { bool at_least_one; unsigned int i; - const struct group_mapping *map; + unsigned int j; at_least_one = false; @@ -138,13 +138,14 @@ (void)sbuf_putc(sb, '('); /* Quadratic time, any improvements welcomed */ - for (map = group_mappings; map->key[0] != '\0'; map++) { - for (i = 0; i < groupc; i++) { - if (map->group == groupv[i]) { + for (i = 0; i < num_group_mappings; i++) { + for (j = 0; j < groupc; j++) { + if (group_mappings[i].group == groupv[j]) { if (at_least_one) (void)sbuf_putc(sb, '|'); - (void)sbuf_cat(sb, map->key); + (void)sbuf_cat(sb, + group_mappings[i].key); at_least_one = true; } Added: soc2013/mattbw/backend/search.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/search.c Fri Jul 12 17:47:08 2013 (r254696) @@ -0,0 +1,63 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include /* bool */ +#include "pkg.h" /* pkg_... */ + +#include "pkgutils.h" /* pkgutils_... */ +#include "search.h" /* search_... */ + +/* + * Performs the search specified by the given "struct search" and emits each + * result according to the likewise-specified filter set. + */ +bool +search_do(struct search *search) +{ + bool success; + struct pkgdb_it *it; + + success = false; + it = pkgdb_search(search->db, + search->term, + search->type, + search->in, + search->sort_by, + NULL); + + if (it != NULL) { + struct pkg *pkg; + + pkg = NULL; + while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) { + pkgutils_add_old_version(search->db, pkg); + pkgutils_emit_filtered(pkg, + search->backend, + search->filters, + pkgutils_pkg_current_state(pkg)); + } + + success = true; + pkg_free(pkg); + } + + pkgdb_it_free(it); + return success; +} Added: soc2013/mattbw/backend/search.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/search.h Fri Jul 12 17:47:08 2013 (r254696) @@ -0,0 +1,43 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include /* bool */ +#include "pk-backend.h" /* Pk... */ +#include "pkg.h" /* match_t, pkgdb... */ + +#ifndef _PKGNG_BACKEND_SEARCH_H_ +#define _PKGNG_BACKEND_SEARCH_H_ + +/* + * Structure collating the various inputs to a search. + */ +struct search { + match_t type; + pkgdb_field in; + pkgdb_field sort_by; + PkBitfield filters; + char *term; + struct pkgdb *db; + PkBackend *backend; +}; + +bool search_do(struct search *search); + +#endif /* _PKGNG_BACKEND_SEARCH_H_ */ From owner-svn-soc-all@FreeBSD.ORG Fri Jul 12 18:58:37 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id EFEBED2E for ; Fri, 12 Jul 2013 18:58:37 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id E106B190B for ; Fri, 12 Jul 2013 18:58:37 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CIwbLB012658 for ; Fri, 12 Jul 2013 18:58:37 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6CIwbNT012653 for svn-soc-all@FreeBSD.org; Fri, 12 Jul 2013 18:58:37 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 12 Jul 2013 18:58:37 GMT Message-Id: <201307121858.r6CIwbNT012653@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254701 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 18:58:38 -0000 Author: mattbw Date: Fri Jul 12 18:58:37 2013 New Revision: 254701 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254701 Log: split event handler into new file Added: soc2013/mattbw/backend/event.c soc2013/mattbw/backend/event.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/install_packages.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Fri Jul 12 17:37:05 2013 (r254700) +++ soc2013/mattbw/backend/Makefile Fri Jul 12 18:58:37 2013 (r254701) @@ -5,8 +5,9 @@ SRCS= pk-backend-pkgng.c SRCS+= \ db.c \ - group_map.c \ + event.c \ group.c \ + group_map.c \ licenses.c \ pkgutils.c \ search.c \ Modified: soc2013/mattbw/backend/actions/install_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install_packages.c Fri Jul 12 17:37:05 2013 (r254700) +++ soc2013/mattbw/backend/actions/install_packages.c Fri Jul 12 18:58:37 2013 (r254701) @@ -18,20 +18,20 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "../pk-backend.h" -#include "pkg.h" +#include /* gboolean */ +#include /* bool, true, false */ +#include "../pk-backend.h" /* pk..., Pk... */ +#include "pkg.h" /* pkg... */ +#include "../actions.h" /* install_packages_thread prototype */ +#include "../event.h" /* event_... */ #include "../pkgutils.h" /* pkgutils_... */ #include "../query.h" /* query_... */ #include "../utils.h" /* INTENTIONALLY_IGNORE, ERR */ -#include "../actions.h" /* install_packages_thread prototype */ - static bool job (struct pkg_jobs *jobs, struct query *q); static bool sim_job(struct pkg_jobs *jobs, struct query *q); static bool solve_job(struct query *q, struct pkg_jobs *jobs); -static int install_event_cb(void *backend_v, struct pkg_event *event); /* * The thread that performs an InstallPackages operation. Should be invoked @@ -81,7 +81,7 @@ if (solve_job(q, jobs) == false) goto cleanup; - pkg_event_register(install_event_cb, backend); + pkg_event_register(event_cb, backend); (void)pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); if (pkg_jobs_apply(jobs) != EPKG_OK) { @@ -155,103 +155,3 @@ return success; } - -/* - * Event handler for events emitted by pkg during an installation. TODO: Many - * of these events are unhandled or deficiently handled. - */ -static int -install_event_cb(void *backend_v, struct pkg_event *event) -{ - PkBackend *backend; - - backend = (PkBackend *)backend_v; - - switch (event->type) { - case PKG_EVENT_INSTALL_BEGIN: - STATUS(backend, PK_STATUS_ENUM_INSTALL); - pkgutils_emit(event->e_install_begin.pkg, - backend, - PK_INFO_ENUM_INSTALLING); - break; - case PKG_EVENT_INSTALL_FINISHED: - pkgutils_emit(event->e_install_finished.pkg, - backend, - PK_INFO_ENUM_FINISHED); - break; - case PKG_EVENT_DEINSTALL_BEGIN: - STATUS(backend, PK_STATUS_ENUM_REMOVE); - pkgutils_emit(event->e_deinstall_begin.pkg, - backend, - PK_INFO_ENUM_REMOVING); - break; - case PKG_EVENT_DEINSTALL_FINISHED: - pkgutils_emit(event->e_deinstall_finished.pkg, - backend, - PK_INFO_ENUM_FINISHED); - break; - case PKG_EVENT_UPGRADE_BEGIN: - STATUS(backend, PK_STATUS_ENUM_UPDATE); - pkgutils_emit(event->e_upgrade_begin.pkg, - backend, - PK_INFO_ENUM_UPDATING); - break; - case PKG_EVENT_UPGRADE_FINISHED: - pkgutils_emit(event->e_upgrade_finished.pkg, - backend, - PK_INFO_ENUM_FINISHED); - break; - case PKG_EVENT_FETCHING: - STATUS(backend, PK_STATUS_ENUM_DOWNLOAD); - break; - case PKG_EVENT_INTEGRITYCHECK_BEGIN: - case PKG_EVENT_INTEGRITYCHECK_FINISHED: - /* Unimplemented */ - break; - case PKG_EVENT_INTEGRITYCHECK_CONFLICT: - ERR(backend, - PK_ERROR_ENUM_PACKAGE_CORRUPT, - event->e_integrity_conflict.pkg_name); - break; - case PKG_EVENT_NEWPKGVERSION: - case PKG_EVENT_NOTICE: - case PKG_EVENT_INCREMENTAL_UPDATE: - /* Unimplemented */ - break; - case PKG_EVENT_ERROR: - /* - * This is sometimes used for nonfatal errors, so we can't - * throw an error code here. - */ - break; - case PKG_EVENT_ERRNO: - case PKG_EVENT_ARCHIVE_COMP_UNSUP: - case PKG_EVENT_ALREADY_INSTALLED: - case PKG_EVENT_FAILED_CKSUM: - case PKG_EVENT_CREATE_DB_ERROR: - case PKG_EVENT_LOCKED: - case PKG_EVENT_REQUIRED: - case PKG_EVENT_MISSING_DEP: - case PKG_EVENT_NOREMOTEDB: - case PKG_EVENT_NOLOCALDB: - /* Unimplemented */ - break; - case PKG_EVENT_FILE_MISMATCH: - ERR(backend, - PK_ERROR_ENUM_PACKAGE_CORRUPT, - pkg_file_path(event->e_file_mismatch.file)); - break; - case PKG_EVENT_DEVELOPER_MODE: - case PKG_EVENT_PLUGIN_ERRNO: - case PKG_EVENT_PLUGIN_ERROR: - case PKG_EVENT_PLUGIN_INFO: - /* Unimplemented */ - break; - case PKG_EVENT_NOT_FOUND: - ERR(backend, - PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, - event->e_not_found.pkg_name); - } - - return EPKG_OK; -} Added: soc2013/mattbw/backend/event.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/event.c Fri Jul 12 18:58:37 2013 (r254701) @@ -0,0 +1,126 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "pk-backend.h" /* pk_..., Pk... */ +#include "pkg.h" /* pkg... */ + +#include "event.h" /* event_... */ +#include "pkgutils.h" /* pkgutils... */ +#include "utils.h" /* ERR, STATUS */ + +/* + * Event handler for events emitted by pkg during an installation. TODO: Many + * of these events are unhandled or deficiently handled. + */ +int +event_cb(void *backend_v, struct pkg_event *event) +{ + PkBackend *backend; + + backend = (PkBackend *)backend_v; + + switch (event->type) { + case PKG_EVENT_INSTALL_BEGIN: + STATUS(backend, PK_STATUS_ENUM_INSTALL); + pkgutils_emit(event->e_install_begin.pkg, + backend, + PK_INFO_ENUM_INSTALLING); + break; + case PKG_EVENT_INSTALL_FINISHED: + pkgutils_emit(event->e_install_finished.pkg, + backend, + PK_INFO_ENUM_FINISHED); + break; + case PKG_EVENT_DEINSTALL_BEGIN: + STATUS(backend, PK_STATUS_ENUM_REMOVE); + pkgutils_emit(event->e_deinstall_begin.pkg, + backend, + PK_INFO_ENUM_REMOVING); + break; + case PKG_EVENT_DEINSTALL_FINISHED: + pkgutils_emit(event->e_deinstall_finished.pkg, + backend, + PK_INFO_ENUM_FINISHED); + break; + case PKG_EVENT_UPGRADE_BEGIN: + STATUS(backend, PK_STATUS_ENUM_UPDATE); + pkgutils_emit(event->e_upgrade_begin.pkg, + backend, + PK_INFO_ENUM_UPDATING); + break; + case PKG_EVENT_UPGRADE_FINISHED: + pkgutils_emit(event->e_upgrade_finished.pkg, + backend, + PK_INFO_ENUM_FINISHED); + break; + case PKG_EVENT_FETCHING: + STATUS(backend, PK_STATUS_ENUM_DOWNLOAD); + break; + case PKG_EVENT_INTEGRITYCHECK_BEGIN: + case PKG_EVENT_INTEGRITYCHECK_FINISHED: + /* Unimplemented */ + break; + case PKG_EVENT_INTEGRITYCHECK_CONFLICT: + ERR(backend, + PK_ERROR_ENUM_PACKAGE_CORRUPT, + event->e_integrity_conflict.pkg_name); + break; + case PKG_EVENT_NEWPKGVERSION: + case PKG_EVENT_NOTICE: + case PKG_EVENT_INCREMENTAL_UPDATE: + /* Unimplemented */ + break; + case PKG_EVENT_ERROR: + /* + * This is sometimes used for nonfatal errors, so we can't + * throw an error code here. + */ + break; + case PKG_EVENT_ERRNO: + case PKG_EVENT_ARCHIVE_COMP_UNSUP: + case PKG_EVENT_ALREADY_INSTALLED: + case PKG_EVENT_FAILED_CKSUM: + case PKG_EVENT_CREATE_DB_ERROR: + case PKG_EVENT_LOCKED: + case PKG_EVENT_REQUIRED: + case PKG_EVENT_MISSING_DEP: + case PKG_EVENT_NOREMOTEDB: + case PKG_EVENT_NOLOCALDB: + /* Unimplemented */ + break; + case PKG_EVENT_FILE_MISMATCH: + ERR(backend, + PK_ERROR_ENUM_PACKAGE_CORRUPT, + pkg_file_path(event->e_file_mismatch.file)); + break; + case PKG_EVENT_DEVELOPER_MODE: + case PKG_EVENT_PLUGIN_ERRNO: + case PKG_EVENT_PLUGIN_ERROR: + case PKG_EVENT_PLUGIN_INFO: + /* Unimplemented */ + break; + case PKG_EVENT_NOT_FOUND: + ERR(backend, + PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, + event->e_not_found.pkg_name); + } + + return EPKG_OK; +} Added: soc2013/mattbw/backend/event.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/event.h Fri Jul 12 18:58:37 2013 (r254701) @@ -0,0 +1,29 @@ +/*- + * + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _PKGNG_BACKEND_EVENT_H_ +#define _PKGNG_BACKEND_EVENT_H_ + +#include "pkg.h" /* struct pkg_event */ + +int event_cb(void *backend, struct pkg_event *event); + +#endif /* !_PKGNG_BACKEND_EVENT_H_ */ From owner-svn-soc-all@FreeBSD.ORG Fri Jul 12 19:14:25 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 66A0D28E for ; Fri, 12 Jul 2013 19:14:25 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 573B519FE for ; Fri, 12 Jul 2013 19:14:25 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CJEPBG093695 for ; Fri, 12 Jul 2013 19:14:25 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6CJEPO6093693 for svn-soc-all@FreeBSD.org; Fri, 12 Jul 2013 19:14:25 GMT (envelope-from jmuniz@FreeBSD.org) Date: Fri, 12 Jul 2013 19:14:25 GMT Message-Id: <201307121914.r6CJEPO6093693@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254706 - soc2013/jmuniz/PackageKit-Setter/packagekit-setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 19:14:25 -0000 Author: jmuniz Date: Fri Jul 12 19:14:25 2013 New Revision: 254706 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254706 Log: Forgot to include the updated Makefile for packagekit-setter last time. This one works. Modified: soc2013/jmuniz/PackageKit-Setter/packagekit-setter/Makefile Modified: soc2013/jmuniz/PackageKit-Setter/packagekit-setter/Makefile ============================================================================== --- soc2013/jmuniz/PackageKit-Setter/packagekit-setter/Makefile Fri Jul 12 18:54:47 2013 (r254705) +++ soc2013/jmuniz/PackageKit-Setter/packagekit-setter/Makefile Fri Jul 12 19:14:25 2013 (r254706) @@ -19,7 +19,9 @@ PLIST_FILES= bin/pk-setter -post-install: +do-build: + +do-install: ${INSTALL_SCRIPT} ${WRKDIR}/pk-setter ${PREFIX}/bin/pk-setter .include From owner-svn-soc-all@FreeBSD.ORG Fri Jul 12 20:14:27 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 84356E48 for ; Fri, 12 Jul 2013 20:14:27 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 593371CEF for ; Fri, 12 Jul 2013 20:14:27 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CKERrx042675 for ; Fri, 12 Jul 2013 20:14:27 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6CKERXc042674 for svn-soc-all@FreeBSD.org; Fri, 12 Jul 2013 20:14:27 GMT (envelope-from jmuniz@FreeBSD.org) Date: Fri, 12 Jul 2013 20:14:27 GMT Message-Id: <201307122014.r6CKERXc042674@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254708 - soc2013/jmuniz/PackageKit-Setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jul 2013 20:14:27 -0000 Author: jmuniz Date: Fri Jul 12 20:14:27 2013 New Revision: 254708 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254708 Log: Changed name of archive to conform, moved archive to another server. Deleted: soc2013/jmuniz/PackageKit-Setter/packagekit-setter-latest.txz From owner-svn-soc-all@FreeBSD.ORG Sat Jul 13 01:55:16 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 522A567D for ; Sat, 13 Jul 2013 01:55:16 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 43A641BCE for ; Sat, 13 Jul 2013 01:55:16 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6D1tGuK097978 for ; Sat, 13 Jul 2013 01:55:16 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6D1tGk0097976 for svn-soc-all@FreeBSD.org; Sat, 13 Jul 2013 01:55:16 GMT (envelope-from jmuniz@FreeBSD.org) Date: Sat, 13 Jul 2013 01:55:16 GMT Message-Id: <201307130155.r6D1tGk0097976@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254739 - soc2013/jmuniz/PackageKit-Setter/packagekit-setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 01:55:16 -0000 Author: jmuniz Date: Sat Jul 13 01:55:16 2013 New Revision: 254739 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254739 Log: Fixed the nits :) Moved the archive off-site, to sourceforge -- for their many mirrors; removed empty comment line; Changed archive name to default, and removed the filename variables; Removed LICENSE_FILE. Modified: soc2013/jmuniz/PackageKit-Setter/packagekit-setter/Makefile Modified: soc2013/jmuniz/PackageKit-Setter/packagekit-setter/Makefile ============================================================================== --- soc2013/jmuniz/PackageKit-Setter/packagekit-setter/Makefile Sat Jul 13 00:53:56 2013 (r254738) +++ soc2013/jmuniz/PackageKit-Setter/packagekit-setter/Makefile Sat Jul 13 01:55:16 2013 (r254739) @@ -1,19 +1,15 @@ # Created by: Justin Edward Muniz -# # $FreeBSD$ PORTNAME= packagekit-setter PORTVERSION= 1.0 CATEGORIES= ports-mgmt sysutils -MASTER_SITES= http://socsvn.freebsd.org/socsvn/soc2013/jmuniz/PackageKit-Setter/ -DISTNAME= packagekit-setter-latest -EXTRACT_SUFX= .txz +MASTER_SITES= http://sourceforge.net/projects/pk-setter/files/ MAINTAINER= jmuniz@FreeBSD.org COMMENT= Back end setting utility for PackageKit LICENSE= GPLv2 -LICENSE_FILE= ${WRKDIR}/COPYING LIB_DEPENDS= packagekit-glib2:${PORTSDIR}/ports-mgmt/packagekit From owner-svn-soc-all@FreeBSD.ORG Sat Jul 13 07:45:26 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 42F30DE3 for ; Sat, 13 Jul 2013 07:45:26 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 323A11650 for ; Sat, 13 Jul 2013 07:45:26 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6D7jQju096796 for ; Sat, 13 Jul 2013 07:45:26 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6D7jQR2096787 for svn-soc-all@FreeBSD.org; Sat, 13 Jul 2013 07:45:26 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 13 Jul 2013 07:45:26 GMT Message-Id: <201307130745.r6D7jQR2096787@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254742 - in soc2013/mattbw: . backend backend/actions backend/query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 07:45:26 -0000 Author: mattbw Date: Sat Jul 13 07:45:25 2013 New Revision: 254742 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254742 Log: refactor jobs query code Added: soc2013/mattbw/backend/query/jobs.c soc2013/mattbw/backend/query/jobs.h Modified: soc2013/mattbw/ (props changed) soc2013/mattbw/README soc2013/mattbw/backend/ (props changed) soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/ (props changed) soc2013/mattbw/backend/actions/install_packages.c soc2013/mattbw/backend/db.h soc2013/mattbw/backend/query/ (props changed) soc2013/mattbw/backend/query/core.c soc2013/mattbw/backend/query/core.h Modified: soc2013/mattbw/README ============================================================================== --- soc2013/mattbw/README Sat Jul 13 04:25:03 2013 (r254741) +++ soc2013/mattbw/README Sat Jul 13 07:45:25 2013 (r254742) @@ -17,9 +17,8 @@ - pkgng (currently building against version 1.1.3; higher versions might work) - FreeBSD (tested with 9.1; should work with higher versions) -Tested primarily with clang in C99 mode; C89 mode likely will not work and C11 -would not work due to header file problems. GNU extensions probably won't break -the build. +Tested primarily with clang in C11 mode; C89 mode likely will not work and C99 +likely would need GNU/clang extensions. -------------------------------------------------------------------------------- Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Sat Jul 13 04:25:03 2013 (r254741) +++ soc2013/mattbw/backend/Makefile Sat Jul 13 07:45:25 2013 (r254742) @@ -25,6 +25,7 @@ SRCS+= \ query/core.c \ query/do.c \ + query/jobs.c \ query/match.c LIBDIR= /usr/local/lib/packagekit-backend Modified: soc2013/mattbw/backend/actions/install_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install_packages.c Sat Jul 13 04:25:03 2013 (r254741) +++ soc2013/mattbw/backend/actions/install_packages.c Sat Jul 13 07:45:25 2013 (r254742) @@ -31,7 +31,6 @@ static bool job (struct pkg_jobs *jobs, struct query *q); static bool sim_job(struct pkg_jobs *jobs, struct query *q); -static bool solve_job(struct query *q, struct pkg_jobs *jobs); /* * The thread that performs an InstallPackages operation. Should be invoked @@ -78,21 +77,20 @@ backend = query_backend(q); query_set_percentage(q, 0); - if (solve_job(q, jobs) == false) - goto cleanup; - pkg_event_register(event_cb, backend); (void)pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); - if (pkg_jobs_apply(jobs) != EPKG_OK) { + if (pkg_jobs_count(jobs) == 0) + ERR(backend, + PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED, + "nothing to do"); + else if (pkg_jobs_apply(jobs) != EPKG_OK) ERR(backend, PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, "job failed"); - goto cleanup; - } - success = true; + else + success = true; -cleanup: pkg_event_register(NULL, NULL); query_set_percentage(q, 100); return success; @@ -109,12 +107,8 @@ struct pkg *pkg; backend = query_backend(q); - success = false; query_set_percentage(q, 0); - if (solve_job(q, jobs) == false) - goto cleanup; - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); pkg = NULL; while (pkg_jobs(jobs, &pkg) == EPKG_OK) @@ -124,34 +118,6 @@ success = true; -cleanup: query_set_percentage(q, 100); return success; } - -/* - * Solves a job and ensures it has packages available. - */ -static bool -solve_job(struct query *q, struct pkg_jobs *jobs) -{ - bool success; - PkBackend *backend; - - success = false; - backend = query_backend(q); - - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); - if (pkg_jobs_solve(jobs) != EPKG_OK) - ERR(backend, - PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, - "could not solve the job"); - else if (pkg_jobs_count(jobs) == 0) - ERR(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "job contains no packages"); - else - success = true; - - return success; -} Modified: soc2013/mattbw/backend/db.h ============================================================================== --- soc2013/mattbw/backend/db.h Sat Jul 13 04:25:03 2013 (r254741) +++ soc2013/mattbw/backend/db.h Sat Jul 13 07:45:25 2013 (r254742) @@ -1,5 +1,4 @@ /*- - * * Copyright (C) 2013 Matt Windsor * * Licensed under the GNU General Public License Version 2 Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Sat Jul 13 04:25:03 2013 (r254741) +++ soc2013/mattbw/backend/query/core.c Sat Jul 13 07:45:25 2013 (r254742) @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include /* assert */ #include #include #include @@ -29,6 +30,7 @@ #include "../utils.h" /* string_match */ #include "../pkgutils.h" /* pkgutils_... */ #include "core.h" /* Prototypes */ +#include "jobs.h" /* query_jobs...*/ enum repo_type { REPO_INVALID, @@ -50,16 +52,26 @@ }; static bool can_remote_iterate(struct query *q); -static bool emit_to_job(struct pkg *pkg, struct query *q); -static const gchar *query_repo(struct query *q); +static bool emit(struct pkg *pkg, const char *match_id, struct query *q); static enum repo_type type_of_repo_name(const char *name); static gchar *match_pkg(struct pkg *pkg, struct query *q); static gchar **init_unpack_source(PkBackend *backend, struct query_source *s); -static int jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg); -static int jobs_repo_from_query(struct pkg_jobs *jobs, struct query *q); static struct pkg *match_iterator(struct pkgdb_it *it, struct query *q, gchar **match_id_p); /* + * Returns the backend stored inside the given query. + */ +PkBackend * +query_backend(struct query *q) +{ + + assert (q != NULL); + assert (q->backend != NULL); + + return q->backend; +} + +/* * Runs an assembled query. */ bool @@ -77,6 +89,8 @@ struct pkgdb *db; struct pkgdb_it *it; + assert(q != NULL); + success = false; match = MATCH_EXACT; match_id = NULL; @@ -120,12 +134,8 @@ ERR(q->backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found"); - else { - if (q->t->type == QUERY_EMIT) - success = q->t->emit.f(pkg, match_id, q); - else if (q->t->type == QUERY_JOB) - success = emit_to_job(pkg, q); - } + else + emit(pkg, match_id, q); pkg_free(pkg); g_free(match_id); @@ -133,12 +143,31 @@ return success; } -/* Returns the backend stored inside the struct query. */ -PkBackend * -query_backend(struct query *q) +/* + * Retrieves the repository for the query, or NULL if none is specified. + */ +const char * +query_repo(struct query *q) +{ + const gchar *repo; + + assert(q != NULL); + + repo = q->id_strv[PK_PACKAGE_ID_DATA]; + return ((repo == NULL || repo[0] == '\0') ? NULL : repo); +} + +/* + * Returns the database stored inside the given query. + */ +struct pkgdb * +query_db(struct query *q) { - return (q == NULL ? NULL : q->backend); + assert(q != NULL); + assert(q->db != NULL); + + return q->db; } /* @@ -155,6 +184,11 @@ bool success; struct query *q; + assert(backend != NULL); + assert(db != NULL); + assert(s != NULL); + assert(t != NULL); + success = false; q = calloc(1, sizeof(struct query)); @@ -217,6 +251,8 @@ { guint scaled_percent; + assert(q != NULL); + if (percent == PK_BACKEND_PERCENTAGE_INVALID) scaled_percent = PK_BACKEND_PERCENTAGE_INVALID; else { @@ -239,6 +275,8 @@ { bool sane; + assert(q != NULL); + /* Innocent until proven guilty */ sane = true; @@ -257,49 +295,32 @@ } /* - * For adapting an emitter function into one that solves and applies a job. + * Sends a query result to the appropriate emitter. */ static bool -emit_to_job(struct pkg *pkg, struct query *q) +emit(struct pkg *pkg, const char *match_id, struct query *q) { bool success; - struct pkg_jobs *jobs; - PkBackend *backend; - - success = false; - jobs = NULL; - - if (q == NULL) - goto cleanup; - backend = query_backend(q); - - if (pkg_jobs_new(&jobs, q->t->job.type, q->db) != EPKG_OK) { - ERR(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "could not init pkg_jobs"); - goto cleanup; - } - if (jobs_repo_from_query(jobs, q) != EPKG_OK) { - ERR(backend, - PK_ERROR_ENUM_REPO_NOT_FOUND, - "could not set repo"); - goto cleanup; - } - if (jobs_add_pkg(jobs, MATCH_EXACT, pkg) != EPKG_OK) { - ERR(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "could not add to job"); - goto cleanup; + assert(match_id != NULL); + assert(pkg != NULL); + assert(q != NULL); + + switch(q->t->type) { + case QUERY_EMIT: + success = q->t->emit.f(pkg, match_id, q); + break; + case QUERY_JOB: + success = query_jobs_run(q, pkg, q->t->job.type, q->t->job.f); + break; } - success = q->t->job.f(jobs, q); -cleanup: - pkg_jobs_free(jobs); return success; } -/* Finds the type of the given PackageKit repository name. */ +/* + * Finds the type of the given PackageKit repository name. + */ static enum repo_type type_of_repo_name(const char *name) { @@ -330,6 +351,9 @@ gchar *match_id; const char **pkg_id_bits; + assert(pkg != NULL); + assert(q != NULL); + pkg_id_bits = calloc(4, sizeof(const char *)); match_id = pkgutils_pkg_to_id_through(pkg, pkg_id_bits); @@ -361,43 +385,6 @@ return match_id; } -/* Retrieves the repository for the query, or NULL if none is specified. */ -static const gchar * -query_repo(struct query *q) -{ - const gchar *repo; - - repo = q->id_strv[PK_PACKAGE_ID_DATA]; - return ((repo == NULL || repo[0] == '\0') ? NULL : repo); -} - -/* Adds a single package to a jobs structure. */ -static int -jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg) -{ - char *name; - - name = NULL; - pkg_get(pkg, PKG_NAME, &name); - return pkg_jobs_add(jobs, type, &name, 1); -} - -/* Sets a jobset to target the repository the given query is looking in. */ -static int -jobs_repo_from_query(struct pkg_jobs *jobs, struct query *q) -{ - int err; - gchar *repo; - - repo = q->id_strv[PK_PACKAGE_ID_DATA]; - if (repo == NULL || repo[0] == '\0') - err = EPKG_OK; - else - err = pkg_jobs_set_repository(jobs, repo); - - return err; -} - /* * Tries to find a query-matching package in a database iterator. Returns the * package if one matches, or NULL; if match_id_p is non-null, its full @@ -410,10 +397,11 @@ gchar *match_id; struct pkg *pkg; - if (q->t->type == QUERY_EMIT) - load_flags = q->t->emit.load_flags; - else - load_flags = PKG_LOAD_BASIC; + assert(it != NULL); + assert(q != NULL); + + load_flags = (q->t->type == QUERY_EMIT) ? + q->t->emit.load_flags : PKG_LOAD_BASIC; match_id = NULL; pkg = NULL; Modified: soc2013/mattbw/backend/query/core.h ============================================================================== --- soc2013/mattbw/backend/query/core.h Sat Jul 13 04:25:03 2013 (r254741) +++ soc2013/mattbw/backend/query/core.h Sat Jul 13 07:45:25 2013 (r254742) @@ -72,9 +72,10 @@ }; PkBackend *query_backend(struct query *q); -bool query_run (struct query *q); +bool query_run(struct query *q); +const char *query_repo(struct query *q); +struct pkgdb *query_db(struct query *q); struct query *query_init(PkBackend *backend, struct pkgdb *db, struct query_source *s, struct query_target *t); void query_free(struct query **q_p); void query_set_percentage(struct query *q, unsigned char percent); - #endif /* !_PKGNG_BACKEND_QUERY_CORE_H_ */ Added: soc2013/mattbw/backend/query/jobs.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/query/jobs.c Sat Jul 13 07:45:25 2013 (r254742) @@ -0,0 +1,106 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include /* assert */ +#include /* bool, true, false */ +#include "../pk-backend.h" /* pk..., Pk... */ +#include "pkg.h" /* pkg... */ + +#include "../utils.h" /* ERR */ +#include "core.h" /* query_... */ +#include "jobs.h" /* query_jobs_... */ + +static int add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg); +static int repo_from_query(struct pkg_jobs *jobs, struct query *q); + +/* + * Creates a job of type "type" for the given package, solves it, and sends it + * to the emitter function "f" alongside its parent query. + */ +bool +query_jobs_run(struct query *q, struct pkg *pkg, pkg_jobs_t type, + job_emit_ptr f) +{ + bool success; + struct pkg_jobs *jobs; + PkBackend *backend; + + assert (q != NULL); + assert (pkg != NULL); + assert (f != NULL); + + success = false; + jobs = NULL; + + backend = query_backend(q); + + if (pkg_jobs_new(&jobs, type, query_db(q)) != EPKG_OK) { + ERR(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not init pkg_jobs"); + goto cleanup; + } + if (repo_from_query(jobs, q) != EPKG_OK) { + ERR(backend, + PK_ERROR_ENUM_REPO_NOT_FOUND, + "could not set repo"); + goto cleanup; + } + if (add_pkg(jobs, MATCH_EXACT, pkg) != EPKG_OK) { + ERR(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not add to job"); + goto cleanup; + } + if (pkg_jobs_solve(jobs) != EPKG_OK) { + ERR(backend, + PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, + "could not solve the job"); + goto cleanup; + } + + success = f(jobs, q); + +cleanup: + pkg_jobs_free(jobs); + return success; +} + +/* Adds a single package to a jobs structure. */ +static int +add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg) +{ + char *name; + + name = NULL; + pkg_get(pkg, PKG_NAME, &name); + return pkg_jobs_add(jobs, type, &name, 1); +} + +/* Sets a jobset to target the repository the given query is looking in. */ +static int +repo_from_query(struct pkg_jobs *jobs, struct query *q) +{ + const char *repo; + + repo = query_repo(q); + + return (repo == NULL ? EPKG_OK : pkg_jobs_set_repository(jobs, repo)); +} Added: soc2013/mattbw/backend/query/jobs.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/query/jobs.h Sat Jul 13 07:45:25 2013 (r254742) @@ -0,0 +1,30 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _PKGNG_BACKEND_QUERY_JOBS_H_ +#define _PKGNG_BACKEND_QUERY_JOBS_H_ + +#include "pkg.h" /* struct pkg */ + +#include "core.h" /* struct query */ + +bool query_jobs_run(struct query *q, struct pkg *pkg, pkg_jobs_t type, job_emit_ptr f); + +#endif /* !_PKGNG_BACKEND_QUERY_JOBS_H_ */ From owner-svn-soc-all@FreeBSD.ORG Sat Jul 13 07:47:43 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id F3F29E02 for ; Sat, 13 Jul 2013 07:47:42 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id E458B1657 for ; Sat, 13 Jul 2013 07:47:42 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6D7lgHW097288 for ; Sat, 13 Jul 2013 07:47:42 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6D7lgpu097284 for svn-soc-all@FreeBSD.org; Sat, 13 Jul 2013 07:47:42 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 13 Jul 2013 07:47:42 GMT Message-Id: <201307130747.r6D7lgpu097284@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254743 - soc2013/mattbw/backend/actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 07:47:43 -0000 Author: mattbw Date: Sat Jul 13 07:47:42 2013 New Revision: 254743 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254743 Log: how did these not get added previously Added: soc2013/mattbw/backend/actions/remove_packages.c soc2013/mattbw/backend/actions/search_groups.c soc2013/mattbw/backend/actions/search_names.c Added: soc2013/mattbw/backend/actions/remove_packages.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/remove_packages.c Sat Jul 13 07:47:42 2013 (r254743) @@ -0,0 +1,157 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include /* gboolean */ +#include /* bool, true, false */ +#include "../pk-backend.h" /* pk..., Pk... */ +#include "pkg.h" /* pkg... */ + +#include "../actions.h" /* remove_packages_thread prototype */ +#include "../event.c" /* event_... */ +#include "../pkgutils.h" /* pkgutils_... */ +#include "../query.h" /* query_... */ +#include "../utils.h" /* INTENTIONALLY_IGNORE, ERR */ + +static bool job (struct pkg_jobs *jobs, struct query *q); +static bool sim_job(struct pkg_jobs *jobs, struct query *q); +static bool solve_job(struct query *q, struct pkg_jobs *jobs); + +/* + * The thread that performs an removePackages operation. Should be invoked + * by the pk_backend_remove_packages hook. + */ +gboolean +remove_packages_thread(PkBackend *backend) +{ + bool success; + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + success = query_match_id_to_job(backend, PKG_JOBS_remove, job); + + (void)pk_backend_finished(backend); + return success ? TRUE : FALSE; +} + +/* + * The thread that performs a Simulate removePackages operation. Should be + * invoked by the pk_backend_simulate_remove_packages hook. + */ +gboolean +simulate_remove_packages_thread(PkBackend *backend) +{ + bool success; + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + success = query_match_id_to_job(backend, PKG_JOBS_remove, sim_job); + + (void)pk_backend_finished(backend); + return success ? TRUE : FALSE; +} + +/* + * Tries to process the given solved removeation jobs. + */ +static bool +job(struct pkg_jobs *jobs, struct query *q) +{ + bool success; + PkBackend *backend; + + success = false; + backend = query_backend(q); + query_set_percentage(q, 0); + + if (solve_job(q, jobs) == false) + goto cleanup; + + pkg_event_register(event_cb, backend); + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_REMOVE); + if (pkg_jobs_apply(jobs) != EPKG_OK) { + ERR(backend, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_REMOVE, + "job failed"); + goto cleanup; + } + success = true; + +cleanup: + pkg_event_register(NULL, NULL); + query_set_percentage(q, 100); + return success; +} + +/* + * Tries to simulate processing the given removal jobs. + */ +static bool +sim_job(struct pkg_jobs *jobs, struct query *q) +{ + bool success; + PkBackend *backend; + struct pkg *pkg; + + backend = query_backend(q); + success = false; + query_set_percentage(q, 0); + + if (solve_job(q, jobs) == false) + goto cleanup; + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); + pkg = NULL; + while (pkg_jobs(jobs, &pkg) == EPKG_OK) + pkgutils_emit(pkg, + backend, + pkgutils_pkg_remove_state(pkg)); + + success = true; + +cleanup: + query_set_percentage(q, 100); + return success; +} + +/* + * Solves a job and ensures it has packages available. + */ +static bool +solve_job(struct query *q, struct pkg_jobs *jobs) +{ + bool success; + PkBackend *backend; + + success = false; + backend = query_backend(q); + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); + if (pkg_jobs_solve(jobs) != EPKG_OK) + ERR(backend, + PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, + "could not solve the job"); + else if (pkg_jobs_count(jobs) == 0) + ERR(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "job contains no packages"); + else + success = true; + + return success; +} Added: soc2013/mattbw/backend/actions/search_groups.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/search_groups.c Sat Jul 13 07:47:42 2013 (r254743) @@ -0,0 +1,99 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "../pk-backend.h" +#include "pkg.h" + +#include "../actions.h" /* search_groups_thread prototype */ +#include "../db.h" /* db_open_remote */ +#include "../group.h" /* group_... */ +#include "../search.h" /* search_... */ +#include "../utils.h" /* INTENTIONALLY_IGNORE */ + +/* + * Searches for a package by group. + */ +gboolean +search_groups_thread(PkBackend *backend) +{ + gboolean success; + guint groupc; + guint i; + PkGroupEnum *groupv; + struct pkgdb_it *it; + gchar **values; + struct search search; + + search.db = NULL; + groupv = NULL; + it = NULL; + search.term = NULL; + success = FALSE; + values = NULL; + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + (void)pk_backend_set_percentage(backend, 0); + + search.db = db_open_remote(backend); + if (search.db == NULL) + goto cleanup; + + values = pk_backend_get_strv(backend, "values"); + groupc = g_strv_length(values); + if (groupc == 0) { + ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "no values"); + goto cleanup; + } + + groupv = calloc(groupc, sizeof(PkGroupEnum)); + if (groupv == NULL) { + ERR(backend, PK_ERROR_ENUM_OOM, "couldn't alloc groupv"); + goto cleanup; + } + + for (i = 0; i < groupc; i++) { + groupv[i] = pk_group_enum_from_string(values[i]); + if (groupv[i] == PK_GROUP_ENUM_UNKNOWN) + ERR(backend, PK_ERROR_ENUM_GROUP_NOT_FOUND, values[i]); + } + + search.term = group_list_to_origin_regex(groupc, groupv); + if (search.term == NULL || search.term[0] == '\0') { + ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "no search.term"); + goto cleanup; + } + + search.type = MATCH_REGEX; + search.in = FIELD_ORIGIN; + search.sort_by = FIELD_ORIGIN; + search.backend = backend; + search.filters = pk_backend_get_uint(backend, "filters"); + + success = search_do(&search); + +cleanup: + free(search.term); + free(groupv); + pkgdb_close(search.db); + + (void)pk_backend_set_percentage(backend, 100); + (void)pk_backend_finished(backend); + return success; +} Added: soc2013/mattbw/backend/actions/search_names.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/search_names.c Sat Jul 13 07:47:42 2013 (r254743) @@ -0,0 +1,73 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "../pk-backend.h" +#include "pkg.h" + +#include "../actions.h" /* search_names_thread prototype */ +#include "../db.h" /* db_open_remote */ +#include "../search.h" /* search_... */ +#include "../utils.h" /* INTENTIONALLY_IGNORE */ + +/* + * Searches for one or more packages by name. + */ +gboolean +search_names_thread(PkBackend *backend) +{ + gboolean success; + struct search search; + + success = FALSE; + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + (void)pk_backend_set_percentage(backend, 0); + + /* TODO: check search type */ + search.type = MATCH_REGEX; + search.in = FIELD_NAME; + search.sort_by = FIELD_NAME; + search.filters = pk_backend_get_uint(backend, "filters"); + search.term = NULL; + search.db = NULL; + search.backend = backend; + + search.db = db_open_remote(backend); + if (search.db != NULL) { + guint i; + guint len; + gchar **values; + + values = pk_backend_get_strv(backend, "values"); + len = g_strv_length(values); + + success = TRUE; + for (i = 0; i < len && success; i++) { + search.term = values[i]; + success = search_do(&search); + (void)pk_backend_set_percentage(backend, + ((i + 1) * 100) / len); + } + } + + pkgdb_close(search.db); + (void)pk_backend_set_percentage(backend, 100); + (void)pk_backend_finished(backend); + return success; +} From owner-svn-soc-all@FreeBSD.ORG Sat Jul 13 10:26:13 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id DED624C1 for ; Sat, 13 Jul 2013 10:26:13 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id CF93D19DC for ; Sat, 13 Jul 2013 10:26:13 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6DAQD73059849 for ; Sat, 13 Jul 2013 10:26:13 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6DAQDFl059842 for svn-soc-all@FreeBSD.org; Sat, 13 Jul 2013 10:26:13 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 13 Jul 2013 10:26:13 GMT Message-Id: <201307131026.r6DAQDFl059842@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254748 - in soc2013/mattbw/backend: . actions query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 10:26:13 -0000 Author: mattbw Date: Sat Jul 13 10:26:13 2013 New Revision: 254748 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254748 Log: generalise job payloads ready for remove_packages Modified: soc2013/mattbw/backend/actions/install_packages.c soc2013/mattbw/backend/actions/remove_packages.c soc2013/mattbw/backend/query.h soc2013/mattbw/backend/query/core.h soc2013/mattbw/backend/query/jobs.c soc2013/mattbw/backend/query/jobs.h Modified: soc2013/mattbw/backend/actions/install_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install_packages.c Sat Jul 13 08:17:55 2013 (r254747) +++ soc2013/mattbw/backend/actions/install_packages.c Sat Jul 13 10:26:13 2013 (r254748) @@ -70,30 +70,12 @@ static bool job(struct pkg_jobs *jobs, struct query *q) { - bool success; - PkBackend *backend; - success = false; - backend = query_backend(q); - query_set_percentage(q, 0); - - pkg_event_register(event_cb, backend); - - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); - if (pkg_jobs_count(jobs) == 0) - ERR(backend, - PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED, - "nothing to do"); - else if (pkg_jobs_apply(jobs) != EPKG_OK) - ERR(backend, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, - "job failed"); - else - success = true; - - pkg_event_register(NULL, NULL); - query_set_percentage(q, 100); - return success; + return query_jobs_apply_emitter(jobs, + q, + PK_STATUS_ENUM_INSTALL, + PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL); } /* @@ -102,22 +84,8 @@ static bool sim_job(struct pkg_jobs *jobs, struct query *q) { - bool success; - PkBackend *backend; - struct pkg *pkg; - - backend = query_backend(q); - query_set_percentage(q, 0); - - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); - pkg = NULL; - while (pkg_jobs(jobs, &pkg) == EPKG_OK) - pkgutils_emit(pkg, - backend, - pkgutils_pkg_install_state(pkg)); - - success = true; - query_set_percentage(q, 100); - return success; + return query_jobs_simulate_emitter(jobs, + q, + pkgutils_pkg_install_state); } Modified: soc2013/mattbw/backend/actions/remove_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/remove_packages.c Sat Jul 13 08:17:55 2013 (r254747) +++ soc2013/mattbw/backend/actions/remove_packages.c Sat Jul 13 10:26:13 2013 (r254748) @@ -78,18 +78,18 @@ backend = query_backend(q); query_set_percentage(q, 0); - if (solve_job(q, jobs) == false) - goto cleanup; - pkg_event_register(event_cb, backend); (void)pk_backend_set_status(backend, PK_STATUS_ENUM_REMOVE); - if (pkg_jobs_apply(jobs) != EPKG_OK) { + if (pkg_jobs_count(jobs) == 0) + ERR(backend, + PK_RROR_ENUM_PACKAGE_NOT_INSTALLED, + "nothing to do"); + else if (pkg_jobs_apply(jobs) != EPKG_OK) ERR(backend, PK_ERROR_ENUM_PACKAGE_FAILED_TO_REMOVE, "job failed"); - goto cleanup; - } + else success = true; cleanup: Modified: soc2013/mattbw/backend/query.h ============================================================================== --- soc2013/mattbw/backend/query.h Sat Jul 13 08:17:55 2013 (r254747) +++ soc2013/mattbw/backend/query.h Sat Jul 13 10:26:13 2013 (r254748) @@ -24,6 +24,7 @@ /* Meta-header for the public interfaces to the query system. */ #include "query/do.h" /* query_do_... */ +#include "query/jobs.h" /* query_jobs_... */ #include "query/match.h" /* query_match_... */ #endif /* !_PKGNG_BACKEND_QUERY_H_ */ Modified: soc2013/mattbw/backend/query/core.h ============================================================================== --- soc2013/mattbw/backend/query/core.h Sat Jul 13 08:17:55 2013 (r254747) +++ soc2013/mattbw/backend/query/core.h Sat Jul 13 10:26:13 2013 (r254748) @@ -31,11 +31,14 @@ typedef bool (*job_emit_ptr) (struct pkg_jobs *jobs, struct query *q); typedef bool (*query_body_ptr) (struct query *q); +/* + * Types of query source. + */ enum query_source_type { - QUERY_SINGLE_ID, - QUERY_SINGLE_NAME, - QUERY_BACKEND_IDS, - QUERY_BACKEND_MIXED + QUERY_SINGLE_ID, /* Expect one (strict) PackageID. */ + QUERY_SINGLE_NAME, /* Expect one package name or name-version. */ + QUERY_BACKEND_IDS, /* Use the backend "package_ids" strv. */ + QUERY_BACKEND_MIXED /* As above but treat non-PackeIDs as names. */ }; enum query_target_type { Modified: soc2013/mattbw/backend/query/jobs.c ============================================================================== --- soc2013/mattbw/backend/query/jobs.c Sat Jul 13 08:17:55 2013 (r254747) +++ soc2013/mattbw/backend/query/jobs.c Sat Jul 13 10:26:13 2013 (r254748) @@ -23,6 +23,8 @@ #include "../pk-backend.h" /* pk..., Pk... */ #include "pkg.h" /* pkg... */ +#include "../event.h" /* event_... */ +#include "../pkgutils.h" /* pkgutils_... */ #include "../utils.h" /* ERR */ #include "core.h" /* query_... */ #include "jobs.h" /* query_jobs_... */ @@ -31,6 +33,36 @@ static int repo_from_query(struct pkg_jobs *jobs, struct query *q); /* + * Generic emitter helper for applying a job with typical failure conditions, + * the standard event handler, and PackageKit backend boilerplate. + */ +bool +query_jobs_apply_emitter(struct pkg_jobs *jobs, struct query *q, + PkStatusEnum status, PkErrorEnum no_jobs, PkErrorEnum job_failed) +{ + bool success; + PkBackend *backend; + + success = false; + backend = query_backend(q); + query_set_percentage(q, 0); + + pkg_event_register(event_cb, backend); + + (void)pk_backend_set_status(backend, status); + if (pkg_jobs_count(jobs) == 0) + ERR(backend, no_jobs, "nothing to do"); + else if (pkg_jobs_apply(jobs) != EPKG_OK) + ERR(backend, job_failed, "job failed"); + else + success = true; + + pkg_event_register(NULL, NULL); + query_set_percentage(q, 100); + return success; +} + +/* * Creates a job of type "type" for the given package, solves it, and sends it * to the emitter function "f" alongside its parent query. */ @@ -83,6 +115,29 @@ return success; } +/* + * Like query_jobs_apply_emitter, but just emits all the packages with the + * information field taken from info(pkg). + */ +bool +query_jobs_simulate_emitter(struct pkg_jobs *jobs, struct query *q, + pkg_info_ptr info) +{ + PkBackend *backend; + struct pkg *pkg; + + backend = query_backend(q); + query_set_percentage(q, 0); + + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); + pkg = NULL; + while (pkg_jobs(jobs, &pkg) == EPKG_OK) + pkgutils_emit(pkg, backend, info(pkg)); + + query_set_percentage(q, 100); + return true; +} + /* Adds a single package to a jobs structure. */ static int add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg) Modified: soc2013/mattbw/backend/query/jobs.h ============================================================================== --- soc2013/mattbw/backend/query/jobs.h Sat Jul 13 08:17:55 2013 (r254747) +++ soc2013/mattbw/backend/query/jobs.h Sat Jul 13 10:26:13 2013 (r254748) @@ -25,6 +25,10 @@ #include "core.h" /* struct query */ +typedef PkInfoEnum (*pkg_info_ptr) (struct pkg *pkg); + +bool query_jobs_apply_emitter(struct pkg_jobs *jobs, struct query *q, PkStatusEnum status, PkErrorEnum no_jobs, PkErrorEnum job_failed); bool query_jobs_run(struct query *q, struct pkg *pkg, pkg_jobs_t type, job_emit_ptr f); +bool query_jobs_simulate_emitter(struct pkg_jobs *jobs, struct query *q, pkg_info_ptr info); #endif /* !_PKGNG_BACKEND_QUERY_JOBS_H_ */ From owner-svn-soc-all@FreeBSD.ORG Sat Jul 13 11:19:22 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 647A873 for ; Sat, 13 Jul 2013 11:19:22 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 555271B3C for ; Sat, 13 Jul 2013 11:19:22 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6DBJMxE026551 for ; Sat, 13 Jul 2013 11:19:22 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6DBJMgY026526 for svn-soc-all@FreeBSD.org; Sat, 13 Jul 2013 11:19:22 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 13 Jul 2013 11:19:22 GMT Message-Id: <201307131119.r6DBJMgY026526@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254751 - in soc2013/mattbw/backend: . actions query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 11:19:22 -0000 Author: mattbw Date: Sat Jul 13 11:19:21 2013 New Revision: 254751 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254751 Log: implemented barebones version of remove_packages; simulation seems to be broken Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions.h soc2013/mattbw/backend/actions/install_packages.c soc2013/mattbw/backend/actions/remove_packages.c soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/pkgutils.h soc2013/mattbw/backend/query/core.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Sat Jul 13 10:47:17 2013 (r254750) +++ soc2013/mattbw/backend/Makefile Sat Jul 13 11:19:21 2013 (r254751) @@ -18,6 +18,7 @@ actions/get_repo_list.c \ actions/install_files.c \ actions/install_packages.c \ + actions/remove_packages.c \ actions/resolve.c \ actions/search_groups.c \ actions/search_names.c @@ -38,7 +39,7 @@ .if USE_PK_PKGCONF PKGS+= packagekit-glib2 .else -CFLAGS+= -isystem/usr/local/include/PackageKit -isystem/usr/local/include/PackageKit/backend +CFLAGS+= -I/usr/local/include/PackageKit -I/usr/local/include/PackageKit/backend LDFLAGS+= -L/usr/local/lib -lpackagekit-glib2 .endif Modified: soc2013/mattbw/backend/actions.h ============================================================================== --- soc2013/mattbw/backend/actions.h Sat Jul 13 10:47:17 2013 (r254750) +++ soc2013/mattbw/backend/actions.h Sat Jul 13 11:19:21 2013 (r254751) @@ -34,9 +34,11 @@ gboolean install_files_thread(PkBackend *backend); gboolean install_packages_thread(PkBackend *backend); gboolean resolve_thread(PkBackend *backend); +gboolean remove_packages_thread(PkBackend *backend); gboolean search_groups_thread(PkBackend *backend); gboolean search_names_thread(PkBackend *backend); gboolean simulate_install_files_thread(PkBackend *backend); gboolean simulate_install_packages_thread(PkBackend *backend); +gboolean simulate_remove_packages_thread(PkBackend *backend); #endif /* !_PKGNG_BACKEND_ACTIONS_H_ */ Modified: soc2013/mattbw/backend/actions/install_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install_packages.c Sat Jul 13 10:47:17 2013 (r254750) +++ soc2013/mattbw/backend/actions/install_packages.c Sat Jul 13 11:19:21 2013 (r254751) @@ -24,12 +24,10 @@ #include "pkg.h" /* pkg... */ #include "../actions.h" /* install_packages_thread prototype */ -#include "../event.h" /* event_... */ #include "../pkgutils.h" /* pkgutils_... */ #include "../query.h" /* query_... */ -#include "../utils.h" /* INTENTIONALLY_IGNORE, ERR */ -static bool job (struct pkg_jobs *jobs, struct query *q); +static bool job(struct pkg_jobs *jobs, struct query *q); static bool sim_job(struct pkg_jobs *jobs, struct query *q); /* Modified: soc2013/mattbw/backend/actions/remove_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/remove_packages.c Sat Jul 13 10:47:17 2013 (r254750) +++ soc2013/mattbw/backend/actions/remove_packages.c Sat Jul 13 11:19:21 2013 (r254751) @@ -24,14 +24,11 @@ #include "pkg.h" /* pkg... */ #include "../actions.h" /* remove_packages_thread prototype */ -#include "../event.c" /* event_... */ #include "../pkgutils.h" /* pkgutils_... */ #include "../query.h" /* query_... */ -#include "../utils.h" /* INTENTIONALLY_IGNORE, ERR */ static bool job (struct pkg_jobs *jobs, struct query *q); static bool sim_job(struct pkg_jobs *jobs, struct query *q); -static bool solve_job(struct query *q, struct pkg_jobs *jobs); /* * The thread that performs an removePackages operation. Should be invoked @@ -43,14 +40,14 @@ bool success; (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - success = query_match_id_to_job(backend, PKG_JOBS_remove, job); + success = query_match_id_to_job(backend, PKG_JOBS_DEINSTALL, job); (void)pk_backend_finished(backend); return success ? TRUE : FALSE; } /* - * The thread that performs a Simulate removePackages operation. Should be + * The thread that performs a Simulate RemovePackages operation. Should be * invoked by the pk_backend_simulate_remove_packages hook. */ gboolean @@ -59,7 +56,7 @@ bool success; (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - success = query_match_id_to_job(backend, PKG_JOBS_remove, sim_job); + success = query_match_id_to_job(backend, PKG_JOBS_DEINSTALL, sim_job); (void)pk_backend_finished(backend); return success ? TRUE : FALSE; @@ -71,31 +68,12 @@ static bool job(struct pkg_jobs *jobs, struct query *q) { - bool success; - PkBackend *backend; - success = false; - backend = query_backend(q); - query_set_percentage(q, 0); - - pkg_event_register(event_cb, backend); - - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_REMOVE); - if (pkg_jobs_count(jobs) == 0) - ERR(backend, - PK_RROR_ENUM_PACKAGE_NOT_INSTALLED, - "nothing to do"); - else if (pkg_jobs_apply(jobs) != EPKG_OK) - ERR(backend, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_REMOVE, - "job failed"); - else - success = true; - -cleanup: - pkg_event_register(NULL, NULL); - query_set_percentage(q, 100); - return success; + return query_jobs_apply_emitter(jobs, + q, + PK_STATUS_ENUM_REMOVE, + PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_REMOVE); } /* @@ -104,54 +82,8 @@ static bool sim_job(struct pkg_jobs *jobs, struct query *q) { - bool success; - PkBackend *backend; - struct pkg *pkg; - - backend = query_backend(q); - success = false; - query_set_percentage(q, 0); - - if (solve_job(q, jobs) == false) - goto cleanup; - - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); - pkg = NULL; - while (pkg_jobs(jobs, &pkg) == EPKG_OK) - pkgutils_emit(pkg, - backend, - pkgutils_pkg_remove_state(pkg)); - - success = true; - -cleanup: - query_set_percentage(q, 100); - return success; -} - -/* - * Solves a job and ensures it has packages available. - */ -static bool -solve_job(struct query *q, struct pkg_jobs *jobs) -{ - bool success; - PkBackend *backend; - - success = false; - backend = query_backend(q); - - (void)pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); - if (pkg_jobs_solve(jobs) != EPKG_OK) - ERR(backend, - PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, - "could not solve the job"); - else if (pkg_jobs_count(jobs) == 0) - ERR(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "job contains no packages"); - else - success = true; - return success; + return query_jobs_simulate_emitter(jobs, + q, + pkgutils_pkg_remove_state); } Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Sat Jul 13 10:47:17 2013 (r254750) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Sat Jul 13 11:19:21 2013 (r254751) @@ -27,10 +27,12 @@ #include "pk-backend.h" #include "pkg.h" -#include "utils.h" /* INTENTIONALLY_IGNORE */ +#include "utils.h" /* INTENTIONALLY_IGNORE, ERR */ #include "group.h" /* group_bitfield */ #include "actions.h" /* Actions threads */ +#define THREAD(bend, thread) (void)pk_backend_thread_create((bend), (thread)) + void pk_backend_initialize(PkBackend *backend) { @@ -41,9 +43,7 @@ if (!pkg_initialized()) err = pkg_init(NULL); if (err) - (void)pk_backend_error_code(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "could not initialise pkg"); + ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "couldn't init pkg"); } void @@ -90,7 +90,7 @@ { INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ - (void)pk_backend_thread_create(backend, get_details_thread); + THREAD(backend, get_details_thread); } void @@ -98,7 +98,7 @@ { INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ - (void)pk_backend_thread_create(backend, get_files_thread); + THREAD(backend, get_files_thread); } PkBitfield @@ -142,7 +142,7 @@ { INTENTIONALLY_IGNORE(filters); /* not yet supported */ - (void)pk_backend_thread_create(backend, get_repo_list_thread); + THREAD(backend, get_repo_list_thread); } void @@ -152,7 +152,7 @@ INTENTIONALLY_IGNORE(only_trusted); /* not yet supported */ INTENTIONALLY_IGNORE(full_paths); /* retrieved from backend */ - (void)pk_backend_thread_create(backend, install_files_thread); + THREAD(backend, install_files_thread); } void @@ -162,34 +162,45 @@ INTENTIONALLY_IGNORE(only_trusted); /* not yet supported */ INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ - (void)pk_backend_thread_create(backend, install_packages_thread); + THREAD(backend, install_packages_thread); +} + +void +pk_backend_remove_packages(PkBackend *backend, gchar **package_ids, + gboolean allow_deps, gboolean autoremove) +{ + + INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + INTENTIONALLY_IGNORE(allow_deps); /* not yet supported */ + INTENTIONALLY_IGNORE(autoremove); /* not yet supported */ + THREAD(backend, remove_packages_thread); } void pk_backend_resolve(PkBackend *backend, PkBitfield filters, gchar **package_ids) { - INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ + INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ - (void)pk_backend_thread_create(backend, resolve_thread); + THREAD(backend, resolve_thread); } void pk_backend_search_groups(PkBackend *backend, PkBitfield filters, gchar **values) { - INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ + INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ (void)pk_backend_set_strv(backend, "values", values); - (void)pk_backend_thread_create(backend, search_groups_thread); + THREAD(backend, search_groups_thread); } void pk_backend_search_names(PkBackend *backend, PkBitfield filters, gchar **values) { - INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ + INTENTIONALLY_IGNORE(filters); /* retrieved from backend */ (void)pk_backend_set_strv(backend, "values", values); - (void)pk_backend_thread_create(backend, search_names_thread); + THREAD(backend, search_names_thread); } void @@ -197,7 +208,7 @@ { INTENTIONALLY_IGNORE(full_paths); /* retrieved from backend */ - (void)pk_backend_thread_create(backend, simulate_install_files_thread); + THREAD(backend, simulate_install_files_thread); } void @@ -205,6 +216,15 @@ { INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ - (void)pk_backend_thread_create(backend, - simulate_install_packages_thread); + THREAD(backend, simulate_install_packages_thread); +} + +void +pk_backend_simulate_remove_packages(PkBackend *backend, gchar **package_ids, + gboolean autoremove) +{ + + INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ + INTENTIONALLY_IGNORE(autoremove); /* not yet supported */ + THREAD(backend, simulate_remove_packages_thread); } Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Sat Jul 13 10:47:17 2013 (r254750) +++ soc2013/mattbw/backend/pkgutils.c Sat Jul 13 11:19:21 2013 (r254751) @@ -25,6 +25,7 @@ #include "pkg.h" #include "pkgutils.h" /* Prototypes */ +#include "utils.h" /* INTENTIONALLY_IGNORE */ static const char *repo_of_remote(struct pkg *pkg); @@ -84,6 +85,18 @@ } /* + * Infers the correct PkInfoEnum to emit for this package if it is being + * removed. + */ +PkInfoEnum +pkgutils_pkg_remove_state(struct pkg *pkg) +{ + + INTENTIONALLY_IGNORE(pkg); + return PK_INFO_ENUM_REMOVING; +} + +/* * Gets the PackageKit repository name for the package. */ const char * Modified: soc2013/mattbw/backend/pkgutils.h ============================================================================== --- soc2013/mattbw/backend/pkgutils.h Sat Jul 13 10:47:17 2013 (r254750) +++ soc2013/mattbw/backend/pkgutils.h Sat Jul 13 11:19:21 2013 (r254751) @@ -27,6 +27,7 @@ PkInfoEnum pkgutils_pkg_current_state(struct pkg *pkg); PkInfoEnum pkgutils_pkg_install_state(struct pkg *pkg); +PkInfoEnum pkgutils_pkg_remove_state(struct pkg *pkg); const char *pkgutils_pk_repo_of(struct pkg *pkg); gchar *pkgutils_pkg_to_id(struct pkg *pkg); gchar *pkgutils_pkg_to_id_through(struct pkg *pkg, const gchar **strv); Modified: soc2013/mattbw/backend/query/core.c ============================================================================== --- soc2013/mattbw/backend/query/core.c Sat Jul 13 10:47:17 2013 (r254750) +++ soc2013/mattbw/backend/query/core.c Sat Jul 13 11:19:21 2013 (r254751) @@ -144,17 +144,16 @@ } /* - * Retrieves the repository for the query, or NULL if none is specified. + * Retrieves the repository for the query, or NULL if none is specified (or + * the query is using the local database only). */ const char * query_repo(struct query *q) { - const gchar *repo; - assert(q != NULL); - repo = q->id_strv[PK_PACKAGE_ID_DATA]; - return ((repo == NULL || repo[0] == '\0') ? NULL : repo); + return (q->rtype == REPO_REMOTE ? + q->id_strv[PK_PACKAGE_ID_DATA] : NULL); } /* From owner-svn-soc-all@FreeBSD.ORG Sat Jul 13 12:55:38 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4CE2187B for ; Sat, 13 Jul 2013 12:55:38 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 3ECD91F5C for ; Sat, 13 Jul 2013 12:55:38 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6DCtbNn022039 for ; Sat, 13 Jul 2013 12:55:37 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6DCtbA0022034 for svn-soc-all@FreeBSD.org; Sat, 13 Jul 2013 12:55:37 GMT (envelope-from zcore@FreeBSD.org) Date: Sat, 13 Jul 2013 12:55:37 GMT Message-Id: <201307131255.r6DCtbA0022034@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254752 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 12:55:38 -0000 Author: zcore Date: Sat Jul 13 12:55:37 2013 New Revision: 254752 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254752 Log: use BAR(5) Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Jul 13 11:19:21 2013 (r254751) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sat Jul 13 12:55:37 2013 (r254752) @@ -130,7 +130,7 @@ pci_emul_add_msicap(pi, 1); - pci_emul_alloc_bar(pi, 0, PCIBAR_IO, AHCI_REGSZ); + pci_emul_alloc_bar(pi, 5, PCIBAR_IO, AHCI_REGSZ); return (0); } @@ -140,7 +140,7 @@ int baridx, uint64_t offset, int size, uint64_t value) { - assert(baridx == 0); + assert(baridx == 5); switch (offset) { default: @@ -156,7 +156,7 @@ { uint32_t value; - assert(baridx == 0); + assert(baridx == 5); switch (offset) { case AHCI_CAP: From owner-svn-soc-all@FreeBSD.ORG Sat Jul 13 12:56:06 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E6774895 for ; Sat, 13 Jul 2013 12:56:05 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id C92EC1F61 for ; Sat, 13 Jul 2013 12:56:05 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6DCu56b025003 for ; Sat, 13 Jul 2013 12:56:05 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6DCu53x024994 for svn-soc-all@FreeBSD.org; Sat, 13 Jul 2013 12:56:05 GMT (envelope-from zcore@FreeBSD.org) Date: Sat, 13 Jul 2013 12:56:05 GMT Message-Id: <201307131256.r6DCu53x024994@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254753 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 12:56:06 -0000 Author: zcore Date: Sat Jul 13 12:56:05 2013 New Revision: 254753 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254753 Log: import block_if from Peter Grehan Added: soc2013/zcore/head/usr.sbin/bhyve/block_if.c soc2013/zcore/head/usr.sbin/bhyve/block_if.h Modified: soc2013/zcore/head/usr.sbin/bhyve/Makefile Modified: soc2013/zcore/head/usr.sbin/bhyve/Makefile ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/Makefile Sat Jul 13 12:55:37 2013 (r254752) +++ soc2013/zcore/head/usr.sbin/bhyve/Makefile Sat Jul 13 12:56:05 2013 (r254753) @@ -6,8 +6,8 @@ DEBUG_FLAGS= -g -O0 -SRCS= acpi.c atpic.c bhyverun.c consport.c dbgport.c elcr.c inout.c -SRCS+= ioapic.c mem.c mevent.c mptbl.c +SRCS= acpi.c atpic.c bhyverun.c block_if.c consport.c dbgport.c elcr.c +SRCS+= inout.c ioapic.c mem.c mevent.c mptbl.c SRCS+= pci_emul.c pci_hostbridge.c pci_passthru.c pci_virtio_block.c SRCS+= pci_virtio_net.c pci_uart.c pit_8254.c pmtmr.c post.c rtc.c SRCS+= xmsr.c spinup_ap.c pci_ahci.c Added: soc2013/zcore/head/usr.sbin/bhyve/block_if.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/zcore/head/usr.sbin/bhyve/block_if.c Sat Jul 13 12:56:05 2013 (r254753) @@ -0,0 +1,371 @@ +/*- + * Copyright (c) 2013 Peter Grehan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bhyverun.h" +#include "block_if.h" + +#define BLOCKIF_SIG 0xb109b109 + +#define BLOCKIF_MAXREQ 8 + +enum blockop { + BOP_READ, + BOP_WRITE, + BOP_CANCEL +}; + +struct blockif_elem { + struct blockif_req *be_req; + enum blockop be_op; +}; + +struct blockif_ctxt { + int bc_magic; + int bc_fd; + int bc_rdonly; + off_t bc_size; + int bc_sectsz; + pthread_t bc_btid; + pthread_mutex_t bc_mtx; + pthread_cond_t bc_cond; + int bc_closing; + + /* Circular request queue */ + int bc_req_next; + u_int bc_req_count; + struct blockif_elem bc_reqs[BLOCKIF_MAXREQ]; +}; + +static int +blockif_enqueue(struct blockif_ctxt *bc, struct blockif_req *breq, + enum blockop op) +{ + + assert(bc->bc_req_count < BLOCKIF_MAXREQ); + + bc->bc_reqs[bc->bc_req_next].be_req = breq; + bc->bc_reqs[bc->bc_req_next].be_op = op; + bc->bc_req_next = (bc->bc_req_next + 1) % BLOCKIF_MAXREQ; + bc->bc_req_count++; + + return (0); +} + +static int +blockif_dequeue(struct blockif_ctxt *bc, struct blockif_elem *el) +{ + int tail; + + if (bc->bc_req_count == 0) + return (ENOENT); + + tail = (bc->bc_req_next - bc->bc_req_count + BLOCKIF_MAXREQ) % + BLOCKIF_MAXREQ; + *el = bc->bc_reqs[tail]; + bc->bc_req_count--; + + return (0); +} + +static void +blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be) +{ + struct blockif_req *br; + int err; + + br = be->be_req; + err = 0; + + switch (be->be_op) { + case BOP_READ: + if (preadv(bc->bc_fd, br->br_iov, br->br_iovcnt, + br->br_offset) < 0) + err = errno; + break; + case BOP_WRITE: + if (bc->bc_rdonly) + err = EROFS; + else if (pwritev(bc->bc_fd, br->br_iov, br->br_iovcnt, + br->br_offset) < 0) + err = errno; + break; + case BOP_CANCEL: + err = EINTR; + break; + default: + err = EINVAL; + break; + } + + (*br->br_callback)(br, err); +} + +static void * +blockif_thr(void *arg) +{ + struct blockif_ctxt *bc; + struct blockif_elem req; + + bc = arg; + + for (;;) { + pthread_mutex_lock(&bc->bc_mtx); + while (!blockif_dequeue(bc, &req)) { + pthread_mutex_unlock(&bc->bc_mtx); + blockif_proc(bc, &req); + pthread_mutex_lock(&bc->bc_mtx); + } + pthread_cond_wait(&bc->bc_cond, &bc->bc_mtx); + + /* + * Check ctxt status here to see if exit requested + */ + if (bc->bc_closing) { + pthread_mutex_unlock(&bc->bc_mtx); + pthread_exit(NULL); + } + } + + /* Not reached */ + return (NULL); +} + +struct blockif_ctxt * +blockif_open(const char *optstr, const char *ident) +{ + char tname[MAXCOMLEN + 1]; + struct blockif_ctxt *bc; + struct stat sbuf; + off_t size; + int extra, fd, ro, sectsz; + + ro = 0; + + /* + * XXX test option. cache/nocache/default behaviour should be + * implemented in the optstr + */ + extra = 0; + if (getenv("BHYVE_BLOCKIF_NOCACHE")) + extra = O_DIRECT; + else if (getenv("BHYVE_BLOCKIF_SYNC")) + extra = O_SYNC; + + fd = open(optstr, O_RDWR | extra); + if (fd < 0) { + /* + * Try again as read-only + */ + fd = open(optstr, O_RDONLY | extra); + if (fd < 0) { + perror("Could not open backing file"); + return (NULL); + } + ro = 1; + } + + if (fstat(fd, &sbuf) < 0) { + perror("Could not stat backing file"); + close(fd); + return (NULL); + } + + /* + * Deal with raw devices + */ + size = sbuf.st_size; + sectsz = DEV_BSIZE; + if (S_ISCHR(sbuf.st_mode)) { + if (ioctl(fd, DIOCGMEDIASIZE, &size) < 0 || + ioctl(fd, DIOCGSECTORSIZE, §sz)) { + perror("Could not fetch dev blk/sector size"); + close(fd); + return (NULL); + } + assert(size != 0); + assert(sectsz != 0); + } + + bc = malloc(sizeof(struct blockif_ctxt)); + if (bc == NULL) { + close(fd); + return (NULL); + } + + memset(bc, 0, sizeof(*bc)); + bc->bc_magic = BLOCKIF_SIG; + bc->bc_fd = fd; + bc->bc_size = size; + bc->bc_sectsz = sectsz; + pthread_mutex_init(&bc->bc_mtx, NULL); + pthread_cond_init(&bc->bc_cond, NULL); + bc->bc_req_next = 0; + bc->bc_req_count = 0; + + pthread_create(&bc->bc_btid, NULL, blockif_thr, bc); + + snprintf(tname, sizeof(tname), "%s blk-%s", vmname, ident); + pthread_set_name_np(bc->bc_btid, tname); + + return (bc); +} + +static int +blockif_request(struct blockif_ctxt *bc, struct blockif_req *breq, + enum blockop op) +{ + int err; + + err = 0; + + pthread_mutex_lock(&bc->bc_mtx); + if (bc->bc_req_count < BLOCKIF_MAXREQ) { + /* + * Enqueue and inform the block i/o thread + * that there is work available + */ + blockif_enqueue(bc, breq, op); + pthread_cond_signal(&bc->bc_cond); + } else { + /* + * Callers are not allowed to enqueue more than + * the specified blockif queue limit. Return an + * error to indicate that the queue length has been + * exceeded. + */ + err = E2BIG; + } + pthread_mutex_unlock(&bc->bc_mtx); + + return (err); +} + +int +blockif_read(struct blockif_ctxt *bc, struct blockif_req *breq) +{ + + assert(bc->bc_magic == BLOCKIF_SIG); + return (blockif_request(bc, breq, BOP_READ)); +} + +int +blockif_write(struct blockif_ctxt *bc, struct blockif_req *breq) +{ + + assert(bc->bc_magic == BLOCKIF_SIG); + return (blockif_request(bc, breq, BOP_WRITE)); +} + +int +blockif_cancel(struct blockif_ctxt *bc, struct blockif_req *breq) +{ + + assert(bc->bc_magic == BLOCKIF_SIG); + return (blockif_request(bc, breq, BOP_CANCEL)); +} + +int +blockif_close(struct blockif_ctxt *bc) +{ + void *jval; + int err; + + err = 0; + + assert(bc->bc_magic == BLOCKIF_SIG); + + /* + * Stop the block i/o thread + */ + bc->bc_closing = 1; + pthread_join(bc->bc_btid, &jval); + + /* XXX Cancel queued i/o's ??? */ + + /* + * Release resources + */ + bc->bc_magic = 0; + close(bc->bc_fd); + free(bc); + + return (0); +} + +/* + * Accessors + */ +off_t +blockif_size(struct blockif_ctxt *bc) +{ + + assert(bc->bc_magic == BLOCKIF_SIG); + return (bc->bc_size); +} + +int +blockif_sectsz(struct blockif_ctxt *bc) +{ + + assert(bc->bc_magic == BLOCKIF_SIG); + return (bc->bc_sectsz); +} + +int +blockif_queuesz(struct blockif_ctxt *bc) +{ + + assert(bc->bc_magic == BLOCKIF_SIG); + return (BLOCKIF_MAXREQ); +} + +int +blockif_is_ro(struct blockif_ctxt *bc) +{ + + assert(bc->bc_magic == BLOCKIF_SIG); + return (bc->bc_rdonly); +} Added: soc2013/zcore/head/usr.sbin/bhyve/block_if.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/zcore/head/usr.sbin/bhyve/block_if.h Sat Jul 13 12:56:05 2013 (r254753) @@ -0,0 +1,56 @@ +/*- + * Copyright (c) 2013 Peter Grehan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _BLOCK_IF_H_ +#define _BLOCK_IF_H_ + +#include +#include + +#define BLOCKIF_IOV_MAX 32 /* XXX */ + +struct blockif_req { + struct iovec br_iov[BLOCKIF_IOV_MAX]; + int br_iovcnt; + off_t br_offset; + void (*br_callback)(struct blockif_req *req, int err); + void *br_param; +}; + +struct blockif_ctxt; +struct blockif_ctxt *blockif_open(const char *optstr, const char *ident); +off_t blockif_size(struct blockif_ctxt *bc); +int blockif_sectsz(struct blockif_ctxt *bc); +int blockif_queuesz(struct blockif_ctxt *bc); +int blockif_is_ro(struct blockif_ctxt *bc); +int blockif_read(struct blockif_ctxt *bc, struct blockif_req *breq); +int blockif_write(struct blockif_ctxt *bc, struct blockif_req *breq); +int blockif_cancel(struct blockif_ctxt *bc, struct blockif_req *breq); +int blockif_close(struct blockif_ctxt *bc); + +#endif /* _BLOCK_IF_H_ */ From owner-svn-soc-all@FreeBSD.ORG Sat Jul 13 17:38:58 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B035E69D for ; Sat, 13 Jul 2013 17:38:58 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 924B41A89 for ; Sat, 13 Jul 2013 17:38:58 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6DHcwCP009485 for ; Sat, 13 Jul 2013 17:38:58 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6DHcw7c009468 for svn-soc-all@FreeBSD.org; Sat, 13 Jul 2013 17:38:58 GMT (envelope-from def@FreeBSD.org) Date: Sat, 13 Jul 2013 17:38:58 GMT Message-Id: <201307131738.r6DHcw7c009468@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254757 - in soc2013/def/crashdump-head/sys: amd64/conf conf crypto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 17:38:58 -0000 Author: def Date: Sat Jul 13 17:38:58 2013 New Revision: 254757 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254757 Log: Import XTS implementation from pefs. Compile kernel with ENCRYPT_CRASH option - compile xts.c into kernel. Added: soc2013/def/crashdump-head/sys/crypto/xts.c soc2013/def/crashdump-head/sys/crypto/xts.h Modified: soc2013/def/crashdump-head/sys/amd64/conf/GENERIC soc2013/def/crashdump-head/sys/conf/files soc2013/def/crashdump-head/sys/conf/options Modified: soc2013/def/crashdump-head/sys/amd64/conf/GENERIC ============================================================================== --- soc2013/def/crashdump-head/sys/amd64/conf/GENERIC Sat Jul 13 15:34:37 2013 (r254756) +++ soc2013/def/crashdump-head/sys/amd64/conf/GENERIC Sat Jul 13 17:38:58 2013 (r254757) @@ -339,3 +339,6 @@ device virtio_blk # VirtIO Block device device virtio_scsi # VirtIO SCSI device device virtio_balloon # VirtIO Memory Balloon device + +# Unattended encrypted kernel crash dumps +option ENCRYPT_CRASH Modified: soc2013/def/crashdump-head/sys/conf/files ============================================================================== --- soc2013/def/crashdump-head/sys/conf/files Sat Jul 13 15:34:37 2013 (r254756) +++ soc2013/def/crashdump-head/sys/conf/files Sat Jul 13 17:38:58 2013 (r254757) @@ -546,6 +546,7 @@ netgraph_mppc_encryption | sctp crypto/sha2/sha2.c optional crypto | geom_bde | ipsec | random | \ sctp | zfs +crypto/xts.c optional crypto | encrypt_crash ddb/db_access.c optional ddb ddb/db_break.c optional ddb ddb/db_capture.c optional ddb Modified: soc2013/def/crashdump-head/sys/conf/options ============================================================================== --- soc2013/def/crashdump-head/sys/conf/options Sat Jul 13 15:34:37 2013 (r254756) +++ soc2013/def/crashdump-head/sys/conf/options Sat Jul 13 17:38:58 2013 (r254757) @@ -897,3 +897,6 @@ # Resource Limits RCTL opt_global.h + +# Unattended encrypted kernel crash dumps +ENCRYPT_CRASH opt_crash.h Added: soc2013/def/crashdump-head/sys/crypto/xts.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/def/crashdump-head/sys/crypto/xts.c Sat Jul 13 17:38:58 2013 (r254757) @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2007, 2008 University of Tsukuba + * Copyright (c) 2010 Gleb Kurtsou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of the University of Tsukuba nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +#ifdef _KERNEL +#include +#else +#include +#endif + +void +xts_aes_keysetup(struct xts_ctx *ctx, const uint8_t *key, uint32_t keybits) +{ + rijndael_set_key(&ctx->o.pctx_aes, key, keybits); +} + +void +xts_aes_encrypt(const struct xts_ctx *ctx, const uint8_t *in, uint8_t *out) +{ + rijndael_encrypt(&ctx->o.pctx_aes, in, out); +} + +void +xts_aes_decrypt(const struct xts_ctx *ctx, const uint8_t *in, uint8_t *out) +{ + rijndael_decrypt(&ctx->o.pctx_aes, in, out); +} + +const struct xts_alg xts_alg_aes = { + .pa_encrypt = xts_aes_encrypt, + .pa_decrypt = xts_aes_decrypt, + .pa_keysetup = xts_aes_keysetup, + .pa_id = XTS_ALG_AES, +}; + +static __inline void +xor128(void *dst, const void *src1, const void *src2) +{ + const uint64_t *s1 = (const uint64_t *)src1; + const uint64_t *s2 = (const uint64_t *)src2; + uint64_t *d = (uint64_t *)dst; + + d[0] = s1[0] ^ s2[0]; + d[1] = s1[1] ^ s2[1]; +} + +static __inline int +shl128(uint64_t *d, const uint64_t *s) +{ + int c0, c1; + + c0 = s[0] & (1ULL << 63) ? 1 : 0; + c1 = s[1] & (1ULL << 63) ? 1 : 0; + d[0] = s[0] << 1; + d[1] = s[1] << 1 | c0; + + return (c1); +} + +static __inline void +gf_mul128(uint64_t *dst, const uint64_t *src) +{ + static const uint8_t gf_128_fdbk = 0x87; + int carry; + + carry = shl128(dst, src); + if (carry != 0) + ((uint8_t *)dst)[0] ^= gf_128_fdbk; +} + +static __inline void +xts_fullblock(algop_crypt_t *data_crypt, const struct xts_ctx *data_ctx, + uint64_t *tweak, const uint8_t *src, uint8_t *dst) +{ + xor128(dst, src, tweak); + data_crypt(data_ctx, dst, dst); + xor128(dst, dst, tweak); + gf_mul128(tweak, tweak); +} + +static __inline void +xts_lastblock(algop_crypt_t *data_crypt, const struct xts_ctx *data_ctx, + uint64_t *tweak, const uint8_t *src, uint8_t *dst, int len) +{ + uint8_t b[XTS_BLK_BYTES]; + + dst -= XTS_BLK_BYTES; /* m - 1 */ + memcpy(b, dst, XTS_BLK_BYTES); + memcpy(b, src, len); + memcpy(dst + XTS_BLK_BYTES, dst, len); + + xor128(dst, b, tweak); + data_crypt(data_ctx, dst, dst); + xor128(dst, dst, tweak); +} + +static __inline void +xts_smallblock(const struct xts_alg *alg, const struct xts_ctx *data_ctx, + uint64_t *tweak, const uint8_t *src, uint8_t *dst, int len) +{ + uint8_t buf[XTS_BLK_BYTES], *p; + + /* + * Encryption/decryption of sectors smaller then 128 bits is not defined + * by IEEE P1619 standard. + * To work around it encrypt such sector in CTR mode. + * CTR tweak (counter) value is XTS-tweak xor'ed with block length, i.e. + * entire small block has to be reencrypted after length change. + */ + memset(buf, len, XTS_BLK_BYTES); + xor128(buf, buf, tweak); + alg->pa_encrypt(data_ctx, buf, buf); + for (p = buf; len > 0; len--) + *(dst++) = *(src++) ^ *(p++); +} + +static __inline void +xts_start(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, + uint64_t *tweak, uint64_t sector, const uint8_t *xtweak) +{ + tweak[0] = htole64(sector); + tweak[1] = *((const uint64_t *)xtweak); + + /* encrypt the tweak */ + alg->pa_encrypt(tweak_ctx, (uint8_t *)tweak, (uint8_t *)tweak); +} + +void +xts_block_encrypt(const struct xts_alg *alg, + const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, + uint64_t sector, const uint8_t *xtweak, int len, + const uint8_t *src, uint8_t *dst) +{ + uint64_t tweak[XTS_BLK_BYTES / 8]; + + xts_start(alg, tweak_ctx, tweak, sector, xtweak); + + if (len < XTS_BLK_BYTES) { + xts_smallblock(alg, data_ctx, tweak, src, dst, len); + return; + } + + while (len >= XTS_BLK_BYTES) { + xts_fullblock(alg->pa_encrypt, data_ctx, tweak, src, dst); + dst += XTS_BLK_BYTES; + src += XTS_BLK_BYTES; + len -= XTS_BLK_BYTES; + } + + if (len != 0) + xts_lastblock(alg->pa_encrypt, data_ctx, tweak, src, dst, len); +} + +void +xts_block_decrypt(const struct xts_alg *alg, + const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, + uint64_t sector, const uint8_t *xtweak, int len, + const uint8_t *src, uint8_t *dst) +{ + uint64_t tweak[XTS_BLK_BYTES / 8]; + uint64_t prevtweak[XTS_BLK_BYTES / 8]; + + xts_start(alg, tweak_ctx, tweak, sector, xtweak); + + if (len < XTS_BLK_BYTES) { + xts_smallblock(alg, data_ctx, tweak, src, dst, len); + return; + } + + if ((len & XTS_BLK_MASK) != 0) + len -= XTS_BLK_BYTES; + + while (len >= XTS_BLK_BYTES) { + xts_fullblock(alg->pa_decrypt, data_ctx, tweak, src, dst); + dst += XTS_BLK_BYTES; + src += XTS_BLK_BYTES; + len -= XTS_BLK_BYTES; + } + + if (len != 0) { + len += XTS_BLK_BYTES; + prevtweak[0] = tweak[0]; + prevtweak[1] = tweak[1]; + gf_mul128(tweak, tweak); + xts_fullblock(alg->pa_decrypt, data_ctx, tweak, src, dst); + dst += XTS_BLK_BYTES; + src += XTS_BLK_BYTES; + len -= XTS_BLK_BYTES; + xts_lastblock(alg->pa_decrypt, data_ctx, prevtweak, + src, dst, len); + } +} Added: soc2013/def/crashdump-head/sys/crypto/xts.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/def/crashdump-head/sys/crypto/xts.h Sat Jul 13 17:38:58 2013 (r254757) @@ -0,0 +1,75 @@ +/*- + * Copyright (c) 2009 Gleb Kurtsou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef __XTS_H +#define __XTS_H + +#include +#include + +#define XTS_BLK_BYTES 16 +#define XTS_BLK_MASK (XTS_BLK_BYTES - 1) +#define XTS_ALG_INVALID 0 +#define XTS_ALG_AES 4 +#define XTS_ALG_CAMELLIA 5 + +struct xts_ctx { + union { + camellia_ctx pctx_camellia; + rijndael_ctx pctx_aes; + } o; +} __aligned(CACHE_LINE_SIZE); + + +typedef void algop_crypt_t(const struct xts_ctx *ctx, const uint8_t *in, uint8_t *out); +typedef void algop_keysetup_t(struct xts_ctx *ctx, const uint8_t *key, uint32_t keybits); + +struct xts_alg { + algop_crypt_t *pa_encrypt; + algop_crypt_t *pa_decrypt; + algop_keysetup_t *pa_keysetup; + int pa_id; +}; + +void xts_block_encrypt(const struct xts_alg *alg, + const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, + uint64_t sector, const uint8_t *xtweak, int len, + const uint8_t *src, uint8_t *dst); + +void xts_block_decrypt(const struct xts_alg *alg, + const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, + uint64_t sector, const uint8_t *xtweak, int len, + const uint8_t *src, uint8_t *dst); + +algop_crypt_t xts_aes_encrypt; +algop_crypt_t xts_aes_decrypt; +algop_keysetup_t xts_aes_keysetup; + +extern const struct xts_alg xts_alg_aes; + +#endif /* __XTS_H */ From owner-svn-soc-all@FreeBSD.ORG Sat Jul 13 17:42:52 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 21DDF799 for ; Sat, 13 Jul 2013 17:42:52 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 13AF81A9A for ; Sat, 13 Jul 2013 17:42:52 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6DHgpu2049632 for ; Sat, 13 Jul 2013 17:42:51 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6DHgpmN049630 for svn-soc-all@FreeBSD.org; Sat, 13 Jul 2013 17:42:51 GMT (envelope-from def@FreeBSD.org) Date: Sat, 13 Jul 2013 17:42:51 GMT Message-Id: <201307131742.r6DHgpmN049630@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254758 - soc2013/def/crashdump-head/sys/sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 17:42:52 -0000 Author: def Date: Sat Jul 13 17:42:51 2013 New Revision: 254758 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254758 Log: Change the kernel dump header format to store a key, a tweak and their sizes. Define a constant AES key for encryption. Modified: soc2013/def/crashdump-head/sys/sys/kerneldump.h Modified: soc2013/def/crashdump-head/sys/sys/kerneldump.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/kerneldump.h Sat Jul 13 17:38:58 2013 (r254757) +++ soc2013/def/crashdump-head/sys/sys/kerneldump.h Sat Jul 13 17:42:51 2013 (r254758) @@ -75,22 +75,33 @@ #define KERNELDUMP_POWERPC_VERSION 1 #define KERNELDUMP_SPARC64_VERSION 1 #define KERNELDUMP_TEXT_VERSION 1 -#define KERNELDUMP_MAX_KEY_SIZE 256 -#define KERNELDUMP_MAX_IV_SIZE 128 +#define KERNELDUMP_KEY_SIZE 32 +#define KERNELDUMP_TWEAK_SIZE 8 uint64_t dumplength; /* excl headers */ uint64_t dumptime; uint32_t blocksize; char hostname[64]; - char versionstring[164]; - char panicstring[164]; - int keyLen; - char keyMaterial[KERNELDUMP_MAX_KEY_SIZE >> 3]; - u_int8_t mode; - u_int8_t IV[KERNELDUMP_MAX_IV_SIZE >> 3]; + char versionstring[168]; + char panicstring[168]; + int keysize; + char key[KERNELDUMP_KEY_SIZE]; + int tweaksize; + char tweak[KERNELDUMP_TWEAK_SIZE]; uint32_t parity; }; /* + * Constant key for kernel crash dumps. + */ +static const char kerneldumpkey[32] = { + 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, + 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, + 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 +}; + +static char kerneldumptweak[KERNELDUMP_TWEAK_SIZE]; + +/* * Parity calculation is endian insensitive. */ static __inline u_int32_t From owner-svn-soc-all@FreeBSD.ORG Sat Jul 13 17:47:23 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 153DFA0D for ; Sat, 13 Jul 2013 17:47:23 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id EBB221AB9 for ; Sat, 13 Jul 2013 17:47:22 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6DHlMMM051186 for ; Sat, 13 Jul 2013 17:47:22 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6DHlMdJ051183 for svn-soc-all@FreeBSD.org; Sat, 13 Jul 2013 17:47:22 GMT (envelope-from def@FreeBSD.org) Date: Sat, 13 Jul 2013 17:47:22 GMT Message-Id: <201307131747.r6DHlMdJ051183@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254759 - in soc2013/def/crashdump-head/sys: kern sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 17:47:23 -0000 Author: def Date: Sat Jul 13 17:47:22 2013 New Revision: 254759 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254759 Log: Change the dumperinfo structure to store a key, a tweak and their context. Modify kerneldump_crypto_init to set context and mkdumpheader to write data in the new format. Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c soc2013/def/crashdump-head/sys/sys/conf.h Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sat Jul 13 17:42:51 2013 (r254758) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sat Jul 13 17:47:22 2013 (r254759) @@ -86,7 +86,7 @@ #include -#include +#include #ifndef PANIC_REBOOT_WAIT_TIME #define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */ @@ -145,8 +145,8 @@ int dumping; /* system is dumping */ int rebooting; /* system is rebooting */ static struct dumperinfo dumper; /* our selected dumper */ -keyInstance dumper_key; -cipherInstance dumper_cipher; +static rijndael_ctx dumper_tweak_ctx; +static rijndael_ctx dumper_data_ctx; /* Context information for dump-debuggers. */ static struct pcb dumppcb; /* Registers. */ @@ -852,8 +852,6 @@ return (EBUSY); dumper = *di; - dumper.key = &dumper_key; - dumper.cipher = &dumper_cipher; kerneldump_crypto_init(&dumper); wantcopy = strlcpy(dumpdevname, devname, sizeof(dumpdevname)); @@ -884,14 +882,14 @@ void kerneldump_crypto_init(struct dumperinfo *di) { - char keyMaterial[KERNELDUMP_MAX_KEY_SIZE >> 3]; - int i; - - for (i = 0 ; i < KERNELDUMP_MAX_KEY_SIZE >> 3 ; i++) - keyMaterial[i] = i; - - rijndael_makeKey(di->key, DIR_ENCRYPT, KERNELDUMP_MAX_KEY_SIZE, keyMaterial); - rijndael_cipherInit(di->cipher, MODE_ECB, NULL); + /* In the future the tweak will be set via sysctl. */ + arc4rand(kerneldumptweak, KERNELDUMP_TWEAK_SIZE, 0); + di->key = (char *)kerneldumpkey; + di->tweak = kerneldumptweak; + di->tweak_ctx = &dumper_tweak_ctx; + di->data_ctx = &dumper_data_ctx; + rijndael_set_key(di->tweak_ctx, di->key, KERNELDUMP_KEY_SIZE << 3); + rijndael_set_key(di->data_ctx, di->key, KERNELDUMP_KEY_SIZE << 3); } void @@ -911,9 +909,9 @@ strncpy(kdh->versionstring, version, sizeof(kdh->versionstring)); if (panicstr != NULL) strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring)); - kdh->keyLen = dumper_key.keyLen; - strncpy(kdh->keyMaterial, dumper_key.keyMaterial, kdh->keyLen); - kdh->mode = dumper_cipher.mode; - strncpy(kdh->IV, dumper_cipher.IV, KERNELDUMP_MAX_IV_SIZE); + kdh->keysize = KERNELDUMP_KEY_SIZE; + strncpy(kdh->key, dumper.key, kdh->keysize); + kdh->tweaksize = KERNELDUMP_TWEAK_SIZE; + strncpy(kdh->tweak, dumper.tweak, kdh->tweaksize); kdh->parity = kerneldump_parity(kdh); } Modified: soc2013/def/crashdump-head/sys/sys/conf.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/conf.h Sat Jul 13 17:42:51 2013 (r254758) +++ soc2013/def/crashdump-head/sys/sys/conf.h Sat Jul 13 17:47:22 2013 (r254759) @@ -331,8 +331,10 @@ u_int maxiosize; /* Max size allowed for an individual I/O */ off_t mediaoffset; /* Initial offset in bytes. */ off_t mediasize; /* Space available in bytes. */ - void *key; /* Key information. */ - void *cipher; /* Cipher information. */ + char *key; /* Key information. */ + char *tweak; /* Tweak. */ + void *tweak_ctx; + void *data_ctx; }; int set_dumper(struct dumperinfo *, const char *_devname); From owner-svn-soc-all@FreeBSD.ORG Sat Jul 13 17:48:29 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E0E93A22 for ; Sat, 13 Jul 2013 17:48:29 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id D26131ABE for ; Sat, 13 Jul 2013 17:48:29 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6DHmT4A055978 for ; Sat, 13 Jul 2013 17:48:29 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6DHmTxw055972 for svn-soc-all@FreeBSD.org; Sat, 13 Jul 2013 17:48:29 GMT (envelope-from dpl@FreeBSD.org) Date: Sat, 13 Jul 2013 17:48:29 GMT Message-Id: <201307131748.r6DHmTxw055972@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254760 - soc2013/dpl/head/contrib/xz/src/xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 17:48:29 -0000 Author: dpl Date: Sat Jul 13 17:48:29 2013 New Revision: 254760 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254760 Log: Put file_pair definition here, since it is used in coder.h also. Modified: soc2013/dpl/head/contrib/xz/src/xz/private.h Modified: soc2013/dpl/head/contrib/xz/src/xz/private.h ============================================================================== --- soc2013/dpl/head/contrib/xz/src/xz/private.h Sat Jul 13 17:47:22 2013 (r254759) +++ soc2013/dpl/head/contrib/xz/src/xz/private.h Sat Jul 13 17:48:29 2013 (r254760) @@ -52,6 +52,41 @@ # define STDERR_FILENO (fileno(stderr)) #endif +typedef struct { + /// Name of the source filename (as given on the command line) or + /// pointer to static "(stdin)" when reading from standard input. + const char *src_name; + + /// Destination filename converted from src_name or pointer to static + /// "(stdout)" when writing to standard output. + char *dest_name; + + /// File descriptor of the source file + int src_fd; + + /// File descriptor of the target file + int dest_fd; + + /// True once end of the source file has been detected. + bool src_eof; + + /// If true, we look for long chunks of zeros and try to create + /// a sparse file. + bool dest_try_sparse; + + /// This is used only if dest_try_sparse is true. This holds the + /// number of zero bytes we haven't written out, because we plan + /// to make that byte range a sparse chunk. + off_t dest_pending_sparse; + + /// Stat of the source file. + struct stat src_st; + + /// Stat of the destination file. + struct stat dest_st; +} file_pair; + + #include "main.h" #include "coder.h" #include "message.h" From owner-svn-soc-all@FreeBSD.ORG Sat Jul 13 18:02:07 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 70BF12A5 for ; Sat, 13 Jul 2013 18:02:07 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 4A1211B25 for ; Sat, 13 Jul 2013 18:02:07 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6DI274Z003352 for ; Sat, 13 Jul 2013 18:02:07 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6DI2756003341 for svn-soc-all@FreeBSD.org; Sat, 13 Jul 2013 18:02:07 GMT (envelope-from def@FreeBSD.org) Date: Sat, 13 Jul 2013 18:02:07 GMT Message-Id: <201307131802.r6DI2756003341@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254761 - in soc2013/def/crashdump-head: sbin/savecore sys/sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 18:02:07 -0000 Author: def Date: Sat Jul 13 18:02:07 2013 New Revision: 254761 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254761 Log: Fix savecore's Makefile. Change savecore to display sizes of a key and a tweak. Don't compile savecore with the key and the tweak. Modified: soc2013/def/crashdump-head/sbin/savecore/Makefile soc2013/def/crashdump-head/sbin/savecore/savecore.c soc2013/def/crashdump-head/sys/sys/kerneldump.h Modified: soc2013/def/crashdump-head/sbin/savecore/Makefile ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/Makefile Sat Jul 13 17:48:29 2013 (r254760) +++ soc2013/def/crashdump-head/sbin/savecore/Makefile Sat Jul 13 18:02:07 2013 (r254761) @@ -4,6 +4,5 @@ DPADD= ${LIBZ} LDADD= -lz MAN= savecore.8 -CFLAGS+=-I/home/def/soc13/vm/usr/include .include Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/savecore.c Sat Jul 13 17:48:29 2013 (r254760) +++ soc2013/def/crashdump-head/sbin/savecore/savecore.c Sat Jul 13 18:02:07 2013 (r254761) @@ -121,7 +121,8 @@ fprintf(f, " Panic String: %s\n", h->panicstring); fprintf(f, " Dump Parity: %u\n", h->parity); fprintf(f, " Bounds: %d\n", bounds); - fprintf(f, " Key length: %d bits\n", h->keyLen); + fprintf(f, " Key length: %d bits\n", h->keysize << 3); + fprintf(f, " Tweak length: %d bits\n", h->tweaksize << 3); switch(status) { case STATUS_BAD: Modified: soc2013/def/crashdump-head/sys/sys/kerneldump.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/kerneldump.h Sat Jul 13 17:48:29 2013 (r254760) +++ soc2013/def/crashdump-head/sys/sys/kerneldump.h Sat Jul 13 18:02:07 2013 (r254761) @@ -91,17 +91,6 @@ }; /* - * Constant key for kernel crash dumps. - */ -static const char kerneldumpkey[32] = { - 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 -}; - -static char kerneldumptweak[KERNELDUMP_TWEAK_SIZE]; - -/* * Parity calculation is endian insensitive. */ static __inline u_int32_t @@ -118,6 +107,17 @@ } #ifdef _KERNEL +/* + * Constant key for kernel crash dumps. + */ +static const char kerneldumpkey[32] = { + 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, + 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, + 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 +}; + +static char kerneldumptweak[KERNELDUMP_TWEAK_SIZE]; + void kerneldump_crypto_init(struct dumperinfo *di); void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver,