+ # If the user defined local sources for ns-3, we uncompress the sources
+ # on the remote sources directory. Else we clone ns-3 from the official repo.
+ source = self.get("sources")
+ if not source:
+ clone_ns3_cmd = "hg clone %(ns3_repo)s/%(ns3_version)s ${SRC}/ns-3/%(ns3_version)s" \
+ % {
+ 'ns3_version': self.get("ns3Version"),
+ 'ns3_repo': self.ns3_repo,
+ }
+ else:
+ if source.find(".tar.gz") > -1:
+ clone_ns3_cmd = (
+ "tar xzf ${SRC}/ns-3/%(basename)s "
+ " --strip-components=1 -C ${SRC}/ns-3/%(ns3_version)s "
+ ) % {
+ 'basename': os.path.basename(source),
+ 'ns3_version': self.get("ns3Version"),
+ }
+ elif source.find(".tar") > -1:
+ clone_ns3_cmd = (
+ "tar xf ${SRC}/ns-3/%(basename)s "
+ " --strip-components=1 -C ${SRC}/ns-3/%(ns3_version)s "
+ ) % {
+ 'basename': os.path.basename(source),
+ 'ns3_version': self.get("ns3Version"),
+ }
+ elif source.find(".zip") > -1:
+ basename = os.path.basename(source)
+ bare_basename = basename.replace(".zip", "") \
+ .replace(".tar", "") \
+ .replace(".tar.gz", "")
+
+ clone_ns3_cmd = (
+ "unzip ${SRC}/ns-3/%(basename)s && "
+ "mv ${SRC}/ns-3/%(bare_basename)s ${SRC}/ns-3/%(ns3_version)s "
+ ) % {
+ 'bare_basename': basename_name,
+ 'basename': basename,
+ 'ns3_version': self.get("ns3Version"),
+ }
+
+ clone_dce_cmd = " echo 'DCE will not be built' "
+ if self.get("enableDCE"):
+ clone_dce_cmd = (
+ # DCE installation
+ # Test if dce is alredy installed
+ " ( "
+ " ( "
+ " ( test -d ${SRC}/dce/ns-3-dce ) "
+ " && echo 'dce binaries found, nothing to do'"
+ " ) "
+ " ) "
+ " || "
+ # Get dce source code
+ " ( "
+ " mkdir -p ${SRC}/dce && "
+ " hg clone %(dce_repo)s ${SRC}/dce/ns-3-dce"
+ " ) "
+ ) % {
+ 'dce_repo': self.dce_repo
+ }
+
+