Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 May 1996 16:22:02 -0700
From:      "Jordan K. Hubbard" <jkh@time.cdrom.com>
To:        babel@cais.cais.com
Cc:        Questions@freebsd.org, JKH@freebsd.org
Subject:   Re: get pkg_add working 
Message-ID:  <21839.833325722@time.cdrom.com>
In-Reply-To: Your message of "Tue, 28 May 1996 19:12:31 EDT." <199605282312.TAA09995@cais.cais.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> <---- Begin Attached File ---->
> begin 644 PKG_ADD.TXT

This is really the wrong way to submit a question - I had to decode it
just to read it, and I daresay most others on this list just whapped
"delete" rather than go to all the extra trouble.  If I'd have been
any busier at the moment I probably would have done the same.. :-)

Anyway, here's the script you asked for..

					Jordan
#! /bin/sh
#
# Script dpa
#	URL = ftp://pm.cse.rmit.edu.au/ftp/pub/FreeBSD/misc/dpa
#
# The current pkg_add command cannot process packages in files that have
# incorrect names e.g. packages that are being read off a DOS file system
# where a shortened name is required.  Shell script dpa (Dos Package Add)
# figures out the real name of a package so it can be temporarily copied
# across to $DEST (with its original name) and have pkg_add run on it.
#
# The user is prompted to have all packages available in the source
# directory installed.
#
# Parameter 1 is taken as the directory holding the 8+3 named packages,
# otherwise we look for a directory named /dos/packages or /dosc/packages
# or /dosd/packages,
# otherwise we ask where the hell these packages are supposed to be.
#
# Note: if you had chosen to mount a dos partition as /dos during the
#       installation, and used the DOS batch file fbsdmove.bat to copy some
#       initial packages into area \PACKAGES on the DOS disk, then this
#       script will figure out where your packages are hiding.
#
# Use:		dpa		(assumes packages in /dos/packages etc.)
#		dpa SRCDIR
#
# phillip@rmit.edu.au  1v0 15-feb-1996


DEST=/root

# if a /home is present, we store temporary package copies there
# (we assume that a large file system is available at /home)
if [ -d /home ] ; then

  if [ ! -d /home/tmp ] ; then
    mkdir /home/tmp
  fi
  export PKG_TMPDIR=/home/tmp		# pkg_add needs lots of space sometimes
  DEST=$PKG_TMPDIR

fi

###########################################################################

# take parameter 1 as the source directory containing the packages

if [ "x$1" != x ] ; then
  SRC=$1

# otherwise, attempt to guess where the DOS file system is that contains
# the FreeBSD packages

else
  SRC=
  echo
  if [ x$SRC = x -a -d /dos/packages/all ] ; then
    SRC=/dos/packages/all
  fi
  if [ x$SRC = x -a -d /dosc/packages/all ] ; then
    SRC=/dosc/packages/all
  fi
  if [ x$SRC = x -a -d /dosd/packages/all ] ; then
    SRC=/dosd/packages/all
  fi

# otherwise we just ask where the FreeBSD packages are
  
  if [ "x$SRC" = x ] ; then
    echo "Please enter the directory where the packages are kept"
    read x
    if [ -d $x ] ; then
      SRC=$x
    else
      echo That does not seem to be a directory...
      exit
    fi
  fi

fi
echo "Using packages in $SRC"

###########################################################################

# Procedure:
#
# a) examine each file to see if it is a gzip compressed file
# b) if it is, we assume it is a .tgz package file and extract the +CONTENTS
#    file in which a line commencing with the string "@name" is used to give
#    us the original package's name
# c) the user is then prompted to see if this package should be copied and
#    installed.

cd $SRC
for x in * ; do
  if [ -n "`file $x | grep gzip`" ] ; then    # non-empty string --> GZIP data
    echo
    y=`tar xzOf $x +CONTENTS | grep @name | cut -d' ' -f2`.tgz	# get real name
    echo "File $x is really $y; install (n/y)? "
    read a
    case $a in

      y*|Y*)						# we install
        cp $x $DEST/$y					# copy to eal name
        echo "Executing: pkg_add $DEST/$y"
        pkg_add $DEST/$y				# and install
        /bin/rm $DEST/$y				# then delete tmp copy
        ;;

      q*|Q*) exit 0 ;;					# quit

      *) echo "Ignoring: $y" ;;

    esac
  fi
done



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