install_helpers: install infoedit from GitHub

This commit also moves repository URL to be the last argument in every git clone command.

refs #3387

Change-Id: I7e90a928ca11a4f67c949fbc10fe1b4f54307dfc
diff --git a/install_helpers/infoedit/README.md b/install_helpers/infoedit/README.md
deleted file mode 100644
index df8a0e5..0000000
--- a/install_helpers/infoedit/README.md
+++ /dev/null
@@ -1,90 +0,0 @@
-A tool used to edit NFD configuration files
-===========================================
-
-This tool is majorly developed for use in NFD integration tests.  However, it can also used to
-edit any INFO-formatted files.
-
-Each invocation of `infoedit` tool performs exactly one edit and the file is modified in place.
-To perform multiple edits, `infoedit` tool should be invoked multiple times on the same file.
-
-## Usage ##
-
-    infoedit [-f file] [-s|d|a|r path] [-v value]
-
-OPTIONS:
-
-* `-f file`: specifies a file to edit
-* `-s path`: specifies a property-tree path to modify
-* `-v value`: used with -s path, sets the value at the path
-* `-d path`: deletes all subtrees matching the path
-* `-a path`: adds a subtree at the path; the subtree is read from stdin
-* `-r path`: replaces a subtree at the path; equivalent to -d path followed by -a path
-
-## Sample command lines ##
-
-    ./infoedit -f nfd.conf -s general.user -v ndn.user
-    ./infoedit -f nfd.conf -s tables.strategy_choice./site -v /localhost/nfd/strategy/broadcast
-    ./infoedit -f nfd.conf -d tables.strategy_choice./
-    ./infoedit -f nfd.conf -d authorizations
-    ./infoedit -f nfd.conf -a rib.localhost_security <<<EOT
-      trust-anchor
-      {
-        type any
-      }
-      EOT
-
-### nfd.conf used in above sample ###
-
-    ; comment1
-
-    general ; comment2
-    {
-        user user ; comment3
-        group group
-    }
-
-    tables
-    {
-        strategy_choice
-        {
-            / /localhost/nfd/strategy/best-route
-            /site /localhost/nfd/strategy/broadcast
-        }
-    }
-
-    authorizations
-    {
-        authorize
-        {
-            certfile file1.cert
-        }
-        authorize
-        {
-            certfile file2.cert
-        }
-    }
-
-### nfd.conf after carrying out all commands in above sample ###
-
-    general
-    {
-        user ndn.user
-        group group
-    }
-    tables
-    {
-        strategy_choice
-        {
-            /site /localhost/nfd/strategy/broadcast
-        }
-    }
-    rib
-    {
-        localhost_security
-        {
-            trust-anchor
-            {
-                type any
-            }
-        }
-    }
\ No newline at end of file
diff --git a/install_helpers/infoedit/infoedit.cpp b/install_helpers/infoedit/infoedit.cpp
deleted file mode 100644
index 958b54f..0000000
--- a/install_helpers/infoedit/infoedit.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright 2015, Regents of the University of California.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
- * file except in compliance with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#include "infoedit.hpp"
-#include <iostream>
-#include <boost/program_options/options_description.hpp>
-#include <boost/program_options/variables_map.hpp>
-#include <boost/program_options/parsers.hpp>
-
-namespace infoedit {
-
-void
-InfoEditor::load(const std::string& fileName)
-{
-  std::ifstream input(fileName);
-  if (!input.good() || !input.is_open()) {
-    throw Error("Failed to open configuration file for parsing");
-  }
-
-  try {
-    boost::property_tree::info_parser::read_info(input, m_info);
-  }
-  catch (boost::property_tree::info_parser::info_parser_error& error) {
-    std::stringstream msg;
-    msg << "Failed to parse configuration file";
-    msg << " " << error.message() << " line " << error.line();
-    throw Error(msg.str());
-  }
-
-  input.close();
-}
-
-InfoEditor&
-InfoEditor::modify(const std::string& section, const std::string& value)
-{
-  m_info.put(section.c_str(), value.c_str());
-  return *this;
-}
-
-InfoEditor&
-InfoEditor::remove(const std::string& section)
-{
-  std::size_t pos = section.find_last_of(".");
-  if (pos == std::string::npos) {
-    m_info.erase(section.c_str());
-  }
-  else {
-    boost::optional<boost::property_tree::ptree&> child =
-      m_info.get_child_optional(section.substr(0, pos));
-    if (child) {
-      child->erase(section.substr(pos + 1));
-    }
-  }
-
-  return *this;
-}
-
-InfoEditor&
-InfoEditor::insert(const std::string& section, std::istream& stream)
-{
-  boost::property_tree::ptree pt;
-  read_info(stream, pt);
-
-  m_info.add_child(section.c_str(), pt);
-
-  return *this;
-}
-
-void
-InfoEditor::save(const std::string& fileName)
-{
-  std::ofstream output(fileName);
-  write_info(output, m_info);
-  output.close();
-}
-
-int
-main(int argc, char** argv)
-{
-  std::string configFile;
-  std::string sectionPath;
-  std::string value;
-
-  namespace po = boost::program_options;
-  po::options_description description("Usage\n"
-                                      "  infoedit [-f file] [-s|d|a|r path] [-v value]\n"
-                                      "Options");
-
-  description.add_options()
-    ("help,h",    "print this help message")
-    ("file,f",    po::value<std::string>(&configFile), "the file to edit")
-    ("section,s", po::value<std::string>(&sectionPath), "the section to modify")
-    ("value,v",   po::value<std::string>(&value), "the value used to modify some section")
-    ("delete,d",  po::value<std::string>(&sectionPath), "the sub tree to delete")
-    ("add,a",     po::value<std::string>(&sectionPath), "adds a sub tree")
-    ("replace,r", po::value<std::string>(&sectionPath), "replace the sub tree")
-    ;
-
-  po::variables_map vm;
-  try {
-      po::store(po::command_line_parser(argc, argv).options(description).run(), vm);
-      po::notify(vm);
-  }
-  catch (const std::exception& e) {
-    std::cerr << "ERROR: " << e.what()
-              << "\n"
-              << description;
-    return 1;
-  }
-
-  if (vm.count("help") > 0) {
-    std::cout << description;
-    return 0;
-  }
-
-  if (vm.count("file") == 0) {
-    std::cerr << "ERROR: the file to edit should be specified"
-              << "\n"
-              << description;
-    return 1;
-  }
-
-  InfoEditor editor;
-  try {
-    editor.load(configFile);
-  }
-  catch (const std::exception& e) {
-    std::cerr << "ERROR: " << e.what() << std::endl;
-    return 1;
-  }
-
-  try {
-    if (vm.count("section") > 0) {
-      if (vm.count("value") == 0) {
-        std::cerr << "ERROR: value must be specified" << std::endl;
-        return 1;
-      }
-
-      editor.modify(sectionPath, value);
-    }
-
-    if (vm.count("delete") > 0) {
-      editor.remove(sectionPath);
-    }
-
-    if (vm.count("add") > 0) {
-      editor.insert(sectionPath, std::cin);
-    }
-
-    if (vm.count("replace") > 0) {
-      editor.remove(sectionPath).insert(sectionPath, std::cin);
-    }
-  }
-  catch (...) {
-    return 1;
-  }
-
-  try {
-    editor.save(configFile);
-  }
-  catch (...) {
-    return 1;
-  }
-
-  return 0;
-}
-
-} // namespace infoedit
-
-int
-main(int argc, char** argv)
-{
-  return infoedit::main(argc, argv);
-}
diff --git a/install_helpers/infoedit/infoedit.hpp b/install_helpers/infoedit/infoedit.hpp
deleted file mode 100644
index 6217c03..0000000
--- a/install_helpers/infoedit/infoedit.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright 2015, Regents of the University of California.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
- * file except in compliance with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#ifndef INTEGRATION_TESTS_INSTALL_HELPERS_INFOEDIT_INFOEDIT_HPP
-#define INTEGRATION_TESTS_INSTALL_HELPERS_INFOEDIT_INFOEDIT_HPP
-
-#include <fstream>
-#include <iostream>
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/info_parser.hpp>
-
-namespace infoedit {
-
-class InfoEditor
-{
-public:
-  class Error : public std::runtime_error
-  {
-  public:
-    Error(const std::string& what)
-      : std::runtime_error(what)
-    {
-    }
-  };
-
-public:
-  void
-  load(const std::string& fileName);
-
-  InfoEditor&
-  modify(const std::string& section, const std::string& value);
-
-  InfoEditor&
-  remove(const std::string& section);
-
-  InfoEditor&
-  insert(const std::string& section, std::istream& stream);
-
-  void
-  save(const std::string& fileName);
-
-private:
-  boost::property_tree::ptree m_info;
-};
-
-} // namespace infoedit
-
-#endif // INTEGRATION_TESTS_INSTALL_HELPERS_INFOEDIT_INFOEDIT_HPP
diff --git a/install_helpers/install_NFD.py b/install_helpers/install_NFD.py
index cf70d03..830644d 100644
--- a/install_helpers/install_NFD.py
+++ b/install_helpers/install_NFD.py
@@ -5,7 +5,7 @@
 def run():
     print "\nINSTALLING NFD"
     print "**************"
-    os.system("git clone https://github.com/named-data/NFD --depth 1")
+    os.system("git clone --depth 1 https://github.com/named-data/NFD")
     os.chdir("NFD")
     os.system("./waf distclean")
     os.system("git submodule init && git submodule update")
diff --git a/install_helpers/install_infoedit.py b/install_helpers/install_infoedit.py
index 737f923..ba8624b 100644
--- a/install_helpers/install_infoedit.py
+++ b/install_helpers/install_infoedit.py
@@ -4,13 +4,9 @@
 # Install infoedit
 def run():
     print "\nINSTALLING infoedit"
-    print "***********************"
-    helper_path = os.path.dirname(os.path.realpath(__file__))
-    cwd_path = os.getcwd()
-    #print helper_path
-    #print cwd_path
-    os.chdir(helper_path)
+    print "**************"
+    os.system("git clone --depth 1 https://github.com/NDN-Routing/infoedit.git")
     os.chdir("infoedit")
-    os.system("g++ -o infoedit -std=c++0x infoedit.cpp $(pkg-config --cflags --libs libndn-cxx)")
-    os.system("sudo mv infoedit /usr/local/bin/")
-    os.chdir(cwd_path)
+    os.system("make")
+    os.system("sudo make install")
+    os.chdir("..")
diff --git a/install_helpers/install_ndncxx.py b/install_helpers/install_ndncxx.py
index 94850be..54fac0d 100644
--- a/install_helpers/install_ndncxx.py
+++ b/install_helpers/install_ndncxx.py
@@ -5,7 +5,7 @@
 def run():
     print "\nINSTALLING ndn-cxx"
     print "**********************"
-    os.system("git clone https://github.com/named-data/ndn-cxx --depth 1")
+    os.system("git clone --depth 1 https://github.com/named-data/ndn-cxx")
     os.chdir("ndn-cxx")
     os.system("./waf distclean")
     os.system("./waf configure")
diff --git a/install_helpers/install_ndntools.py b/install_helpers/install_ndntools.py
index cf49556..9147a2b 100644
--- a/install_helpers/install_ndntools.py
+++ b/install_helpers/install_ndntools.py
@@ -5,7 +5,7 @@
 def run():
     print "\nINSTALLING ndn-tools"
     print "***********************"
-    os.system("git clone https://github.com/named-data/ndn-tools --depth 1")
+    os.system("git clone --depth 1 https://github.com/named-data/ndn-tools")
     os.chdir("ndn-tools")
     os.system("./waf distclean")
     os.system("./waf configure")
diff --git a/install_helpers/install_ndntraffic.py b/install_helpers/install_ndntraffic.py
index 3203dce..0969f15 100644
--- a/install_helpers/install_ndntraffic.py
+++ b/install_helpers/install_ndntraffic.py
@@ -5,7 +5,7 @@
 def run():
     print "\nINSTALLING ndn-traffic-generator"
     print "********************************"
-    os.system("git clone https://github.com/named-data/ndn-traffic-generator --depth 1")
+    os.system("git clone --depth 1 https://github.com/named-data/ndn-traffic-generator")
     os.chdir("ndn-traffic-generator")
     os.system("./waf distclean")
     os.system("./waf configure")
diff --git a/install_helpers/install_repo.py b/install_helpers/install_repo.py
index 10e2dff..1307724 100644
--- a/install_helpers/install_repo.py
+++ b/install_helpers/install_repo.py
@@ -5,7 +5,7 @@
 def run():
     print "\nINSTALLING repo-ng"
     print "***********************"
-    os.system("git clone https://github.com/named-data/repo-ng --depth 1")
+    os.system("git clone --depth 1 https://github.com/named-data/repo-ng")
     os.chdir("repo-ng")
     os.system("./waf distclean")
     os.system("./waf configure")