Best Python code snippet using lisa_python
build.py
Source:build.py
...117 vsh(118"""119./configure --prefix={prefix} --build={triple} {args}120""".format(**kwargs))121 def make_install(self, **kwargs):122 kwargs.setdefault('archive', False)123 kwargs.setdefault('check', False)124 kwargs.setdefault('parallel', True)125 kwargs.setdefault('make', 'make -j {0}'.format(ncpu))126 kwargs.setdefault('make_check', 'make check')127 kwargs.setdefault('make_args', '')128 kwargs['parallel'] or kwargs.update(make = 'make')129 kwargs['check'] or kwargs.update(make_check = ':')130 vsh('{make} {make_args} && {make_check} && make install'.format(**kwargs))131 if kwargs['archive'] is not False:132 binMake(kwargs['archive'])133 def patch(self, *args):134 for f in args:135 vsh('patch -Np1 < {0}'.format(f))136buildCommands = BuildCommands()137reposcopy = buildCommands.reposcopy138configure = buildCommands.configure139make_install = buildCommands.make_install140patch = buildCommands.patch141def extract(name, ext, dirname = ''):142 d = dict(143 dstroot = BUILDROOT,144 srcroot = SRCROOT,145 f = name + ext,146 p7zip = P7ZIP,147 )148 if ext.endswith('.xz'):149 cmd = """{p7zip} x -so {srcroot}/{f} | tar xf - -C {dstroot}""".format(**d)150 else:151 cmd = """tar xf {srcroot}/{f} -C {dstroot}""".format(**d)152 vsh(cmd)153 if dirname:154 os.chdir(os.path.join(BUILDROOT, dirname))155 else:156 os.chdir(os.path.join(BUILDROOT, name))157 print >> sys.stderr, os.getcwd()158def binMake(name):159 srcroot = BUILDROOT160 dstroot = DEPOSROOT161 vsh(162"""163tar czf {dstroot}/{name}.tar.gz \164--exclude=".git*" \165--exclude=".svn*" \166--exclude=".hg*" \167-C {srcroot} {name}168""".format(**locals().copy()))169def binCheck(name):170 srcroot = DEPOSROOT171 dstroot = BUILDROOT172 if not os.path.exists(os.path.join(srcroot, name + '.tar.gz')): return False173 vsh(174"""175tar xf {srcroot}/{name}.tar.gz -C {dstroot}176cd {dstroot}/{name}177make install178""".format(**locals().copy()))179 return True180#-------------------------------------------------------------------------------181def install_core_resources():182 # note install project license183 f = 'LICENSE'184 installFile(os.path.join(PROJECT_ROOT, f),185 os.path.join(W_DOCDIR, 'nihonshu', f))186 # note: install python module187 f = 'createwineprefix.py'188 os.link(os.path.join(PROJECT_ROOT, f),189 os.path.join(W_BINDIR, f))190 # note: install inf191 f = 'osx-wine.inf'192 os.link(os.path.join(PROJECT_ROOT, 'osx-wine-inf', f),193 os.path.join(W_DATADIR, 'wine/plugin/inf', f))194def install_plugin():195 def install_plugin_7z():196 src = os.path.join(PROJECT_ROOT, 'rsrc/7z922.exe')197 dst = os.path.join(destroot, '7-Zip')198 p7zip('x', '-o' + dst, src, '-x!$*')199 src = os.path.join(PROJECT_ROOT, 'inf/7z.inf')200 dst = os.path.join(destroot, 'inf/7z.inf')201 installFile(src, dst)202 def install_plugin_vsrun6():203 src = os.path.join(PROJECT_ROOT, 'rsrc/vsrun6sp6/Vs6sp6.exe')204 # Visual Basic 6.0 SP 6 ------------------------------------------------205 dst = os.path.join(destroot, 'vbrun6sp6')206 sub_src = 'vbrun60.cab'207 cabextract('-L', '-d', dst, '-F', sub_src, src)208 sub_src = os.path.join(dst, sub_src)209 cabextract('-L', '-d', dst, sub_src)210 os.remove(sub_src)211 # Visual C++ 6.0 SP 6 --------------------------------------------------212 dst = os.path.join(destroot, 'vcrun6sp6')213 sub_src = 'vcredist.exe'214 cabextract('-L', '-d', dst, '-F', sub_src, src)215 destroot = os.path.join(W_DATADIR, 'wine/plugin')216 dx9_feb2010 = os.path.join(PROJECT_ROOT, 'rsrc/directx9/directx_feb2010_redist.exe')217 dx9_jun2010 = os.path.join(PROJECT_ROOT, 'rsrc/directx9/directx_Jun2010_redist.exe')218 vcrun2005 = os.path.join(PROJECT_ROOT, 'rsrc/vcrun2005sp1_jun2011')219 vcrun2008 = os.path.join(PROJECT_ROOT, 'rsrc/vcrun2008sp1_jun2011')220 vcrun2010 = os.path.join(PROJECT_ROOT, 'rsrc/vcrun2010sp1_aug2011')221 makedirs(destroot)222 # INSTALL RUNTIME ----------------------------------------------------------223 p7zip('x', '-o' + os.path.join(destroot, 'directx9/feb2010'), dx9_feb2010, '-x!*_x64.cab')224 p7zip('x', '-o' + os.path.join(destroot, 'directx9/jun2010'), dx9_jun2010, '-x!*_x64.cab', '-x!*200?*', '-x!Feb2010*')225 shutil.copytree(vcrun2005, os.path.join(destroot, 'vcrun2005sp1_jun2011'))226 shutil.copytree(vcrun2008, os.path.join(destroot, 'vcrun2008sp1_jun2011'))227 shutil.copytree(vcrun2010, os.path.join(destroot, 'vcrun2010sp1_aug2011'))228 install_plugin_vsrun6()229 install_plugin_7z()230 # INSTALL INF --------------------------------------------------------------231 for f in [232 'inf/dxredist.inf',233 'inf/vsredist.inf',234 'inf/win2k.reg',235 'inf/winxp.reg',236 ]:237 src = os.path.join(PROJECT_ROOT, f)238 dst = os.path.join(destroot, 'inf')239 dst = os.path.join(dst, os.path.basename(f))240 installFile(src, dst)241#-------------------------------------------------------------------------------242# FREETYPE ---------------------------------------------------------------------243def build_freetype(name = 'freetype'):244 message(name)245 if binCheck(name): return246 reposcopy(name)247 git_checkout()248 autogen()249 configure(250 '--with-old-mac-fonts',251 )252 make_install(archive = name)253# GETTEXT ----------------------------------------------------------------------254def build_gettext(name = 'gettext-0.18.3.1'):255 message(name)256 if binCheck(name): return257 extract(name, '.tar.gz')258 configure(259 '--disable-csharp',260 '--disable-java',261 '--disable-native-java',262 '--disable-openmp',263 '--enable-threads=posix',264 '--with-included-gettext',265 '--with-included-glib',266 '--with-included-libcroro',267 '--with-included-libunistring',268 '--without-cvs',269 '--without-emacs',270 '--without-git',271 )272 make_install(archive = name)273# GLIB -------------------------------------------------------------------------274def build_glib(name = 'glib'):275 message(name)276 if binCheck(name): return277 reposcopy(name)278 git_checkout('glib-2-38')279 autogen()280 configure(281 '--disable-fam',282 '--disable-selinux',283 '--disable-silent-rules',284 '--disable-xattr',285 '--with-threads=posix',286 )287 make_install(archive = name)288# GMP --------------------------------------------------------------------------289def build_gmp(name = 'gmp-5.1'):290 message(name)291 if binCheck(name): return292 reposcopy(name)293 hg_update()294 autoreconf()295 vsh(296"""297grep '^@set' .bootstrap > doc/version.texi298unset CFLAGS CXXFLAGS299./configure --prefix={prefix} ABI=32300""".format(301 prefix = PREFIX,302 ))303 make_install(check = True, archive = name)304# GNUTLS -----------------------------------------------------------------------305def build_libtasn1(name = 'libtasn1-3.3'):306 message(name)307 if binCheck(name): return308 extract(name, '.tar.gz')309 configure(310 '--disable-gtk-doc',311 '--disable-gtk-doc-html',312 '--disable-gtk-doc-pdf',313 '--disable-silent-rules',314 '--disable-static',315 )316 make_install(archive = name)317def build_nettle(name = 'nettle-2.7.1'):318 message(name)319 if binCheck(name): return320 extract(name, '.tar.gz')321 configure(322 '--disable-documentation',323 )324 make_install(archive = name)325# note: gnutls will fail depending on nettle version.326def build_gnutls(name = 'gnutls'):327 build_libtasn1()328 build_nettle()329 message(name)330 if binCheck(name): return331 reposcopy(name)332 git_checkout(branch = 'gnutls_3_1_x')333 autotools.make(334 'autoreconf',335 )336 configure(337 '--disable-doc',338 '--disable-gtk-doc',339 '--disable-gtk-doc-html',340 '--disable-gtk-doc-pdf',341 '--disable-nls',342 '--disable-silent-rules',343 '--disable-static',344 '--enable-threads=posix',345 )346 make_install(archive = name)347# GSM --------------------------------------------------------------------------348def build_gsm(name = 'gsm-1.0.13'):349 message(name)350 extract(name, '.tar.gz', 'gsm-1.0-pl13')351 vsh(352"""353make {install_name} \354CC='{cc} -ansi -pedantic' \355CCFLAGS='-c {cflags} -DNeedFunctionPrototypes=1' \356LDFLAGS='{ldflags}' \357LIBGSM='{install_name}' \358AR='{cc}' \359ARFLAGS='-dynamiclib -fPIC -v -arch i386 -install_name $(LIBGSM) -compatibility_version 1 -current_version 1.0.3 -o' \360RANLIB=':' \361RMFLAGS='-f'362install -m 0644 inc/gsm.h {prefix}/include363""".format(364 prefix = PREFIX,365 cc = os.getenv('CC'),366 cflags = os.getenv('CFLAGS'),367 ldflags = os.getenv('LDFLAGS'),368 install_name = os.path.join(LIBDIR, 'libgsm.dylib'),369 ))370# LIBFFI -----------------------------------------------------------------------371def build_libffi(name = 'libffi'):372 message(name)373 if binCheck(name): return374 reposcopy(name)375 git_checkout()376 configure()377 make_install(archive = name)378# LIBGPHOTO2 -------------------------------------------------------------------379def build_libexif(name = 'libexif-0.6.21'):380 message(name)381 if binCheck(name): return382 extract(name, '.tar.bz2')383 configure(384 '--disable-docs',385 '--disable-nls',386 '--with-doc-dir=' + os.path.join(DOCDIR, name),387 )388 make_install(archive = name)389def build_popt(name = 'popt-1.14'):390 message(name)391 if binCheck(name): return392 extract(name, '.tar.gz')393 configure(394 '--disable-nls',395 )396 make_install(archive = name)397def build_gd(name = 'libgd-2.1.0'):398 message(name)399 if binCheck(name): return400 extract(name, '.tar.xz')401 configure(402 '--without-fontconfig',403 '--without-x',404 '--with-freetype=' + PREFIX,405 '--with-jpeg=' + PREFIX,406 '--with-png=' + PREFIX,407 '--with-tiff=' + PREFIX,408 '--with-zlib=' + PREFIX,409 )410 make_install(archive = name)411def build_libgphoto2(name = 'libgphoto2'):412 build_libexif()413 build_popt()414 build_gd()415 message(name)416 if binCheck(name): return417 reposcopy(name)418 autoreconf(419 '-s',420 )421 configure(422 '--disable-nls',423 '--with-drivers=all',424 'CFLAGS="{cflags} -D_DARWIN_C_SOURCE"'.format(cflags = os.getenv('CFLAGS')),425 )426 make_install(archive = name)427# LIBJPEG-TURBO ----------------------------------------------------------------428def build_libjpeg_turbo(name = 'libjpeg-turbo'):429 message(name)430 if binCheck(name): return431 reposcopy(name)432 git_checkout('1.3.x')433 vsh(434"""435sed -i '' 's|$(datadir)/doc|&/libjpeg-turbo|' Makefile.am436""")437 autoreconf()438 configure(439 '--with-jpeg8',440 )441 make_install(archive = name)442# LIBPNG -----------------------------------------------------------------------443def build_libpng(name = 'libpng'):444 message(name)445 if binCheck(name): return446 reposcopy(name)447 git_checkout('libpng16')448 autogen()449 configure()450 make_install(archive = name)451# LIBUSB -----------------------------------------------------------------------452def build_libusb(name = 'libusb'):453 message(name)454 if binCheck(name): return455 reposcopy(name)456 vsh(457"""458sed -i '' '/^.\\/configure/,$d' autogen.sh459""")460 autogen()461 configure()462 make_install(archive = name)463 build_libusb_compat()464 465def build_libusb_compat(name = 'libusb-compat-0.1'):466 message(name)467 if binCheck(name): return468 reposcopy(name)469 vsh(470"""471sed -i '' '/^.\\/configure/,$d' autogen.sh472""")473 autogen()474 configure()475 make_install(archive = name)476# LIBTIFF ----------------------------------------------------------------------477def build_libtiff(name = 'libtiff'):478 message(name)479 if binCheck(name): return480 reposcopy(name)481 git_checkout('branch-3-9')482 configure(483 '--disable-jbig',484 '--disable-silent-rules',485 '--without-x',486 )487 make_install(archive = name)488# LITTLE-CMS -------------------------------------------------------------------489def build_lcms(name = 'Little-CMS'):490 message(name)491 if binCheck(name): return492 reposcopy(name)493 configure()494 make_install(archive = name)495# MPG123 -----------------------------------------------------------------------496# dependencies: SDL497#498def build_mpg123(name = 'mpg123'):499 message(name)500 if binCheck(name): return501 reposcopy(name)502 autoreconf()503 configure(504 '--with-default-audio=coreaudio',505 '--with-optimization=0',506 )507 make_install(archive = name)508# READLINE ---------------------------------------------------------------------509def build_readline(name = 'readline'):510 message(name)511 if binCheck(name): return512 reposcopy(name)513 git_checkout()514 patch(os.path.join(PROJECT_ROOT, 'osx-wine-patch/readline.patch'))515 configure(516 '--enable-multibyte',517 '--with-curses',518 )519 make_install(archive = name)520# SANE-BACKENDS ----------------------------------------------------------------521# dependencies: jpeg, libusb-compat, net-snmp, tiff, zlib522#523def build_net_snmp(name = 'net-snmp'):524 message(name)525 if binCheck(name): return526 reposcopy(name)527 git_checkout()528 configure(529 '--with-defaults',530 )531 make_install(archive=name)532def build_sane(name = 'sane-backends'):533 build_net_snmp()534 message(name)535 if binCheck(name): return536 reposcopy(name)537 git_checkout()538 configure(539 '--disable-latex',540 '--disable-maintainer-mode',541 '--disable-silent-rules',542 '--disable-translations',543 '--enable-libusb_1_0',544 '--enable-local-backends',545 '--with-docdir=' + os.path.join(DOCDIR, name),546 '--without-v4l',547 )548 make_install(archive = name)549# SDL --------------------------------------------------------------------------550def build_SDL(name = 'SDL'):551 message(name)552 if binCheck(name): return553 reposcopy(name)554 hg_update('SDL-1.2')555 autogen()556 configure()557 make_install(archive = name)558# WINE -------------------------------------------------------------------------559def build_wine(name = 'wine'):560 message(name)561 if not binCheck(name):562 reposcopy(name)563# git_checkout('wine-1.7.4')564 git_checkout()565 for f in os.listdir(PATCHROOT):566 if f.startswith('wine_'):567 patch(os.path.join(PATCHROOT, f))568 configure(569 '--without-capi',570 '--without-oss',571 '--without-v4l',572 '--with-x',573 '--x-inc=/opt/X11/include',574 '--x-lib=/opt/X11/lib',575 'CC=' + CLANG,576 'CXX=' + CLANGXX,577 'CFLAGS="-arch i386 %s"' % os.getenv('CFLAGS'),578 'CXXFLAGS="-arch i386 %s"' % os.getenv('CXXFLAGS'),579 prefix = W_PREFIX,580 )581 make_install(archive = name)582 # note: add rpath583 vsh("""install_name_tool -add_rpath /opt/X11/lib {W_BINDIR}/wine""".format(**globals()))584 # note: rename executable585 src = os.path.join(W_BINDIR, 'wine')586 dst = os.path.join(W_LIBEXECDIR, 'wine')587 os.rename(src, dst)588 # note: install wine loader589 src = os.path.join(PROJECT_ROOT, 'wineloader.py.in')590 dst = os.path.join(W_BINDIR, 'wine')591 with open(src, 'r') as i:592 str = i.read()593 str = str.replace('___CAPTION___', 'Nihonshu - Customized Wine binary for OS X (Ja)')594 with open(dst, 'w') as o:595 o.write(str)596 os.chmod(dst, 0755)597 installDoc(598 name,599 'ANNOUNCE',600 'AUTHORS',601 'COPYING.LIB',602 'LICENSE',603 'README',604 )605# WINETRICKS / CABEXTRACT ------------------------------------------------------606def build_cabextract(name = 'cabextract-1.4'):607 message(name)608 extract(name, '.tar.gz')609 configure(prefix = W_PREFIX)610 make_install()611 installDoc(612 name,613 'AUTHORS',614 'COPYING',615 'README',616 )617def build_winetricks(name = 'winetricks'):618 build_cabextract()619 message(name)620 reposcopy(name)621 git_checkout("edit")622 vsh("""make install PREFIX={W_PREFIX}""".format(**globals()))623 ### RENAME EXECUTABLE ###624 os.rename(os.path.join(W_BINDIR, 'winetricks'),625 os.path.join(W_LIBEXECDIR, 'winetricks'))626 ### INSTALL WINETRICKS LOADER ###627 installFile(os.path.join(PROJECT_ROOT, 'winetricksloader.py'),628 os.path.join(W_BINDIR, 'winetricks'),629 0755)630 installDoc(631 name,632 'src/COPYING',633 )634# XZ ---------------------------------------------------------------------------635def build_xz(name = 'xz'):636 message(name)637 if binCheck(name): return638 reposcopy(name)639 git_checkout()640 autogen()641 configure(642 '--disable-nls',643 '--disable-silent-rules',644 )645 make_install(archive = name)646# ZLIB -------------------------------------------------------------------------647def build_zlib(name = 'zlib'):648 message(name)649 if binCheck(name): return650 reposcopy(name)651 git_checkout()652 vsh("""./configure --prefix={PREFIX}""".format(**globals()))653 make_install(archive = name)654#-------------------------------------------------------------------------------655def create_distfile():656 def create_distfile_clean():657 rm(os.path.join(W_DATADIR, 'applications'))658 for root, dirs, files in os.walk(W_LIBDIR):659 if root == os.path.join(W_LIBDIR, 'wine'): continue660 if root == W_LIBDIR:661 for d in dirs:662 d = os.path.join(root, d)663 if d.endswith((664 'gettext',665 'gio',666 'glib-2.0',667 'libffi-3.0.13',...
BUILD
Source:BUILD
1if [ $SUIDINSTALL == "y" ]; then2 MAKE_INSTALL="make suidinstall"3else4 MAKE_INSTALL="make install"5fi &&6OPTS+=" --datadir=/usr/share \7 --localstatedir=/var \8 --sysconfdir=/etc/kismet"9default_config &&10make all plugins &&11make &&12prepare_install &&...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!