Skip to content

Commit

Permalink
fixed --quickstart to detect the latest OTP tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Parfitt committed Jun 2, 2014
1 parent 168edc5 commit 61cdd77
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ sudo make uninstall

## Quickstart

To create erln8 config files, clone the default OTP repo, and build Erlang R16B02, simply run:
To create erln8 config files, clone the default OTP repo, and build the latest version of Erlang (OTP-17.0.1 as of writing), simply run:

```
erln8 --quickstart
Expand All @@ -107,7 +107,7 @@ Depending on your system, it could take quite awhile to download the OTP Git rep
Once the quickstart completes, you'll still need to cd to a directory where you want to use Erlang and run:

```
erln8 --use R16B02
erln8 --use quickstart_build
```


Expand Down
42 changes: 38 additions & 4 deletions erln8.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ void list_erlangs() {
// a partial ~/ERLN8_CONFIG_DIR tree
void initialize() {
if(check_home()) {
g_error("Configuration directory ~/" ERLN8_CONFIG_DIR " already exists\n");
g_warning("Configuration directory ~/" ERLN8_CONFIG_DIR " already exists\n");
return;
} else {
//if(erl_on_path()) {
// g_warning("Erlang already exists on the current PATH\n");
Expand Down Expand Up @@ -1209,6 +1210,37 @@ void dounlink() {
}
}

void display_latest_quickstart() {
gchar* repo = "default";
GHashTable* repos = get_repos();
gboolean has_repo = g_hash_table_contains(repos, repo);
g_hash_table_destroy(repos);
if(!has_repo) {
g_error("Unknown repo %s\n", repo);
}
gchar* source_path = get_config_subdir_file_name("repos", repo);
if(!g_file_test(source_path, G_FILE_TEST_EXISTS |
G_FILE_TEST_IS_REGULAR)) {
g_error("Missing repo for %s, which should be in %s. Maybe you forgot to erln8 --clone repo_name\n",
repo,
source_path);
}
// too much color? I'd like this message to stand out
printf("%sDetected latest Erlang/OTP tag: %s\n", blue(), green());
gchar* fetchcmd = g_strconcat("cd ",
source_path,
" && git describe --abbrev=0 --tags",
NULL);
int result = system(fetchcmd);
if(result != 0) {
g_error("Error fetching from repo %s\n", repo);
}
printf("%s\n", color_reset());
g_free(source_path);
g_free(fetchcmd);
}


// if not executing one of the erlang commands
// then process erln8 options etc
int erln8(int argc, gchar* argv[]) {
Expand All @@ -1229,9 +1261,11 @@ int erln8(int argc, gchar* argv[]) {
doclone();
opt_repo = "default";
opt_config = "default";
// TODO: detect the latest tag and use that!
opt_tag = "OTP_R16B02";
opt_id = "R16B02";
// detect the latest git TAG from the OTP repo
// I hope this works... ;-)
opt_tag = "`git describe --abbrev=0 --tags`";
opt_id = "quickstart_build";
display_latest_quickstart();
dobuild();
return 0;
}
Expand Down

0 comments on commit 61cdd77

Please sign in to comment.