0% found this document useful (0 votes)
72 views17 pages

Project 1 - Shell Scripting: Weesan Lee

The document describes re-implementing pkgtools scripts in Bash to manage software packages. The scripts include pkgtools2.sh as the master script, and pkginstall2, pkgremove2, and pkginfo2 to install, remove, and get info on packages. Packages will be installed to /import/pkgs/name and symlinked to /import. The /import/pkgs/pkg-version file tracks package metadata.

Uploaded by

Ceh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views17 pages

Project 1 - Shell Scripting: Weesan Lee

The document describes re-implementing pkgtools scripts in Bash to manage software packages. The scripts include pkgtools2.sh as the master script, and pkginstall2, pkgremove2, and pkginfo2 to install, remove, and get info on packages. Packages will be installed to /import/pkgs/name and symlinked to /import. The /import/pkgs/pkg-version file tracks package metadata.

Uploaded by

Ceh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

Project 1 - Shell

Scripting
WeeSan Lee <[email protected]>
http://www.cs.ucr.edu/~weesan/cs183/

Goal

To re-implement pkgtools scripts in Bash

pkgtools2.sh
pkginstall2 -> pkgtools2.sh
pkgremove2 -> pkgtools2.sh
pkginfo2 -> pkgtools2.sh

pkgtools2.sh

The master script


$ ./pkgtools2.sh init

Create an installer group with GID 200


Setup /import

/import/bin
/import/etc

$ IMPORT_HOME=/usr/local ./pkgtools2.sh
init -g 300 -u weesan -u wlee

pkginstall2

$ ./pkginstall2 emacs

What version is this emacs? 22.2


Where (e.g. URL, ftp_site[:dir], or person) to get upgrades?
http://ftp.gnu.org/gnu/emacs/emacs-22.2.tar.gz
emacs-22.2 has been installed to the import repository.

Pay attention to the symbolic links on the


man directory

pkgremove2

$ ./pkgremove2 emacs

emacs-22.2 has been removed from the import repository.

pkginfo2

$ ./pkginfo2 -a

$ ./pkginfo2 -i

emacs-22.2 weesan ftp://ftp.gnu.org/gnu/emacs/ Mon Apr 21 0:02:26 PDT 2008 *


vm-7.19 weesan http://www.wonderworks.com/vm/ Mon Jan 21 21:02:58 PST 2008

vm-7.19 weesan http://www.wonderworks.com/vm/ Mon Jan 21 21:02:58 PST 2008

$ ./pkginfo2 -u

emacs-22.2 weesan ftp://ftp.gnu.org/gnu/emacs/ Mon Apr 21 0:02:26 PDT 2008 *

IMPORT_HOME

All scripts should use $IMPORT_HOME if its


defined, or /import otherwise

Help Messages & Manpages


(optional)

Run the scripts without options or -h to give usage

$ pkgtools2.sh -h
$ pkginstall2 -h
$ pkgremove2 -h
$ pkginfo2 -h

Manpages (optional)

pkgtools2.sh.8
pkginstall2.8
pkgremove.8
pkginfo2.8

Scoring & Due

Scoring

pkgtools2.sh
pkginstall2
pkgremove2
pkginfo2
Manpages (optional)

Due

4/27/08 Sun @ 11:55pm

20 points
30 points
30 points
20 points
10 points

Ideally, we want php goes to


/import, but

php
$ CFLAGS=-O3 ./configure --prefix=/import
$ make
$ make install

'make install' will install php to /import


/import/bin/php
/import/bin/pear
/import/etc/pear.conf
/import/include/php/
/import/lib/php/
/import/man/man1/php.1

Alternatively, we can make php


goes to /import/pkgs/php
php
instead

$ CFLAGS=-O3 ./configure --prefix=/import/pkgs/php


$ make
$ make install

'make install' will install php to /import/pkgs/php


/import/pkgs/php/bin/php
/import/pkgs/php/bin/pear
/import/pkgs/php/etc/pear.conf
/import/pkgs/php/include/php/
/import/pkgs/php/lib/php/
/import/pkgs/php/man/man1/php.1

The question is: how to make


files under /import/pkgs/php
appear to /import?

/import/pkgs/php/bin/php
/import/pkgs/php/bin/pear
/import/pkgs/php/etc/pear.conf
/import/pkgs/php/include/php/
/import/pkgs/php/lib/php/
/import/pkgs/php/man/man1/php.1
/import/bin/
/import/bin/
/import/etc/
/import/include/
/import/lib/
/import/man/

One way is to copy every php


file over

/import/pkgs/php/bin/php
/import/pkgs/php/bin/pear
/import/pkgs/php/etc/pear.conf
/import/pkgs/php/include/php/
/import/pkgs/php/lib/php/
/import/pkgs/php/man/man1/php.1

Copy
/import/bin/php
/import/bin/pear
/import/etc/pear.conf
/import/include/php/
/import/lib/php/
/import/man/man1/php.1

A better way is to create


symbolic links for each php file

/import/pkgs/php/bin/php
/import/pkgs/php/bin/pear
/import/pkgs/php/etc/pear.conf
/import/pkgs/php/include/php/
/import/pkgs/php/lib/php/
/import/pkgs/php/man/man1/php.1

Create symbolic links


/import/bin/php /import/pkgs/php/bin/php
/import/bin/pear /import/pkgs/php/bin/pear
/import/etc/pear.conf /import/pkgs/php/etc/pear.conf
/import/include/php/ /import/pkgs/php/include/php/
/import/lib/php/ /import/pkgs/php/lib/php/
/import/man/man1/php.1 /import/pkgs/php/man/man1/php.1

The tricky man directory

/import/pkgs/php/bin/php
/import/pkgs/php/bin/pear
/import/pkgs/php/etc/pear.conf
/import/pkgs/php/include/php/
/import/pkgs/php/lib/php/
/import/pkgs/php/man/man1/php.1

Create symbolic links


/import/bin/php /import/pkgs/php/bin/php
/import/bin/pear /import/pkgs/php/bin/pear
/import/etc/pear.conf /import/pkgs/php/etc/pear.conf
/import/include/php/ /import/pkgs/php/include/php/
/import/lib/php/ /import/pkgs/php/lib/php/
/import/man/man1/php.1 /import/pkgs/php/man/man1/php.1

/import/pkgs/pkg-version

Format of /import/pkgs/pkg-version

emacs-20.7 weesan ftp://ftp.gnu.org/gnu/emacs/ Wed Oct 16 18:02:26 PDT 2002 *

emacs
20.7
weesan
ftp:///emacs/
Wed PDT 2002
*

package name
version
login name, ie. $USER
url
date
deleted flag

/import/pkgs/pkg-version

How is /import/pkgs/pkg-version maintained?

pkginstall2

Append a new entry to the end of the file if no entry that


matches the package name
Otherwise, replace the old entry (ended with '*') with the
new info

pkgremove2

Insert an '*' at the end of the entry that matches the


package name

You might also like