Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 May 2008 23:22:46 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Matthias Apitz <matthias.apitz@oclc.org>
Cc:        Manolis Kiagias <sonicy@otenet.gr>, "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: Asus eee
Message-ID:  <87skwaqeax.fsf@kobe.laptop>
In-Reply-To: <20080522071727.GA6009@rebelion.Sisis.de> (Matthias Apitz's message of "Thu, 22 May 2008 09:17:27 %2B0200")
References:  <972994690801011020u60ed0a0et6d8356cdb1f6f974@mail.gmail.com> <20080102141419.GB61289@sandvine.com> <p06240807c3b721bd576d@[128.113.24.47]> <20080521143210.GA70289@rebelion.Sisis.de> <4834516F.1010002@otenet.gr> <87prre275y.fsf@kobe.laptop> <20080522071727.GA6009@rebelion.Sisis.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 22 May 2008 09:17:27 +0200, Matthias Apitz <matthias.apitz@oclc.org=
> wrote:
> El d=A8=AAa Thursday, May 22, 2008 a las 09:18:33AM +0300, Giorgos Kerami=
das escribi=A8=AE:
>> Alternatively, you can use `pkg_create -b' to save the installed
>> copies of a few ports, and move them over.  Installed packages can be
>> saved anywhere you prefer to store them.  I some times use `/usr/pkg'.
>
> Thanks for your hint concerning pkg_create. I've stumbled over this as
> well and we must not only create a given package, but also all the
> packages from which it depends with for example:
>
> # pkg_create -Rb stardict-2.4.8_5
>
> this gave me in this example 144 packages in the current dir; I run it
> twice to see if pkg_create detects that a given dependency is already
> there or if it will rebuild the package, and it does rebuild them; this
> means if I run pkg_create for the 200 ports I've compiled (even if I let
> out what perhaps I don't need on the smaller EeePC it is a lot of
> stuff), it will do a lot of work twice; is there a way to let pkg_create
> check if the pkg is already built and there?

That's true.  There is going to be at least *some* duplication of work
if you run `pkg_create -Rb' multiple times :-/

There's no option to inhibit pkg_create output if a package already
exists, i.e. something like a `noclobber' option.  Maybe we can hack a
new feature for this.  That would be cool.

Then you could run, for example, `pkg_create -Rbn' and avoid recreating
packages every time a dependency is met as part of one of the packages
you want to transfer.

I'll haev to test a bit the following patch, and get it reviewed by our
packaging tools people, but it seems pretty straightforward.

%%%
Index: usr.sbin/pkg_install/create/create.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/create.h,v
retrieving revision 1.26
diff -u -r1.26 create.h
--- usr.sbin/pkg_install/create/create.h	8 Nov 2005 20:48:26 -0000	1.26
+++ usr.sbin/pkg_install/create/create.h	22 May 2008 20:11:20 -0000
@@ -46,6 +46,7 @@
 extern int	Dereference;
 extern int	PlistOnly;
 extern int	Recursive;
+extern int	NoClobber;
=20
 enum zipper {NONE, GZIP, BZIP, BZIP2 };
 extern enum zipper	Zipper;
Index: usr.sbin/pkg_install/create/main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/main.c,v
retrieving revision 1.41
diff -u -r1.41 main.c
--- usr.sbin/pkg_install/create/main.c	7 Nov 2007 10:53:36 -0000	1.41
+++ usr.sbin/pkg_install/create/main.c	22 May 2008 20:07:33 -0000
@@ -16,7 +16,7 @@
 #include "lib.h"
 #include "create.h"
=20
-static char Options[] =3D "EGYNORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o=
:b:";
+static char Options[] =3D "EGYNnORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:=
o:b:";
=20
 match_t	MatchType	=3D MATCH_GLOB;
 char	*Prefix		=3D NULL;
@@ -41,6 +41,7 @@
 int	Dereference	=3D FALSE;
 int	PlistOnly	=3D FALSE;
 int	Recursive	=3D FALSE;
+int	NoClobber	=3D FALSE;
 #if defined(__FreeBSD_version) && __FreeBSD_version >=3D 500039
 enum zipper	Zipper  =3D BZIP2;
 #else
@@ -192,6 +193,10 @@
 	    Recursive =3D TRUE;
 	    break;
=20
+	case 'n':
+		NoClobber =3D TRUE;
+		break;
+
 	case '?':
 	default:
 	    usage();
@@ -228,7 +233,7 @@
 usage()
 {
     fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
-"usage: pkg_create [-YNOhjvyz] [-C conflicts] [-P pkgs] [-p prefix]",
+"usage: pkg_create [-YNOhjnvyz] [-C conflicts] [-P pkgs] [-p prefix]",
 "                  [-i iscript] [-I piscript] [-k dscript] [-K pdscript]",
 "                  [-r rscript] [-s srcdir] [-S basedir]",
 "                  [-t template] [-X excludefile]",
Index: usr.sbin/pkg_install/create/perform.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/perform.c,v
retrieving revision 1.82
diff -u -r1.82 perform.c
--- usr.sbin/pkg_install/create/perform.c	7 Jan 2006 22:10:57 -0000	1.82
+++ usr.sbin/pkg_install/create/perform.c	22 May 2008 20:17:37 -0000
@@ -28,6 +28,8 @@
 #include <libgen.h>
 #include <signal.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <sys/syslimits.h>
 #include <sys/wait.h>
 #include <unistd.h>
@@ -336,6 +338,7 @@
 static void
 make_dist(const char *homedir, const char *pkg, const char *suff, Package =
*plist)
 {
+    struct stat sb;
     char tball[FILENAME_MAX];
     PackingList p;
     int ret;
@@ -355,6 +358,16 @@
     else
 	snprintf(tball, FILENAME_MAX, "%s/%s.%s", homedir, pkg, suff);
=20
+    /*
+     * If the package tarball exists already, and we are running in `no
+     * clobber' mode, skip this package.
+     */
+    if (stat(tball, &sb) =3D=3D 0 && NoClobber =3D=3D TRUE) {
+	if (Verbose)
+	    printf("Skipping package '%s'.  It already exists.\n", tball);
+	return;
+    }
+
     args[nargs++] =3D "-c";
     args[nargs++] =3D "-f";
     args[nargs++] =3D tball;
Index: usr.sbin/pkg_install/create/pkg_create.1
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/pkg_create.1,v
retrieving revision 1.72
diff -u -r1.72 pkg_create.1
--- usr.sbin/pkg_install/create/pkg_create.1	9 Dec 2007 11:01:57 -0000	1.72
+++ usr.sbin/pkg_install/create/pkg_create.1	22 May 2008 20:20:27 -0000
@@ -350,6 +350,24 @@
 .It Fl G
 Use exact matching for
 .Ar pkg-name .
+.It Fl n
+Run in
+.Dq no clobber
+mode.
+If a package tarball exists, the
+.Nm
+utility will not overwrite it.
+This is useful, for example, when multiple packages are saved with
+several consecutive runs of
+.Nm
+with the
+.Fl Rb
+options.
+Saving common dependencies multiple times would do a lot of duplicate
+work in this case.
+The
+.Fl n
+option avoids repackaging common dependencies multiple times.
 .El
 .Sh PACKING LIST DETAILS
 The
%%%



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87skwaqeax.fsf>