On Fri, Mar 25, 2011 at 12:11 PM, Baptiste Daroussin <b...@freebsd.org> wrote:
> Hi all,
>

Hi,

Great news!

I'll try to contribute with what I can for this project!

I've mirrored the pkgng Git repo here as well:

 - http://git.unix-heaven.org/cgit.cgi/pkgng/

And attached is my first patch :)

Could you please review and if possible, apply it?

Regards,
Marin

-- 
Marin Atanasov Nikolov

dnaeon AT gmail DOT com
daemon AT unix-heaven DOT org
http://www.unix-heaven.org/
From bd17ad1dfa336717fcc924217552dadd5236ed5f Mon Sep 17 00:00:00 2001
From: Marin Atanasov Nikolov <dae...@unix-heaven.org>
Date: Sat, 26 Mar 2011 14:19:04 +0200
Subject: [PATCH] Clarify a bit more the GOALS and some other minor changes

	- Clarify GOALS a bit more
	- Added main.h which contains CMD_MAX_LEN
	- Use strnlen() instead of strlen() in main.c
	- Use float numbers in fetch_status()
---
 docs/GOALS |  178 ++++++++++++++++++++++++++++++++++++++----------------------
 pkg/add.c  |    2 +-
 pkg/main.c |    9 ++--
 pkg/main.h |    7 +++
 4 files changed, 126 insertions(+), 70 deletions(-)
 create mode 100644 pkg/main.h

diff --git a/docs/GOALS b/docs/GOALS
index 1c381d2..ccf3414 100644
--- a/docs/GOALS
+++ b/docs/GOALS
@@ -1,104 +1,152 @@
-comamnds:
+pkgng - New version of FreeBSD's pkg_install
+
+Table of Contents:
+
+    1. Available commands of pkgng
+    2. Available subcommands of pkgng
+    3. General behaviour
+    4. New manifest format
+	4.1. During new install
+	4.2. During package deletion
+	4.3. During upgrade of a package
+    5. Additional resources
+
+
+1. Available commands of pkgng:
+-------------------------------
+
 - pkg:
-	- one command to rule them all
-	- each time pkg has to query the installed database it will try to first
-	  read the cache is the cache is too old (check but last mtime of the
-	  directory) it will regenerate the cache from installed package
+
+	- One command to rule them all
+	- Each time `pkg' has to query the package database it will try to first
+	  read the cache and if the cache is too old (check by last mtime of the
+	  directory) it will regenerate the cache for the installed packages.
 
 - pkg_*:
-	this will be shell script their goal is to be 100% compatible with
-	pkg_install they will call pkg which the good options (not sure it will
-	be really done in the end)
 
-subcommands:
+	- These will be shell scripts, which goal is to be 100% compatible with
+	  pkg_install. They will call `pkg' with the appropriate options (not sure
+	  it will be really done in the end).
+
+2. Available subcommands of pkgng:
+----------------------------------
+
 - add:
-	- installs a package if local package is given
-	- manage http/ftp url to download throught libfetch a package and try to
-	  install it.
-	- in the two previous case, if the package as not installed dependencies
-	  it will try to fetch/find them in the same place the original package
-	  was.
-	- it will manage a completely new repository format pkg add bla will
-	  check in the database of the repository if the is a bla package and
-	  install it as well as it's dependencies but the dependencies will be
-	  compute before begining the fetch install process, to be sure
-	  everything is ok.
-	- should be able to only take a plist or a manifest in argument
+
+	- Installs a package if a local package is given
+	- Manages ftp/http downloads of packages through libfetch and
+	  tries to install them.
+	- In the two previous cases, if a package does not have it's 
+	  dependencies installed, `pkgng' will try to fetch/find them in the same
+	  place as the original package was.
+	- It will manage a completely new repository format. 
+	  `pkg add <foo>' will check in the database of the repository for 
+	  package <foo> and try to install it as well as it's dependencies.
+	  Dependencies will be computed before beginning the fetch/install
+	  process to ensure that everything will be OK.
+	- Should be able to only take a plist or a manifest in argument
 	  considering the files are already installed
 
 - repo:
-	- takes only one argument and generate two databases files (maybe more for
-	  the time we will be willing to work with UPDATING and MOVED) the first
-	  repo contain every informations concerning a package except files
-	  (which will be in the second one) + it will compute and add a sha256
-	  sum for each package.
-	  the database will be a sqlite file compressed with the xz format.
-	  the database will be signed so we can trust the sha256 of the
-	  packages, so if a package has the expected hash, it is considered
+
+	- Takes only one argument and generates two database files (maybe more for
+	  the time we will be willing to work with UPDATING and MOVED).
+	  The first repo contains all information about a package, except for
+	  the files (which will be in the second one) + it will compute and 
+	  add a sha256 sum for each package.
+	- The database will be a sqlite file compressed with the xz format.
+	- The database will be signed so we can trust the sha256 of the
+	  packages, and if a package has the expected hash, it is considered
 	  trusted.
 
 - search:
-	- will search both the remote repository to gives informations
-	  to users
+
+	- Will search both of the remote repositories to provide information
+	  to the users.
 
 - info: 
-	- will give to users any informations about local package
+
+	- Will provide any information to the users about a local package.
 
 - create:
-	- will create the package in the new format (+MANIFEST) in txz (tar.xz)
-	  directly options to create tbz and tgz will be provided.
-	- it should be able to create a package for a "fakeroot" directory
+    
+	- Will create the package in the new format (+MANIFEST) in txz (tar.xz).
+	- Options for creating tbz and tgz will be provided.
+	- It should be able to create a package for a "fakeroot" directory
 	  taking a plist or a manifest in arguments (the plist is for
-	  compatibility which bsd.ports.mk
+	  compatibility with bsd.ports.mk)
 
 - delete:
-	- will delete a package normally to be able to remove the empty
-	  directories cleanly it will delete every directory (found in the path
-	  of the files) that are not in the package +MTREE (mtree contains the
-	  official hier(7)
+
+	- Will delete a package. To be able to remove the empty directories
+	  cleanly it will delete every directory (found in the path of the 
+	  files), which are not in the package +MTREE (mtree contains the 
+	  official hier(7)).
 
 - upgrade:
-	- will compute the remote repository to check is there is new upgrades
+
+	- Will compute the remote repository to check if there are new upgrades
 	  available and apply them.
 
 - update:
-	- will fetch the remote repository cache files
+
+	- Will fetch the remote repository cache files.
 
 - lint: 
-	- will check for the given package and warn the user about problems :
+
+	- Will check for the given package and warn the user about possible problems:
 	* bad prefix
 	* setuids
 	* etc
 
-General behaviour:
-the manifest contains compatibility keywords: exec, unexec which will be
-executed as there are in pkg_install but will display a warning to show the user
-exec/unexec is deprecated
+3. General behaviour:
+---------------------
+
+The manifest contains compatibility keywords: exec, unexec which will be
+executed as they are in pkg_install, but will display a warning to show the user
+exec/unexec is deprecated.
+
+If install and deinstall scripts are present they will be executed as they were in
+pkg_install, and the user will be warned that they are deprecated.
+
+4. New manifest format
+----------------------
+
+The new manifest format will have:
 
-if install and deinstall scripts are found they will be executed as they were in
-pkg_install warning for deprecated
+    4.1. During new install
+    -----------------------
+    
+    - pre-install
+    - post-install
 
-the new manifest format will have:
-in case of a new install:
-pre-install
-post-install
+    4.2. During package deletion
+    ----------------------------
 
-in case of a pkg delete:
-pre-uninstall
-post-uninstall
+    - pre-uninstall
+    - post-uninstall
 
-in case of an upgrade : 
-pre-upgrade
-post-upgrade
+    4.3. During upgrade of a package
+    --------------------------------
+
+    - pre-upgrade
+    - post-upgrade
+
+They could be files - +PRE-*, +POST-*, etc.
+
+They could be sh string in the manifest in arrays:
 
-they could be files +PRE-* +POST* etc
-they could be sh string in the manifest in arrays:
 "pre-install": [
         "/usr/sbin/pw useradd foo",
 ],
 
-they could be both
+They could be both.
+
+5. Additional resources
+-----------------------
+
+Some information can be found here and if there are conflicts, this file
+is right one :)
+
+    - http://wiki.freebsd.org/Pkg_install2_specs
 
-some informations could be found here if there is conflicts in the two, this file
-is right :):
-http://wiki.freebsd.org/Pkg_install2_specs
diff --git a/pkg/add.c b/pkg/add.c
index 50758b4..22cb72d 100644
--- a/pkg/add.c
+++ b/pkg/add.c
@@ -18,7 +18,7 @@ fetch_status(void *data, const char *url, off_t total, off_t done, time_t elapse
 	data = NULL;
 	elapsed = 0;
 
-	percent = ((float)done / (float)total) * 100;
+	percent = ((float)done / (float)total) * 100.0;
 	printf("\rFetching %s... %d%%", url, percent);
 
 	if (done == total)
diff --git a/pkg/main.c b/pkg/main.c
index edf6f3f..f46610d 100644
--- a/pkg/main.c
+++ b/pkg/main.c
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <sysexits.h>
 
+#include "main.h"
 #include "create.h"
 #include "delete.h"
 #include "info.h"
@@ -59,11 +60,11 @@ exec_help(int argc, char **argv)
 {
 	if (argc != 2) {
 		usage_help();
-		return(EX_USAGE);
+		return (EX_USAGE);
 	}
 
 	for (int i = 0; i < cmd_len; i++) {
-		if (strcmp(cmd[i].name, argv[1]) == 0) {
+		if (strncmp(cmd[i].name, argv[1], CMD_MAX_LEN) == 0) {
 			assert(cmd[i].usage != NULL);
 			cmd[i].usage();
 			return (0);
@@ -86,11 +87,11 @@ main(int argc, char **argv)
 	if (argc < 2)
 		usage();
 
-	len = strlen(argv[1]);
+	len = strnlen(argv[1], CMD_MAX_LEN);
 	for (i = 0; i < cmd_len; i++) {
 		if (strncmp(argv[1], cmd[i].name, len) == 0) {
 			/* if we have the exact cmd */
-			if (len == strlen(cmd[i].name)) {
+			if (len == strnlen(cmd[i].name, CMD_MAX_LEN)) {
 				command = &cmd[i];
 				ambiguous = 0;
 				break;
diff --git a/pkg/main.h b/pkg/main.h
new file mode 100644
index 0000000..e12b4eb
--- /dev/null
+++ b/pkg/main.h
@@ -0,0 +1,7 @@
+#ifndef _MAIN_H
+#define _MAIN_H
+
+#define CMD_MAX_LEN 32 
+
+#endif
+
-- 
1.7.2.3

_______________________________________________
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"

Reply via email to