Advertisement
Guest User

C2 AuFS & Docker support

a guest
Jul 26th, 2016
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.22 KB | None | 0 0
  1. From 88ca55ce5420589044d8cc459737447651069579 Mon Sep 17 00:00:00 2001
  2. From: Jamie Coldhill <[email protected]>
  3. Date: Wed, 27 Jul 2016 12:17:08 +0800
  4. Subject: [PATCH] Add AuFS driver and Docker support to C2
  5.  
  6. Ground work done by pckbls here:
  7. https://github.com/pckbls/LibreELEC.tv.7.0/commits/libreelec-7.0
  8.  
  9. ---
  10. .../addons/addon-depends/containerd/package.mk | 3 +
  11. .../containerd/patches/containerd-epoll.patch | 149 +++++++++++++++++++++
  12. packages/addons/addon-depends/runc/package.mk | 3 +
  13. packages/addons/service/docker/package.mk | 6 +-
  14. .../service/docker/source/config/docker.conf | 2 +-
  15. projects/Odroid_C2/linux/linux.aarch64.conf | 38 ++++--
  16. 6 files changed, 189 insertions(+), 12 deletions(-)
  17. create mode 100644 packages/addons/addon-depends/containerd/patches/containerd-epoll.patch
  18.  
  19. diff --git a/packages/addons/addon-depends/containerd/package.mk b/packages/addons/addon-depends/containerd/package.mk
  20. index c420f3e..4c29fe4 100644
  21. --- a/packages/addons/addon-depends/containerd/package.mk
  22. +++ b/packages/addons/addon-depends/containerd/package.mk
  23. @@ -49,6 +49,9 @@ pre_make_target() {
  24. ;;
  25. esac
  26. ;;
  27. + aarch64)
  28. + export GOARCH=arm64
  29. + ;;
  30. esac
  31.  
  32. export GOOS=linux
  33. diff --git a/packages/addons/addon-depends/containerd/patches/containerd-epoll.patch b/packages/addons/addon-depends/containerd/patches/containerd-epoll.patch
  34. new file mode 100644
  35. index 0000000..4ecd043
  36. --- /dev/null
  37. +++ b/packages/addons/addon-depends/containerd/patches/containerd-epoll.patch
  38. @@ -0,0 +1,149 @@
  39. +diff --git a/archutils/epoll.go b/archutils/epoll.go
  40. +new file mode 100644
  41. +index 0000000..c8ade64
  42. +--- /dev/null
  43. ++++ b/archutils/epoll.go
  44. +@@ -0,0 +1,19 @@
  45. ++// +build linux,!arm64
  46. ++
  47. ++package archutils
  48. ++
  49. ++import (
  50. ++ "syscall"
  51. ++)
  52. ++
  53. ++func EpollCreate1(flag int) (int, error) {
  54. ++ return syscall.EpollCreate1(flag)
  55. ++}
  56. ++
  57. ++func EpollCtl(epfd int, op int, fd int, event *syscall.EpollEvent) error {
  58. ++ return syscall.EpollCtl(epfd, op, fd, event)
  59. ++}
  60. ++
  61. ++func EpollWait(epfd int, events []syscall.EpollEvent, msec int) (int, error) {
  62. ++ return syscall.EpollWait(epfd, events, msec)
  63. ++}
  64. +diff --git a/archutils/epoll_arm64.go b/archutils/epoll_arm64.go
  65. +new file mode 100644
  66. +index 0000000..00abc68
  67. +--- /dev/null
  68. ++++ b/archutils/epoll_arm64.go
  69. +@@ -0,0 +1,70 @@
  70. ++// +build linux,arm64
  71. ++
  72. ++package archutils
  73. ++
  74. ++// #include <sys/epoll.h>
  75. ++/*
  76. ++int EpollCreate1(int flag) {
  77. ++ return epoll_create1(flag);
  78. ++}
  79. ++
  80. ++int EpollCtl(int efd, int op,int sfd, int events, int fd) {
  81. ++ struct epoll_event event;
  82. ++ event.events = events;
  83. ++ event.data.fd = fd;
  84. ++
  85. ++ return epoll_ctl(efd, op, sfd, &event);
  86. ++}
  87. ++
  88. ++struct event_t {
  89. ++ uint32_t events;
  90. ++ int fd;
  91. ++};
  92. ++
  93. ++struct epoll_event events[128];
  94. ++int run_epoll_wait(int fd, struct event_t *event) {
  95. ++ int n, i;
  96. ++ n = epoll_wait(fd, events, 128, -1);
  97. ++ for (i = 0; i < n; i++) {
  98. ++ event[i].events = events[i].events;
  99. ++ event[i].fd = events[i].data.fd;
  100. ++ }
  101. ++ return n;
  102. ++}
  103. ++*/
  104. ++import "C"
  105. ++
  106. ++import (
  107. ++ "fmt"
  108. ++ "syscall"
  109. ++ "unsafe"
  110. ++)
  111. ++
  112. ++func EpollCreate1(flag int) (int, error) {
  113. ++ fd := int(C.EpollCreate1(C.int(flag)))
  114. ++ if fd < 0 {
  115. ++ return fd, fmt.Errorf("failed to create epoll, errno is %d", fd)
  116. ++ }
  117. ++ return fd, nil
  118. ++}
  119. ++
  120. ++func EpollCtl(epfd int, op int, fd int, event *syscall.EpollEvent) error {
  121. ++ errno := C.EpollCtl(C.int(epfd), C.int(syscall.EPOLL_CTL_ADD), C.int(fd), C.int(event.Events), C.int(event.Fd))
  122. ++ if errno < 0 {
  123. ++ return fmt.Errorf("Failed to ctl epoll")
  124. ++ }
  125. ++ return nil
  126. ++}
  127. ++
  128. ++func EpollWait(epfd int, events []syscall.EpollEvent, msec int) (int, error) {
  129. ++ var c_events [128]C.struct_event_t
  130. ++ n := int(C.run_epoll_wait(C.int(epfd), (*C.struct_event_t)(unsafe.Pointer(&c_events))))
  131. ++ if n < 0 {
  132. ++ return int(n), fmt.Errorf("Failed to wait epoll")
  133. ++ }
  134. ++ for i := 0; i < n; i++ {
  135. ++ events[i].Fd = int32(c_events[i].fd)
  136. ++ events[i].Events = uint32(c_events[i].events)
  137. ++ }
  138. ++ return int(n), nil
  139. ++}
  140. +diff --git a/supervisor/monitor_linux.go b/supervisor/monitor_linux.go
  141. +index adf4ffd..b176585 100644
  142. +--- a/supervisor/monitor_linux.go
  143. ++++ b/supervisor/monitor_linux.go
  144. +@@ -5,6 +5,7 @@ import (
  145. + "syscall"
  146. +
  147. + "github.com/Sirupsen/logrus"
  148. ++ "github.com/docker/containerd/archutils"
  149. + "github.com/docker/containerd/runtime"
  150. + )
  151. +
  152. +@@ -14,7 +15,7 @@ func NewMonitor() (*Monitor, error) {
  153. + exits: make(chan runtime.Process, 1024),
  154. + ooms: make(chan string, 1024),
  155. + }
  156. +- fd, err := syscall.EpollCreate1(0)
  157. ++ fd, err := archutils.EpollCreate1(0)
  158. + if err != nil {
  159. + return nil, err
  160. + }
  161. +@@ -47,7 +48,7 @@ func (m *Monitor) Monitor(p runtime.Process) error {
  162. + Fd: int32(fd),
  163. + Events: syscall.EPOLLHUP,
  164. + }
  165. +- if err := syscall.EpollCtl(m.epollFd, syscall.EPOLL_CTL_ADD, fd, &event); err != nil {
  166. ++ if err := archutils.EpollCtl(m.epollFd, syscall.EPOLL_CTL_ADD, fd, &event); err != nil {
  167. + return err
  168. + }
  169. + EpollFdCounter.Inc(1)
  170. +@@ -67,7 +68,7 @@ func (m *Monitor) MonitorOOM(c runtime.Container) error {
  171. + Fd: int32(fd),
  172. + Events: syscall.EPOLLHUP | syscall.EPOLLIN,
  173. + }
  174. +- if err := syscall.EpollCtl(m.epollFd, syscall.EPOLL_CTL_ADD, fd, &event); err != nil {
  175. ++ if err := archutils.EpollCtl(m.epollFd, syscall.EPOLL_CTL_ADD, fd, &event); err != nil {
  176. + return err
  177. + }
  178. + EpollFdCounter.Inc(1)
  179. +@@ -82,7 +83,7 @@ func (m *Monitor) Close() error {
  180. + func (m *Monitor) start() {
  181. + var events [128]syscall.EpollEvent
  182. + for {
  183. +- n, err := syscall.EpollWait(m.epollFd, events[:], -1)
  184. ++ n, err := archutils.EpollWait(m.epollFd, events[:], -1)
  185. + if err != nil {
  186. + if err == syscall.EINTR {
  187. + continue
  188. diff --git a/packages/addons/addon-depends/runc/package.mk b/packages/addons/addon-depends/runc/package.mk
  189. index 280ad75..73cd07c 100644
  190. --- a/packages/addons/addon-depends/runc/package.mk
  191. +++ b/packages/addons/addon-depends/runc/package.mk
  192. @@ -49,6 +49,9 @@ pre_make_target() {
  193. ;;
  194. esac
  195. ;;
  196. + aarch64)
  197. + export GOARCH=arm64
  198. + ;;
  199. esac
  200.  
  201. export GOOS=linux
  202. diff --git a/packages/addons/service/docker/package.mk b/packages/addons/service/docker/package.mk
  203. index f5e5756..b5595f7 100644
  204. --- a/packages/addons/service/docker/package.mk
  205. +++ b/packages/addons/service/docker/package.mk
  206. @@ -20,7 +20,7 @@ PKG_NAME="docker"
  207. PKG_VERSION="1.11.2"
  208. PKG_REV="104"
  209. PKG_ARCH="any"
  210. -PKG_ADDON_PROJECTS="Generic RPi RPi2"
  211. +PKG_ADDON_PROJECTS="Generic RPi RPi2 Odroid_C2"
  212. PKG_LICENSE="ASL"
  213. PKG_SITE="http://www.docker.com/"
  214. PKG_URL="https://github.com/docker/docker/archive/v${PKG_VERSION}.tar.gz"
  215. @@ -40,7 +40,6 @@ configure_target() {
  216. export DOCKER_BUILDTAGS="daemon \
  217. autogen \
  218. exclude_graphdriver_devicemapper \
  219. - exclude_graphdriver_aufs \
  220. exclude_graphdriver_btrfs"
  221.  
  222. case $TARGET_ARCH in
  223. @@ -59,6 +58,9 @@ configure_target() {
  224. ;;
  225. esac
  226. ;;
  227. + aarch64)
  228. + export GOARCH=arm64
  229. + ;;
  230. esac
  231.  
  232. export GOOS=linux
  233. diff --git a/packages/addons/service/docker/source/config/docker.conf b/packages/addons/service/docker/source/config/docker.conf
  234. index 36908b5..da46d48 100644
  235. --- a/packages/addons/service/docker/source/config/docker.conf
  236. +++ b/packages/addons/service/docker/source/config/docker.conf
  237. @@ -1,2 +1,2 @@
  238. DOCKER_DAEMON_OPTS="--graph=/storage/.kodi/userdata/addon_data/service.system.docker/docker"
  239. -DOCKER_STORAGE_OPTS="--storage-driver=overlay"
  240. +DOCKER_STORAGE_OPTS="--storage-driver=aufs"
  241. diff --git a/projects/Odroid_C2/linux/linux.aarch64.conf b/projects/Odroid_C2/linux/linux.aarch64.conf
  242. index fcbb553..ffa3743 100644
  243. --- a/projects/Odroid_C2/linux/linux.aarch64.conf
  244. +++ b/projects/Odroid_C2/linux/linux.aarch64.conf
  245. @@ -104,7 +104,8 @@ CONFIG_CPUSETS=y
  246. CONFIG_PROC_PID_CPUSET=y
  247. CONFIG_CGROUP_CPUACCT=y
  248. CONFIG_RESOURCE_COUNTERS=y
  249. -# CONFIG_MEMCG is not set
  250. +CONFIG_MEMCG=y
  251. +CONFIG_MEMCG_KMEM=y
  252. CONFIG_CGROUP_PERF=y
  253. CONFIG_CGROUP_SCHED=y
  254. CONFIG_FAIR_GROUP_SCHED=y
  255. @@ -484,7 +485,7 @@ CONFIG_IPV6_NDISC_NODETYPE=y
  256. CONFIG_NETFILTER=y
  257. # CONFIG_NETFILTER_DEBUG is not set
  258. CONFIG_NETFILTER_ADVANCED=y
  259. -# CONFIG_BRIDGE_NETFILTER is not set
  260. +CONFIG_BRIDGE_NETFILTER=y
  261.  
  262. #
  263. # Core Netfilter Configuration
  264. @@ -558,7 +559,7 @@ CONFIG_NETFILTER_XTABLES=m
  265. #
  266. # Xtables matches
  267. #
  268. -# CONFIG_NETFILTER_XT_MATCH_ADDRTYPE is not set
  269. +CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=m
  270. # CONFIG_NETFILTER_XT_MATCH_BPF is not set
  271. # CONFIG_NETFILTER_XT_MATCH_CGROUP is not set
  272. # CONFIG_NETFILTER_XT_MATCH_CLUSTER is not set
  273. @@ -567,7 +568,7 @@ CONFIG_NETFILTER_XTABLES=m
  274. # CONFIG_NETFILTER_XT_MATCH_CONNLABEL is not set
  275. # CONFIG_NETFILTER_XT_MATCH_CONNLIMIT is not set
  276. # CONFIG_NETFILTER_XT_MATCH_CONNMARK is not set
  277. -# CONFIG_NETFILTER_XT_MATCH_CONNTRACK is not set
  278. +CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
  279. # CONFIG_NETFILTER_XT_MATCH_CPU is not set
  280. # CONFIG_NETFILTER_XT_MATCH_DCCP is not set
  281. # CONFIG_NETFILTER_XT_MATCH_DEVGROUP is not set
  282. @@ -588,6 +589,7 @@ CONFIG_NETFILTER_XT_MATCH_IPRANGE=m
  283. # CONFIG_NETFILTER_XT_MATCH_NFACCT is not set
  284. # CONFIG_NETFILTER_XT_MATCH_OSF is not set
  285. CONFIG_NETFILTER_XT_MATCH_OWNER=m
  286. +# CONFIG_NETFILTER_XT_MATCH_PHYSDEV is not set
  287. # CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set
  288. # CONFIG_NETFILTER_XT_MATCH_QUOTA is not set
  289. # CONFIG_NETFILTER_XT_MATCH_QUOTA2 is not set
  290. @@ -694,7 +696,7 @@ CONFIG_DNS_RESOLVER=y
  291. CONFIG_RPS=y
  292. CONFIG_RFS_ACCEL=y
  293. CONFIG_XPS=y
  294. -# CONFIG_CGROUP_NET_PRIO is not set
  295. +CONFIG_CGROUP_NET_PRIO=y
  296. # CONFIG_CGROUP_NET_CLASSID is not set
  297. CONFIG_NET_RX_BUSY_POLL=y
  298. CONFIG_BQL=y
  299. @@ -1356,14 +1358,15 @@ CONFIG_NET_CORE=y
  300. # CONFIG_DUMMY is not set
  301. # CONFIG_EQUALIZER is not set
  302. # CONFIG_NET_TEAM is not set
  303. -# CONFIG_MACVLAN is not set
  304. +CONFIG_MACVLAN=y
  305. +# CONFIG_MACVTAP is not set
  306. # CONFIG_VXLAN is not set
  307. CONFIG_NETCONSOLE=y
  308. CONFIG_NETPOLL=y
  309. # CONFIG_NETPOLL_TRAP is not set
  310. CONFIG_NET_POLL_CONTROLLER=y
  311. CONFIG_TUN=y
  312. -# CONFIG_VETH is not set
  313. +CONFIG_VETH=y
  314. CONFIG_NLMON=m
  315.  
  316. #
  317. @@ -1659,7 +1662,7 @@ CONFIG_VT_CONSOLE_SLEEP=y
  318. CONFIG_HW_CONSOLE=y
  319. CONFIG_VT_HW_CONSOLE_BINDING=y
  320. CONFIG_UNIX98_PTYS=y
  321. -# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
  322. +CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
  323. CONFIG_LEGACY_PTYS=y
  324. CONFIG_LEGACY_PTY_COUNT=256
  325. # CONFIG_SERIAL_NONSTANDARD is not set
  326. @@ -3411,7 +3414,24 @@ CONFIG_F2FS_FS=y
  327. CONFIG_F2FS_STAT_FS=y
  328. # CONFIG_F2FS_FS_XATTR is not set
  329. # CONFIG_F2FS_CHECK_FS is not set
  330. -# CONFIG_AUFS_FS is not set
  331. +CONFIG_AUFS_FS=y
  332. +CONFIG_AUFS_BRANCH_MAX_127=y
  333. +# CONFIG_AUFS_BRANCH_MAX_511 is not set
  334. +# CONFIG_AUFS_BRANCH_MAX_1023 is not set
  335. +# CONFIG_AUFS_BRANCH_MAX_32767 is not set
  336. +CONFIG_AUFS_SBILIST=y
  337. +# CONFIG_AUFS_HNOTIFY is not set
  338. +# CONFIG_AUFS_HFSNOTIFY is not set
  339. +# CONFIG_AUFS_EXPORT is not set
  340. +# CONFIG_AUFS_XATTR is not set
  341. +CONFIG_AUFS_FHSM=y
  342. +# CONFIG_AUFS_RDU is not set
  343. +# CONFIG_AUFS_SHWH is not set
  344. +# CONFIG_AUFS_BR_RAMFS is not set
  345. +# CONFIG_AUFS_BR_FUSE is not set
  346. +# CONFIG_AUFS_BR_HFSPLUS is not set
  347. +CONFIG_AUFS_BDEV_LOOP=y
  348. +# CONFIG_AUFS_DEBUG is not set
  349. CONFIG_NETWORK_FILESYSTEMS=y
  350. CONFIG_NFS_FS=y
  351. CONFIG_NFS_V2=y
  352. --
  353. 1.9.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement