Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: go/src/infra/tools/cr/cmd/firstrun/firstrun_nix.go

Issue 1929153002: Add beginnings of new cr command (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // +build !windows
6
7 /*
8 Linux/Unix/Posix-specific function implementations for the firstrun subcommand.
9 */
10
11 package firstrun
12
13 import (
14 "os"
15 "os/user"
16 "path/filepath"
17
18 "infra/tools/cr/lib/terminal"
19 )
20
21 // firstrunCheckNotInstalled is a sanity check to make sure that the user really
seanmccullough1 2016/04/29 00:54:36 FYI unexported vars/funcs etc need not be GoDoc'd
22 // wants to do firstrun again, if it looks like cr is already installed.
23 func firstrunCheckNotInstalled() {
24 // Check to see if a path ending in '/cr/bin' in in $PATH.
25 pathenv := os.Getenv("PATH")
26 terminal.Debug("$PATH is %v\n", pathenv)
seanmccullough1 2016/04/29 00:54:36 why not log.Printf?
27 possible_dirs := make([]string, 1)
28 for _, elem := range filepath.SplitList(pathenv) {
29 terminal.Debug("Examining %v\n", elem)
30 head, bindir := filepath.Split(elem)
31 crdir := filepath.Base(head)
32 terminal.Debug("Last elements of path are %v, %v\n", crdir, bind ir)
33 if bindir == "bin" && crdir == "cr" {
34 possible_dirs = append(possible_dirs, elem)
35 }
36 }
37 terminal.Debug("Possible dirs are %v\n", possible_dirs)
38 // Check to see if an executable called 'cr' is in that path.
39 }
40
41 // firstrunPromptInstallDir prompts the user for a directory path to install cr.
42 func firstrunPromptInstallDir() {
43 // Figure out a sane place to suggest.
44 _, err := user.Current()
45 if err != nil {
46 }
47 // Suggest it and ask the user for an alternative.
48 // Check that the chosen directory makes sense.
49 }
50
51 // firstrunInitInstallDir sets up the selected directory to house cr. It creates
52 // the modules/ and bin/ subdirectories, places the cr executable in the
53 // top level, and symlinks it into bin/.
54 func firstrunInitInstallDir(dir string) {
55 // Create the cr/ directory.
56 // Copy this executable into the cr/ directory.
57 // Create the bin/ subdirectory.
58 // Add a symlink to the cr executable in the bin/ subdirectory.
59 // Create the modules/ subdirectory.
60 }
61
62 // firstrunUpdatePath finds the rcfile in which $PATH is set, sees if it can
63 // automatically update it, and prompts the user for permission to do so.
64 func firstrunUpdatePath() {
65 // Detect the user's default shell.
66 // Find their shell's rcfile.
67 // Find lines modifying $PATH in that file.
68 // Fine a line mentioning depot_tools.
69 // Produce a git-style diff adding the install bin/ dir to that line, or
70 // above that line.
71 // Prompt the user to see if they want to apply that diff.
72 // Apply the diff, or print instructions on how to do it manually.
73 }
74
75 // firstrunPrintUpdatePathInstructions prints instructions for the user to
76 // update their $PATH manually. This is used if updatePath fails, or if the user
77 // declines to have their rcfile updated automatically.
78 func firstrunPrintUpdatePathInstructions() {
79
seanmccullough1 2016/04/29 00:54:36 all of these noop funcs: implement, replace with a
agable 2016/05/05 23:59:42 Planning to implement. Coming soon.
80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698