Merge lp:~xavi-garcia-mena/go-unityscopes/utils-setup-scopes-env into lp:go-unityscopes/v2

Proposed by Xavi Garcia
Status: Needs review
Proposed branch: lp:~xavi-garcia-mena/go-unityscopes/utils-setup-scopes-env
Merge into: lp:go-unityscopes/v2
Prerequisite: lp:~xavi-garcia-mena/go-unityscopes/utils-config-scopefiles
Diff against target: 101 lines (+91/-0)
2 files modified
utils/install-tools.sh (+45/-0)
utils/setup-scopes-env/setup-scopes-env.go (+46/-0)
To merge this branch: bzr merge lp:~xavi-garcia-mena/go-unityscopes/utils-setup-scopes-env
Reviewer Review Type Date Requested Status
Unity API Team Pending
Review via email: mp+265835@code.launchpad.net

Commit message

Adding binary tool to setup the chroot environment to build go scopes.

Description of the change

Adding binary tool to setup the chroot environment to build go scopes.

To post a comment you must log in.

Unmerged revisions

73. By Xavi Garcia

Added setup-scopes-env tool to prepare the chroot to crosscompile. Added install script

72. By Xavi Garcia

Added scopefiles package to deal with the configuration files and how and where config files are located and verified

71. By Xavi Garcia

Added utilites series information to describe the different configurations we can face when crosscompiling go scopes

70. By Xavi Garcia

Added utils directory with tools for building. Added common test utils package. Added utils command package to run system commands

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'utils/install-tools.sh'
--- utils/install-tools.sh 1970-01-01 00:00:00 +0000
+++ utils/install-tools.sh 2015-07-24 14:24:31 +0000
@@ -0,0 +1,45 @@
1#/bin/bash
2
3# Function that executes a given command and compares its return command with a given one.
4# In case the expected and the actual return codes are different it exits
5# the script.
6# Parameters:
7# $1: Command to be executed (string)
8# $2: Expected return code (number), may be undefined.
9function executeCommand()
10{
11 # gets the command
12 CMD=$1
13 # sets the return code expected
14 # if it's not definedset it to 0
15 OK_CODE=$2
16 if [ -n $2 ]
17 then
18 OK_CODE=0
19 fi
20 # executes the command
21 eval ${CMD}
22
23 # checks if the command was executed successfully
24 RET_CODE=$?
25 if [ $RET_CODE -ne $OK_CODE ]
26 then
27 echo ""
28 echo "ERROR executing command: \"$CMD\""
29 echo "Exiting..."
30 exit 1
31 fi
32}
33
34# ******************************************************************************
35# * MAIN *
36# ******************************************************************************
37
38echo -n "Installing setup-scopes-env... "
39executeCommand "cd setup-scopes-env"
40executeCommand "go install"
41executeCommand "cd .."
42echo "Done"
43
44
45
046
=== added directory 'utils/setup-scopes-env'
=== added file 'utils/setup-scopes-env/setup-scopes-env.go'
--- utils/setup-scopes-env/setup-scopes-env.go 1970-01-01 00:00:00 +0000
+++ utils/setup-scopes-env/setup-scopes-env.go 2015-07-24 14:24:31 +0000
@@ -0,0 +1,46 @@
1package main
2
3import (
4 "flag"
5 "fmt"
6 "launchpad.net/go-unityscopes/v2/utils/command"
7 "launchpad.net/go-unityscopes/v2/utils/series"
8 "os"
9 "strings"
10)
11
12func main() {
13 seriesPtr := flag.String("series", "", "The series name, for example 'vivid'")
14 listPtr := flag.Bool("l", false, "Prints the list of valid series")
15 flag.Parse()
16
17 // series stores the information about packages and chroot names
18 series := series.NewSeries()
19
20 if *listPtr == true {
21 series.PrintValidSeries()
22 return
23 }
24
25 seriesChroot := series.GetChrootName(*seriesPtr)
26 if seriesChroot == "" {
27 os.Exit(1)
28 }
29
30 packagesList := series.GetPackagesList(*seriesPtr)
31 packagesStr := strings.Join(packagesList, " ")
32 if packagesStr == "" {
33 os.Exit(2)
34 }
35
36 var cmd command.Command
37 cmd.ExecuteWithStdout(fmt.Sprintf("sudo click chroot -aarmhf -f%s -s %s create", seriesChroot, *seriesPtr))
38 err := cmd.ExecuteWithStdout(fmt.Sprintf("sudo click chroot -aarmhf -f%s -s %s maint apt-get install %s", seriesChroot, *seriesPtr, packagesStr))
39 if err != nil {
40 fmt.Println("\n------------------")
41 fmt.Printf("An error has occurred: %s\n", err.Error())
42 } else {
43 fmt.Println("\n------------------")
44 fmt.Println("chroot setup was successful.")
45 }
46}

Subscribers

People subscribed via source and target branches

to all changes: