Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 70 lines (62 sloc) 2.108 kb
e59261f @rtomayko split package registration and installation into separate programs
authored
1 #!/bin/sh
dd99548 @rtomayko rpg-package-register doesn't leak expr output
authored
2 # Register a gem in the local package database.
e59261f @rtomayko split package registration and installation into separate programs
authored
3 set -e
4 . rpg-sh-setup
5
6 [ "$*" ] || set -- '--help'; ARGV="$@"
7 USAGE '${PROGNAME} [-f] <file>...
f45da50 @rtomayko rpg-dependencies -p output is suitable for xargs'ing into rpg-package-re...
authored
8 ${PROGNAME} [-f] <package> <version>
37c0dec @rtomayko surgeory on the README/TODO
authored
9 Register a gem in the package database.'
e59261f @rtomayko split package registration and installation into separate programs
authored
10
11 force=false
12 test "$1" = '-f' && {
13 force=true
14 shift
15 }
16
f45da50 @rtomayko rpg-dependencies -p output is suitable for xargs'ing into rpg-package-re...
authored
17 # Under the second synopsis form, we first perform a `rpg-fetch` on the
18 # `<package>` and `<version>` given and then continue with the resulting
19 # filename.
e1ac29d @rtomayko package-register fails with package name but no version
authored
20 if ! expr -- "$1" : '.*\.gem' >/dev/null
f45da50 @rtomayko rpg-dependencies -p output is suitable for xargs'ing into rpg-package-re...
authored
21 then
e1ac29d @rtomayko package-register fails with package name but no version
authored
22 if test $# -eq 2
23 then gemfile=$(rpg-fetch "$1" "$2")
24 set -- "$gemfile"
25 else echo "$PROGNAME: '$1' package version required"
26 exit 2
27 fi
f45da50 @rtomayko rpg-dependencies -p output is suitable for xargs'ing into rpg-package-re...
authored
28 fi
29
e59261f @rtomayko split package registration and installation into separate programs
authored
30 for file in "$@"
31 do
32 # Information we can extract from the gem name.
33 gemname=$(basename $file .gem)
34 package=${gemname%-*}
35 version=${gemname##*-}
36
37 # These are directories and file locations into the package database.
38 packagedir="$RPGDB/$package/$version"
39 gemspec="$packagedir/gemspec"
40 deps="$packagedir/deps"
41
42 # Try to exit if the package is already registered and looks okay. The
43 # `-f` argument can be used to override and force the package to be
44 # registered again.
45 if test -f "$packagedir/gemspec" -a -f "$packagedir/name"
46 then
47 if $force
48 then notice "$package $version already registered: proceeding due to -f"
49 else notice "$package $version already registered: bypassing"
c41c758 @rtomayko two phase rpg-install fetches / dep solves before installing
authored
50 echo "$packagedir"
e59261f @rtomayko split package registration and installation into separate programs
authored
51 exit 0
52 fi
53 else
54 notice "$package $version -> $packagedir"
55 fi
56
57 # Create the package directory, write `name` and `version` files,
58 # extract and write gemspec related files.
59 #
60 # The `name` and `version` files are redundant since that info can be
61 # obtained from `$(basename $(dirname <path>))` and `$(basename <path>)`,
62 # but having them there makes some things a bit easier.
63 mkdir -p "$packagedir"
64 echo "$package" > "$packagedir/name"
65 echo "$version" > "$packagedir/version"
eb3ac03 @rtomayko rpg-package-spec does everything gemspec related
authored
66 rpg-unpack -cm "$file" > "$gemspec"
67 rpg-package-spec -i "$gemspec"
e59261f @rtomayko split package registration and installation into separate programs
authored
68 echo "$packagedir"
69 done
Something went wrong with that request. Please try again.