Python script to create packages, sane?



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




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



Relevant Pages

  • installed ports backup script for FreeBSD
    ... The following shell script will enumerate the contents of the package ... all of the ports and packages that are currently installed on your system. ... This can be useful for creating a 'ports backup', ...
    (comp.unix.bsd.freebsd.misc)
  • Re: portupgrade O(n^m)?
    ... wanted to try and port sections of portupgrade and its related tools to ... in 15 mn to 20 mn you have your packages. ... because packages don't break when compiling. ... pkg_add for around 500 ports replaced. ...
    (freebsd-hackers)
  • Re: portupgrade O(n^m)?
    ... in 15 mn to 20 mn you have your packages. ... >> because packages don't break when compiling. ... >> packages for installation are already present on the machine. ... >> modifying the origins of the ports. ...
    (freebsd-hackers)
  • Re: [HOW-TO] cvsup for ports -- Re: compact portsnap db
    ... It is better to use all ports or all packages so either do: ... people install php at all. ... And yes there are some ports that don't have packages for licencing ... Preferring cvsup to portsnap is kinda like preferring vim ...
    (freebsd-questions)
  • Re: [HOW-TO] cvsup for ports -- Re: compact portsnap db
    ... The only problems I've ever seen with installing packages is that at ... And yes there are some ports that don't have packages for licencing etc ... though I can't recall ever having to install one of those. ... >> Preferring cvsup to portsnap is kinda like preferring vim over ...
    (freebsd-questions)