Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Revising directory structure and Rakefile #10

Merged
merged 5 commits into from Jan 13, 2012

Conversation

Projects
None yet
3 participants
Contributor

dpk commented Jan 10, 2012

Rationale

  • The Rakefile now uses rake's built-in methods for simulating
    Unix file commands. These report what they're doing as they
    do it, so there's no need for us to give our own diagnostics.
  • We now have a more traditional rake; rake install procedure
    for installation. This doesn't force sudo on people who don't
    need it. (Homebrew chmods /usr/local/bin to be writable, so we
    don't need sudo for people who've installed Homebrew.)
  • We now have a clean framework for allowing future scripts to
    be compiled (in C/C++/Objective-C/MacRuby...) separately from
    their installation.

Antirationale

  • Only one script is being compiled right now; the rest are just
    copied verbatim from src to bin. Although the extensibility of
    this approach is admirable, it might be better to wait until
    someone writes some more scripts in C/etc/MacRuby.

Ideas

  • Support switches --no-{script} to suppress installation of a
    particular script.
  • Support switch --base to allow installing somewhere other than
    /usr/local/bin/
@dpk dpk Made Rakefile more idiomatic; moved scripts to `src` before rake.
Rationale:
* The Rakefile now uses rake's built-in methods for simulating
  Unix file commands. These report what they're doing as they
  do it, so there's no need for us to give our own diagnostics.
* We now have a more traditional `rake`; `rake install` procedure
  for installation. This doesn't force `sudo` on people who don't
  need it. (Homebrew chmods /usr/local/bin to be writable, so we
  don't need sudo for people who've installed Homebrew.)
* We now have a clean framework for allowing future scripts to
  be compiled (in C/C++/Objective-C/MacRuby...) separately from
  their installation.

Antirationale:
* Only one script is being compiled right now; the rest are just
  copied verbatim from src to bin. Although the extensibility of
  this approach is admirable, it might be better to wait until
  someone writes some more scripts in C/etc/MacRuby.

Ideas:
* Support switches `--no-{script}` to suppress installation of a
  particular script.
* Support switch `--base` to allow installing somewhere other than
  /usr/local/bin/
cd10cb6
Owner

morgant commented Jan 10, 2012

Hmm, it fails as follows (showing rake --trace):

in /Users/morgan/Desktop/Personal/tools-osx)
** Invoke default (first_time)
** Execute default
rake aborted!
undefined method `exist?' for Dir:Class
/Users/morgan/Desktop/Personal/tools-osx/rakefile:9
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

Mac OS X 10.5 (which I'm still running) has rake v0.7.3 & 1.8.6, is it possible that the exist? and empty? methods don't exist?

Contributor

dpk commented Jan 10, 2012

D'oh. Hold on a minute. I forgot that Apple still doesn't ship Ruby 1.9 by default.

Contributor

dpk commented Jan 10, 2012

Should work now.

Owner

morgant commented Jan 10, 2012

Further errors (again, rake --trace):

(in /Users/morgan/Desktop/Personal/tools-osx)
** Invoke default (first_time)
** Execute default
rake aborted!
undefined method `lines' for #<String:0x353130>
/Users/morgan/Desktop/Personal/tools-osx/rakefile:13
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
Contributor

dpk commented Jan 10, 2012

Hrmm. Sorry about this. I only have Lion's stock 1.8.7 and 1.9, so I can't test for things added between 1.8.6 and 1.8.7. Try now?

Owner

morgant commented Jan 11, 2012

No worries, I'm happy to keep testing. Apologies for all the extra work for you.

Further errors (it doesn't like each_line either):

(in /Users/morgan/Desktop/Personal/tools-osx)
** Invoke default (first_time)
** Execute default
rake aborted!
no block given
/Users/morgan/Desktop/Personal/tools-osx/rakefile:13:in `each_line'
/Users/morgan/Desktop/Personal/tools-osx/rakefile:13
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
Contributor

dpk commented Jan 11, 2012

How about that?

Owner

morgant commented Jan 11, 2012

So damn close! rake & sudo rake install work without error, but the output of the former has a line feed after every word:

(in /Users/morgan/Desktop/Personal/tools-osx)
Warning:
MacRuby
is
not
installed;
therefore,
`dict`,
a
tools-osx
script
that
depends
on
it,
will
not
be
installed
either.
This
does
not
affect
any
other
script.
If
you
would
like
to
use
`dict`,
install
MacRuby
from
http://macruby.org/
then
re-install
tools-osx.
Contributor

dpk commented Jan 11, 2012

So they changed the behaviour of String#split without arguments between 1.8.6 and 1.8.7? That's crazy. Anyhow, I think this is the one.

That worked! Thank you very much!

I still have to do the manual merge and I'll probably add back in some of my feedback stuff since even echoing the commands it's running isn't as clear as it could be. This is a great step forward for the Rakefile.

Contributor

dpk commented Jan 11, 2012

Why do you think that more diagnostics are necessary?

And might I suggest adding a --verbose/-v option for those?

Owner

morgant commented Jan 11, 2012

I'm just used to build/install scripts being overly verbose and I guess I've come to expect it. That said, I want it to be friendly as opposed to the spam one usually gets from make and the likes.

Contributor

dpk commented Jan 11, 2012

Personally, I think it's better Unix style to only output what we need to. For build scripts, that's following the make pattern of letting the user see the exact steps being taken to compile.

But if you feel more stuff is needed, well, it's your package. But I think such things are best suppressed unless explicitly requested.

Owner

morgant commented Jan 11, 2012

That's a very good point, I was partly feeling that it wasn't verbose enough because rake doesn't look like it's doing anything (for me, because I don't have MacRuby, so it just shows the warning and nothing more) and sudo rake install looks like it's doing only one thing (the install command). I'll probably start by making the former show it copying to ./bin (it does show the macruby compile process, if you have MacRuby installed), then it'll make more sense.

Contributor

dpk commented Jan 11, 2012

Really? Just doing rake should say:

mkdir ./bin
Warning: MacRuby is not installed; therefore, `dict`,
a tools-osx script that depends on it, will not be 
installed either. This does not affect any other script.

If you would like to use `dict`, install MacRuby from
http://macruby.org/ then re-install tools-osx.

cp ./src/32bitSafePerl ./bin/32bitSafePerl
cp ./src/clipcat ./bin/clipcat
cp ./src/eject ./bin/eject
cp ./src/ql ./bin/ql
cp ./src/swuser ./bin/swuser
cp ./src/trash ./bin/trash
cp ./src/urlmnt ./bin/urlmnt
cp ./src/with ./bin/with

If it doesn't, there's something wrong with the Rakefile. Again.

Owner

morgant commented Jan 12, 2012

Yeah, I don't get all that. Definitely explains the confusion.

I'd assume that all those commands just need to be run through the sh command (currently only macrubyc & install are), correct?

Contributor

dpk commented Jan 12, 2012

Try adding include Fileutils::Verbose at the top of the Rakefile. If that doesn't work... grr...

Owner

morgant commented Jan 12, 2012

No luck with include FileUtils::Verbose. I don't think I can thank you enough for your assistance & patience on this.

casper commented Jan 12, 2012

Try this: Rake::FileUtilsExt.verbose(true)

Owner

morgant commented Jan 13, 2012

uninitialized constant Rake::FileUtilsExt

Contributor

dpk commented Jan 13, 2012

How about RakeFileUtils.verbose(true)? http://rake.rubyforge.org/classes/RakeFileUtils.html

Owner

morgant commented Jan 13, 2012

Gah, my apologies, I screwed up when I tested include FileUtils::Verbose and had forgotten to delete ./bin/! Deleted and re-tested and that one worked. Thanks!

@morgant morgant merged commit d7939f1 into morgant:master Jan 13, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment