Skip to content

Commit be477f1

Browse files
committed
Add content
1 parent 0d10176 commit be477f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+3003
-1
lines changed

.clang-format

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# See more @ https://clang.llvm.org/docs/ClangFormatStyleOptions.html
2+
BasedOnStyle: LLVM
3+
UseTab: Never
4+
IndentWidth: 2
5+
TabWidth: 2
6+
BreakBeforeBraces: Allman
7+
AllowShortIfStatementsOnASingleLine: false
8+
IndentCaseLabels: false
9+
ColumnLimit: 0
10+
AccessModifierOffset: -2
11+
PointerAlignment: Left
12+
NamespaceIndentation: None

.devcontainer/alpine/Dockerfile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
FROM alpine:3.13
2+
3+
RUN sed -i 's|dl-cdn.alpinelinux.org/alpine|ftp.acc.umu.se/mirror/alpinelinux.org|g' /etc/apk/repositories
4+
5+
# base-tools for C and C++
6+
RUN apk update \
7+
&& apk add --no-cache \
8+
autoconf \
9+
automake \
10+
cmake \
11+
g++ \
12+
gcc \
13+
gdb \
14+
libtool \
15+
make \
16+
pkgconf \
17+
&& rm -r /var/cache/apk/*
18+
19+
# Other useful tools for C and C++
20+
RUN apk update \
21+
&& apk add --no-cache \
22+
clang-extra-tools \
23+
valgrind \
24+
&& rm -r /var/cache/apk/*
25+
26+
# Other useful tools.
27+
RUN apk update \
28+
&& apk add --no-cache \
29+
bash \
30+
ca-certificates \
31+
curl \
32+
git \
33+
sudo \
34+
&& rm -r /var/cache/apk/*
35+
36+
# project-specific dependencies
37+
RUN apk update \
38+
&& apk add --no-cache \
39+
openssl-dev \
40+
musl-nscd-dev \
41+
&& rm -r /var/cache/apk/*
42+
43+
RUN adduser \
44+
-s /bin/bash \
45+
-D \
46+
build \
47+
&& addgroup sudo \
48+
&& adduser build sudo \
49+
&& echo -e "\n# Allow sudo without password\n%sudo ALL=(ALL) NOPASSWD:ALL\n" >> /etc/sudoers
50+
51+
# Don't run as root inside container,
52+
# see https://github.com/microsoft/vscode-remote-release/issues/22
53+
ENV HOME /home/build
54+
ENV THIRD_PARTY_ROOT /home/build/third_party
55+
ENV DIST alpine
56+
USER build
57+
58+
CMD ["/bin/bash", "-l"]

.devcontainer/devcontainer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Ref: https://code.visualstudio.com/docs/remote/containers#_devcontainerjson-reference
2+
{
3+
"name": "nss-http",
4+
"image": "1nfiniteloop/nss-http-builder",
5+
"extensions": [
6+
"llvm-vs-code-extensions.vscode-clangd",
7+
"ms-vscode.cmake-tools",
8+
"twxs.cmake"
9+
],
10+
"runArgs": [
11+
"--name=nss-http.vscode",
12+
"--volume=vscode.cache:/home/build",
13+
"--cap-add=SYS_PTRACE",
14+
"--security-opt",
15+
"seccomp=unconfined"
16+
]
17+
}

.devcontainer/ubuntu/Dockerfile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
FROM ubuntu:focal
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN sed --in-place=~ 's|archive.ubuntu.com|ftp.acc.umu.se|g' /etc/apt/sources.list
6+
7+
# base-tools for C and C++
8+
RUN apt-get update \
9+
&& apt-get install \
10+
--no-install-recommends \
11+
--assume-yes \
12+
--quiet \
13+
autoconf \
14+
automake \
15+
cmake \
16+
g++ \
17+
gcc \
18+
gdb \
19+
libtool \
20+
make \
21+
pkg-config \
22+
&& rm -r /var/lib/apt/lists/*
23+
24+
# Other useful tools for C and C++
25+
RUN apt-get update \
26+
&& apt-get install \
27+
--no-install-recommends \
28+
--assume-yes \
29+
--quiet \
30+
clangd \
31+
valgrind \
32+
&& rm -r /var/lib/apt/lists/*
33+
34+
# Other useful tools.
35+
RUN apt-get update \
36+
&& apt-get install \
37+
--no-install-recommends \
38+
--assume-yes \
39+
--quiet \
40+
ca-certificates \
41+
curl \
42+
git \
43+
less \
44+
nano \
45+
sudo \
46+
xz-utils \
47+
&& rm -r /var/lib/apt/lists/*
48+
49+
# Project-specific dependencies
50+
RUN apt-get update \
51+
&& apt-get install \
52+
--no-install-recommends \
53+
--assume-yes \
54+
--quiet \
55+
libssl-dev \
56+
&& rm -r /var/lib/apt/lists/*
57+
58+
RUN useradd \
59+
--uid 1000 \
60+
--shell /bin/bash \
61+
--create-home \
62+
build \
63+
&& adduser build sudo \
64+
&& echo "\n# Allow sudo without password\n%sudo ALL=(ALL) NOPASSWD:ALL\n" >> /etc/sudoers
65+
66+
# Don't run as root inside container,
67+
# see https://github.com/microsoft/vscode-remote-release/issues/22
68+
ENV HOME /home/build
69+
ENV THIRD_PARTY_ROOT /home/build/third_party
70+
ENV DIST ubuntu
71+
USER build
72+
73+
CMD ["/bin/bash", "-l"]

.github/workflows/build.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Build app
2+
3+
on:
4+
push:
5+
branches: main
6+
tags:
7+
- 'v*'
8+
9+
jobs:
10+
main:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
16+
- name: Set up QEMU
17+
uses: docker/setup-qemu-action@v1
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v1
21+
22+
- name: Login to Docker Hub
23+
uses: docker/login-action@v1
24+
with:
25+
username: ${{ secrets.DOCKERHUB_USER }}
26+
password: ${{ secrets.DOCKERHUB_TOKEN }}
27+
28+
# ref: https://github.com/docker/build-push-action
29+
- name: Create builder container
30+
uses: docker/build-push-action@v2
31+
with:
32+
context: .
33+
file: .devcontainer/ubuntu/Dockerfile
34+
platforms: linux/amd64
35+
push: true
36+
tags: |
37+
1nfiniteloop/nss-http-builder:latest
38+
1nfiniteloop/nss-http-builder:1.0.0
39+
# ref: https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-use-an-external-cache-source-for-a-build---cache-from
40+
cache-from: type=registry,ref=1nfiniteloop/nss-http-builder:latest
41+
cache-to: type=inline
42+
43+
# ref: https://github.com/actions/cache
44+
- name: Get cache for third party dependencies
45+
id: cache
46+
uses: actions/cache@v2
47+
with:
48+
path: third_party_root/install
49+
key: third-party-${{ hashFiles('third_party') }}
50+
51+
- name: Build third-party dependencies
52+
if: steps.cache.outputs.cache-hit != 'true'
53+
run: |
54+
docker run \
55+
--rm \
56+
--user root \
57+
--workdir /home/build \
58+
--env THIRD_PARTY_ROOT=/home/build/nss-http/third_party_root \
59+
--volume $(pwd):/home/build/nss-http \
60+
1nfiniteloop/nss-http-builder /bin/bash -c ' \
61+
mkdir --parents nss-http/third_party_root/source \
62+
&& for dep in nss-http/third_party/{boost,cpr,yaml_cpp}; \
63+
do ${dep} || break; done'
64+
65+
- name: Build nss-http
66+
run: |
67+
docker run \
68+
--rm \
69+
--user root \
70+
--workdir /home/build \
71+
--env THIRD_PARTY_ROOT=/home/build/nss-http/third_party_root \
72+
--volume $(pwd):/home/build/nss-http \
73+
1nfiniteloop/nss-http-builder /bin/bash -c ' \
74+
mkdir --parents nss-http/build/Release
75+
cmake \
76+
-D VERSION=1.0.0 \
77+
-D BUILD=Release \
78+
-D UNITTEST=OFF \
79+
-S nss-http \
80+
-B nss-http/build/Release \
81+
&& make --directory=nss-http/build/Release package'

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Compiled Object files
5+
*.slo
6+
*.lo
7+
*.o
8+
*.obj
9+
10+
# Precompiled Headers
11+
*.gch
12+
*.pch
13+
14+
# Compiled Dynamic libraries
15+
*.so
16+
*.dylib
17+
*.dll
18+
19+
# Fortran module files
20+
*.mod
21+
*.smod
22+
23+
# Compiled Static libraries
24+
*.lai
25+
*.la
26+
*.a
27+
*.lib
28+
29+
# Executables
30+
*.exe
31+
*.out
32+
*.app
33+
34+
# Project
35+
build/
36+
.vscode/
37+
.clangd/
38+
compile_commands.json

CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(nss-http
3+
VERSION ${VERSION}
4+
DESCRIPTION "Name service switch implementation for query unix accounts over http"
5+
HOMEPAGE_URL "https://github.com/1nfiniteloop/nss-http"
6+
)
7+
8+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake-module)
9+
set(CMAKE_BUILD_TYPE ${BUILD})
10+
option(UNITTEST "Build unit tests and its dependencies" ON)
11+
12+
# Language-specific settings
13+
add_compile_options(-Wall -Wextra -pedantic -Werror)
14+
set(CMAKE_CXX_STANDARD 17)
15+
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb3")
16+
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
17+
18+
# THIRD_PARTY_ROOT and DIST provided from Dockerfile
19+
set(CMAKE_PREFIX_PATH
20+
$ENV{THIRD_PARTY_ROOT}/install/$ENV{DIST}/boost_1_75_0
21+
$ENV{THIRD_PARTY_ROOT}/install/$ENV{DIST}/cpr-1.6.2
22+
$ENV{THIRD_PARTY_ROOT}/install/$ENV{DIST}/yaml-cpp-0.6.3
23+
$ENV{THIRD_PARTY_ROOT}/install/$ENV{DIST}/googletest-release-1.10.0
24+
)
25+
26+
if (UNITTEST)
27+
include(ImportGTest)
28+
enable_testing()
29+
add_custom_target(test_all COMMAND ${CMAKE_CTEST_COMMAND})
30+
endif()
31+
32+
# Third party dependencies:
33+
include(ImportBoost)
34+
include(ImportCpr)
35+
include(ImportYamlCpp)
36+
37+
# Project components
38+
add_subdirectory(debian)
39+
add_subdirectory(source)
40+
41+
# Package
42+
include(PackageDebian)

0 commit comments

Comments
 (0)