Permalink
Browse files

rpg-shit-list fixes up non-compatible packages

  • Loading branch information...
1 parent bb5d4d1 commit bbf5937239595bb528368926b7ea61749ae419e3 @rtomayko committed Mar 16, 2010
Showing with 75 additions and 19 deletions.
  1. +1 −0 .gitignore
  2. +3 −3 Makefile
  3. +21 −16 rpg-package-install.sh
  4. +50 −0 rpg-shit-list.sh
View
@@ -49,3 +49,4 @@
/rpg-package-register.html
/rpg-package-spec.html
/rpg-parse-index.html
+/rpg-shit-list
View
@@ -32,7 +32,7 @@ SOURCES = \
rpg-build.sh rpg-env.sh rpg-update.sh rpg-resolve.sh rpg-upgrade.sh \
rpg-steal.sh rpg-fsck.sh rpg-status.sh rpg-outdated.sh \
rpg-package-register.sh rpg-package-install.sh rpg-solve.sh rpg-unpack.sh \
- rpg-package-spec.rb rpg-parse-index.rb
+ rpg-package-spec.rb rpg-parse-index.rb rpg-shit-list.sh
USERPROGRAMS = rpg rpg-sh-setup
@@ -42,7 +42,7 @@ PROGRAMPROGRAMS = \
rpg-build rpg-env rpg-update rpg-resolve rpg-upgrade \
rpg-steal rpg-fsck rpg-status rpg-outdated rpg-parse-package-list \
rpg-package-register rpg-package-install rpg-solve rpg-unpack \
- rpg-package-spec rpg-parse-index
+ rpg-package-spec rpg-parse-index rpg-shit-list
PROGRAMS = $(USERPROGRAMS) $(PROGRAMPROGRAMS)
@@ -52,7 +52,7 @@ DOCHTML = \
rpg-build.html rpg-env.html rpg-update.html rpg-resolve.html \
rpg-upgrade.html rpg-steal.html rpg-fsck.html rpg-status.html \
rpg-outdated.html rpg-package-register.html rpg-package-install.html \
- rpg-solve.html rpg-package-spec.html rpg-parse-index.html
+ rpg-solve.html rpg-package-spec.html rpg-parse-index.html rpg-shit-list.html
.SUFFIXES: .sh .rb .html
View
@@ -42,21 +42,22 @@ rpg_ln () {
fi
}
+# Usage: rpg_install_dir `<source>` `<dest>` `<manifest>`
+#
# 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"
+ mkdir -p "$2"
for file in "$1"/*
do
if test -f "$file"
then # link dest to source
- rpg_ln "$file" "$dest/$(basename $file)"
- echo "$dest/$(basename $file)" >> "$manifest"
+ rpg_ln "$file" "$2/$(basename $file)"
+ echo "$2/$(basename $file)" >> "$3"
elif test -d "$file"
then # recurse into directories
- rpg_install_dir "$file" "$dest/$(basename $file)" "$manifest"
+ rpg_install_dir "$file" "$2/$(basename $file)" "$manifest"
else warn "unknown file type: $file"
return 1
@@ -85,12 +86,14 @@ notice "$package $version"
# Fetch the gem into the cache and unpack into the packs area if
# its not already there.
-if test -d "$RPGPACKS/$package-$version"
+if ! $force && test -d "$RPGPACKS/$package-$version"
then notice "sources already exist. bypassing fetch and unpack."
-else gemfile=$(rpg-fetch "$package" "$version")
+else rm -rf "$RPGPACKS/$package-$version"
+ gemfile=$(rpg-fetch "$package" "$version")
notice "unpacking $gemfile into $RPGPACKS"
mkdir -p "$RPGPACKS"
rpg-unpack -p "$RPGPACKS" "$gemfile"
+ rpg-shit-list "$package" "$version" "$RPGPACKS/$package-$version"
fi
# If the package already has an active/installed version, check if its
@@ -113,6 +116,9 @@ test -e "$packagedir/active" && {
fi
}
+# Path to the unpacked package directory.
+pack="$RPGPACKS/$package-$version"
+
# This is our file manifest. We record everything installed in here
# so we know how to uninstall the package. Create/truncate it in case
# it already exists.
@@ -127,15 +133,13 @@ echo "# $(date)" > "$manifest"
# detect in progress or failed installations.
ln -sf "$version" "$packagedir/installing"
-# Go into the unpackaged package dir to make installing a bit easier.
-cd "$RPGPACKS/$package-$version"
# Extension Libraries
# -------------------
# Build extension libraries if they exist. Bail out if the build fails.
-exts="$(rpg-build "$(pwd)")" || {
+exts="$(rpg-build "$pack")" || {
warn "extension failed to build"
exit 1
}
@@ -150,12 +154,12 @@ test -n "$exts" && {
while read dl
do
prefix=$(
- grep '^target_prefix.=' "$(dirname $dl)/Makefile" |
+ grep '^target_prefix.=' "$pack/$(dirname $dl)/Makefile" |
sed 's/^target_prefix *= *//'
)
dest="${RPGLIB}${prefix}/$(basename $dl)"
mkdir -p "${RPGLIB}${prefix}"
- rpg_ln "$dl" "$dest"
+ rpg_ln "$pack/$dl" "$dest"
echo "$dest" >> "$manifest"
done
}
@@ -166,7 +170,7 @@ test -n "$exts" && {
# Recursively install all library files into `RPGLIB`.
test -d lib && {
mkdir -p "$RPGLIB"
- rpg_install_dir lib "$RPGLIB" "$manifest"
+ rpg_install_dir "$pack/lib" "$RPGLIB" "$manifest"
}
# Ruby Executables
@@ -175,7 +179,7 @@ test -d lib && {
# Write executable scripts into `RPGBIN` and rewrite shebang lines.
test -d bin && {
mkdir -p "$RPGBIN"
- for file in bin/*
+ for file in "$pack"/bin/*
do dest="$RPGBIN/$(basename $file)"
notice "$dest [!]"
sed "s@^#!.*ruby.*@#!$(ruby_command)@" \
@@ -192,8 +196,9 @@ test -d bin && {
# 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][0-9A-Za-z]*$' >/dev/null
+ for file in "$pack"/man/*
+ do if test -f "$file" &&
+ expr "$file" : '.*\.[0-9][0-9A-Za-z]*$' >/dev/null
then
section=${file##*\.}
dest="$RPGMAN/man$section/$(basename $file)"
View
@@ -0,0 +1,50 @@
+#!/bin/sh
+# Modify package to work around issues
+set -e
+. rpg-sh-setup
+
+ARGV="$@"
+USAGE '${PROGNAME} <package> <version> <path>
+Patch package to work with rpg.'
+
+package="$1"
+version="$2"
+path="$3"
+
+# Usage: `sedi <expr> <file>`
+#
+# Run `sed` on `<file>` in-place.
+sedi () {
+ sed "$1" < "$2" > "$2+"
+ mv "$2+" "$2"
+}
+
+# Note that this package is on the shit-list.
+fixable () {
+ heed "incompatible package detected: $package/$version (fixing)"
+ test -n "$*" && notice "$*"
+}
+
+# Master list of shit list packages with hacks.
+case "$package" in
+memcached)
+ fixable "memcached.rb reads VERSION file from package root"
+ cd "$path"
+ sedi "s/VERSION = File.read.*/VERSION = '$version'/" lib/memcached.rb
+ ;;
+
+haml)
+ fixable "haml reads VERSION, VERSION_NAME, REVISION files from package root"
+ cd "$path"
+ revision=$(cat REVISION 2>/dev/null || true)
+ vername=$(cat VERSION_NAME 2>/dev/null || true)
+ sedi "
+ s/File.read(scope('VERSION'))/'$version'/g
+ s/File.read(scope('REVISION'))/'$revision'/g
+ s/File.read(scope('VERSION_NAME'))/'$vername'/g
+ " lib/haml/version.rb
+ ;;
+esac
+
+# Make sure we exit with success.
+:

0 comments on commit bbf5937

Please sign in to comment.