SMACC2
Functions | Variables
generate_debs Namespace Reference

Functions

def build_deb_package (workspace_source_folder, package_name, packagepath, ubuntu_version, ros_distro, already_visited)
 
def iterate_debian_generation (workspace_source_folder, package_names, identified_install_packages, osversion, rosversion)
 
def get_identified_packages (workspace_folder)
 
def push_debian_files (repo_owner, reponame, osname, osversion, debianfiles)
 
def remove_debian_files (repo_owner, reponame, osname, osversion, debianfiles)
 
def create_and_push_smacc_debians (osname, osversion, rosversion)
 

Variables

string repo_owner = "pibgeus"
 
 rospack = rospkg.RosPack()
 
 packages = rospack.list()
 
 packagesl = list(packages)
 
 parser = argparse.ArgumentParser()
 
 help
 
 default
 
 type
 
 args = parser.parse_args()
 
string osname = "ubuntu"
 
 osversion = args.ubuntu_version
 
 ros_version = args.ros_version
 
 relative_smacc_folder = args.smacc_src_folder
 
 workspace_folder = os.path.abspath(os.path.join(os.getcwd(), "."))
 
 homefolder = os.getenv("HOME")
 
 packagecloud_token_filepath = os.path.join(homefolder, ".packagecloud")
 
 outfile = open(packagecloud_token_filepath, "w")
 
def smacc_debians = create_and_push_smacc_debians(osname, osversion, ros_version)
 

Function Documentation

◆ build_deb_package()

def generate_debs.build_deb_package (   workspace_source_folder,
  package_name,
  packagepath,
  ubuntu_version,
  ros_distro,
  already_visited 
)

Definition at line 26 of file generate_debs.py.

28):
29 print("-----------------------")
30 print("Working folder: " + str(os.getcwd()))
31 print("Building debian package: " + str(package_name))
32 cmd = (
33 "bloom-generate rosdebian --os-name ubuntu --os-version "
34 + str(ubuntu_version)
35 + " --ros-distro "
36 + str(ros_distro)
37 + " "
38 + str(packagepath)
39 )
40 print(cmd)
41 bloomprocess = subprocess.Popen(cmd, shell=True)
42 bloomprocess.wait()
43
44 develpackagefolder = None
45 for root, dirs, files in os.walk(workspace_source_folder, topdown=False):
46 if "package.xml" in files and package_name == root.split("/")[-1]:
47 print(root)
48 develpackagefolder = root
49 break
50
51 localpackagepath = develpackagefolder
52
53 print("current directory:")
54 print(os.getcwd())
55 print("debian files:")
56 print(os.listdir(""))
57
58 # copy the debian folder generated by bloom inside the package
59 shutil.move("debian", os.path.join(localpackagepath, "debian"))
60
61 os.chdir(localpackagepath)
62 fakerootprocess = subprocess.Popen("fakeroot debian/rules binary", shell=True)
63 fakerootprocess.wait()
64
65 os.chdir(localpackagepath)
66 shutil.rmtree("debian")
67 shutil.rmtree("obj-x86_64-linux-gnu")
68
69 os.chdir(workspace_source_folder)
70
71 # improve this regex
72
73 firstregexstr = ".*ros-" + ros_distro + r"-.*\.deb"
74 regexstr = ".*ros-" + ros_distro + "-" + package_name.replace("_", "-") + r".*\.deb"
75 print("Finding deb package: " + str(regexstr))
76
77 thisfolderfiles = []
78 for root, dirs, files in os.walk(workspace_source_folder, topdown=False):
79 thisfolderfiles = thisfolderfiles + [os.path.join(root, f) for f in files]
80
81 debianfiles = [f for f in thisfolderfiles if re.search(firstregexstr, f)]
82 print("DETECTED DEBIAN FILES:")
83 print(debianfiles)
84 print("VISITED DEBIAN FILES:")
85 print(already_visited)
86
87 debianfilename = [
88 f for f in debianfiles if re.search(regexstr, f) and f not in already_visited
89 ][0]
90
91 print("Debian file found: ")
92 print(debianfilename)
93
94 installdebiantask = subprocess.Popen("sudo dpkg -i " + debianfilename, shell=True)
95 installdebiantask.wait()
96
97 return debianfilename
98
99

Referenced by iterate_debian_generation().

Here is the caller graph for this function:

◆ create_and_push_smacc_debians()

def generate_debs.create_and_push_smacc_debians (   osname,
  osversion,
  rosversion 
)

Definition at line 175 of file generate_debs.py.

175def create_and_push_smacc_debians(osname, osversion, rosversion):
176 workspace_source_folder = os.path.join(workspace_folder, relative_smacc_folder)
177 identified_install_packages = get_identified_packages(workspace_folder)
178
179 smacc_manual_order_packages = [ # 'forward_global_planner',
180 "smacc_msgs",
181 "smacc",
182 "sr_all_events_go",
183 "sr_conditional",
184 "sr_event_countdown",
185 "keyboard_client",
186 "multirole_sensor_client",
187 "ros_publisher_client",
188 "ros_timer_client",
189 "nav2z_client",
190 "forward_global_planner",
191 "forward_local_planner",
192 "backward_global_planner",
193 "undo_path_global_planner",
194 "backward_local_planner",
195 "move_group_interface_client",
196 "sm_atomic",
197 "sm_dance_bot",
198 "sm_dance_bot_strikes_back",
199 "sm_moveit",
200 ]
201
202 smacc_debian_files = iterate_debian_generation(
203 workspace_source_folder,
204 smacc_manual_order_packages,
205 identified_install_packages,
206 osversion,
207 rosversion,
208 )
209
210 create_repo_task = subprocess.Popen("package_cloud repository create smacc", shell=True)
211 create_repo_task.wait()
212
213 # ----- PUSHING TO SMACC --------------
214 remove_debian_files(repo_owner, "smacc", osname, osversion, smacc_debian_files)
215 push_debian_files(repo_owner, "smacc", osname, osversion, smacc_debian_files)
216
217 return smacc_debian_files
218
219
def remove_debian_files(repo_owner, reponame, osname, osversion, debianfiles)
def iterate_debian_generation(workspace_source_folder, package_names, identified_install_packages, osversion, rosversion)
def push_debian_files(repo_owner, reponame, osname, osversion, debianfiles)
def get_identified_packages(workspace_folder)
def create_and_push_smacc_debians(osname, osversion, rosversion)

References get_identified_packages(), iterate_debian_generation(), push_debian_files(), and remove_debian_files().

Here is the call graph for this function:

◆ get_identified_packages()

def generate_debs.get_identified_packages (   workspace_folder)

Definition at line 119 of file generate_debs.py.

119def get_identified_packages(workspace_folder):
120 identified_install_packages = {}
121 exclude_with_words = ["ridgeback", "mecanum", "catkin"]
122 for pname in packagesl:
123 packpath = rospack.get_path(pname)
124 print(pname)
125 if workspace_folder in packpath:
126 if any([True for excludedword in exclude_with_words if excludedword in pname]):
127 continue
128
129 identified_install_packages[pname] = packpath
130 return identified_install_packages
131
132

Referenced by create_and_push_smacc_debians().

Here is the caller graph for this function:

◆ iterate_debian_generation()

def generate_debs.iterate_debian_generation (   workspace_source_folder,
  package_names,
  identified_install_packages,
  osversion,
  rosversion 
)

Definition at line 100 of file generate_debs.py.

102):
103 os.chdir(workspace_source_folder)
104 debianfiles = []
105 for pname in package_names:
106 debianfiles.append(
108 workspace_source_folder,
109 pname,
110 identified_install_packages[pname],
111 osversion,
112 rosversion,
113 debianfiles,
114 )
115 )
116 return debianfiles
117
118
def build_deb_package(workspace_source_folder, package_name, packagepath, ubuntu_version, ros_distro, already_visited)

References build_deb_package().

Referenced by create_and_push_smacc_debians().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ push_debian_files()

def generate_debs.push_debian_files (   repo_owner,
  reponame,
  osname,
  osversion,
  debianfiles 
)

Definition at line 133 of file generate_debs.py.

133def push_debian_files(repo_owner, reponame, osname, osversion, debianfiles):
134 for debf in debianfiles:
135 print("pushing debfile")
136 push_debian_task = subprocess.Popen(
137 "package_cloud push "
138 + repo_owner
139 + "/"
140 + reponame
141 + "/"
142 + osname
143 + "/"
144 + osversion
145 + " "
146 + debf,
147 shell=True,
148 )
149 push_debian_task.wait()
150
151

Referenced by create_and_push_smacc_debians().

Here is the caller graph for this function:

◆ remove_debian_files()

def generate_debs.remove_debian_files (   repo_owner,
  reponame,
  osname,
  osversion,
  debianfiles 
)

Definition at line 152 of file generate_debs.py.

152def remove_debian_files(repo_owner, reponame, osname, osversion, debianfiles):
153 for debf in debianfiles:
154 shortdebfile = debf.split("/")[-1]
155 print("yanking debfile")
156 push_debian_task = subprocess.Popen(
157 "package_cloud yank "
158 + repo_owner
159 + "/"
160 + reponame
161 + "/"
162 + osname
163 + "/"
164 + osversion
165 + " "
166 + shortdebfile,
167 shell=True,
168 )
169 push_debian_task.wait()
170
171
172# ------------------------ SMACC PACKAGES -----------------------
173
174

Referenced by create_and_push_smacc_debians().

Here is the caller graph for this function:

Variable Documentation

◆ args

generate_debs.args = parser.parse_args()

◆ default

generate_debs.default

Definition at line 241 of file generate_debs.py.

◆ help

generate_debs.help

Definition at line 241 of file generate_debs.py.

◆ homefolder

generate_debs.homefolder = os.getenv("HOME")

Definition at line 275 of file generate_debs.py.

◆ osname

string generate_debs.osname = "ubuntu"

Definition at line 261 of file generate_debs.py.

◆ osversion

generate_debs.osversion = args.ubuntu_version

Definition at line 262 of file generate_debs.py.

◆ outfile

generate_debs.outfile = open(packagecloud_token_filepath, "w")

Definition at line 278 of file generate_debs.py.

◆ packagecloud_token_filepath

generate_debs.packagecloud_token_filepath = os.path.join(homefolder, ".packagecloud")

Definition at line 276 of file generate_debs.py.

◆ packages

generate_debs.packages = rospack.list()

Definition at line 237 of file generate_debs.py.

◆ packagesl

generate_debs.packagesl = list(packages)

Definition at line 238 of file generate_debs.py.

◆ parser

generate_debs.parser = argparse.ArgumentParser()

◆ relative_smacc_folder

generate_debs.relative_smacc_folder = args.smacc_src_folder

Definition at line 269 of file generate_debs.py.

◆ repo_owner

string generate_debs.repo_owner = "pibgeus"

Definition at line 232 of file generate_debs.py.

◆ ros_version

generate_debs.ros_version = args.ros_version

Definition at line 263 of file generate_debs.py.

◆ rospack

generate_debs.rospack = rospkg.RosPack()

Definition at line 236 of file generate_debs.py.

◆ smacc_debians

def generate_debs.smacc_debians = create_and_push_smacc_debians(osname, osversion, ros_version)

Definition at line 282 of file generate_debs.py.

◆ type

generate_debs.type

◆ workspace_folder

generate_debs.workspace_folder = os.path.abspath(os.path.join(os.getcwd(), "."))

Definition at line 270 of file generate_debs.py.