GithubHelp home page GithubHelp logo

apkman's Introduction

apkman

Package Manager and Toolbox for enclave development

Alpine Linux is MUSL based. Alpine Linux packages are compatible for use with OE SDK.

apkman makes it easy to use Alpine Linux packages for developing enclaves.

Installation

apkman is a self-contained bash script. Download it from openenclave repository, make it executable and add to path.

wget https://raw.githubusercontent.com/openenclave/openenclave/feature/apkman/tools/apkman/apkman
chmod +x apkman
# Add location of apkman to PATH

Usage

Installing packages

Search for packages using apkman search.

Install packages using apkman add.

Look for -static and -dev packages.

If unsure of package use https://pkgs.alpinelinux.org/contents to search for package with given contents.

Using packages

apkman root command gives the path to root folder of Alpine Linux distribution that apkman manages.

Add $(apkman root)/usr/include to compiler include paths. Add $(apkman root)/usr/lib to linker path. Add other folders as needed.

Use headers (e.g sqlite.h) in C/C++ code. Add library (e.g libsqlite.a) to linker.

Installing and using tools

Install necessary tools via apkman add.

Use apkman exec to run the tool.

Using tools via apkman ensures that the artifacts generated by the tools are compatible with OE SDK. This approach also allows using the same tool for building enclave artifacts even if the specific version of the tools is not available on the host system.

Build libraries using apkman

Use apkman exec sh or apkman exec bash to enter the Alpine Linux distribution managed by apkman. Use this environment to build libraries. Alpine-linux compiler toolchain is MUSL based and therefore the built libraries are OE SDK compatible.

Here is an example of building a Web Assembly interpreter using apkman.

Demos

  • Libraries

    • libcurl Demonstrating use of standard libcurl to perform HTTP request.
    • libevent Demonstrates use of libevent to write a simple echo server.
    • libgmp Demonstrates use of GNU Multi-Precision Library to compute digits of Pi.
    • hiredis Demonstrates use of hiredis C client library to perform basic database operations.
    • sqlite Demonstrates use of sqlite to create an in-memory database and perform database operations.
    • zlib Demonstrates use of zlib compression library to compress and decompress files.
  • Cpp

    • boost Demonstrates use of some boost libraries like bimap, multiprecision, serialization
    • cpp20 Demonstrates use of coroutines
    • protobuf Demonstrates use of protocol buffers within enclave.
  • Runtimes

    • lua Demonstrates use of Lua which is a powerful, efficient, lightweight, embeddable scripting language.
    • ocaml Demonstrates use of Ocaml which is a functional programming lanuguage used in financial industry as well as for writing static analysis tools.
    • quickjs Demonstrates use of QuickJS which is a small embeddable Javascript Engine that supports ES2020 specification.
    • wasm Demonstrates use of wasm3 which is a Web Assembly interpreter.

Design

apkman maintains an Alpine Linux distribution instance at ~/.apkman/alpine-fs. Alpine Linux exists as a regular directory. This makes it trivial to use headers and libraries from the Alpine distribution to build enclaves.

Traditionally, root filesystems are "entered" via the chroot (change root) command. However, chroot requires sudo access. This makes it less than ideal for development purposes. Super user access may not always be available. Additionally, any files touched by a super user process will have root ownership and cannot be easily managed by a non super-user process.

To avoid the need for root access, apkman "enters" the Alpine Linux distribution via the following commands:

  • unshare command which allows creating a separate user namespace in which chroot can be executed.
  • or proot when unshare is not available. proot is an implementation of chroot using ptrace. Is typically used to run Linux distributions atop restrictive environments like Android.

Cross compilation

Using binfmt_misc and qemu user space emulation, it is possible to run ARMv7 Alpine Linux distribution on x86-64 machine. This allows managing ARMv7 packages via apkman.

apkman's People

Contributors

anakrish avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

apkman's Issues

Instructions don't work as is on Windows

The Readme file does not say this can only be done on Linux, and enclaves are OS-agnostic.
Please either add the equivalent steps for Windows, or state how to install the prerequisites so the commands work as listed.

Question about the ues of the library NTL

Hi, @anakrish .
Now, I'm trying to perform some encryptions and decryptions inside the enclave. In doing so, I need to build the static library GMP and NTL inside the enclave.

But as mentioned in issue openenclave-#3880, it's very difficult to do this. Currently, do we have any updates on solving this issue?

BTW, the library NTL is up to 43M which will take up a lot of enclave memory (128M). In fact, I only need part of the files in the NTL. Can I extract some files from the NTL, and then build NTL inside the enclave?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.