[csw-maintainers] mirroring a subset of pkgs

Daniel Pocock daniel at opencsw.org
Fri Dec 16 08:11:50 CET 2011



pkgutil has the ability to run in download-only mode and collect
packages for installation later/on other machines

However, it then becomes necessary to manually pkgadd each pkg.gz on the
target machine - potentially a painful process

I've written a script (see below) that should provide an all-in-one
solution to this problem, I'd appreciate any feedback on this approach

In particular,

- can anyone comment on how I should handle packages that are not
architecture specific?

- should bldcat work on a Linux host?  It chokes on the first line,
#!/usr/bin/env perl -w and when that is fixed, it gives a bad file
descriptor error



#!/bin/bash

# Mirrors a subset of CSW packages for pkgutil to install

### Configurable settings
####################################################

PKG_SUBSET_MAIN="pkgutil wget rsync gangliaweb nagios netsnmp git gitk " \
        "coreutils dtracetoolkit gtar openssl lsof netcat socat vim xtail"
MIRROR_MAIN=http://mirror.opencsw.org/opencsw/unstable
# If commented, won't try to fetch:
#PKG_SUBSET_EXPERIMENTAL="sqsh"
MIRROR_EXPERIMENTAL=http://buildfarm.opencsw.org/opencsw/experimental

# Where to put the downloads:
PKG_DEST=/tmp/pkgmirror

# Which versions to fetch:
PKG_VERSIONS=5.10

# Which bin dir contains pkgutil
#PKGUTIL_BINDIR=/opt/csw/bin
PKGUTIL_BINDIR=/home/daniel/ws/pkgutil-trunk

# The binary names
PKGUTIL="${PKGUTIL_BINDIR}/pkgutil"
BLDCAT="${PKGUTIL_BINDIR}/bldcat"

### End of configurable settings
#############################################

mkdir -p ${PKG_DEST} || exit 1

for PKG_ARCH in i386 sparc ;
do

  for PKG_VERSION in ${PKG_VERSIONS} ;
  do
    # Identify the platform, create a directory:
    PKG_PLATFORM="${PKG_ARCH}:${PKG_VERSION}"
    PKG_PLATFORM_DEST="${PKG_DEST}/${PKG_ARCH}/${PKG_VERSION}"
    mkdir -p ${PKG_PLATFORM_DEST} || exit 1

    # Get the main packages we want:
    ${PKGUTIL} -d -y -t ${MIRROR_MAIN} -T ${PKG_PLATFORM} \
       -P ${PKG_PLATFORM_DEST} ${PKG_SUBSET_MAIN} || exit 1

    # Get any experimental packages we want:
    if [ ! -z "${PKG_SUBSET_EXPERIMENTAL}" ];
    then
      for PKG_NAME in ${PKG_SUBSET_EXPERIMENTAL} ;
      do
        # Notice the URL is different for each package in experimental:
        ${PKGUTIL} -d -y -t ${MIRROR_EXPERIMENTAL}/${PKG_NAME} \
          -T ${PKG_PLATFORM} \
          -P ${PKG_PLATFORM_DEST} ${PKG_NAME} || exit 1
      done
    fi
    # Create the catalog file:
    ${BLDCAT} ${PKG_PLATFORM_DEST} || exit 1
  done
done




More information about the maintainers mailing list