From 05c1b453b27f8e2629215d6faba92f12dcf2ab93 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 6 Aug 2009 22:36:30 -0400 Subject: [PATCH] Add `mr bootstrap` which downloads an url to a .mrconfig file in the current directory and then checks out all repositories configured in it. This is intended for projects that want to publish a mrconfig file to automate use of their several repositories. --- debian/changelog | 8 +++++--- debian/copyright | 2 +- mr | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index 32958fa..87a496e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,11 @@ mr (0.41) UNRELEASED; urgency=low * Add -p switch, that makes mr search the current directory and its - parents for a .mrconfig file to use. Useful for projects that want - to publish a mrconfig file to use to check out their several repositories, - without requiring users put it anywhere in particular. + parents for a .mrconfig file to use. + * Add `mr bootstrap`, which downloads an url to a .mrconfig file + in the current directory and then checks out all repositories configured + in it. This is intended for projects that want to publish a mrconfig file + to automate use of their several repositories. -- Joey Hess Thu, 06 Aug 2009 22:13:05 -0400 diff --git a/debian/copyright b/debian/copyright index 24c49f0..5acf191 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,5 +1,5 @@ Files: * -Copyright: (c) 2007 Joey Hess +Copyright: (c) 2007-2009 Joey Hess License: GPL-2+ On Debian systems, the complete text of the GPL can be found in /usr/share/common-licenses/GPL. diff --git a/mr b/mr index 4dbaa7a..fd380db 100755 --- a/mr +++ b/mr @@ -20,6 +20,8 @@ B [options] diff B [options] log +B [options] bootstrap url + B [options] register [repository] B [options] config section ["parameter=[value]" ...] @@ -98,6 +100,14 @@ These commands are also available: =over 4 +=item bootstrap url + +Causes mr to download the url, save it to a .mrconfig file in the +current directory, and then check out all repositories listed in it. + +(Please only do this if you have reason to trust the url, since +mrconfig files can contain arbitrary commands!) + =item list (or ls) List the repositories that mr will act on. @@ -354,7 +364,7 @@ the documentation in the files for details about using them. =head1 AUTHOR -Copyright 2007 Joey Hess +Copyright 2007-2009 Joey Hess Licensed under the GNU GPL version 2 or higher. @@ -1023,6 +1033,9 @@ sub dispatch { elsif ($action eq 'register') { register(@ARGV); } + elsif ($action eq 'bootstrap') { + bootstrap(); + } elsif ($action eq 'remember' || $action eq 'offline' || $action eq 'online') { @@ -1128,6 +1141,25 @@ sub register { exec($command) || die "exec: $!"; } +sub bootstrap { + my $url=shift @ARGV; + + if (! defined $url || ! length $url) { + die "mr: bootstrap requires url\n"; + } + + if (-e ".mrconfig") { + die "mr: .mrconfig file already exists, not overwriting with $url\n"; + } + + if (system("curl", "-s", $url, "-o", ".mrconfig") != 0) { + die "mr: download of $url failed\n"; + } + + exec("mr $ENV{MR_SWITCHES} -c .mrconfig checkout"); + die "failed to run mr checkout"; +} + # alias expansion and command stemming sub expandaction { my $action=shift; @@ -1393,6 +1425,7 @@ help = man -l "$tmp" || error "man failed" list = true config = +bootstrap = online = if [ -s ~/.mrlog ]; then -- 2.39.2