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
1=== added file 'utils/install-tools.sh'
2--- utils/install-tools.sh 1970-01-01 00:00:00 +0000
3+++ utils/install-tools.sh 2015-07-24 14:24:31 +0000
4@@ -0,0 +1,45 @@
5+#/bin/bash
6+
7+# Function that executes a given command and compares its return command with a given one.
8+# In case the expected and the actual return codes are different it exits
9+# the script.
10+# Parameters:
11+# $1: Command to be executed (string)
12+# $2: Expected return code (number), may be undefined.
13+function executeCommand()
14+{
15+ # gets the command
16+ CMD=$1
17+ # sets the return code expected
18+ # if it's not definedset it to 0
19+ OK_CODE=$2
20+ if [ -n $2 ]
21+ then
22+ OK_CODE=0
23+ fi
24+ # executes the command
25+ eval ${CMD}
26+
27+ # checks if the command was executed successfully
28+ RET_CODE=$?
29+ if [ $RET_CODE -ne $OK_CODE ]
30+ then
31+ echo ""
32+ echo "ERROR executing command: \"$CMD\""
33+ echo "Exiting..."
34+ exit 1
35+ fi
36+}
37+
38+# ******************************************************************************
39+# * MAIN *
40+# ******************************************************************************
41+
42+echo -n "Installing setup-scopes-env... "
43+executeCommand "cd setup-scopes-env"
44+executeCommand "go install"
45+executeCommand "cd .."
46+echo "Done"
47+
48+
49+
50
51=== added directory 'utils/setup-scopes-env'
52=== added file 'utils/setup-scopes-env/setup-scopes-env.go'
53--- utils/setup-scopes-env/setup-scopes-env.go 1970-01-01 00:00:00 +0000
54+++ utils/setup-scopes-env/setup-scopes-env.go 2015-07-24 14:24:31 +0000
55@@ -0,0 +1,46 @@
56+package main
57+
58+import (
59+ "flag"
60+ "fmt"
61+ "launchpad.net/go-unityscopes/v2/utils/command"
62+ "launchpad.net/go-unityscopes/v2/utils/series"
63+ "os"
64+ "strings"
65+)
66+
67+func main() {
68+ seriesPtr := flag.String("series", "", "The series name, for example 'vivid'")
69+ listPtr := flag.Bool("l", false, "Prints the list of valid series")
70+ flag.Parse()
71+
72+ // series stores the information about packages and chroot names
73+ series := series.NewSeries()
74+
75+ if *listPtr == true {
76+ series.PrintValidSeries()
77+ return
78+ }
79+
80+ seriesChroot := series.GetChrootName(*seriesPtr)
81+ if seriesChroot == "" {
82+ os.Exit(1)
83+ }
84+
85+ packagesList := series.GetPackagesList(*seriesPtr)
86+ packagesStr := strings.Join(packagesList, " ")
87+ if packagesStr == "" {
88+ os.Exit(2)
89+ }
90+
91+ var cmd command.Command
92+ cmd.ExecuteWithStdout(fmt.Sprintf("sudo click chroot -aarmhf -f%s -s %s create", seriesChroot, *seriesPtr))
93+ err := cmd.ExecuteWithStdout(fmt.Sprintf("sudo click chroot -aarmhf -f%s -s %s maint apt-get install %s", seriesChroot, *seriesPtr, packagesStr))
94+ if err != nil {
95+ fmt.Println("\n------------------")
96+ fmt.Printf("An error has occurred: %s\n", err.Error())
97+ } else {
98+ fmt.Println("\n------------------")
99+ fmt.Println("chroot setup was successful.")
100+ }
101+}

Subscribers

People subscribed via source and target branches

to all changes: