How to use grubby_install_patch_makefile method in autotest

Best Python code snippet using autotest_python

boottool.py

Source:boottool.py Github

copy

Full Screen

...1138 groups = match.groups()1139 return (int(groups[2]), int(groups[3]))1140 else:1141 return None1142 def grubby_install_patch_makefile(self):1143 '''1144 Patch makefile, making CFLAGS more forgivable to older toolchains1145 '''1146 cflags_line = 'CFLAGS += $(RPM_OPT_FLAGS) -std=gnu99 -ggdb\n'1147 libs_line = 'grubby_LIBS = -lblkid -lpopt -luuid\n'1148 shutil.move('Makefile', 'Makefile.boottool.bak')1149 o = open('Makefile', 'w')1150 for l in open('Makefile.boottool.bak').readlines():1151 if l.startswith('CFLAGS += '):1152 o.write(cflags_line)1153 elif l.startswith('grubby_LIBS = -lblkid -lpopt'):1154 o.write(libs_line)1155 else:1156 o.write(l)1157 o.close()1158 def grubby_install_backup(self, path):1159 '''1160 Backs up the current grubby binary to make room the one we'll build1161 :type path: string1162 :param path: path to the binary that should be backed up1163 '''1164 backup_path = '%s.boottool.bkp' % path1165 if (os.path.exists(path) and not os.path.exists(backup_path)):1166 try:1167 shutil.move(path, backup_path)1168 except Exception:1169 self.log.warn('Failed to backup the current grubby binary')1170 def grubby_install_fetch_tarball(self, topdir):1171 '''1172 Fetches and verifies the grubby source tarball1173 '''1174 tarball_name = os.path.basename(GRUBBY_TARBALL_URI)1175 # first look in the current directory1176 try:1177 tarball = tarball_name1178 f = open(tarball)1179 except Exception:1180 try:1181 # then the autotest source directory1182 # pylint: disable=E06111183 from autotest.client.shared.settings import settings1184 top_path = settings.get_value('COMMON', 'autotest_top_path')1185 tarball = os.path.join(top_path, tarball_name)1186 f = open(tarball)1187 except Exception:1188 # then try to grab it from github1189 try:1190 tarball = os.path.join(topdir, tarball_name)1191 urllib.urlretrieve(GRUBBY_TARBALL_URI, tarball)1192 f = open(tarball)1193 except Exception:1194 return None1195 tarball_md5 = md5.md5(f.read()).hexdigest()1196 if tarball_md5 != GRUBBY_TARBALL_MD5:1197 return None1198 return tarball1199 def grubby_build(self, topdir, tarball):1200 '''1201 Attempts to build grubby from the source tarball1202 '''1203 def log_lines(lines):1204 for line in lines:1205 self.log.debug(line.strip())1206 try:1207 find_header('popt.h')1208 except ValueError:1209 self.log.debug('No popt.h header present, skipping build')1210 return False1211 tarball_name = os.path.basename(tarball)1212 srcdir = os.path.join(topdir, 'src')1213 srcdir = self._extract_tarball(tarball, srcdir)1214 os.chdir(srcdir)1215 self.grubby_install_patch_makefile()1216 result = subprocess.Popen(['make'],1217 stdout=subprocess.PIPE,1218 stderr=subprocess.PIPE)1219 if result.wait() != 0:1220 self.log.debug('Failed to build grubby during "make" step')1221 log_lines(result.stderr.read().splitlines())1222 return False1223 install_root = os.path.join(topdir, 'install_root')1224 os.environ['DESTDIR'] = install_root1225 result = subprocess.Popen(['make', 'install'],1226 stdout=subprocess.PIPE,1227 stderr=subprocess.PIPE)1228 if result.wait() != 0:1229 self.log.debug('Failed to build grubby during "make install" step')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful