Skip to content
Browse files

two phase rpg-install fetches / dep solves before installing

  • Loading branch information...
1 parent 997a567 commit c41c7582d9435d83517820ba5f74b3fa3d9ea42f @rtomayko committed Mar 14, 2010
Showing with 76 additions and 170 deletions.
  1. +1 −1 rpg-deps.sh
  2. +61 −156 rpg-install.sh
  3. +1 −1 rpg-list.sh
  4. +3 −2 rpg-package-install.sh
  5. +1 −0 rpg-package-register.sh
  6. +1 −1 rpg-resolve.sh
  7. +1 −1 rpg-sh-setup.sh
  8. +3 −4 rpg-solve.sh
  9. +4 −4 rpg-steal.sh
View
2 rpg-deps.sh
@@ -3,7 +3,7 @@ set -e
. rpg-sh-setup
[ "$*" ] || set -- "--help"; ARGV="$@"
-USAGE '${PROGNAME} [-d] [-r] <package>
+USAGE '${PROGNAME} [-d] [-r] <package> [<version>]
List dependencies for a package or gem file.
Options:
View
217 rpg-install.sh
@@ -1,166 +1,71 @@
#!/bin/sh
+# The `rpg-install` program
+#
set -e
. rpg-sh-setup
[ "$*" ] || set -- '--help'; ARGV="$@"
-USAGE '${PROGNAME} <package> [<version>...]
-Install package into rpg environment.'
-
-name="$1"
-vers="${2:->=0}"
-
-[ "$name" ] || helpthem
-
-# Usage: rpg_ln <source> <dest>
-# Attempt to hard link <dest> to <source> but fall back to cp(1) if
-# you're crossing file systems or the ln fails otherwise.
-rpg_ln () {
- if ln -f "$1" "$2"
- then notice "$2 [ln]"
- else notice "$2 [cp]"
- cp "$1" "$2"
- fi
-}
-
-# Recursive file hierarchy copy routine. Attempts to hardlink files
-# and falls back to normal copies.
-rpg_install_dir () {
- local src="$1" dest="$2" manifest="$3"
- mkdir -p "$dest"
- for file in "$1"/*
+USAGE '${PROGNAME} <package> [[-v] <version>] ...
+ ${PROGNAME} <package>[/<version>]...
+Install packages into rpg environment.'
+
+
+RPGSESSION="$RPGDB/@session"
+sessiondir="$RPGSESSION"
+packlist="$sessiondir"/package-list
+
+rm -rf "$sessiondir"
+mkdir -p "$sessiondir"
+
+notice "writing argv"
+for a in "$@"
+do echo "$a"
+done > "$sessiondir"/argv
+
+notice "writing user package-list"
+rpg-parse-package-list "$@" |
+sed "s/^/$(id -un)@$(hostname) /" > "$packlist"
+
+notice "entering dep solve loop"
+changed=true
+while $changed
+do
+ </dev/null >"$packlist+"
+
+ notice "solving deplist"
+ cut -d ' ' -f 2- "$packlist" |
+ rpg-solve -u |
+ tee "$sessiondir/solved" |
+ while read package op version
do
- if test -f "$file"
- then # link dest to source
- rpg_ln "$file" "$dest/$(basename $file)"
- echo "$dest/$(basename $file)" >> "$manifest"
-
- elif test -d "$file"
- then # recurse into directories
- rpg_install_dir "$file" "$dest/$(basename $file)" "$manifest"
-
- else warn "unknown file type: $file"
- return 1
- fi
- done
- return 0
-}
-
-notice "$name $vers installation commencing ..."
-
-# Fetch the gem into the cache.
-gemfile=$(rpg-fetch $name $vers)
-gemname=$(basename $gemfile .gem)
-gemvers=${gemname##*-}
-
-# Install all dependencies
-rpg-deps "$gemfile" |
-xargs -n 2 rpg install
-
-# Unpack the gem into the packages area if its not already there
-test -d "$RPGPACKS/$gemname" || {
- notice "unpacking $gemfile into $RPGPACKS"
- mkdir -p "$RPGPACKS"
- cd "$RPGPACKS"
- gem unpack "$gemfile" >/dev/null
-}
-
-# Get the manifest file going.
-dbdir="$RPGDB/$name"
-manifest="$dbdir/$gemvers"
-
-# Check if the package already has an installed version
-test -e "$dbdir/active" && {
- curvers=$(readlink $dbdir/active)
- if rpg-version-test -q "$curvers" "$vers"
- then notice "$name $curvers is installed and current"
- exit 0
- else notice "$name $curvers is installed but $gemvers requested"
- unlink "$dbdir/active"
+ gemfile=$(rpg-fetch "$package" "$version")
+ packagedir=$(rpg-package-register "$gemfile")
+
+ notice "adding $package $version deps to packlist"
+ grep '^runtime ' < "$packagedir"/deps |
+ cut -d ' ' -f 2- |
+ sed "s/^/$package /" |
+ cat "$packlist" -
+ done |
+ sort -b -u -k 2,4 >> "$packlist+"
+
+ if cmp -s "$packlist" "$packlist+"
+ then
+ notice "package list did not change"
+ changed=false
+ else
+ notice "package list changed"
+ # diff "$packlist" "$packlist+" 1>&2 || true
+ changed=true
fi
-}
+ mv "$packlist+" "$packlist"
+done
-mkdir -p "$dbdir"
-echo "# $(date)" > "$manifest"
-ln -sf "$gemvers" "$dbdir/installing"
-
-# Go into the unpackaged package dir to make installing a bit easier.
-cd "$RPGPACKS/$gemname"
-
-# Extension Library Files
-# -----------------------
-
-# Build extension libraries if they exist. Bail out if the build fails.
-exts="$(rpg-build "$(pwd)")" || {
- warn "extension failed to build"
- exit 1
-}
-
-# Install any extensions to `RPGLIB`. This is kind of tricky. We should
-# be running `make` in the extension directory but I haven't had time to
-# make it work right so just pull the prefix out of the `Makefile` and
-# install the shared libs manually.
-test -n "$exts" && {
- mkdir -p "$RPGLIB"
- echo "$exts" |
- while read dl
- do
- # make install sitearchdir=/lib
- prefix=$(
- grep '^target_prefix.=' "$(dirname $dl)/Makefile" |
- sed 's/^target_prefix *= *//'
- )
- dest="${RPGLIB}${prefix}/$(basename $dl)"
- rpg_ln "$dl" "$dest"
- echo "$dest" >> "$manifest"
- done
-}
-
-# Ruby Library Files
-# ------------------
-
-# Recursively install all library files into `RPGLIB`.
-test -d lib && {
- mkdir -p "$RPGLIB"
- rpg_install_dir lib "$RPGLIB" "$manifest"
-}
-
-# Ruby Executables
-# ----------------
-
-# Write executable scripts into `RPGBIN` and rewrite shebang lines.
-test -d bin && {
- mkdir -p "$RPGBIN"
- for file in bin/*
- do dest="$RPGBIN/$(basename $file)"
- notice "$dest [!]"
- sed "s@^#!.*ruby.*@#!$(ruby_command)@" \
- < "$file" \
- > "$dest"
- chmod 0755 "$dest"
- echo "$dest" >> "$manifest"
- done
-}
-
-# Manpages
-# --------
-
-# Install any manpages included with the package into `RPGMAN`. Make
-# sure files are being installed under the prescribed hierarchy.
-test -d man && {
- for file in man/*
- do
- if test -f "$file" && expr "$file" : '.*\.[0-9]' >/dev/null
- then
- section=${file##*\.}
- dest="$RPGMAN/man$section/$(basename $file)"
- mkdir -p "$RPGMAN/man$section"
- rpg_ln "$file" "$dest"
- echo "$dest" >> "$manifest"
- fi
- done
-}
+echo "HERES THE PACKAGE LIST:"
+cat "$packlist"
+echo "HERES YOUR JANK:"
+cat "$sessiondir"/solved
-# Mark this package as active
-unlink "$dbdir/installing"
-ln -sf "$gemvers" "$dbdir/active"
+cat "$sessiondir"/solved |
+xargs -n 3 rpg-package-install
View
2 rpg-list.sh
@@ -35,7 +35,7 @@ cd "$RPGDB" || exit 0
for glob in "$@"
do
matched=false
- for path in $(ls -1 $glob/active 2>/dev/null)
+ for path in $(ls -1d $glob/active 2>/dev/null)
do
matched=true
package=${path%/active}
View
5 rpg-package-install.sh
@@ -71,8 +71,9 @@ rpg_install_dir () {
# Establish our directories in the package database. These should
# have already been created by `rpg-package-register`. If not, bail
# out now since something isn't right.
-package="$1"
-version="$2"
+package="$1";shift
+version="$1";shift
+test "$version" = '=' && version="$1";shift
packagedir="$RPGDB/$package"
test -d "$packagedir/$version" || {
View
1 rpg-package-register.sh
@@ -46,6 +46,7 @@ do
if $force
then notice "$package $version already registered: proceeding due to -f"
else notice "$package $version already registered: bypassing"
+ echo "$packagedir"
exit 0
fi
else
View
2 rpg-resolve.sh
@@ -27,7 +27,7 @@ package="$1"; shift
[ "$*" ] || helpthem
index="$RPGINDEX/release"
-rpg-update -s
+test -f "$index" || rpg-update -s
versions=$(
grep "^$package " < "$index" |
View
2 rpg-sh-setup.sh
@@ -221,7 +221,7 @@ warn () { echo "$PROGNAME:" "$@" 1>&2; }
# Write an informationational message to stderr prefixed with the name
# of the current script. Don't use this, use `notice`.
heed () {
- printf "%18s %s\n" "${PROGNAME#rpg-}:" "$*" 1>&2
+ printf "%20s %s\n" "${PROGNAME#rpg-}:" "$*" 1>&2
}
# We rewite the `notice` function to `head` if `RPGVERBOSE` is enabled
View
7 rpg-solve.sh
@@ -18,11 +18,10 @@ Options
# Run ourself and then `sort | uniq` the output down to the best
# match if the `-u` option was given.
+maxvers=
[ "$1" = '-u' ] && {
shift
- "$0" "$@" |
- sort -u -b -k1,1
- exit
+ maxvers='-n 1'
}
# Done parsing args.
@@ -37,7 +36,7 @@ failedpacks=
resolve () {
if test -n "$current"
then
- rpg-resolve -p "$current" "$expression" || {
+ rpg-resolve -p $maxvers "$current" "$expression" || {
failed=$(( $failed + 1 ))
echo "$current != *"
notice "failed to resolve $current $expression"
View
8 rpg-steal.sh
@@ -14,8 +14,8 @@ then tampon="echo"
else tampon="rpg-install"
fi
-gem list --local |
-sed "s|^\(${GEMNAME_PATTERN}\) *(\([$GEMVERS_PATTERN\).*|GEM \1 \2|" |
-grep '^GEM ' |
-sed 's/^GEM //' |
+gem list --local |
+sed "s|^\(${GEMNAME_BRE}\) *(\([$GEMVERS_BRE\).*|GEM \1 \2|" |
+grep '^GEM ' |
+sed 's/^GEM //' |
xargs -n 2 "$tampon"

0 comments on commit c41c758

Please sign in to comment.
Something went wrong with that request. Please try again.