rkt-1.24.0.ebuild 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. inherit bash-completion-r1 autotools flag-o-matic systemd toolchain-funcs user
  5. KEYWORDS="~amd64"
  6. PXE_VERSION="1235.0.0"
  7. PXE_SYSTEMD_VERSION="v231"
  8. KVM_LINUX_VERSION="4.9.2"
  9. KVMTOOL_VERSION="cfae4d64482ed745214e3c62dd84b79c2ae0f325"
  10. QEMU_VERSION="v2.8.0"
  11. PXE_URI="http://alpha.release.core-os.net/amd64-usr/${PXE_VERSION}/coreos_production_pxe_image.cpio.gz"
  12. PXE_FILE="${PN}-pxe-${PXE_VERSION}.img"
  13. SRC_URI_KVM="mirror://kernel/linux/kernel/v4.x/linux-${KVM_LINUX_VERSION}.tar.xz
  14. ${PXE_URI} -> ${PXE_FILE}
  15. "
  16. SRC_URI="https://github.com/coreos/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
  17. rkt_stage1_coreos? ( $PXE_URI -> $PXE_FILE )
  18. rkt_stage1_kvm_lkvm? (
  19. https://kernel.googlesource.com/pub/scm/linux/kernel/git/will/kvmtool/+archive/${KVMTOOL_VERSION}.tar.gz -> kvmtool-${KVMTOOL_VERSION}.tar.gz
  20. ${SRC_URI_KVM}
  21. )
  22. rkt_stage1_kvm_qemu? (
  23. http://wiki.qemu-project.org/download/qemu-${QEMU_VERSION#v}.tar.bz2
  24. ${SRC_URI_KVM}
  25. )
  26. rkt_stage1_src? ( https://github.com/systemd/systemd/archive/${PXE_SYSTEMD_VERSION}.tar.gz -> systemd-${PXE_SYSTEMD_VERSION#v}.tar.gz )"
  27. DESCRIPTION="rkt is an App Container runtime for Linux"
  28. HOMEPAGE="https://github.com/coreos/rkt"
  29. LICENSE="Apache-2.0"
  30. SLOT="0"
  31. # The rkt_stage1_kvm flag has been replaced by the rkt_stage1_kvm_lkvm and rkt_stage1_kvm_qemu flags
  32. IUSE="doc examples +rkt_stage1_coreos +rkt_stage1_fly rkt_stage1_host rkt_stage1_kvm rkt_stage1_kvm_lkvm rkt_stage1_kvm_qemu rkt_stage1_src +actool systemd"
  33. REQUIRED_USE="|| ( rkt_stage1_coreos rkt_stage1_fly rkt_stage1_host rkt_stage1_kvm_lkvm rkt_stage1_kvm_qemu rkt_stage1_src ) rkt_stage1_host? ( systemd ) !rkt_stage1_kvm"
  34. # Some tests fail.
  35. # rkt_stage1_src needs to copy /bin/mount, which requires root privileges during src_compile
  36. RESTRICT="test rkt_stage1_src? ( userpriv )"
  37. DEPEND=">=dev-lang/go-1.5
  38. app-arch/cpio
  39. app-crypt/trousers
  40. sys-fs/squashfs-tools
  41. dev-perl/Capture-Tiny
  42. rkt_stage1_src? ( >=sys-apps/util-linux-2.27 )
  43. rkt_stage1_kvm_qemu? (
  44. sys-apps/attr[static-libs(+)]
  45. sys-libs/libcap[static-libs(+)]
  46. sys-libs/zlib[static-libs(+)]
  47. >=x11-libs/pixman-0.28.0[static-libs(+)]
  48. )"
  49. RDEPEND="!app-emulation/rocket
  50. rkt_stage1_host? ( systemd? (
  51. >=sys-apps/systemd-222
  52. app-shells/bash:0
  53. ) )"
  54. BUILDDIR="build-${P}"
  55. STAGE1_DEFAULT_LOCATION="/usr/share/rkt/stage1.aci"
  56. pkg_setup() {
  57. enewgroup rkt-admin
  58. enewgroup rkt
  59. }
  60. src_unpack() {
  61. local x
  62. for x in ${A}; do
  63. case ${x} in
  64. *.img|linux-*) continue ;;
  65. kvmtool-*)
  66. mkdir kvmtool || die
  67. pushd kvmtool >/dev/null || die
  68. unpack ${x}
  69. popd >/dev/null || die
  70. ;;
  71. *)
  72. unpack ${x}
  73. esac
  74. done
  75. }
  76. src_prepare() {
  77. eapply_user
  78. # This patch breaks linux kernel cc-option checks when the
  79. # compiler doesn't recognize the -no-pie option.
  80. rm stage1/usr_from_kvm/kernel/patches/0002-for-debian-gcc.patch || die
  81. # avoid sdjournal include for bug 595874
  82. if ! use systemd; then
  83. sed -e "s/^\\(LOCAL_DIST_SRC_FILTER := .*\\)'$/\\1|api_service'/" \
  84. -i rkt/rkt.mk || die
  85. fi
  86. sed -e 's|^RKT_REQ_PROG(\[GIT\],.*|#\0|' -i configure.ac || die
  87. # disable git fetch of systemd
  88. sed -e 's~^include makelib/git.mk$~'\
  89. 'ifneq ($(wildcard $(RKT_STAGE1_SYSTEMD_SRC)),)\n\n'\
  90. 'get_systemd_sources: | $(UFS_SYSTEMDDIR)\n'\
  91. '\tmv "$(RKT_STAGE1_SYSTEMD_SRC)" "$(UFS_SYSTEMD_SRCDIR)"\n\n'\
  92. '$(UFS_SYSTEMD_CONFIGURE): get_systemd_sources\n\n'\
  93. 'else ifneq ($(wildcard $(UFS_SYSTEMD_SRCDIR)),)\n\n'\
  94. 'else\n'\
  95. '\t\0\n'\
  96. 'endif~' -i stage1/usr_from_src/usr_from_src.mk || die
  97. # disable git fetch of kvmtool
  98. sed -e 's~^include makelib/git.mk$~'\
  99. 'ifneq ($(wildcard $(shell echo "$${WORKDIR}/kvmtool")),)\n\n'\
  100. '$(call forward-vars, get_lkvm_sources, LKVM_SRCDIR)\n'\
  101. 'get_lkvm_sources: | $(LKVM_TMPDIR)\n'\
  102. '\tmv "$${WORKDIR}/kvmtool" "$(LKVM_SRCDIR)"\n\n'\
  103. '$(LKVM_PATCH_STAMP): get_lkvm_sources\n\n'\
  104. 'else ifneq ($(wildcard $(LKVM_SRCDIR)),)\n\n'\
  105. 'else\n'\
  106. '\t\0\n'\
  107. 'endif~' -i stage1/usr_from_kvm/lkvm.mk || die
  108. # disable git fetch of qemu
  109. sed -e 's~^include makelib/git.mk$~'\
  110. 'ifneq ($(wildcard $(shell echo "$${WORKDIR}/qemu-'${QEMU_VERSION#v}'")),)\n\n'\
  111. '$(call forward-vars, get_qemu_sources, QEMU_SRCDIR)\n'\
  112. 'get_qemu_sources: | $(QEMU_TMPDIR)\n'\
  113. '\tmv "$${WORKDIR}/qemu-'${QEMU_VERSION#v}'" "$(QEMU_SRCDIR)"\n\n'\
  114. '$(QEMU_CONF_STAMP): get_qemu_sources\n\n'\
  115. 'else ifneq ($(wildcard $(QEMU_SRCDIR)),)\n\n'\
  116. 'else\n'\
  117. '\t\0\n'\
  118. 'endif~' \
  119. -e 's|QEMU_CONFIGURATION_OPTS :=|\0 --disable-bzip2 --disable-libssh2 --disable-opengl|' \
  120. -i stage1/usr_from_kvm/qemu.mk || die
  121. # disable fetch of kernel sources
  122. sed -e 's|wget .*|ln -s "$${DISTDIR}/linux-'${KVM_LINUX_VERSION}'.tar.xz" "$@"|' \
  123. -i stage1/usr_from_kvm/kernel.mk || die
  124. if use rkt_stage1_host; then
  125. # Make systemdUnitsPath consistent with host
  126. sed -e 's|\(systemdUnitsPath := \).*|\1"'$(systemd_get_systemunitdir)'"|' \
  127. -i stage1/init/init.go || die
  128. fi
  129. eautoreconf
  130. }
  131. src_configure() {
  132. local flavors hypervisors myeconfargs=(
  133. --with-stage1-default-images-directory="/usr/share/rkt"
  134. --with-stage1-default-location="${STAGE1_DEFAULT_LOCATION}"
  135. )
  136. use systemd || myeconfargs+=( --enable-sdjournal=no )
  137. # enable flavors (first is default)
  138. use rkt_stage1_host && flavors+=",host"
  139. use rkt_stage1_src && flavors+=",src"
  140. use rkt_stage1_coreos && flavors+=",coreos"
  141. use rkt_stage1_fly && flavors+=",fly"
  142. { use rkt_stage1_kvm_lkvm || use rkt_stage1_kvm_qemu; } && flavors+=",kvm"
  143. myeconfargs+=( --with-stage1-flavors="${flavors#,}" )
  144. if use rkt_stage1_src; then
  145. myeconfargs+=(
  146. --with-stage1-systemd-version=${PXE_SYSTEMD_VERSION}
  147. --with-stage1-systemd-src="${WORKDIR}/systemd-${PXE_SYSTEMD_VERSION#v}"
  148. )
  149. fi
  150. if use rkt_stage1_coreos || use rkt_stage1_kvm_lkvm || use rkt_stage1_kvm_qemu; then
  151. myeconfargs+=(
  152. --with-coreos-local-pxe-image-path="${DISTDIR}/${PXE_FILE}"
  153. --with-coreos-local-pxe-image-systemd-version="${PXE_SYSTEMD_VERSION}"
  154. )
  155. fi
  156. if use rkt_stage1_kvm_lkvm || use rkt_stage1_kvm_qemu; then
  157. use rkt_stage1_kvm_lkvm && hypervisors+=",lkvm"
  158. use rkt_stage1_kvm_qemu && hypervisors+=",qemu"
  159. myeconfargs+=( --with-stage1-kvm-hypervisors="${hypervisors#,}" )
  160. fi
  161. # Go's 6l linker does not support PIE, disable so cgo binaries
  162. # which use 6l+gcc for linking can be built correctly.
  163. if gcc-specs-pie; then
  164. append-ldflags -nopie
  165. fi
  166. export CC=$(tc-getCC)
  167. export CGO_ENABLED=1
  168. export CGO_CFLAGS="${CFLAGS}"
  169. export CGO_CPPFLAGS="${CPPFLAGS}"
  170. export CGO_CXXFLAGS="${CXXFLAGS}"
  171. export CGO_LDFLAGS="${LDFLAGS}"
  172. export BUILDDIR
  173. econf "${myeconfargs[@]}"
  174. }
  175. src_compile() {
  176. local arch=${ARCH}
  177. case ${arch} in
  178. amd64) arch=x86_64;;
  179. esac
  180. ARCH=${arch} emake V=3
  181. ARCH=${arch} emake V=3 bash-completion
  182. }
  183. src_install() {
  184. dodoc README.md
  185. use doc && dodoc -r Documentation
  186. use examples && dodoc -r examples
  187. use actool && dobin "${S}/${BUILDDIR}/tools/actool"
  188. dobin "${S}/${BUILDDIR}/target/bin/rkt"
  189. insinto /usr/share/rkt
  190. doins "${S}/${BUILDDIR}/target/bin/"*.aci
  191. # create symlink for default stage1 image path
  192. if use rkt_stage1_host; then
  193. dosym stage1-host.aci "${STAGE1_DEFAULT_LOCATION}"
  194. elif use rkt_stage1_src; then
  195. dosym stage1-src.aci "${STAGE1_DEFAULT_LOCATION}"
  196. elif use rkt_stage1_coreos; then
  197. dosym stage1-coreos.aci "${STAGE1_DEFAULT_LOCATION}"
  198. elif use rkt_stage1_fly; then
  199. dosym stage1-fly.aci "${STAGE1_DEFAULT_LOCATION}"
  200. elif use rkt_stage1_kvm_lkvm; then
  201. dosym stage1-kvm-lkvm.aci "${STAGE1_DEFAULT_LOCATION}"
  202. elif use rkt_stage1_kvm_qemu; then
  203. dosym stage1-kvm-qemu.aci "${STAGE1_DEFAULT_LOCATION}"
  204. fi
  205. systemd_dounit "${S}"/dist/init/systemd/*.service \
  206. "${S}"/dist/init/systemd/*.timer \
  207. "${S}"/dist/init/systemd/*.socket
  208. insinto /usr/lib/tmpfiles.d
  209. doins "${S}"/dist/init/systemd/tmpfiles.d/*
  210. newbashcomp "${S}"/dist/bash_completion/rkt.bash rkt
  211. keepdir /etc/${PN}
  212. fowners :rkt-admin /etc/${PN}
  213. fperms 2775 /etc/${PN}
  214. }