Last active
November 15, 2017 13:08
-
-
Save Zetten/fc670c07489d33f286bf7450af5eb325 to your computer and use it in GitHub Desktop.
Bazel RPM repository rule for EL6 Devtoolset2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package(default_visibility = ['//visibility:public']) | |
filegroup( | |
name = "all_files", | |
srcs = glob([ | |
"bin/*", | |
"lib64/*", | |
"opt/rh/devtoolset-2/root/usr/**", | |
"sbin/*", | |
"usr/bin/*", | |
"usr/include/**", | |
"usr/lib64/*", | |
"usr/sbin/*", | |
]), | |
) | |
filegroup( | |
name = "ar", | |
srcs = [ | |
"opt/rh/devtoolset-2/root/usr/bin/ar" | |
], | |
) | |
filegroup( | |
name = "as", | |
srcs = [ | |
"opt/rh/devtoolset-2/root/usr/bin/as" | |
], | |
) | |
filegroup( | |
name = "gcc", | |
srcs = [ | |
"opt/rh/devtoolset-2/root/usr/bin/gcc" | |
], | |
) | |
filegroup( | |
name = "ld", | |
srcs = [ | |
"opt/rh/devtoolset-2/root/usr/bin/ld" | |
], | |
) | |
filegroup( | |
name = "nm", | |
srcs = [ | |
"opt/rh/devtoolset-2/root/usr/bin/nm" | |
], | |
) | |
filegroup( | |
name = "objcopy", | |
srcs = [ | |
"opt/rh/devtoolset-2/root/usr/bin/objcopy" | |
], | |
) | |
filegroup( | |
name = "objdump", | |
srcs = [ | |
"opt/rh/devtoolset-2/root/usr/bin/objdump" | |
], | |
) | |
filegroup( | |
name = "strip", | |
srcs = [ | |
"opt/rh/devtoolset-2/root/usr/bin/strip" | |
], | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _new_rpm_bundle_archive_impl(rctx): | |
rpms = [] | |
# Download the RPMs | |
for url, sha256 in rctx.attr.urls.items(): | |
rpm_path = rctx.path(url[url.rfind("/")+1:]) | |
rctx.download( | |
url=url, | |
output=rpm_path, | |
sha256=sha256) | |
rpms += [rpm_path] | |
# Unpack the RPMs | |
for rpm in rpms: | |
result = rctx.execute(["bash", "-c", "rpm2cpio %s | cpio -idmv" % str(rpm.realpath)]) | |
if result.return_code != 0: | |
fail("Failed to unpack RPM (%s): %s" % (result.return_code, result.stderr)) | |
for f in rctx.attr.strip_files: | |
rctx.execute(["bash", "-c", "rm -f %s" % str(rctx.path(f).realpath)]) | |
# And finally add the build file | |
rctx.symlink(rctx.attr.build_file, "BUILD.bazel") | |
_new_rpm_bundle_archive = repository_rule( | |
implementation=_new_rpm_bundle_archive_impl, | |
attrs={ | |
"urls": attr.string_dict(mandatory=True, allow_empty=False), | |
"strip_files": attr.string_list(mandatory=True, allow_empty=True), | |
"build_file": attr.label(mandatory=True), | |
}) | |
def new_rpm_bundle_archive(name, urls, build_file, strip_files=[], **kwargs): | |
_new_rpm_bundle_archive( | |
name=name, | |
urls=urls, | |
strip_files=strip_files, | |
build_file=build_file, | |
**kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load("@com_cgi_idpf//tools/bzl:rpm_bundle_archive.bzl", "new_rpm_bundle_archive") | |
new_rpm_bundle_archive( | |
name = "el6_devtoolset2", | |
build_file = "//third-party/cxx/toolchain/devtoolset2_linux_gcc:el6_devtoolset2.BUILD", | |
urls = { | |
"http://mirror.centos.org/centos/6/os/x86_64/Packages/bash-4.1.2-48.el6.x86_64.rpm": "1c097552862774425f9f09daccff4a4980d9ffc83942d28b57b1151f790a9e4b", | |
"http://mirror.centos.org/centos/6/os/x86_64/Packages/coreutils-8.4-46.el6.x86_64.rpm": "6f978d78b2fee279f617bee86daa70c388cffdd914b19e2599799146a108bf84", | |
"http://mirror.centos.org/centos/6/os/x86_64/Packages/gmp-4.3.1-12.el6.x86_64.rpm": "df8aaeb80aadbfd03634c3091148aac5ab5079373f427fb42051089f3a95fc8d", | |
"http://mirror.centos.org/centos/6/os/x86_64/Packages/libgcc-4.4.7-18.el6.x86_64.rpm": "bb45e0b836c1fd8daee9beb96bd584d5550eff614c1b8f8c4b67a12da93db7af", | |
"http://mirror.centos.org/centos/6/os/x86_64/Packages/libgfortran-4.4.7-18.el6.x86_64.rpm": "e25e6058abbc4117235503e639f6bdb7824a367f13d58457644a8e37673a5120", | |
"http://mirror.centos.org/centos/6/os/x86_64/Packages/libselinux-2.0.94-7.el6.x86_64.rpm": "e7a34a5deb2a708631fec7b759f5a3c4a81046ac3a48f34080f01eee18e8b130", | |
"http://mirror.centos.org/centos/6/os/x86_64/Packages/libstdc++-4.4.7-18.el6.x86_64.rpm": "70d7e69e94cc126f8070209a348fc791393446ca17b2b93ba01a8f2c2e56bdeb", | |
"http://mirror.centos.org/centos/6/os/x86_64/Packages/mpfr-2.4.1-6.el6.x86_64.rpm": "20d2ce3bc1ea03844a0beb1726b01ef50d8555b3c9facb65264055a634709cf4", | |
"http://mirror.centos.org/centos/6/os/x86_64/Packages/sed-4.2.1-10.el6.x86_64.rpm": "4ef0cd3b93d6cef57037aaf858f61810da69cc2f905a4da1cadc5e641a5c4b7f", | |
"http://mirror.centos.org/centos/6/updates/x86_64/Packages/glibc-2.12-1.209.el6_9.2.x86_64.rpm": "0e0c823ee4eea6dd1093dadb523997fb82d1aa569240cf9656c8e7cbcb4570fc", | |
"http://mirror.centos.org/centos/6/updates/x86_64/Packages/glibc-devel-2.12-1.209.el6_9.2.x86_64.rpm": "4f0a6c0baa9cfb07da2399e130d8770d37c17a83bb3e9f1899be5f79be7c6e2b", | |
"http://mirror.centos.org/centos/6/updates/x86_64/Packages/glibc-headers-2.12-1.209.el6_9.2.x86_64.rpm": "021becbbd47a5ddcd82b59a697918f7af7193539cf574039593016e0b2e44cc0", | |
"http://mirror.centos.org/centos/6/updates/x86_64/Packages/kernel-headers-2.6.32-696.6.3.el6.x86_64.rpm": "6f30972fd2421b4c3daad28236677edc3fc168bcc20cd68914b8803866e5bb05", | |
"https://people.centos.org/tru/devtools-2/6/x86_64/RPMS/devtoolset-2-binutils-2.23.52.0.1-10.el6.x86_64.rpm": "ab01a6624a5ddf0586c345f2e2e896a2b2261206e6e78e92c95d3ca5bd4dfe74", | |
"https://people.centos.org/tru/devtools-2/6/x86_64/RPMS/devtoolset-2-gcc-4.8.2-15.el6.x86_64.rpm": "90ab19a2cd088bde9dd3fc251b9eab7f628dd5012e54a53fa9df980af97f87e0", | |
"https://people.centos.org/tru/devtools-2/6/x86_64/RPMS/devtoolset-2-gcc-c++-4.8.2-15.el6.x86_64.rpm": "30ae0e3a18706908551ca538b2f649418c3782d2dc40a2fd31df8677c4127f39", | |
"https://people.centos.org/tru/devtools-2/6/x86_64/RPMS/devtoolset-2-gcc-gfortran-4.8.2-15.el6.x86_64.rpm": "2689f08ac549f8713d6c908fdc8d83952fef703c6dd5c77bdbc091aff788e2f7", | |
"https://people.centos.org/tru/devtools-2/6/x86_64/RPMS/devtoolset-2-libstdc++-devel-4.8.2-15.el6.x86_64.rpm": "9ecdffd1a1bcd69c018f2f29fcee53ca19ad9911bace68d633487fca19c092d1", | |
}, | |
strip_files = [ | |
"usr/bin/[" | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment