From owner-freebsd-questions@FreeBSD.ORG Sat Dec 30 08:44:27 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0C86A16A407 for ; Sat, 30 Dec 2006 08:44:27 +0000 (UTC) (envelope-from vinny-mail-01+f.questions@palaceofretention.ca) Received: from www.giovannetti.ca (www.giovannetti.ca [206.248.136.48]) by mx1.freebsd.org (Postfix) with ESMTP id 9F30D13C428 for ; Sat, 30 Dec 2006 08:44:26 +0000 (UTC) (envelope-from vinny-mail-01+f.questions@palaceofretention.ca) Received: from [192.168.2.3] (intgateway.palaceofretention.ca [10.10.10.42]) by www.giovannetti.ca (Postfix) with ESMTP id 407F411460 for ; Sat, 30 Dec 2006 03:27:47 -0500 (EST) Message-ID: <45962055.8090001@palaceofretention.ca> Date: Sat, 30 Dec 2006 03:16:21 -0500 From: Vinny User-Agent: Thunderbird 1.5.0.9 (X11/20061228) MIME-Version: 1.0 To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Python script to create packages, sane? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Dec 2006 08:44:27 -0000 Hi Everyone, OBuname: FreeBSD 6.1-RELEASE-p3 #0: Tue Aug 22 22:42:18 EDT 2006 root@localhost:/usr/obj/usr/src/sys/THE i386 I'm been working with and learning the ports and packages system. I enjoy the challenge because this stuff can get awfully vexing every now and then. I just finished running 'portmanager -u -f -l' after several days (with a little 'portmanager -u -f -l --resume' every now and then). I have this nicely up-to-date large (450+) set of ports installed. It cost a lot in terms of time. So I want to take all these installed ports and build packages out of them. Enter the following python program: ====================== 8< =================== #!/usr/bin/env python # make_package.py # # Script to create packages for currently installed ports/packages. # Uses pkg_create with the -b option. # It will build packages in the current working directory so a # 'cd /usr/ports/packages/All' command would be useful before # running it. # # Usage: script make_package.log && make_package.py /var/db/pkg/* # # needed modules import sys, os pkg_create = "/usr/sbin/pkg_create" print '===========' dash_b = '-b' for name in sys.argv[1:]: # print ":: ", name pkg_name = name.split('/')[-1] print "Installed package:", pkg_name # run pkg_create command, capture errors but don't stop print "Command: ", pkg_create, dash_b, pkg_name status = os.spawnv(os.P_WAIT, pkg_create, [pkg_create, dash_b, pkg_name]) print "Status:", status ====================== 8< =================== The results of running it are encouraging: # cd /usr/ports/packages/All # script make_packages.log Script started, output file is make_packages.log # ~/bin/make_packages.py /var/db/pkg/* =========== Installed package: GraphicsMagick-1.1.7 Command: /usr/sbin/pkg_create -b GraphicsMagick-1.1.7 Status: 0 Installed package: ImageMagick-6.2.9.8 Command: /usr/sbin/pkg_create -b ImageMagick-6.2.9.8 Status: 0 [... and so on for 450+ ports. only 3 errors below] Installed package: pkgdb.db Command: /usr/sbin/pkg_create -b pkgdb.db pkg_create: can't change directory to '/var/db/pkg/pkgdb.db'! Status: 1 [of course] Installed package: xorg-libraries-6.9.0 Command: /usr/sbin/pkg_create -b xorg-libraries-6.9.0 tar: lib/libGL.a: Cannot stat: No such file or directory pkg_create: make_dist: tar command failed with code 256 Status: 2 Installed package: xorg-server-6.9.0_5 Command: /usr/sbin/pkg_create -b xorg-server-6.9.0_5 tar: lib/modules/extensions/libGLcore.so: Cannot stat: No such file or directory pkg_create: make_dist: tar command failed with code 256 Status: 2 [...] ================== I've seen the last few types of errors with package creation before. I was using both portupgrade and 'make package' commands when I encountered such errors. To fix them is to simply force re-installation of the port in question. No big deal. A brief directory listing shows fresh packages: /usr/ports/packages/All# ls -lat | more total 3019778 -rw-r--r-- 1 root ports 48352 Dec 30 02:21 make_packages.log -rw-r--r-- 1 root ports 13217116 Dec 30 02:21 zope-3.3.0.tgz drwxr-xr-x 2 root ports 29184 Dec 29 18:33 . -rw-r--r-- 1 root ports 1410567 Dec 29 18:33 xorg-vfbserver-6.9.0_2.tgz -rw-r--r-- 1 root ports 176158 Dec 29 18:33 xterm-223.tgz -rw-r--r-- 1 root ports 423100 Dec 29 18:33 xvid-1.1.2,1.tgz [...] To make a long story short and actually ask a question, will building packages this way make proper packages? Am I doing something fundamentally wrong in this approach? I'd like to simply use the generated packages as a local repository for the other FreeBSD systems I use. Thanks for any comments. Vinny