diff --git a/.circleci/config.yml b/.circleci/config.yml index 7b7699271..9009376bf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,30 +5,43 @@ jobs: working_directory: /app docker: - image: ubuntu:16.04 + environment: + CACHE_VERSION: v1 steps: - checkout # Install any system package dependencies. - - run: env INSTALL_TEST_DEPENDENCIES=true ./build/scripts/install_build_dependencies + - run: env INSTALL_TEST_DEPENDENCIES=true ./tasks/install-system-build-dependencies - restore_cache: # CircleCI's prefix based matching will mean the cache from the last # cache for this branch will be restored. key: cache-build-deps-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ arch }}- + # The bootstrap's "task" file will be cached on subsequent runs, but due + # to the reliance on timestamps, this fact might not get picked up in the + # CI environment. So if a stamp file exists for the initial bootstrap + # process, re-touch it to prevent re-downloads. + - run: touch -c build/work/stamp/bootstrap-* # Build all the API Umbrella software dependencies. - run: ./configure - - run: make all test-deps test-bundle + - run: make all test-deps + # Cache the staged build data and task checksums of what's been + # completed. But explicitly don't cache most of the build/work/tasks/* + # data, since that contains a lot of the intermediate build files, which + # can significantly increase the cache size. - save_cache: key: cache-build-deps-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ arch }}-{{ epoch }} paths: - - build/work - - CMakeCache.txt - - CMakeFiles - - Makefile - - cmake_install.cmake - - type: shell - command: | - groupadd -r api-umbrella - useradd -r -g api-umbrella -s /sbin/nologin -d /opt/api-umbrella -c "API Umbrella user" api-umbrella - ./test/scripts/circle-ci + - .task + - build/work/dev-env + - build/work/stage + - build/work/stamp + - build/work/task + - build/work/tasks/app-deps/admin-ui/yarn/_persist + - build/work/tasks/app-deps/web-app/bundle/_persist + - build/work/tasks/app/admin-ui/build/_persist/dist + - build/work/tasks/app/web-app/precompile/_persist/public/web-assets + - build/work/tasks/test-deps/bundle/_persist + - build/work/test-env + - run: make test:circle-ci - store_test_results: path: test/tmp/reports - store_artifacts: diff --git a/.dockerignore b/.dockerignore index fd2393bd6..e2076a22a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,14 +1,7 @@ -# CMake -CMakeCache.txt -CMakeFiles -Makefile -cmake_install.cmake -install_manifest.txt -install_manifest_core.txt -install_manifest_hadoop-analytics.txt - +.task build/work build/package/work +build/package/verify/.rnd .vagrant workspace @@ -16,18 +9,12 @@ chef/cookbooks chef/tmp .bundle .ruby-version -CMakeCache.txt -CMakeFiles Dockerfile* Makefile -cmake_install.cmake docker-compose.yml install_manifest.txt install_manifest_core.txt install_manifest_hadoop-analytics.txt -build/work -build/package/work -build/package/verify/.rnd deploy/.env deploy/log deploy/tmp diff --git a/.gitignore b/.gitignore index 669afaf3f..9c3f81cb9 100644 --- a/.gitignore +++ b/.gitignore @@ -17,18 +17,13 @@ # Ignore bundler config /.bundle -# Ignore Circle CI items, so the GitHub pages publish task can work. +# Ignore Circle CI items, so the GitHub pages publish task can work. /.ruby-version -# CMake -/CMakeCache.txt -/CMakeFiles -/Makefile -/cmake_install.cmake -/install_manifest.txt -/install_manifest_core.txt -/install_manifest_hadoop-analytics.txt +# Build task checksums +/.task +/Makefile /build/work /build/package/work /build/package/verify/.rnd diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index c601ec2a8..000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,92 +0,0 @@ -cmake_minimum_required(VERSION 3.6.0 FATAL_ERROR) -project(api-umbrella) - -# Installation prefix -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX /opt/api-umbrella CACHE PATH "default install path" FORCE) -endif() -set(INSTALL_PREFIX_EMBEDDED ${CMAKE_INSTALL_PREFIX}/embedded) - -# Where to install cmake ExternalProjects. -set(EP_BASE build/work/external-projects) -set_directory_properties(PROPERTIES EP_BASE ${EP_BASE}) -set(WORK_DIR ${CMAKE_BINARY_DIR}/build/work) -set(PACKAGE_WORK_DIR ${CMAKE_BINARY_DIR}/build/package/work) - -# Directory to store "stamp" files indicating when a step was completed or last -# touched. -set(STAMP_DIR ${WORK_DIR}/stamp) -execute_process(COMMAND mkdir -p ${STAMP_DIR}) - -# Where to stage installations during "make" phase. -set(STAGE_DIR ${WORK_DIR}/stage) -set(STAGE_PREFIX_DIR ${STAGE_DIR}${CMAKE_INSTALL_PREFIX}) -set(STAGE_EMBEDDED_DIR ${STAGE_DIR}${INSTALL_PREFIX_EMBEDDED}) - -# Where to install development-only dependencies. -set(DEV_INSTALL_PREFIX ${WORK_DIR}/dev-env) -set(DEV_VENDOR_DIR ${DEV_INSTALL_PREFIX}/vendor) - -# Where to install test-only dependencies. -set(TEST_INSTALL_PREFIX ${WORK_DIR}/test-env) -set(TEST_VENDOR_DIR ${TEST_INSTALL_PREFIX}/vendor) -set(TEST_VENDOR_LUA_SHARE_DIR ${TEST_VENDOR_DIR}/share/lua/5.1) -set(TEST_VENDOR_LUA_LIB_DIR ${TEST_VENDOR_DIR}/lib/lua/5.1) - -# PATH variables to use when executing other commands. Note that we use a -# hard-coded base default path (instead of $ENV{PATH}), since using $ENV{PATH} -# makes cmake think there have been PATH changes which trigger rebuilds, even -# when the path hasn't changed. -set(DEFAULT_PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin) -set(STAGE_EMBEDDED_PATH ${STAGE_EMBEDDED_DIR}/bin:${DEFAULT_PATH}) -set(DEV_PATH ${DEV_INSTALL_PREFIX}/bin:${STAGE_EMBEDDED_PATH}) - -# Where to install app-level vendor dependencies. -set(VENDOR_DIR ${WORK_DIR}/vendor) -set(VENDOR_LUA_DIR ${VENDOR_DIR}/share/lua/5.1) -if(ENABLE_DEPLOY_ONLY) - set(LUA_PREFIX ${INSTALL_PREFIX_EMBEDDED}) -else() - set(LUA_PREFIX ${STAGE_EMBEDDED_DIR}) -endif() -set(LUAROCKS_CMD env LUA_PATH=${LUA_PREFIX}/openresty/luajit/share/lua/5.1/?.lua$${LUA_PREFIX}/openresty/luajit/share/lua/5.1/?/init.lua$$ ${LUA_PREFIX}/bin/luarocks) -set(OPM_CMD env LUA_PATH=${LUA_PREFIX}/openresty/lualib/?.lua$${LUA_PREFIX}/openresty/lualib/?/init.lua$$ PATH=${STAGE_EMBEDDED_PATH} LD_LIBRARY_PATH=${STAGE_EMBEDDED_DIR}/openresty/luajit/lib:${STAGE_EMBEDDED_DIR}/lib opm) - -# Misc dependencies/functions. -include(ExternalProject) -find_package(PkgConfig REQUIRED) -include(${CMAKE_SOURCE_DIR}/build/cmake/functions/GetGitRevisionDescription.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/functions/GetGitTimestamp.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/functions/luarocks_install.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/functions/opm_install.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/functions/require_program.cmake) - -# make deps -include(${CMAKE_SOURCE_DIR}/build/cmake/deps.cmake) - -# make build-deps -include(${CMAKE_SOURCE_DIR}/build/cmake/build-deps.cmake OPTIONAL) - -# make app-deps -include(${CMAKE_SOURCE_DIR}/build/cmake/app-deps.cmake OPTIONAL) - -# make app -include(${CMAKE_SOURCE_DIR}/build/cmake/app.cmake OPTIONAL) - -# make test-deps -include(${CMAKE_SOURCE_DIR}/build/cmake/test-deps.cmake OPTIONAL) - -# make test-bundle -include(${CMAKE_SOURCE_DIR}/build/cmake/test-bundle.cmake OPTIONAL) - -# make test -include(${CMAKE_SOURCE_DIR}/build/cmake/test.cmake OPTIONAL) - -# make distclean -include(${CMAKE_SOURCE_DIR}/build/cmake/distclean.cmake OPTIONAL) - -# make install -include(${CMAKE_SOURCE_DIR}/build/cmake/install.cmake OPTIONAL) - -# make package -include(${CMAKE_SOURCE_DIR}/build/cmake/package.cmake OPTIONAL) diff --git a/Dockerfile-dev-build b/Dockerfile-dev-build index 00956b3e5..cee586718 100644 --- a/Dockerfile-dev-build +++ b/Dockerfile-dev-build @@ -1,46 +1,53 @@ -FROM ubuntu:16.04 +FROM ubuntu:16.04 AS build + +RUN mkdir -p /app/build /build/build/work +RUN ln -snf /build/build/work /app/build/work +WORKDIR /app -RUN mkdir /app -RUN mkdir /build -WORKDIR /build ENV DOCKER_DEV true ENV NOKOGIRI_USE_SYSTEM_LIBRARIES 1 -COPY build/scripts/install_build_dependencies /app/build/scripts/install_build_dependencies +COPY tasks/install-system-build-dependencies /app/tasks/install-system-build-dependencies COPY build/package_dependencies.sh /app/build/package_dependencies.sh -RUN env INSTALL_TEST_DEPENDENCIES=true /app/build/scripts/install_build_dependencies - -COPY build/scripts/download_cmake /app/build/scripts/download_cmake -RUN /app/build/scripts/download_cmake +RUN env INSTALL_TEST_DEPENDENCIES=true /app/tasks/install-system-build-dependencies -COPY CMakeLists.txt /app/CMakeLists.txt -COPY build/cmake/functions /app/build/cmake/functions -COPY build/cmake/deps /app/build/cmake/deps -COPY build/cmake/deps.cmake /app/build/cmake/deps.cmake -COPY build/patches /app/build/patches +COPY Makefile.in /app/Makefile.in +COPY Taskfile.yml /app/Taskfile.yml COPY configure /app/configure -RUN /app/configure && make deps +COPY tasks/bootstrap-* /app/tasks/ +COPY tasks/helpers.sh /app/tasks/helpers.sh +RUN ./configure -COPY build/cmake/build-deps /app/build/cmake/build-deps -COPY build/cmake/build-deps.cmake /app/build/cmake/build-deps.cmake -RUN /app/configure && make build-deps +COPY build/patches /app/build/patches +COPY tasks/deps /app/tasks/deps +RUN make deps -COPY build/cmake/test-deps /app/build/cmake/test-deps -COPY build/cmake/test-deps.cmake /app/build/cmake/test-deps.cmake -RUN /app/configure && make test-deps +COPY tasks/build-deps /app/tasks/build-deps +RUN make build-deps COPY Gemfile /app/Gemfile COPY Gemfile.lock /app/Gemfile.lock -COPY build/cmake/test-bundle.cmake /app/build/cmake/test-bundle.cmake -RUN /app/configure && make test-bundle +COPY tasks/test-deps /app/tasks/test-deps +RUN make test-deps -COPY build/cmake/app-deps /app/build/cmake/app-deps -COPY build/cmake/app-deps.cmake /app/build/cmake/app-deps.cmake -RUN /app/configure && make app-deps +COPY src/api-umbrella/admin-ui/package.json /app/src/api-umbrella/admin-ui/package.json +COPY src/api-umbrella/admin-ui/yarn.lock /app/src/api-umbrella/admin-ui/yarn.lock +COPY src/api-umbrella/web-app/Gemfile /app/src/api-umbrella/web-app/Gemfile +COPY src/api-umbrella/web-app/Gemfile.lock /app/src/api-umbrella/web-app/Gemfile.lock +COPY tasks/app-deps /app/tasks/app-deps +RUN make app-deps COPY . /app -RUN /app/configure && make && \ - rm -rf /build/build/work/src/api-umbrella-core/tmp/admin-ui-build/node_modules/*/.node_modules.ember-try +RUN make + +RUN rm -rf build/work/tasks + +FROM ubuntu:16.04 + +COPY --from=build /app /app +COPY --from=build /build /build +RUN env INSTALL_TEST_DEPENDENCIES=true /app/tasks/install-system-build-dependencies +WORKDIR /app RUN groupadd -r api-umbrella && \ useradd -r -g api-umbrella -s /sbin/nologin -d /opt/api-umbrella -c "API Umbrella user" api-umbrella @@ -48,7 +55,5 @@ RUN groupadd -r api-umbrella && \ ENV PATH "/app/bin:/build/build/work/dev-env/sbin:/build/build/work/dev-env/bin:/build/build/work/test-env/sbin:/build/build/work/test-env/bin:/build/build/work/stage/opt/api-umbrella/sbin:/build/build/work/stage/opt/api-umbrella/bin:/build/build/work/stage/opt/api-umbrella/embedded/sbin:/build/build/work/stage/opt/api-umbrella/embedded/bin:${PATH}" ENV API_UMBRELLA_ROOT /build/build/work/stage/opt/api-umbrella -WORKDIR /app - ENTRYPOINT ["/app/docker/dev/docker-entrypoint"] CMD ["/app/docker/dev/docker-start"] diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 000000000..e44180c4e --- /dev/null +++ b/Makefile.in @@ -0,0 +1,25 @@ +# A minimal Makefile that downloads the "task" tool and passes things off to +# that tool for executing (so "make all" actually becomes "task all"). See +# Taskfile.yml for more detail. + +ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +WORK_DIR:=$(ROOT_DIR)/build/work + +prefix = @prefix@ +export PREFIX=$(prefix) + +.PHONY: default task-passthrough +default: all + +# Download and locally install the "task" tool. +TASK_VERSION:=2.0.2 +$(ROOT_DIR)/tasks/bootstrap-$(TASK_VERSION): ; +$(WORK_DIR)/stamp/bootstrap-$(TASK_VERSION): $(ROOT_DIR)/tasks/bootstrap-$(TASK_VERSION) + $(ROOT_DIR)/tasks/bootstrap-$(TASK_VERSION) + +task-passthrough: $(WORK_DIR)/stamp/bootstrap-$(TASK_VERSION) + $(WORK_DIR)/task $(MAKECMDGOALS) + +# Match all commands sent to "make" and send them to "task" instead. +%: task-passthrough + @true diff --git a/Rakefile b/Rakefile index b462c7ef5..15212b2ff 100644 --- a/Rakefile +++ b/Rakefile @@ -15,11 +15,10 @@ ENV["PATH"] = [ "#{API_UMBRELLA_SRC_ROOT}/build/work/test-env/sbin", "#{API_UMBRELLA_SRC_ROOT}/build/work/dev-env/bin", "#{API_UMBRELLA_SRC_ROOT}/build/work/dev-env/sbin", - "#{API_UMBRELLA_SRC_ROOT}/build/work/cmake/bin", ENV["PATH"], ].join(":") Dir.glob(File.join(API_UMBRELLA_SRC_ROOT, "scripts/rake/*.rake")).each { |r| import r } task(:default).clear -task(:default => [:lint, :test]) +task(:default => [:test]) diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 000000000..8d218b849 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,798 @@ +# Run build tasks, test tasks, and other generic tasks via the go-task tool: +# https://github.com/go-task/task +# +# The primary reason we're using this over something more standard like Make is +# that it provides a simple mechanism to skip tasks based on file checksums. +# This lets us more easily cache and skip steps in the CI and Docker +# development environment (since we only need to cache the build output and +# checksum files, rather than also needing to cache all the intermediate build +# files). +# +# A few general notes on the approach: +# +# - We mostly defer each task to a shell script to do the actual work. +# - For the build process, we use "stamp" files as outputs and also use those +# within the dependency chain. We use these stamp files so that the +# checksumming approach properly invalidates the entire chain of dependencies +# when build files change (whereas just using "deps" in go-task doesn't fully +# work for multiple levels of dependencies). So, for example, if the libgeoip +# dependency changes, rebuilding it properly cascades and triggers a rebuild +# of openresty (1st level dependency) and luarocks (2nd level dependency). + +version: "2" + +output: prefixed + +tasks: + deps:bundler: + deps: + - deps:rubygems + cmds: + - ./tasks/deps/bundler + sources: + - ./build/work/stamp/deps/rubygems + - ./tasks/deps/bundler + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/bundler + method: checksum + + deps:elasticsearch: + cmds: + - ./tasks/deps/elasticsearch + sources: + - ./tasks/deps/elasticsearch + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/elasticsearch + method: checksum + + deps:geolitecity: + cmds: + - ./tasks/deps/geolitecity + sources: + - ./tasks/deps/geolitecity + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/geolitecity + method: none + + deps:golang: + cmds: + - ./tasks/deps/golang + sources: + - ./tasks/deps/golang + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/golang + method: checksum + + deps:libcidr: + cmds: + - ./tasks/deps/libcidr + sources: + - ./tasks/deps/libcidr + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/libcidr + method: checksum + + deps:libestr: + cmds: + - ./tasks/deps/libestr + sources: + - ./tasks/deps/libestr + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/libestr + method: checksum + + deps:libfastjson: + cmds: + - ./tasks/deps/libfastjson + sources: + - ./tasks/deps/libfastjson + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/libfastjson + method: checksum + + deps:libgeoip: + cmds: + - ./tasks/deps/libgeoip + sources: + - ./tasks/deps/libgeoip + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/libgeoip + method: checksum + + deps:luarocks: + deps: + - deps:openresty + cmds: + - ./tasks/deps/luarocks + sources: + - ./build/work/stamp/deps/openresty + - ./tasks/deps/luarocks + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/luarocks + method: checksum + + deps:mongodb: + cmds: + - ./tasks/deps/mongodb + sources: + - ./tasks/deps/mongodb + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/mongodb + method: checksum + + deps:mora: + deps: + - deps:golang + cmds: + - ./tasks/deps/mora + sources: + - ./build/work/stamp/deps/golang + - ./tasks/deps/mora + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/mora + method: checksum + + deps:openresty: + deps: + - deps:libgeoip + cmds: + - ./tasks/deps/openresty + sources: + - ./build/work/stamp/deps/libgeoip + - ./tasks/deps/openresty + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/openresty + method: checksum + + deps:perp: + cmds: + - ./tasks/deps/perp + sources: + - ./tasks/deps/perp + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/perp + method: checksum + + deps:rsyslog: + deps: + - deps:libestr + - deps:libfastjson + cmds: + - ./tasks/deps/rsyslog + sources: + - ./build/work/stamp/deps/libestr + - ./build/work/stamp/deps/libfastjson + - ./tasks/deps/rsyslog + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/rsyslog + method: checksum + + deps:ruby: + cmds: + - ./tasks/deps/ruby + sources: + - ./tasks/deps/ruby + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/ruby + method: checksum + + deps:rubygems: + deps: + - deps:ruby + cmds: + - ./tasks/deps/rubygems + sources: + - ./build/work/stamp/deps/ruby + - ./tasks/deps/rubygems + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/rubygems + method: checksum + + deps:runit_svlogd: + cmds: + - ./tasks/deps/runit_svlogd + sources: + - ./tasks/deps/runit_svlogd + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/runit_svlogd + method: checksum + + deps:trafficserver: + cmds: + - ./tasks/deps/trafficserver + sources: + - ./tasks/deps/trafficserver + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/deps/trafficserver + method: checksum + + deps: + cmds: + - task: deps:bundler + - task: deps:elasticsearch + - task: deps:geolitecity + - task: deps:libcidr + - task: deps:luarocks + - task: deps:mongodb + - task: deps:mora + - task: deps:openresty + - task: deps:perp + - task: deps:rsyslog + - task: deps:runit_svlogd + - task: deps:trafficserver + + build-deps:nodejs: + cmds: + - ./tasks/build-deps/nodejs + sources: + - ./tasks/build-deps/nodejs + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/build-deps/nodejs + method: checksum + + build-deps:yarn: + deps: + - build-deps:nodejs + cmds: + - ./tasks/build-deps/yarn + sources: + - ./build/work/stamp/build-deps/nodejs + - ./tasks/build-deps/yarn + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/build-deps/yarn + method: checksum + + build-deps: + cmds: + - task: build-deps:yarn + + app-deps:admin-ui:yarn: + deps: + - build-deps:yarn + cmds: + - ./tasks/app-deps/admin-ui/yarn + sources: + - ./build/work/stamp/build-deps/yarn + - ./src/api-umbrella/admin-ui/package.json + - ./src/api-umbrella/admin-ui/yarn.lock + - ./tasks/app-deps/admin-ui/yarn + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/admin-ui/yarn + method: checksum + + app-deps:lua:argparse: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/argparse + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/argparse + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/argparse + method: checksum + + app-deps:lua:cmsgpack: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/cmsgpack + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/cmsgpack + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/cmsgpack + method: checksum + + app-deps:lua:iconv: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/iconv + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/iconv + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/iconv + method: checksum + + app-deps:lua:icu-date: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/icu-date + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/icu-date + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/icu-date + method: checksum + + app-deps:lua:inspect: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/inspect + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/inspect + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/inspect + method: checksum + + app-deps:lua:libcidr-ffi: + deps: + - deps:libcidr + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/libcidr-ffi + sources: + - ./build/work/stamp/deps/libcidr + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/libcidr-ffi + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/libcidr-ffi + method: checksum + + + app-deps:lua:luaposix: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/luaposix + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/luaposix + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/luaposix + method: checksum + + app-deps:lua:luasocket: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/luasocket + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/luasocket + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/luasocket + method: checksum + + app-deps:lua:lustache: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/lustache + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/lustache + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/lustache + method: checksum + + app-deps:lua:lyaml: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/lyaml + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/lyaml + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/lyaml + method: checksum + + app-deps:lua:penlight: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/penlight + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/penlight + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/penlight + method: checksum + + app-deps:lua:resty-http: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/resty-http + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/resty-http + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/resty-http + method: checksum + + app-deps:lua:resty-logger-socket: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/resty-logger-socket + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/resty-logger-socket + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/resty-logger-socket + method: checksum + + app-deps:lua:resty-shcache: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/resty-shcache + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/resty-shcache + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/resty-shcache + method: checksum + + app-deps:lua:resty-txid: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/resty-txid + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/resty-txid + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/resty-txid + method: checksum + + app-deps:lua:resty-uuid: + deps: + - deps:luarocks + cmds: + - ./tasks/app-deps/lua/resty-uuid + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/app-deps/lua/resty-uuid + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/lua/resty-uuid + method: checksum + + app-deps:web-app:bundle: + deps: + - deps:bundler + cmds: + - ./tasks/app-deps/web-app/bundle + sources: + - ./build/work/stamp/deps/bundler + - ./src/api-umbrella/web-app/Gemfile + - ./src/api-umbrella/web-app/Gemfile.lock + - ./tasks/app-deps/web-app/bundle + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app-deps/web-app/bundle + method: checksum + + app-deps: + cmds: + - task: app-deps:admin-ui:yarn + - task: app-deps:lua:argparse + - task: app-deps:lua:cmsgpack + - task: app-deps:lua:iconv + - task: app-deps:lua:icu-date + - task: app-deps:lua:inspect + - task: app-deps:lua:libcidr-ffi + - task: app-deps:lua:luaposix + - task: app-deps:lua:luasocket + - task: app-deps:lua:lustache + - task: app-deps:lua:lyaml + - task: app-deps:lua:penlight + - task: app-deps:lua:resty-http + - task: app-deps:lua:resty-logger-socket + - task: app-deps:lua:resty-shcache + - task: app-deps:lua:resty-txid + - task: app-deps:lua:resty-uuid + - task: app-deps:web-app:bundle + + app:admin-ui:build: + deps: + - app-deps:admin-ui:yarn + cmds: + - ./tasks/app/admin-ui/build + sources: + - ./build/work/stamp/app-deps/admin-ui/yarn + - ./src/api-umbrella/admin-ui/app/**/*.hbs + - ./src/api-umbrella/admin-ui/app/**/*.html + - ./src/api-umbrella/admin-ui/app/**/*.js + - ./src/api-umbrella/admin-ui/app/**/*.scss + - ./src/api-umbrella/admin-ui/config/**/*.js + - ./src/api-umbrella/admin-ui/ember-cli-build.js + - ./src/api-umbrella/admin-ui/lib/**/*.js + - ./tasks/app/admin-ui/build + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app/admin-ui/build + method: checksum + + app:core: + deps: + - app:admin-ui:build + - app:web-app:precompile + cmds: + - ./tasks/app/core + sources: + - ./build/work/stamp/app/admin-ui/build + - ./build/work/stamp/app/web-app/precompile + - ./tasks/app/core + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app/core + method: checksum + + app:static-site: + deps: + - build-deps:nodejs + - deps:bundler + cmds: + - ./tasks/app/static-site + sources: + - ./build/work/stamp/build-deps/nodejs + - ./build/work/stamp/deps/bundler + - ./tasks/app/static-site + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app/static-site + method: checksum + + app:web-app:precompile: + deps: + - app-deps:web-app:bundle + cmds: + - ./tasks/app/web-app/precompile + sources: + - ./build/work/stamp/app-deps/web-app/bundle + - ./src/api-umbrella/web-app/app/assets/**/*.css + - ./src/api-umbrella/web-app/app/assets/**/*.erb + - ./src/api-umbrella/web-app/app/assets/**/*.js + - ./src/api-umbrella/web-app/app/assets/**/*.scss + - ./tasks/app/web-app/precompile + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/app/web-app/precompile + method: checksum + + app: + cmds: + - task: app:core + - task: app:static-site + + all: + cmds: + - task: app + - task: app-deps + - task: build-deps + - task: deps + + test-deps:bundle: + deps: + - deps:bundler + cmds: + - ./tasks/test-deps/bundle + sources: + - ./build/work/stamp/deps/bundler + - ./Gemfile + - ./Gemfile.lock + - ./tasks/test-deps/bundle + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/test-deps/bundle + method: checksum + + test-deps:elasticsearch5: + cmds: + - ./tasks/test-deps/elasticsearch5 + sources: + - ./tasks/test-deps/elasticsearch5 + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/test-deps/elasticsearch5 + method: checksum + + test-deps:elasticsearch6: + cmds: + - ./tasks/test-deps/elasticsearch6 + sources: + - ./tasks/test-deps/elasticsearch6 + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/test-deps/elasticsearch6 + method: checksum + + test-deps:luacheck: + deps: + - deps:luarocks + cmds: + - ./tasks/test-deps/luacheck + sources: + - ./build/work/stamp/deps/luarocks + - ./tasks/test-deps/luacheck + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/test-deps/luacheck + method: checksum + + test-deps:mailhog: + cmds: + - ./tasks/test-deps/mailhog + sources: + - ./tasks/test-deps/mailhog + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/test-deps/mailhog + method: checksum + + test-deps:mongo-orchestration: + cmds: + - ./tasks/test-deps/mongo-orchestration + sources: + - ./tasks/test-deps/mongo-orchestration + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/test-deps/mongo-orchestration + method: checksum + + test-deps:openldap: + cmds: + - ./tasks/test-deps/openldap + sources: + - ./tasks/test-deps/openldap + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/test-deps/openldap + method: checksum + + test-deps:phantomjs: + cmds: + - ./tasks/test-deps/phantomjs + sources: + - ./tasks/test-deps/phantomjs + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/test-deps/phantomjs + method: checksum + + test-deps:shellcheck: + cmds: + - ./tasks/test-deps/shellcheck + sources: + - ./tasks/test-deps/shellcheck + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/test-deps/shellcheck + method: checksum + + test-deps:unbound: + cmds: + - ./tasks/test-deps/unbound + sources: + - ./tasks/test-deps/unbound + - ./tasks/helpers.sh + generates: + - ./build/work/stamp/test-deps/unbound + method: checksum + + test-deps: + cmds: + - task: test-deps:bundle + - task: test-deps:elasticsearch5 + - task: test-deps:elasticsearch6 + - task: test-deps:luacheck + - task: test-deps:mailhog + - task: test-deps:mongo-orchestration + - task: test-deps:openldap + - task: test-deps:phantomjs + - task: test-deps:shellcheck + - task: test-deps:unbound + + lint:js: + deps: + - app-deps:admin-ui:yarn + cmds: + - ./tasks/lint/js + + lint:lua: + deps: + - test-deps:luacheck + cmds: + - ./tasks/lint/lua + + lint:ruby: + deps: + - test-deps:bundle + cmds: + - ./tasks/lint/ruby + + lint:shell: + deps: + - test-deps:shellcheck + cmds: + - ./tasks/lint/shell + + lint: + cmds: + - task: lint:js + - task: lint:lua + - task: lint:ruby + - task: lint:shell + + outdated: + cmds: + - ./tasks/outdated + + test: + deps: + - all + - test-deps + cmds: + - ./tasks/test/default + + test:circle-ci: + deps: + - all + - test-deps + cmds: + - ./tasks/test/circle-ci + + distclean: + cmds: + - ./tasks/distclean + + install: + cmds: + - ./tasks/install + + package: + cmds: + - ./tasks/package + + install-system-build-dependencies: + cmds: + - ./tasks/install-system-build-dependencies + + default: + cmds: + - task: all diff --git a/bin/api-umbrella-env b/bin/api-umbrella-env index 2d88f4c65..491596127 100644 --- a/bin/api-umbrella-env +++ b/bin/api-umbrella-env @@ -59,9 +59,9 @@ export LD_LIBRARY_PATH="$API_UMBRELLA_EMBEDDED_ROOT/openresty/luajit/lib:$API_UM # Note that we purposefully don't use any of the default Lua load paths (like # /usr/local) so that other Lua packages on the system aren't picked up (since # they might conflict). -export LUA_PATH="$API_UMBRELLA_EMBEDDED_ROOT/apps/core/shared/vendor/resty_modules/lualib/?.lua;\ -$API_UMBRELLA_EMBEDDED_ROOT/apps/core/shared/vendor/share/lua/5.1/?.lua;\ -$API_UMBRELLA_EMBEDDED_ROOT/apps/core/shared/vendor/share/lua/5.1/?/init.lua;\ +export LUA_PATH="$API_UMBRELLA_EMBEDDED_ROOT/apps/core/shared/vendor/lua/resty_modules/lualib/?.lua;\ +$API_UMBRELLA_EMBEDDED_ROOT/apps/core/shared/vendor/lua/share/lua/5.1/?.lua;\ +$API_UMBRELLA_EMBEDDED_ROOT/apps/core/shared/vendor/lua/share/lua/5.1/?/init.lua;\ $API_UMBRELLA_EMBEDDED_ROOT/openresty/lualib/?.lua;\ $API_UMBRELLA_EMBEDDED_ROOT/openresty/lualib/?/init.lua;\ $API_UMBRELLA_EMBEDDED_ROOT/openresty/luajit/share/luajit-2.1.0-beta2/?.lua;\ @@ -71,8 +71,8 @@ $API_UMBRELLA_EMBEDDED_ROOT/openresty/luajit/share/lua/5.1/?/init.lua" if [ -n "$API_UMBRELLA_SRC_ROOT" ]; then export LUA_PATH="$API_UMBRELLA_SRC_ROOT/src/?.lua;$LUA_PATH" fi -export LUA_CPATH="$API_UMBRELLA_EMBEDDED_ROOT/apps/core/shared/vendor/resty_modules/?.so;\ -$API_UMBRELLA_EMBEDDED_ROOT/apps/core/shared/vendor/lib/lua/5.1/?.so;\ +export LUA_CPATH="$API_UMBRELLA_EMBEDDED_ROOT/apps/core/shared/vendor/lua/resty_modules/?.so;\ +$API_UMBRELLA_EMBEDDED_ROOT/apps/core/shared/vendor/lua/lib/lua/5.1/?.so;\ $API_UMBRELLA_EMBEDDED_ROOT/openresty/lualib/?.so;\ $API_UMBRELLA_EMBEDDED_ROOT/openresty/luajit/lib/lua/5.1/?.so" diff --git a/build/cmake/app-deps.cmake b/build/cmake/app-deps.cmake deleted file mode 100644 index 8c811049b..000000000 --- a/build/cmake/app-deps.cmake +++ /dev/null @@ -1,3 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/build/cmake/app-deps/core-lua-deps.cmake) - -add_custom_target(app-deps ALL DEPENDS ${STAMP_DIR}/core-lua-deps) diff --git a/build/cmake/app-deps/core-lua-deps.cmake b/build/cmake/app-deps/core-lua-deps.cmake deleted file mode 100644 index fa2aed94d..000000000 --- a/build/cmake/app-deps/core-lua-deps.cmake +++ /dev/null @@ -1,136 +0,0 @@ -set(LUAROCK_ARGPARSE_VERSION 0.6.0-1) -set(LUAROCK_ARGPARSE_HASH 6656139dd66430075aa2093556857a84) -set(LUAROCK_CMSGPACK_VERSION 0.4.0-0) -set(LUAROCK_CMSGPACK_HASH f459d16fffdbbc85e582803321b3cec9) -set(LUAROCK_ICONV_VERSION 7-3) -set(LUAROCK_ICONV_HASH 138d21a895d267f09ff40fcb75324f74) -set(LUAROCK_INSPECT_VERSION 3.1.1-0) -set(LUAROCK_INSPECT_HASH 8a8a05f10b07a603e44e4f8b39bddd35) -set(LUAROCK_LUAPOSIX_VERSION 34.0.4-1) -set(LUAROCK_LUAPOSIX_HASH e584252902055ee40f250a1a304ec18e) -set(LUAROCK_LUSTACHE_VERSION 1.3.1-0) -set(LUAROCK_LUSTACHE_HASH 840ecd41bf19ed1751916de2cd46229e) -set(LUAROCK_LYAML_VERSION 6.2.2-1) -set(LUAROCK_LYAML_HASH d8c8c11db09bfc3f82838d0195d7cf04) -set(LUAROCK_PENLIGHT_VERSION 1.5.4-1) -set(LUAROCK_PENLIGHT_HASH 8f4e6b4c7e851c28cb3e95be728d6507) -set(LUAROCK_RESTY_UUID_VERSION 1.1-1) -set(LUAROCK_RESTY_UUID_HASH d14ae99d6f18edd5c934e6050e974c5e) -set(LUA_LUASOCKET_VERSION 4df569e9f867432f25f0bfbfa56b0962feb3326e) -set(LUA_LUASOCKET_HASH 8e95251f3aec7dc5bd732c78bb25192b) -set(LUA_RESTY_LOGGER_SOCKET_VERSION 15cc1c256e55b8e68ec9b220b6883c227a763d4e) -set(LUA_RESTY_LOGGER_SOCKET_HASH efe14697a8c4be612c011f54fce06191) -set(LUA_RESTY_SHCACHE_VERSION fb2e275c2cdca08eaa34a7b73375e41ac3eff200) -set(LUA_RESTY_SHCACHE_HASH 5d3cbcf8fbad1954cdcb3826afa41afe) -set(OPM_ICU_DATE_VERSION 857990ba72cf48f7ae20dfb861a783231b5a2e79) -set(OPM_ICU_DATE_HASH 580f4a650782556266cc341630d39f63) -set(OPM_LIBCIDR_VERSION 0.1.3) -set(OPM_LIBCIDR_HASH 9d995b83a7d857fcdec949725711b784) -set(OPM_RESTY_HTTP_VERSION 0.12) -set(OPM_RESTY_HTTP_HASH edc5d6deb82c1f5f628e382290c79209) -set(OPM_RESTY_TXID_VERSION 1.0.0) -set(OPM_RESTY_TXID_HASH 0c2ebfef460d537316e52f696d8bbfb7) - -# LuaRock app dependencies -luarocks_install(argparse ${LUAROCK_ARGPARSE_VERSION} ${LUAROCK_ARGPARSE_HASH}) -luarocks_install(inspect ${LUAROCK_INSPECT_VERSION} ${LUAROCK_INSPECT_HASH}) -luarocks_install(lua-cmsgpack ${LUAROCK_CMSGPACK_VERSION} ${LUAROCK_CMSGPACK_HASH}) -luarocks_install(lua-iconv ${LUAROCK_ICONV_VERSION} ${LUAROCK_ICONV_HASH}) -luarocks_install(lua-resty-uuid ${LUAROCK_RESTY_UUID_VERSION} ${LUAROCK_RESTY_UUID_HASH}) -luarocks_install(luaposix ${LUAROCK_LUAPOSIX_VERSION} ${LUAROCK_LUAPOSIX_HASH}) -luarocks_install(lustache ${LUAROCK_LUSTACHE_VERSION} ${LUAROCK_LUSTACHE_HASH}) -luarocks_install(lyaml ${LUAROCK_LYAML_VERSION} ${LUAROCK_LYAML_HASH}) -luarocks_install(penlight ${LUAROCK_PENLIGHT_VERSION} ${LUAROCK_PENLIGHT_HASH}) - -# OPM app dependencies -opm_install(lua-libcidr-ffi GUI ${OPM_LIBCIDR_VERSION} ${OPM_LIBCIDR_HASH} libcidr) -opm_install(lua-resty-http pintsized ${OPM_RESTY_HTTP_VERSION} ${OPM_RESTY_HTTP_HASH}) -opm_install(lua-resty-txid GUI ${OPM_RESTY_TXID_VERSION} ${OPM_RESTY_TXID_HASH}) - -ExternalProject_Add( - opm_lua-icu-date - EXCLUDE_FROM_ALL 1 - DEPENDS luarocks - URL https://github.com/GUI/lua-icu-date/archive/${OPM_ICU_DATE_VERSION}.tar.gz - URL_HASH MD5=${OPM_ICU_DATE_HASH} - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND ${LUAROCKS_CMD} --tree=${VENDOR_DIR} make --local icu-date-git-1.rockspec -) - -# Other Lua app dependencies (non-luarocks) -ExternalProject_Add( - lua_luasocket_url - EXCLUDE_FROM_ALL 1 - DEPENDS luarocks - URL https://github.com/diegonehab/luasocket/archive/${LUA_LUASOCKET_VERSION}.tar.gz - URL_HASH MD5=${LUA_LUASOCKET_HASH} - # Just install the URL parsing library from luasocket (rather than the whole - # luarocks, since we don't need the other parts, and the luarock is somewhat - # outdated). In order to just install this one file, patch it to work without - # the base luasocket library present (it doesn't actually use the base stuff - # for anything). - PATCH_COMMAND sed -i -e "s%local socket = require.*%local socket = {}%" src/url.lua - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND install -D -m 644 /src/url.lua ${VENDOR_LUA_DIR}/socket/url.lua -) - -ExternalProject_Add( - lua_resty_logger_socket - EXCLUDE_FROM_ALL 1 - DEPENDS luarocks - URL https://github.com/cloudflare/lua-resty-logger-socket/archive/${LUA_RESTY_LOGGER_SOCKET_VERSION}.tar.gz - URL_HASH MD5=${LUA_RESTY_LOGGER_SOCKET_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND install -D -m 644 /lib/resty/logger/socket.lua ${VENDOR_LUA_DIR}/resty/logger/socket.lua -) - -ExternalProject_Add( - lua_resty_shcache - EXCLUDE_FROM_ALL 1 - DEPENDS luarocks - URL https://github.com/cloudflare/lua-resty-shcache/archive/${LUA_RESTY_SHCACHE_VERSION}.tar.gz - URL_HASH MD5=${LUA_RESTY_SHCACHE_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND install -D -m 644 /shcache.lua ${VENDOR_LUA_DIR}/shcache.lua -) - -set( - LUA_DEPS - lua_luasocket_url - lua_resty_logger_socket - lua_resty_shcache - luarock_argparse - luarock_inspect - luarock_lua-cmsgpack - luarock_lua-iconv - luarock_lua-resty-uuid - luarock_luaposix - luarock_lustache - luarock_lyaml - luarock_penlight - opm_lua-icu-date - opm_lua-libcidr-ffi - opm_lua-resty-http - opm_lua-resty-txid -) - -# Also depend on the internal stamp files used by ExternalProject_Add, since -# add_custom_command seems to require files to properly work when updates -# occur (we can't just specify the ExternalProject_Add target names or -# updates aren't detected). But we still need to depend on the project names -# directly for the initial install dependency ordering. -foreach(LUA_DEP ${LUA_DEPS}) - list(APPEND LUA_DEPS_DEPENDS ${LUA_DEP}) - list(APPEND LUA_DEPS_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${LUA_DEP}-complete) -endforeach() - -add_custom_command( - OUTPUT ${STAMP_DIR}/core-lua-deps - DEPENDS ${LUA_DEPS_DEPENDS} - COMMAND touch ${STAMP_DIR}/core-lua-deps -) diff --git a/build/cmake/app.cmake b/build/cmake/app.cmake deleted file mode 100644 index 35e6dda1c..000000000 --- a/build/cmake/app.cmake +++ /dev/null @@ -1,8 +0,0 @@ -# Define a timestamped release name for our app installations. Base this on the -# last git commit timestamp so installs are consistent for each git commit. -get_git_timestamp(RELEASE_TIMESTAMP) - -include(${CMAKE_SOURCE_DIR}/build/cmake/app/core.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/app/static-site.cmake) - -add_custom_target(app ALL DEPENDS ${STAMP_DIR}/core api_umbrella_static_site) diff --git a/build/cmake/app/core-admin-ui.cmake b/build/cmake/app/core-admin-ui.cmake deleted file mode 100644 index c518cfd54..000000000 --- a/build/cmake/app/core-admin-ui.cmake +++ /dev/null @@ -1,52 +0,0 @@ -file(GLOB_RECURSE admin_ui_files - ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/app/*.hbs - ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/app/*.html - ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/app/*.js - ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/app/*.scss - ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/config/*.js - ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/lib/*.js -) -add_custom_command( - OUTPUT - ${STAMP_DIR}/core-admin-ui-build-dir - ${CORE_BUILD_DIR}/tmp/admin-ui-build/package.json - DEPENDS - ${admin_ui_files} - ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/ember-cli-build.js - ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/package.json - ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/yarn.lock - COMMAND mkdir -p ${CORE_BUILD_DIR}/tmp/admin-ui-build - COMMAND rsync -a -v --delete-after "--filter=:- ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/.gitignore" --exclude=/dist ${CMAKE_SOURCE_DIR}/src/api-umbrella/admin-ui/ ${CORE_BUILD_DIR}/tmp/admin-ui-build/ - COMMAND touch ${STAMP_DIR}/core-admin-ui-build-dir -) - -add_custom_command( - OUTPUT - ${STAMP_DIR}/core-admin-ui-yarn-install - ${CORE_BUILD_DIR}/tmp/admin-ui-build/node_modules - DEPENDS - yarn - ${STAMP_DIR}/core-admin-ui-build-dir - COMMAND cd ${CORE_BUILD_DIR}/tmp/admin-ui-build && env PATH=${DEV_INSTALL_PREFIX}/bin:${DEFAULT_PATH} yarn install --frozen-lockfile - # In the CI environment, the "node-sass/vendor" directory seems to sometimes - # go away. A bit of a hack, but try to workaround this by forcing node-sass - # to be reinstalled if the vendor dir is missing. - # - # See: - # https://github.com/yarnpkg/yarn/issues/1981 - # https://github.com/yarnpkg/yarn/issues/1832 - # https://github.com/sass/node-sass/issues/1579 - COMMAND cd ${CORE_BUILD_DIR}/tmp/admin-ui-build && test -d node_modules/node-sass && test -d node_modules/node-sass/vendor || env PATH=${DEV_INSTALL_PREFIX}/bin:${DEFAULT_PATH} yarn add node-sass --force - COMMAND touch ${STAMP_DIR}/core-admin-ui-yarn-install -) - -add_custom_command( - OUTPUT - ${STAMP_DIR}/core-admin-ui-build - ${CORE_BUILD_DIR}/tmp/admin-ui-build/dist - DEPENDS - ${STAMP_DIR}/core-admin-ui-build-dir - ${STAMP_DIR}/core-admin-ui-yarn-install - COMMAND cd ${CORE_BUILD_DIR}/tmp/admin-ui-build && rm -rf ./dist && env PATH=${DEV_INSTALL_PREFIX}/bin:${DEFAULT_PATH} ./node_modules/.bin/ember build --environment=production --output-path=./dist - COMMAND touch ${STAMP_DIR}/core-admin-ui-build -) diff --git a/build/cmake/app/core-web-app.cmake b/build/cmake/app/core-web-app.cmake deleted file mode 100644 index 2d1d07758..000000000 --- a/build/cmake/app/core-web-app.cmake +++ /dev/null @@ -1,51 +0,0 @@ -add_custom_command( - OUTPUT - ${STAMP_DIR}/core-web-app-bundle - ${WORK_DIR}/src/web-app/.bundle - ${VENDOR_DIR}/bundle - DEPENDS - bundler - ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/Gemfile - ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/Gemfile.lock - COMMAND env PATH=${STAGE_EMBEDDED_PATH} BUNDLE_GEMFILE=${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/Gemfile BUNDLE_APP_CONFIG=${WORK_DIR}/src/web-app/.bundle bundle config --local build.nokogiri --use-system-libraries - COMMAND env PATH=${STAGE_EMBEDDED_PATH} BUNDLE_GEMFILE=${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/Gemfile BUNDLE_APP_CONFIG=${WORK_DIR}/src/web-app/.bundle bundle install --path=${VENDOR_DIR}/bundle - COMMAND touch -c ${WORK_DIR}/src/web-app/.bundle - COMMAND touch -c ${VENDOR_DIR}/bundle - COMMAND touch ${STAMP_DIR}/core-web-app-bundle -) - -file(GLOB_RECURSE web_app_public_files - ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/public/*.html -) -add_custom_command( - OUTPUT ${STAMP_DIR}/core-web-app-public - DEPENDS ${web_app_public_files} - COMMAND mkdir -p ${CORE_BUILD_DIR}/tmp/web-app-public - COMMAND rsync -a --delete-after ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/public/ ${CORE_BUILD_DIR}/tmp/web-app-public/ - COMMAND touch ${STAMP_DIR}/core-web-app-public -) - -file(GLOB_RECURSE web_asset_files - ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/app/assets/*.css - ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/app/assets/*.scss - ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/app/assets/*.erb - ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/app/assets/*.js -) -add_custom_command( - OUTPUT ${STAMP_DIR}/core-web-app-precompile - DEPENDS - ${STAMP_DIR}/core-web-app-bundle - ${web_asset_files} - ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/config/initializers/assets.rb - COMMAND env PATH=${STAGE_EMBEDDED_PATH} BUNDLE_GEMFILE=${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/Gemfile BUNDLE_APP_CONFIG=${WORK_DIR}/src/web-app/.bundle RAILS_TMP_PATH=${CORE_BUILD_DIR}/tmp/web-app-tmp RAILS_PUBLIC_PATH=${CORE_BUILD_DIR}/tmp/web-app-build RAILS_ENV=production RAILS_SECRET_TOKEN=temp RAILS_ASSETS_PRECOMPILE=true bundle exec rake -f ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/Rakefile assets:clobber assets:precompile - COMMAND touch ${STAMP_DIR}/core-web-app-precompile -) - -add_custom_command( - OUTPUT - ${STAMP_DIR}/core-web-app-build - DEPENDS - ${STAMP_DIR}/core-web-app-public - ${STAMP_DIR}/core-web-app-precompile - COMMAND touch ${STAMP_DIR}/core-web-app-build -) diff --git a/build/cmake/app/core.cmake b/build/cmake/app/core.cmake deleted file mode 100644 index e231b8cd3..000000000 --- a/build/cmake/app/core.cmake +++ /dev/null @@ -1,141 +0,0 @@ -set(CORE_BUILD_DIR ${WORK_DIR}/src/api-umbrella-core) - -include(${CMAKE_SOURCE_DIR}/build/cmake/app/core-admin-ui.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/app/core-web-app.cmake) - -# Copy the vendored libraries into the shared build directory. -add_custom_command( - OUTPUT ${CORE_BUILD_DIR}/shared/vendor - DEPENDS - ${STAMP_DIR}/core-web-app-bundle - ${STAMP_DIR}/core-lua-deps - COMMAND mkdir -p ${CORE_BUILD_DIR}/shared/vendor - COMMAND rsync -a --delete-after ${VENDOR_DIR}/ ${CORE_BUILD_DIR}/shared/vendor/ - COMMAND touch -c ${CORE_BUILD_DIR}/shared/vendor -) - -# Copy the code into a build release directory. -file(GLOB_RECURSE core_files - ${CMAKE_SOURCE_DIR}/bin/* - ${CMAKE_SOURCE_DIR}/config/* - ${CMAKE_SOURCE_DIR}/templates/* - ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/Gemfile* -) -add_custom_command( - OUTPUT ${STAMP_DIR}/core-build-release-dir - DEPENDS ${core_files} - COMMAND mkdir -p ${CORE_BUILD_DIR}/releases/0 - COMMAND rsync -a --delete-after --delete-excluded "--filter=:- ${CMAKE_SOURCE_DIR}/.gitignore" --include=/templates/etc/perp/.boot --exclude=.* --exclude=/templates/etc/test-env* --exclude=/templates/etc/perp/test-env* --exclude=/src/api-umbrella/web-app/spec --exclude=/src/api-umbrella/web-app/app/assets --include=/bin/*** --include=/config/*** --include=/LICENSE.txt --include=/templates/*** --include=/src/*** --exclude=* ${CMAKE_SOURCE_DIR}/ ${CORE_BUILD_DIR}/releases/0/ - COMMAND touch ${STAMP_DIR}/core-build-release-dir -) - -add_custom_command( - OUTPUT - ${STAMP_DIR}/core-build-install-dist - ${CORE_BUILD_DIR}/releases/0/build/dist/admin-ui - ${CORE_BUILD_DIR}/releases/0/build/dist/web-app-public - DEPENDS - ${STAMP_DIR}/core-admin-ui-build - ${STAMP_DIR}/core-web-app-build - ${STAMP_DIR}/core-build-release-dir - COMMAND mkdir -p ${CORE_BUILD_DIR}/releases/0/build/dist/web-app-public - COMMAND rsync -a --delete-after ${CORE_BUILD_DIR}/tmp/admin-ui-build/dist/ ${CORE_BUILD_DIR}/releases/0/build/dist/admin-ui/ - COMMAND rsync -a --delete-after ${CORE_BUILD_DIR}/tmp/web-app-public/ ${CORE_BUILD_DIR}/releases/0/build/dist/web-app-public/ - COMMAND rsync -a --delete-after ${CORE_BUILD_DIR}/tmp/web-app-build/web-assets/ ${CORE_BUILD_DIR}/releases/0/build/dist/web-app-public/web-assets/ - COMMAND touch ${STAMP_DIR}/core-build-install-dist -) - -# Create a symlink to the latest release. -add_custom_command( - OUTPUT ${STAMP_DIR}/core-build-current-symlink - DEPENDS ${STAMP_DIR}/core-build-release-dir - WORKING_DIRECTORY ${CORE_BUILD_DIR} - COMMAND ln -snf releases/0 ./current - COMMAND touch ${STAMP_DIR}/core-build-current-symlink -) - -# Create a symlink to the shared vendor directory within the release. -add_custom_command( - OUTPUT ${STAMP_DIR}/core-build-release-vendor-symlink - DEPENDS - ${STAMP_DIR}/core-build-release-dir - ${CORE_BUILD_DIR}/shared/vendor - WORKING_DIRECTORY ${CORE_BUILD_DIR}/releases/0 - COMMAND ln -snf ../../shared/vendor ./vendor - COMMAND touch ${STAMP_DIR}/core-build-release-vendor-symlink -) - -# Copy the gems into the build directory and cleanup for production use. -add_custom_command( - OUTPUT ${CORE_BUILD_DIR}/releases/0/src/api-umbrella/web-app/.bundle/config - DEPENDS - ${STAMP_DIR}/core-build-release-dir - ${STAMP_DIR}/core-build-release-vendor-symlink - WORKING_DIRECTORY ${CORE_BUILD_DIR}/releases/0/src/api-umbrella/web-app - # Disable all non-production gems and remove any old, unused gems. - COMMAND env PATH=${STAGE_EMBEDDED_PATH} bundle config --local build.nokogiri --use-system-libraries - COMMAND env PATH=${STAGE_EMBEDDED_PATH} bundle install --path=../../../vendor/bundle --without=development test assets --clean --deployment - # Purge gem files we don't need to make for a lighter package distribution. - COMMAND cd ${CORE_BUILD_DIR}/shared/vendor/bundle && rm -rf ruby/*/cache ruby/*/gems/*/test* ruby/*/gems/*/spec ruby/*/bundler/gems/*/test* ruby/*/bundler/gems/*/spec ruby/*/bundler/gems/*/.git - COMMAND touch -c ${CORE_BUILD_DIR}/releases/0/src/api-umbrella/web-app/.bundle/config -) - -# -# Build the release dir. -# -add_custom_command( - OUTPUT ${STAMP_DIR}/core-build-release - DEPENDS - ${STAMP_DIR}/core-build-release-dir - ${STAMP_DIR}/core-build-release-vendor-symlink - ${STAMP_DIR}/core-build-current-symlink - ${CORE_BUILD_DIR}/releases/0/src/api-umbrella/web-app/.bundle/config - COMMAND touch ${STAMP_DIR}/core-build-release -) - -# Copy the built shared directory to the stage install path. -add_custom_command( - OUTPUT ${STAGE_EMBEDDED_DIR}/apps/core - DEPENDS ${CORE_BUILD_DIR}/shared/vendor - DEPENDS ${STAMP_DIR}/core-build-release - DEPENDS ${STAMP_DIR}/core-build-install-dist - COMMAND mkdir -p ${STAGE_EMBEDDED_DIR}/apps/core - COMMAND rsync -a --delete-after --delete-excluded --exclude=/tmp ${CORE_BUILD_DIR}/ ${STAGE_EMBEDDED_DIR}/apps/core/ - COMMAND touch -c ${STAGE_EMBEDDED_DIR}/apps/core -) - -# Create a symlink for the main "api-umbrella" binary. -add_custom_command( - OUTPUT ${STAMP_DIR}/core-api-umbrella-bin-symlink - DEPENDS ${STAGE_EMBEDDED_DIR}/apps/core - COMMAND mkdir -p ${STAGE_PREFIX_DIR}/bin - COMMAND cd ${STAGE_PREFIX_DIR}/bin && ln -snf ../embedded/apps/core/current/bin/api-umbrella ./api-umbrella - COMMAND touch ${STAMP_DIR}/core-api-umbrella-bin-symlink -) -add_custom_command( - OUTPUT ${STAMP_DIR}/core-api-umbrella-env-bin-symlink - DEPENDS ${STAGE_EMBEDDED_DIR}/apps/core - COMMAND mkdir -p ${STAGE_PREFIX_DIR}/bin - COMMAND cd ${STAGE_PREFIX_DIR}/bin && ln -snf ../embedded/apps/core/current/bin/api-umbrella-env ./api-umbrella-env - COMMAND touch ${STAMP_DIR}/core-api-umbrella-env-bin-symlink -) -add_custom_command( - OUTPUT ${STAMP_DIR}/core-api-umbrella-exec-bin-symlink - DEPENDS ${STAGE_EMBEDDED_DIR}/apps/core - COMMAND mkdir -p ${STAGE_PREFIX_DIR}/bin - COMMAND cd ${STAGE_PREFIX_DIR}/bin && ln -snf ../embedded/apps/core/current/bin/api-umbrella-exec ./api-umbrella-exec - COMMAND touch ${STAMP_DIR}/core-api-umbrella-exec-bin-symlink -) - -# -# Install the core app into the stage location. -# -add_custom_command( - OUTPUT ${STAMP_DIR}/core - DEPENDS - ${STAGE_EMBEDDED_DIR}/apps/core - ${STAMP_DIR}/core-api-umbrella-bin-symlink - ${STAMP_DIR}/core-api-umbrella-env-bin-symlink - ${STAMP_DIR}/core-api-umbrella-exec-bin-symlink - COMMAND touch ${STAMP_DIR}/core -) diff --git a/build/cmake/app/static-site.cmake b/build/cmake/app/static-site.cmake deleted file mode 100644 index 88e449b80..000000000 --- a/build/cmake/app/static-site.cmake +++ /dev/null @@ -1,20 +0,0 @@ -# api-umbrella-static-site: Example website content - -set(API_UMBRELLA_STATIC_SITE_VERSION c02b8869cafb063deb7f9436d0137b0ea6e652aa) -set(API_UMBRELLA_STATIC_SITE_HASH 07dbd5e6d96e62a9ad6b725b14f727a1) - -ExternalProject_Add( - api_umbrella_static_site - EXCLUDE_FROM_ALL 1 - DEPENDS bundler nodejs - URL https://github.com/NREL/api-umbrella-static-site/archive/${API_UMBRELLA_STATIC_SITE_VERSION}.tar.gz - URL_HASH MD5=${API_UMBRELLA_STATIC_SITE_HASH} - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND env PATH=${STAGE_EMBEDDED_PATH} bundle config --local build.nokogiri --use-system-libraries - COMMAND env PATH=${STAGE_EMBEDDED_PATH} bundle install --path=${VENDOR_DIR}/bundle - BUILD_COMMAND env PATH=${DEV_PATH} bundle exec middleman build - INSTALL_COMMAND rm -rf ${STAGE_EMBEDDED_DIR}/apps/static-site/releases - COMMAND mkdir -p ${STAGE_EMBEDDED_DIR}/apps/static-site/releases/0/build - COMMAND rsync -a /build/ ${STAGE_EMBEDDED_DIR}/apps/static-site/releases/0/build/ - COMMAND cd ${STAGE_EMBEDDED_DIR}/apps/static-site && ln -snf releases/0 ./current -) diff --git a/build/cmake/build-deps.cmake b/build/cmake/build-deps.cmake deleted file mode 100644 index 238a906cc..000000000 --- a/build/cmake/build-deps.cmake +++ /dev/null @@ -1,3 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/build/cmake/build-deps/nodejs.cmake) - -add_custom_target(build-deps ALL DEPENDS nodejs yarn) diff --git a/build/cmake/build-deps/nodejs.cmake b/build/cmake/build-deps/nodejs.cmake deleted file mode 100644 index 4c1a4e242..000000000 --- a/build/cmake/build-deps/nodejs.cmake +++ /dev/null @@ -1,30 +0,0 @@ -# NodeJS: For building admin-ui Ember app. - -set(NODEJS_VERSION 8.11.2) -set(NODEJS_HASH 213599127d24496cbf1cbb2a7c51060a3506d6b11132c59bb7f9f8a0edd210a7) -set(YARN_VERSION 1.7.0) -set(YARN_HASH e149b4cc0c2cb903551a0b857a2b3c78) - -ExternalProject_Add( - nodejs - EXCLUDE_FROM_ALL 1 - URL https://nodejs.org/dist/v${NODEJS_VERSION}/node-v${NODEJS_VERSION}-linux-x64.tar.xz - URL_HASH SHA256=${NODEJS_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND rsync -a -v / ${DEV_INSTALL_PREFIX}/ -) - -ExternalProject_Add( - yarn - EXCLUDE_FROM_ALL 1 - DEPENDS nodejs - URL https://github.com/yarnpkg/yarn/releases/download/v${YARN_VERSION}/yarn-v${YARN_VERSION}.tar.gz - URL_HASH MD5=${YARN_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND rsync -a -v --delete / ${DEV_INSTALL_PREFIX}/yarn/ - COMMAND cd ${DEV_INSTALL_PREFIX}/bin && ln -snf ../yarn/bin/yarn ./yarn - # Remove the previous bin symlink that was necessary. - COMMAND rm -f ${DEV_INSTALL_PREFIX}/bin/yarn.js -) diff --git a/build/cmake/deps.cmake b/build/cmake/deps.cmake deleted file mode 100644 index 46eeb166a..000000000 --- a/build/cmake/deps.cmake +++ /dev/null @@ -1,25 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/build/cmake/deps/elasticsearch.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/deps/libcidr.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/deps/mongodb.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/deps/mora.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/deps/openresty.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/deps/perp.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/deps/rsyslog.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/deps/ruby.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/deps/runit_svlogd.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/deps/trafficserver.cmake) - -add_custom_target(deps ALL DEPENDS - bundler - elasticsearch - geolitecity - libcidr - luarocks - mongodb - mora - openresty - perp - rsyslog - runit_svlogd - trafficserver -) diff --git a/build/cmake/deps/elasticsearch.cmake b/build/cmake/deps/elasticsearch.cmake deleted file mode 100644 index d69aafda7..000000000 --- a/build/cmake/deps/elasticsearch.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# Elasticsearch: Analytics database - -find_package(Java 1.7 REQUIRED COMPONENTS Runtime) -require_program(rsync) - -set(ELASTICSEARCH_VERSION 2.4.6) -set(ELASTICSEARCH_HASH c3441bef89cd91206edf3cf3bd5c4b62550e60a9) - -ExternalProject_Add( - elasticsearch - EXCLUDE_FROM_ALL 1 - URL https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz - URL_HASH SHA1=${ELASTICSEARCH_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND rsync -a -v --checksum --delete-after / ${STAGE_EMBEDDED_DIR}/elasticsearch/ - COMMAND mkdir -p ${STAGE_EMBEDDED_DIR}/elasticsearch/plugins -) diff --git a/build/cmake/deps/libcidr.cmake b/build/cmake/deps/libcidr.cmake deleted file mode 100644 index 5c5758849..000000000 --- a/build/cmake/deps/libcidr.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# libcidr: CIDR IP calculations for libcidr-ffi LuaRock - -set(LIBCIDR_VERSION 1.2.3) -set(LIBCIDR_HASH c5efcc7ae114fdaa5583f58dacecd9de) - -ExternalProject_Add( - libcidr - EXCLUDE_FROM_ALL 1 - URL https://www.over-yonder.net/~fullermd/projects/libcidr/libcidr-${LIBCIDR_VERSION}.tar.xz - URL_HASH MD5=${LIBCIDR_HASH} - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND make PREFIX=${INSTALL_PREFIX_EMBEDDED} - INSTALL_COMMAND make install NO_DOCS=1 NO_EXAMPLES=1 PREFIX=${INSTALL_PREFIX_EMBEDDED} DESTDIR=${STAGE_DIR} -) diff --git a/build/cmake/deps/libgeoip.cmake b/build/cmake/deps/libgeoip.cmake deleted file mode 100644 index fc31c4929..000000000 --- a/build/cmake/deps/libgeoip.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# libgeoip & GeoLiteCityv6.dat: GeoIP locations - -set(LIBGEOIP_VERSION 1.6.12) -set(LIBGEOIP_HASH 77d496cc40daa1dbc2b97365807d64d7) - -list(APPEND LIBGEOIP_CONFIGURE_CMD env) -list(APPEND LIBGEOIP_CONFIGURE_CMD /configure) -list(APPEND LIBGEOIP_CONFIGURE_CMD --prefix=${INSTALL_PREFIX_EMBEDDED}) - -ExternalProject_Add( - libgeoip - EXCLUDE_FROM_ALL 1 - URL https://github.com/maxmind/geoip-api-c/releases/download/v${LIBGEOIP_VERSION}/GeoIP-${LIBGEOIP_VERSION}.tar.gz - URL_HASH MD5=${LIBGEOIP_HASH} - CONFIGURE_COMMAND ${LIBGEOIP_CONFIGURE_CMD} - INSTALL_COMMAND make install DESTDIR=${STAGE_DIR} - COMMAND find ${STAGE_EMBEDDED_DIR}/bin/ -name geoiplookup* -exec chrpath -d {} $ -) - -execute_process(COMMAND date -u +%Y%m%d OUTPUT_VARIABLE CURRENT_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) -ExternalProject_Add( - # Make the project name dynamic based on the current date. This forces a - # re-download once per day. This helps ensure development and CI environments - # are using fresh GeoIP data files without downloading on each run. - geolitecity-${CURRENT_DATE} - EXCLUDE_FROM_ALL 1 - URL https://geolite.maxmind.com/download/geoip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz - DOWNLOAD_NO_EXTRACT 1 - # Since we re-download every day as a separate project name, this cleans up - # any old downloads in the work directory. - CONFIGURE_COMMAND find ${CMAKE_BINARY_DIR}/${EP_BASE} -maxdepth 2 -name geolitecity* -not -name geolitecity-${CURRENT_DATE}* -print -exec rm -rf {} $ - BUILD_COMMAND gunzip -c > /GeoLiteCityv6.dat - INSTALL_COMMAND install -D -m 644 /GeoLiteCityv6.dat ${STAGE_EMBEDDED_DIR}/var/db/geoip/city-v6.dat -) -add_custom_target(geolitecity DEPENDS geolitecity-${CURRENT_DATE}) diff --git a/build/cmake/deps/mongodb.cmake b/build/cmake/deps/mongodb.cmake deleted file mode 100644 index cf0188d03..000000000 --- a/build/cmake/deps/mongodb.cmake +++ /dev/null @@ -1,17 +0,0 @@ -# MongoDB: General database - -set(MONGODB_VERSION 3.2.20) -set(MONGODB_HASH 01f7660d86b3de679ce388eaa681286a) - -ExternalProject_Add( - mongodb - EXCLUDE_FROM_ALL 1 - URL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB_VERSION}.tgz - URL_HASH MD5=${MONGODB_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND rsync -a -v / ${STAGE_EMBEDDED_DIR}/ - # Trim our own distribution by removing some larger files we don't need for - # API Umbrella. - COMMAND rm -f ${STAGE_EMBEDDED_DIR}/bin/bsondump ${STAGE_EMBEDDED_DIR}/bin/mongoexport ${STAGE_EMBEDDED_DIR}/bin/mongofiles ${STAGE_EMBEDDED_DIR}/bin/mongoimport ${STAGE_EMBEDDED_DIR}/bin/mongooplog ${STAGE_EMBEDDED_DIR}/bin/mongoperf ${STAGE_EMBEDDED_DIR}/bin/mongos -) diff --git a/build/cmake/deps/mora.cmake b/build/cmake/deps/mora.cmake deleted file mode 100644 index 563565756..000000000 --- a/build/cmake/deps/mora.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# Mora: HTTP API for MongoDB (allowing OpenResty connectivity) - -set(GOLANG_VERSION 1.10.2) -set(GOLANG_HASH 4b677d698c65370afa33757b6954ade60347aaca310ea92a63ed717d7cb0c2ff) -set(MORA_VERSION 8127901857cf88d3f0902708b25ad930354973a3) -set(MORA_HASH b86cea913596370cd58fce89b23acd97) - -# Built with Go -ExternalProject_Add( - golang - EXCLUDE_FROM_ALL 1 - URL https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz - URL_HASH SHA256=${GOLANG_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" -) -ExternalProject_Get_Property(golang SOURCE_DIR) -set(GOLANG_SOURCE_DIR ${SOURCE_DIR}) - -ExternalProject_Add( - mora - DEPENDS golang - URL https://github.com/emicklei/mora/archive/${MORA_VERSION}.tar.gz - URL_HASH MD5=${MORA_HASH} - SOURCE_DIR ${WORK_DIR}/gocode/src/github.com/emicklei/mora - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND env PATH=${GOLANG_SOURCE_DIR}/bin:${WORK_DIR}/gocode/bin:${DEFAULT_PATH} GOPATH=${WORK_DIR}/gocode GOROOT=${GOLANG_SOURCE_DIR} go install - INSTALL_COMMAND install -D -m 755 ${WORK_DIR}/gocode/bin/mora ${STAGE_EMBEDDED_DIR}/bin/mora -) diff --git a/build/cmake/deps/openresty.cmake b/build/cmake/deps/openresty.cmake deleted file mode 100644 index d0f948e9a..000000000 --- a/build/cmake/deps/openresty.cmake +++ /dev/null @@ -1,100 +0,0 @@ -# OpenResty and nginx plugins - -include(${CMAKE_SOURCE_DIR}/build/cmake/deps/libgeoip.cmake) - -set(LUAROCKS_VERSION 2.4.4) -set(LUAROCKS_HASH 04e8b19d565e86b1d08f745adc4b1a56) -set(OPENRESTY_VERSION 1.13.6.2) -set(OPENRESTY_HASH d95bc4bbe15e4b045a0593b4ecc0db38) -set(OPENSSL_VERSION 1.0.2o) -set(OPENSSL_HASH ec3f5c9714ba0fd45cb4e087301eb1336c317e0d20b575a125050470e8089e4d) -set(PCRE_VERSION 8.42) -set(PCRE_HASH 085b6aa253e0f91cae70b3cdbe8c1ac2) - -# Pull in newer version of PCRE (8.20+) for OpenResty to enable PCRE JIT. -ExternalProject_Add( - pcre - EXCLUDE_FROM_ALL 1 - URL https://ftp.pcre.org/pub/pcre/pcre-${PCRE_VERSION}.tar.bz2 - URL_HASH MD5=${PCRE_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" -) -ExternalProject_Get_Property(pcre SOURCE_DIR) -set(PCRE_SOURCE_DIR ${SOURCE_DIR}) - -# OpenResty's ssl_certificate_by_lua functionality requires OpenSSL 1.0.2e+ -ExternalProject_Add( - openssl - EXCLUDE_FROM_ALL 1 - URL https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz - URL_HASH SHA256=${OPENSSL_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" -) -ExternalProject_Get_Property(openssl SOURCE_DIR) -set(OPENSSL_SOURCE_DIR ${SOURCE_DIR}) - -list(APPEND OPENRESTY_CONFIGURE_CMD /configure) -list(APPEND OPENRESTY_CONFIGURE_CMD --prefix=${INSTALL_PREFIX_EMBEDDED}/openresty) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-cc-opt=-I${STAGE_EMBEDDED_DIR}/include) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-ld-opt=-L${STAGE_EMBEDDED_DIR}/lib) -list(APPEND OPENRESTY_CONFIGURE_CMD --error-log-path=stderr) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-ipv6) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-openssl=${OPENSSL_SOURCE_DIR}) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-pcre=${PCRE_SOURCE_DIR}) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-pcre-opt=-g) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-pcre-conf-opt=--enable-unicode-properties) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-pcre-jit) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-http_geoip_module) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-http_gunzip_module) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-http_gzip_static_module) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-http_realip_module) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-http_ssl_module) -list(APPEND OPENRESTY_CONFIGURE_CMD --with-http_stub_status_module) - -ExternalProject_Add( - openresty - EXCLUDE_FROM_ALL 1 - DEPENDS libgeoip openssl pcre - URL https://openresty.org/download/openresty-${OPENRESTY_VERSION}.tar.gz - URL_HASH MD5=${OPENRESTY_HASH} - BUILD_IN_SOURCE 1 - # Patch opm to allow it to pick up dynamic LUA_PATH and LUA_CPATH, since we - # need different paths while performing staged installations. - PATCH_COMMAND patch -p1 < ${CMAKE_SOURCE_DIR}/build/patches/openresty-opm.patch - # Similarly, patch openresty's configure process so it doesn't introduce a - # hard-coded path to nginx. This allows nginx to be picked up on the normal - # PATH semantics, so it can worked in staged environments at different - # locations. - COMMAND patch -p1 < ${CMAKE_SOURCE_DIR}/build/patches/openresty-cli.patch - CONFIGURE_COMMAND ${OPENRESTY_CONFIGURE_CMD} - # Wipe the .openssl directory inside the openssl dir, or else openresty - # will fail to build on rebuilds: https://trac.nginx.org/nginx/ticket/583 - BUILD_COMMAND COMMAND cd ${OPENSSL_SOURCE_DIR} && rm -rf .openssl - COMMAND make - INSTALL_COMMAND make install DESTDIR=${STAGE_DIR} - COMMAND chrpath -d ${STAGE_EMBEDDED_DIR}/openresty/nginx/sbin/nginx - COMMAND cd ${STAGE_EMBEDDED_DIR}/bin && ln -snf ../openresty/bin/opm ./opm - COMMAND cd ${STAGE_EMBEDDED_DIR}/bin && ln -snf ../openresty/bin/resty ./resty - COMMAND cd ${STAGE_EMBEDDED_DIR}/bin && ln -snf ../openresty/luajit/bin/luajit ./luajit - COMMAND mkdir -p ${STAGE_EMBEDDED_DIR}/sbin && cd ${STAGE_EMBEDDED_DIR}/sbin && ln -snf ../openresty/nginx/sbin/nginx ./nginx -) - -# LuaRocks: Lua dependency management -ExternalProject_Add( - luarocks - EXCLUDE_FROM_ALL 1 - DEPENDS openresty - URL http://luarocks.org/releases/luarocks-${LUAROCKS_VERSION}.tar.gz - URL_HASH MD5=${LUAROCKS_HASH} - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND /configure --prefix=${INSTALL_PREFIX_EMBEDDED}/openresty/luajit --with-lua=${STAGE_EMBEDDED_DIR}/openresty/luajit --with-lua-include=${STAGE_EMBEDDED_DIR}/openresty/luajit/include/luajit-2.1 --lua-suffix=jit - BUILD_COMMAND make build - INSTALL_COMMAND make install DESTDIR=${STAGE_DIR} - COMMAND cd ${STAGE_EMBEDDED_DIR}/bin && ln -snf ../openresty/luajit/bin/luarocks ./luarocks - COMMAND rm -rf ${VENDOR_DIR}/share/lua ${VENDOR_DIR}/lib/luarocks - COMMAND rm -rf ${TEST_VENDOR_DIR}/share/lua ${TEST_VENDOR_DIR}/lib/luarocks -) diff --git a/build/cmake/deps/perp.cmake b/build/cmake/deps/perp.cmake deleted file mode 100644 index 570667196..000000000 --- a/build/cmake/deps/perp.cmake +++ /dev/null @@ -1,19 +0,0 @@ -# Perp: Process supervision and control - -set(PERP_VERSION 2.07) -set(PERP_HASH a2acc7425d556d9635a25addcee9edb5) - -ExternalProject_Add( - perp - EXCLUDE_FROM_ALL 1 - URL http://b0llix.net/perp/distfiles/perp-${PERP_VERSION}.tar.gz - URL_HASH MD5=${PERP_HASH} - PATCH_COMMAND sed -i -e "s%BINDIR.*%BINDIR = ${INSTALL_PREFIX_EMBEDDED}/bin%" conf.mk - COMMAND sed -i -e "s%SBINDIR.*%SBINDIR = ${INSTALL_PREFIX_EMBEDDED}/sbin%" conf.mk - COMMAND sed -i -e "s%MANDIR.*%MANDIR = ${INSTALL_PREFIX_EMBEDDED}/share/man%" conf.mk - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND make - COMMAND make strip - INSTALL_COMMAND make install DESTDIR=${STAGE_DIR} -) diff --git a/build/cmake/deps/rsyslog.cmake b/build/cmake/deps/rsyslog.cmake deleted file mode 100644 index 23db137fb..000000000 --- a/build/cmake/deps/rsyslog.cmake +++ /dev/null @@ -1,69 +0,0 @@ -# rsyslog: Log buffering and processing - -set(LIBESTR_VERSION 0.1.10) -set(LIBESTR_HASH bd655e126e750edd18544b88eb1568d200a424a0c23f665eb14bbece07ac703c) -set(LIBFASTJSON_VERSION 0.99.8) -set(LIBFASTJSON_HASH 730713ad1d851def7ac8898f751bbfdd) -set(RSYSLOG_VERSION 8.35.0) -set(RSYSLOG_HASH d216a7f7c88341d5964657e61a33193c13d884c988822fced9fce3ab0b1f1082) - -find_package(CURL REQUIRED) -require_program(autoconf) -require_program(automake) -require_program(libtool) -pkg_check_modules(LIBUUID REQUIRED uuid) - -# Build libestr dependency for rsyslog, since Ubuntu 12.04's package is too old -# and CentOS 6's package has some pkg-config issues, so it's not picked up -# (https://bugzilla.redhat.com/show_bug.cgi?id=1152899). -ExternalProject_Add( - libestr - EXCLUDE_FROM_ALL 1 - URL http://libestr.adiscon.com/files/download/libestr-${LIBESTR_VERSION}.tar.gz - URL_HASH SHA256=${LIBESTR_HASH} - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND /configure --prefix=${INSTALL_PREFIX_EMBEDDED} - INSTALL_COMMAND make install DESTDIR=${STAGE_DIR} -) - -ExternalProject_Add( - libfastjson - EXCLUDE_FROM_ALL 1 - URL https://github.com/rsyslog/libfastjson/archive/v${LIBFASTJSON_VERSION}.tar.gz - URL_HASH MD5=${LIBFASTJSON_HASH} - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND sh autogen.sh - COMMAND /configure --prefix=${INSTALL_PREFIX_EMBEDDED} - INSTALL_COMMAND make install DESTDIR=${STAGE_DIR} -) - -list(APPEND RSYSLOG_DEPENDS libestr) -list(APPEND RSYSLOG_DEPENDS libfastjson) - -list(APPEND RSYSLOG_CONFIGURE_CMD env) -list(APPEND RSYSLOG_CONFIGURE_CMD LIBESTR_CFLAGS=-I${STAGE_EMBEDDED_DIR}/include) -list(APPEND RSYSLOG_CONFIGURE_CMD "LIBESTR_LIBS=-L${STAGE_EMBEDDED_DIR}/lib -lestr") -list(APPEND RSYSLOG_CONFIGURE_CMD LIBFASTJSON_CFLAGS=-I${STAGE_EMBEDDED_DIR}/include/libfastjson) -list(APPEND RSYSLOG_CONFIGURE_CMD "LIBFASTJSON_LIBS=-L${STAGE_EMBEDDED_DIR}/lib -lfastjson") -list(APPEND RSYSLOG_CONFIGURE_CMD /configure) -list(APPEND RSYSLOG_CONFIGURE_CMD --prefix=${INSTALL_PREFIX_EMBEDDED}) -list(APPEND RSYSLOG_CONFIGURE_CMD --disable-liblogging-stdlog) -list(APPEND RSYSLOG_CONFIGURE_CMD --disable-libgcrypt) -list(APPEND RSYSLOG_CONFIGURE_CMD --enable-imptcp) -list(APPEND RSYSLOG_CONFIGURE_CMD --enable-impstats) -list(APPEND RSYSLOG_CONFIGURE_CMD --enable-mmjsonparse) -list(APPEND RSYSLOG_CONFIGURE_CMD --enable-mmutf8fix) -list(APPEND RSYSLOG_CONFIGURE_CMD --enable-elasticsearch) - -ExternalProject_Add( - rsyslog - EXCLUDE_FROM_ALL 1 - DEPENDS ${RSYSLOG_DEPENDS} - URL http://www.rsyslog.com/download/files/download/rsyslog/rsyslog-${RSYSLOG_VERSION}.tar.gz - URL_HASH SHA256=${RSYSLOG_HASH} - CONFIGURE_COMMAND rm -rf && mkdir -p # Clean across version upgrades - COMMAND ${RSYSLOG_CONFIGURE_CMD} - INSTALL_COMMAND make install DESTDIR=${STAGE_DIR} - COMMAND chrpath -d ${STAGE_EMBEDDED_DIR}/sbin/rsyslogd - COMMAND find ${STAGE_EMBEDDED_DIR}/lib/rsyslog/ -name *.so -exec chrpath -d {} $ -) diff --git a/build/cmake/deps/ruby.cmake b/build/cmake/deps/ruby.cmake deleted file mode 100644 index 1d95193ea..000000000 --- a/build/cmake/deps/ruby.cmake +++ /dev/null @@ -1,49 +0,0 @@ -# Ruby & Bundler: For Rails web-app component - -set(BUNDLER_VERSION 1.16.2) -set(BUNDLER_HASH 3bb53e03db0a8008161eb4c816ccd317120d3c415ba6fee6f90bbc7f7eec8690) -set(RUBY_VERSION 2.4.4) -set(RUBY_HASH 45a8de577471b90dc4838c5ef26aeb253a56002896189055a44dc680644243f1) -set(RUBYGEMS_VERSION 2.7.7) -set(RUBYGEMS_HASH 1df4c1883656593eb1b48f572a085f16f73e7c759e69dcafe26189a6eca7cc0f) - -list(APPEND RUBY_CONFIGURE_CMD env) -list(APPEND RUBY_CONFIGURE_CMD /configure) -list(APPEND RUBY_CONFIGURE_CMD --prefix=${INSTALL_PREFIX_EMBEDDED}) -list(APPEND RUBY_CONFIGURE_CMD --enable-load-relative) -list(APPEND RUBY_CONFIGURE_CMD --disable-rpath) -list(APPEND RUBY_CONFIGURE_CMD --disable-install-doc) - -ExternalProject_Add( - ruby - EXCLUDE_FROM_ALL 1 - URL https://cache.ruby-lang.org/pub/ruby/ruby-${RUBY_VERSION}.tar.bz2 - URL_HASH SHA256=${RUBY_HASH} - CONFIGURE_COMMAND rm -rf && mkdir -p # Clean across version upgrades - COMMAND ${RUBY_CONFIGURE_CMD} - INSTALL_COMMAND make install DESTDIR=${STAGE_DIR} -) - -ExternalProject_Add( - rubygems - EXCLUDE_FROM_ALL 1 - DEPENDS ruby - URL https://rubygems.org/downloads/rubygems-update-${RUBYGEMS_VERSION}.gem - URL_HASH SHA256=${RUBYGEMS_HASH} - DOWNLOAD_NO_EXTRACT 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND env PATH=${STAGE_EMBEDDED_PATH} gem update --system ${RUBYGEMS_VERSION} --no-document -) - -ExternalProject_Add( - bundler - EXCLUDE_FROM_ALL 1 - DEPENDS rubygems - URL https://rubygems.org/downloads/bundler-${BUNDLER_VERSION}.gem - URL_HASH SHA256=${BUNDLER_HASH} - DOWNLOAD_NO_EXTRACT 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND env PATH=${STAGE_EMBEDDED_PATH} gem install --no-document --env-shebang --local --force -) diff --git a/build/cmake/deps/runit_svlogd.cmake b/build/cmake/deps/runit_svlogd.cmake deleted file mode 100644 index 21ee3a1a4..000000000 --- a/build/cmake/deps/runit_svlogd.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# runit's svlogd as alternative to perp's tinylog with more features. - -set(RUNIT_VERSION 2.1.2) -set(RUNIT_HASH 6c985fbfe3a34608eb3c53dc719172c4) - -ExternalProject_Add( - runit_svlogd - EXCLUDE_FROM_ALL 1 - URL http://smarden.org/runit/runit-${RUNIT_VERSION}.tar.gz - URL_HASH MD5=${RUNIT_HASH} - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND cd runit-${RUNIT_VERSION}/src && make svlogd - INSTALL_COMMAND install -D -m 755 runit-${RUNIT_VERSION}/src/svlogd ${STAGE_EMBEDDED_DIR}/bin/svlogd -) diff --git a/build/cmake/deps/trafficserver.cmake b/build/cmake/deps/trafficserver.cmake deleted file mode 100644 index 06eae3cfa..000000000 --- a/build/cmake/deps/trafficserver.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# TrafficServer: HTTP caching server - -set(TRAFFICSERVER_VERSION 7.1.3) -set(TRAFFICSERVER_HASH 1ddb23a1c0564929d2246ff3cd97595a9d0b1891736a9d0ef8ca56f52a7b86159b657bbc22f2e64aaccee13009ceff2a47c92b8b25121d65c7ccfdedf8b084ea) - -list(APPEND TRAFFICSERVER_CONFIGURE_CMD env) -list(APPEND TRAFFICSERVER_CONFIGURE_CMD SPHINXBUILD=false) -list(APPEND TRAFFICSERVER_CONFIGURE_CMD /configure) -list(APPEND TRAFFICSERVER_CONFIGURE_CMD --prefix=${INSTALL_PREFIX_EMBEDDED}) -list(APPEND TRAFFICSERVER_CONFIGURE_CMD --enable-experimental-plugins) - -ExternalProject_Add( - trafficserver - EXCLUDE_FROM_ALL 1 - URL http://mirror.olnevhost.net/pub/apache/trafficserver/trafficserver-${TRAFFICSERVER_VERSION}.tar.bz2 - URL_HASH SHA512=${TRAFFICSERVER_HASH} - CONFIGURE_COMMAND rm -rf && mkdir -p # Clean across version upgrades - COMMAND ${TRAFFICSERVER_CONFIGURE_CMD} - INSTALL_COMMAND make install DESTDIR=${STAGE_DIR} - COMMAND chrpath -d ${STAGE_EMBEDDED_DIR}/lib/libtsmgmt.so - COMMAND find ${STAGE_EMBEDDED_DIR}/libexec/trafficserver/ -name *.so -exec chrpath -d {} $ - COMMAND find ${STAGE_EMBEDDED_DIR}/bin/ -name traffic_* -exec chrpath -d {} $ -) diff --git a/build/cmake/distclean.cmake b/build/cmake/distclean.cmake deleted file mode 100644 index e5918c007..000000000 --- a/build/cmake/distclean.cmake +++ /dev/null @@ -1,3 +0,0 @@ -add_custom_target(distclean - COMMAND ${CMAKE_SOURCE_DIR}/build/scripts/distclean -) diff --git a/build/cmake/functions/GetGitRevisionDescription.cmake b/build/cmake/functions/GetGitRevisionDescription.cmake deleted file mode 100644 index 85eae1562..000000000 --- a/build/cmake/functions/GetGitRevisionDescription.cmake +++ /dev/null @@ -1,130 +0,0 @@ -# - Returns a version string from Git -# -# These functions force a re-configure on each git commit so that you can -# trust the values of the variables in your build system. -# -# get_git_head_revision( [ ...]) -# -# Returns the refspec and sha hash of the current head revision -# -# git_describe( [ ...]) -# -# Returns the results of git describe on the source tree, and adjusting -# the output so that it tests false if an error occurs. -# -# git_get_exact_tag( [ ...]) -# -# Returns the results of git describe --exact-match on the source tree, -# and adjusting the output so that it tests false if there was no exact -# matching tag. -# -# Requires CMake 2.6 or newer (uses the 'function' command) -# -# Original Author: -# 2009-2010 Ryan Pavlik -# http://academic.cleardefinition.com -# Iowa State University HCI Graduate Program/VRAC -# -# Copyright Iowa State University 2009-2010. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -if(__get_git_revision_description) - return() -endif() -set(__get_git_revision_description YES) - -# We must run the following at "include" time, not at function call time, -# to find the path to this module rather than the path to a calling list file -get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) - -function(get_git_head_revision _refspecvar _hashvar) - set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - set(GIT_DIR "${GIT_PARENT_DIR}/.git") - while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories - set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") - get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) - if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) - # We have reached the root directory, we are not in git - set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) - set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) - return() - endif() - set(GIT_DIR "${GIT_PARENT_DIR}/.git") - endwhile() - # check if this is a submodule - if(NOT IS_DIRECTORY ${GIT_DIR}) - file(READ ${GIT_DIR} submodule) - string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) - get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) - get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) - endif() - set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") - if(NOT EXISTS "${GIT_DATA}") - file(MAKE_DIRECTORY "${GIT_DATA}") - endif() - - if(NOT EXISTS "${GIT_DIR}/HEAD") - return() - endif() - set(HEAD_FILE "${GIT_DATA}/HEAD") - configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) - - configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" - "${GIT_DATA}/grabRef.cmake" - @ONLY) - include("${GIT_DATA}/grabRef.cmake") - - set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) - set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) -endfunction() - -function(git_describe _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - get_git_head_revision(refspec hash) - if(NOT GIT_FOUND) - set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) - return() - endif() - if(NOT hash) - set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) - return() - endif() - - # TODO sanitize - #if((${ARGN}" MATCHES "&&") OR - # (ARGN MATCHES "||") OR - # (ARGN MATCHES "\\;")) - # message("Please report the following error to the project!") - # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") - #endif() - - #message(STATUS "Arguments to execute_process: ${ARGN}") - - execute_process(COMMAND - "${GIT_EXECUTABLE}" - describe - ${hash} - ${ARGN} - WORKING_DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE - res - OUTPUT_VARIABLE - out - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT res EQUAL 0) - set(out "${out}-${res}-NOTFOUND") - endif() - - set(${_var} "${out}" PARENT_SCOPE) -endfunction() - -function(git_get_exact_tag _var) - git_describe(out --exact-match ${ARGN}) - set(${_var} "${out}" PARENT_SCOPE) -endfunction() diff --git a/build/cmake/functions/GetGitRevisionDescription.cmake.in b/build/cmake/functions/GetGitRevisionDescription.cmake.in deleted file mode 100644 index 6d8b708ef..000000000 --- a/build/cmake/functions/GetGitRevisionDescription.cmake.in +++ /dev/null @@ -1,41 +0,0 @@ -# -# Internal file for GetGitRevisionDescription.cmake -# -# Requires CMake 2.6 or newer (uses the 'function' command) -# -# Original Author: -# 2009-2010 Ryan Pavlik -# http://academic.cleardefinition.com -# Iowa State University HCI Graduate Program/VRAC -# -# Copyright Iowa State University 2009-2010. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -set(HEAD_HASH) - -file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) - -string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) -if(HEAD_CONTENTS MATCHES "ref") - # named branch - string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") - if(EXISTS "@GIT_DIR@/${HEAD_REF}") - configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) - else() - configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) - file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) - if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") - set(HEAD_HASH "${CMAKE_MATCH_1}") - endif() - endif() -else() - # detached HEAD - configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) -endif() - -if(NOT HEAD_HASH) - file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) - string(STRIP "${HEAD_HASH}" HEAD_HASH) -endif() diff --git a/build/cmake/functions/GetGitTimestamp.cmake b/build/cmake/functions/GetGitTimestamp.cmake deleted file mode 100644 index f3c878844..000000000 --- a/build/cmake/functions/GetGitTimestamp.cmake +++ /dev/null @@ -1,38 +0,0 @@ -function(get_git_timestamp _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - get_git_head_revision(refspec hash) - if(NOT GIT_FOUND) - set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) - return() - endif() - - execute_process(COMMAND - git log --max-count=1 --date=iso --format=%cd ${hash} - WORKING_DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE - res - OUTPUT_VARIABLE - out - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT res EQUAL 0) - set(out "${out}-${res}-NOTFOUND") - endif() - - execute_process(COMMAND - date -d ${out} -u +%Y%m%d%H%M%S - WORKING_DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE - res - OUTPUT_VARIABLE - out - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT res EQUAL 0) - set(out "${out}-${res}-NOTFOUND") - endif() - - set(${_var} "${out}" PARENT_SCOPE) -endfunction() diff --git a/build/cmake/functions/luarocks_install.cmake b/build/cmake/functions/luarocks_install.cmake deleted file mode 100644 index 7a3955e26..000000000 --- a/build/cmake/functions/luarocks_install.cmake +++ /dev/null @@ -1,22 +0,0 @@ -function(_luarocks_install tree_dir package version hash) - ExternalProject_Add( - luarock_${package} - EXCLUDE_FROM_ALL 1 - DEPENDS luarocks ${ARGV5} - URL https://luarocks.org/${package}-${version}.rockspec - URL_HASH MD5=${hash} - DOWNLOAD_NO_EXTRACT 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND ${LUAROCKS_CMD} --tree=${tree_dir} install ${package} ${version} ${ARGV4} - COMMAND find ${tree_dir} -name *.so -exec chrpath -d {} $ - ) -endfunction() - -function(luarocks_install package version hash) - _luarocks_install(${VENDOR_DIR} ${package} ${version} ${hash} ${ARGV3} ${ARGV4}) -endfunction() - -function(test_luarocks_install package version hash) - _luarocks_install(${TEST_VENDOR_DIR} ${package} ${version} ${hash} ${ARGV3} ${ARGV4}) -endfunction() diff --git a/build/cmake/functions/opm_install.cmake b/build/cmake/functions/opm_install.cmake deleted file mode 100644 index 39e6d9e88..000000000 --- a/build/cmake/functions/opm_install.cmake +++ /dev/null @@ -1,22 +0,0 @@ -function(_opm_install tree_dir package account version hash) - ExternalProject_Add( - opm_${package} - EXCLUDE_FROM_ALL 1 - DEPENDS openresty ${ARGV5} - URL https://opm.openresty.org/api/pkg/tarball/${account}/${package}-${version}.opm.tar.gz - URL_HASH MD5=${hash} - DOWNLOAD_NO_EXTRACT 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND mkdir -p ${tree_dir} && cd ${tree_dir} && ${OPM_CMD} --cwd get ${account}/${package}=${version} - COMMAND find ${tree_dir}/resty_modules -name *.so -exec chrpath -d {} $ - ) -endfunction() - -function(opm_install package account version hash) - _opm_install(${VENDOR_DIR} ${package} ${account} ${version} ${hash} ${ARGV4}) -endfunction() - -function(test_opm_install package account version hash) - _opm_install(${TEST_VENDOR_DIR} ${package} ${account} ${version} ${hash} ${ARGV4}) -endfunction() diff --git a/build/cmake/functions/require_program.cmake b/build/cmake/functions/require_program.cmake deleted file mode 100644 index 29a2a86ca..000000000 --- a/build/cmake/functions/require_program.cmake +++ /dev/null @@ -1,6 +0,0 @@ -function(require_program name) - find_program(${name} ${name}) - if(NOT ${name}) - MESSAGE(FATAL_ERROR "Could not find ${name}") - endif() -endfunction(require_program) diff --git a/build/cmake/install.cmake b/build/cmake/install.cmake deleted file mode 100644 index 3879e8ba0..000000000 --- a/build/cmake/install.cmake +++ /dev/null @@ -1,95 +0,0 @@ -install( - DIRECTORY ${STAGE_PREFIX_DIR}/ - DESTINATION ${CMAKE_INSTALL_PREFIX} - USE_SOURCE_PERMISSIONS - COMPONENT core -) -install( - PROGRAMS ${CMAKE_SOURCE_DIR}/build/package/files/etc/init.d/api-umbrella - DESTINATION /etc/init.d - COMPONENT core -) -install( - FILES ${CMAKE_SOURCE_DIR}/build/package/files/etc/logrotate.d/api-umbrella - DESTINATION /etc/logrotate.d - COMPONENT core -) -install( - FILES ${CMAKE_SOURCE_DIR}/build/package/files/etc/sudoers.d/api-umbrella - DESTINATION /etc/sudoers.d - PERMISSIONS OWNER_READ GROUP_READ - COMPONENT core -) - -# If /etc/api-umbrella/api-umbrella.yml doesn't exist, install it. -# -# If /etc/api-umbrella/api-umbrella.yml does exist, install the default version -# to api-umbrella.yml.default (so it's available for reference, but we don't -# overwrite any local changes). -# -# The CODE block is so that this conditional is deferred until install time -# (rather than when cmake builds the makefile). See: -# https://cmake.org/Bug/view.php?id=12646 -install( - CODE " - if(NOT EXISTS \$ENV{DESTDIR}/etc/api-umbrella/api-umbrella.yml) - file(INSTALL ${CMAKE_SOURCE_DIR}/build/package/files/etc/api-umbrella/api-umbrella.yml DESTINATION /etc/api-umbrella) - else() - message(STATUS \"Skipping: \$ENV{DESTDIR}/etc/api-umbrella/api-umbrella.yml\") - file(INSTALL ${CMAKE_SOURCE_DIR}/build/package/files/etc/api-umbrella/api-umbrella.yml DESTINATION /etc/api-umbrella RENAME api-umbrella.yml.default) - endif() - " - COMPONENT core -) - -install( - CODE " - message(STATUS \"Directories: \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/embedded/apps/core/releases/${RELEASE_TIMESTAMP}\") - execute_process( - WORKING_DIRECTORY \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/embedded/apps/core - # Multiple commands in execute_process are executed in parallel - # (http://public.kitware.com/pipermail/cmake/2016-March/063076.html). Since - # the order of these matter, use a shell wrapper. - COMMAND sh -c \"rm -rf releases/${RELEASE_TIMESTAMP} && mv releases/0 releases/${RELEASE_TIMESTAMP} && ln -snf releases/${RELEASE_TIMESTAMP} ./current\" - ) - message(STATUS \"Directories: \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/embedded/apps/static-site/releases/${RELEASE_TIMESTAMP}\") - execute_process( - WORKING_DIRECTORY \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/embedded/apps/static-site - # Multiple commands in execute_process are executed in parallel - # (http://public.kitware.com/pipermail/cmake/2016-March/063076.html). Since - # the order of these matter, use a shell wrapper. - COMMAND sh -c \"rm -rf releases/${RELEASE_TIMESTAMP} && mv releases/0 releases/${RELEASE_TIMESTAMP} && ln -snf releases/${RELEASE_TIMESTAMP} ./current\" - ) - message(STATUS \"Directories: \$ENV{DESTDIR}/usr/bin \$ENV{DESTDIR}/var/log \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/etc \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/var/db \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/var/log \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/var/run \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/var/tmp\") - execute_process( - COMMAND mkdir -p \$ENV{DESTDIR}/usr/bin \$ENV{DESTDIR}/var/log \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/etc \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/var/db \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/var/log \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/var/run \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/var/tmp - ) - message(STATUS \"Installing: \$ENV{DESTDIR}/usr/bin/api-umbrella\") - execute_process( - WORKING_DIRECTORY \$ENV{DESTDIR}/usr/bin - COMMAND ln -snf ../..${CMAKE_INSTALL_PREFIX}/bin/api-umbrella ./api-umbrella - ) - message(STATUS \"Installing: \$ENV{DESTDIR}/var/log/api-umbrella\") - execute_process( - WORKING_DIRECTORY \$ENV{DESTDIR}/var/log - COMMAND ln -snf ../..${CMAKE_INSTALL_PREFIX}/var/log ./api-umbrella - ) - message(STATUS \"Replacing: \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/embedded/openresty/luajit/bin/luarocks-5.1 \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/embedded/openresty/luajit/bin/luarocks-admin-5.1 \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/embedded/openresty/luajit/share/lua/5.1/luarocks/site_config.lua\") - execute_process( - COMMAND sed -i \"s#${STAGE_DIR}##g\" \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/embedded/openresty/luajit/bin/luarocks-5.1 \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/embedded/openresty/luajit/bin/luarocks-admin-5.1 \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/embedded/openresty/luajit/share/lua/5.1/luarocks/site_config.lua - ) - message(STATUS \"Permissions: \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/var/tmp\") - execute_process( - COMMAND chmod 1777 \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/var/tmp - ) - " - COMPONENT core -) - -add_custom_target(install-core - COMMAND ${CMAKE_COMMAND} -D CMAKE_INSTALL_COMPONENT=core -P ${CMAKE_BINARY_DIR}/cmake_install.cmake -) - -add_custom_target(after-install - COMMAND ${CMAKE_SOURCE_DIR}/build/package/scripts/after-install 1 -) diff --git a/build/cmake/package.cmake b/build/cmake/package.cmake deleted file mode 100644 index 268c615d8..000000000 --- a/build/cmake/package.cmake +++ /dev/null @@ -1,21 +0,0 @@ -add_custom_command( - OUTPUT ${STAMP_DIR}/package-bundle - DEPENDS - bundler - ${CMAKE_SOURCE_DIR}/build/package/Gemfile - ${CMAKE_SOURCE_DIR}/build/package/Gemfile.lock - COMMAND env PATH=${STAGE_EMBEDDED_DIR}/bin:${DEFAULT_PATH} BUNDLE_GEMFILE=${CMAKE_SOURCE_DIR}/build/package/Gemfile BUNDLE_APP_CONFIG=${WORK_DIR}/src/package/.bundle bundle config --local build.nokogiri --use-system-libraries - COMMAND env PATH=${STAGE_EMBEDDED_DIR}/bin:${DEFAULT_PATH} BUNDLE_GEMFILE=${CMAKE_SOURCE_DIR}/build/package/Gemfile BUNDLE_APP_CONFIG=${WORK_DIR}/src/package/.bundle bundle install --path=${VENDOR_DIR}/bundle - COMMAND touch ${STAMP_DIR}/package-bundle -) - -add_custom_target(package-core - DEPENDS ${STAMP_DIR}/package-bundle - COMMAND rm -rf ${WORK_DIR}/package-dest-core - COMMAND make - COMMAND make install-core DESTDIR=${WORK_DIR}/package-dest-core - COMMAND env PATH=${STAGE_EMBEDDED_DIR}/bin:${DEFAULT_PATH} BUNDLE_GEMFILE=${CMAKE_SOURCE_DIR}/build/package/Gemfile BUNDLE_APP_CONFIG=${WORK_DIR}/src/package/.bundle WORK_DIR=${WORK_DIR} PACKAGE_WORK_DIR=${PACKAGE_WORK_DIR} PACKAGE=core ${CMAKE_SOURCE_DIR}/build/package/build_package - COMMAND rm -rf ${WORK_DIR}/package-dest-core -) - -add_custom_target(package DEPENDS package-core) diff --git a/build/cmake/test-bundle.cmake b/build/cmake/test-bundle.cmake deleted file mode 100644 index e5e12b6e3..000000000 --- a/build/cmake/test-bundle.cmake +++ /dev/null @@ -1,19 +0,0 @@ -add_custom_command( - OUTPUT - ${STAMP_DIR}/test-bundle - ${WORK_DIR}/.bundle - ${WORK_DIR}/bundle - DEPENDS - bundler - ${CMAKE_SOURCE_DIR}/Gemfile - ${CMAKE_SOURCE_DIR}/Gemfile.lock - COMMAND env PATH=${STAGE_EMBEDDED_PATH} BUNDLE_GEMFILE=${CMAKE_SOURCE_DIR}/Gemfile BUNDLE_APP_CONFIG=${WORK_DIR}/.bundle bundle config --local build.nokogiri --use-system-libraries - COMMAND env PATH=${STAGE_EMBEDDED_PATH} BUNDLE_GEMFILE=${CMAKE_SOURCE_DIR}/Gemfile BUNDLE_APP_CONFIG=${WORK_DIR}/.bundle bundle install --path=${VENDOR_DIR}/bundle - COMMAND touch -c ${WORK_DIR}/.bundle - COMMAND touch -c ${WORK_DIR}/bundle - COMMAND touch ${STAMP_DIR}/test-bundle -) - -add_custom_target(test-bundle DEPENDS - ${STAMP_DIR}/test-bundle -) diff --git a/build/cmake/test-deps.cmake b/build/cmake/test-deps.cmake deleted file mode 100644 index 3d1bf8c04..000000000 --- a/build/cmake/test-deps.cmake +++ /dev/null @@ -1,21 +0,0 @@ -include(${CMAKE_SOURCE_DIR}/build/cmake/test-deps/elasticsearch5.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/test-deps/elasticsearch6.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/test-deps/luacheck.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/test-deps/mailhog.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/test-deps/mongo-orchestration.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/test-deps/openldap.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/test-deps/phantomjs.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/test-deps/shellcheck.cmake) -include(${CMAKE_SOURCE_DIR}/build/cmake/test-deps/unbound.cmake) - -add_custom_target(test-deps DEPENDS - elasticsearch5 - elasticsearch6 - luacheck - mailhog - mongo-orchestration - openldap - phantomjs - shellcheck - unbound -) diff --git a/build/cmake/test-deps/elasticsearch5.cmake b/build/cmake/test-deps/elasticsearch5.cmake deleted file mode 100644 index a5c4a2ce8..000000000 --- a/build/cmake/test-deps/elasticsearch5.cmake +++ /dev/null @@ -1,17 +0,0 @@ - -find_package(Java 1.7 REQUIRED COMPONENTS Runtime) -require_program(rsync) - -set(ELASTICSEARCH5_VERSION 5.6.9) -set(ELASTICSEARCH5_HASH 9dae4794cad7b804bffe09d03c94ab25b3e9c586) - -ExternalProject_Add( - elasticsearch5 - EXCLUDE_FROM_ALL 1 - URL https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH5_VERSION}.tar.gz - URL_HASH SHA1=${ELASTICSEARCH5_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND rsync -a -v --checksum --delete-after / ${TEST_INSTALL_PREFIX}/elasticsearch5/ - COMMAND chown -R nobody ${TEST_INSTALL_PREFIX}/elasticsearch5 -) diff --git a/build/cmake/test-deps/elasticsearch6.cmake b/build/cmake/test-deps/elasticsearch6.cmake deleted file mode 100644 index 9323f9018..000000000 --- a/build/cmake/test-deps/elasticsearch6.cmake +++ /dev/null @@ -1,16 +0,0 @@ -find_package(Java 1.7 REQUIRED COMPONENTS Runtime) -require_program(rsync) - -set(ELASTICSEARCH6_VERSION 6.2.4) -set(ELASTICSEARCH6_HASH 8db5931278fd7a8687659ebcfaeab0d0f87f7d22) - -ExternalProject_Add( - elasticsearch6 - EXCLUDE_FROM_ALL 1 - URL https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH6_VERSION}.tar.gz - URL_HASH SHA1=${ELASTICSEARCH6_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND rsync -a -v --checksum --delete-after / ${TEST_INSTALL_PREFIX}/elasticsearch6/ - COMMAND chown -R nobody ${TEST_INSTALL_PREFIX}/elasticsearch6 -) diff --git a/build/cmake/test-deps/luacheck.cmake b/build/cmake/test-deps/luacheck.cmake deleted file mode 100644 index 30bdbf339..000000000 --- a/build/cmake/test-deps/luacheck.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(LUAROCK_LUACHECK_VERSION 0.22.0-1) -set(LUAROCK_LUACHECK_HASH 17608776f5d37ca898f96f4973b3be0e) - -test_luarocks_install(luacheck ${LUAROCK_LUACHECK_VERSION} ${LUAROCK_LUACHECK_HASH}) - -add_custom_target(luacheck DEPENDS luarock_luacheck) diff --git a/build/cmake/test-deps/mailhog.cmake b/build/cmake/test-deps/mailhog.cmake deleted file mode 100644 index 99407342a..000000000 --- a/build/cmake/test-deps/mailhog.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# MailHog: SMTP testing server - -set(MAILHOG_VERSION 1.0.0) -set(MAILHOG_HASH 3b758c81bfe2c9110911511daca1a7bc) - -ExternalProject_Add( - mailhog - EXCLUDE_FROM_ALL 1 - URL https://github.com/mailhog/MailHog/releases/download/v${MAILHOG_VERSION}/MailHog_linux_amd64 - URL_HASH MD5=${MAILHOG_HASH} - DOWNLOAD_NO_EXTRACT 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND install -D -m 755 ${TEST_INSTALL_PREFIX}/bin/mailhog -) diff --git a/build/cmake/test-deps/mongo-orchestration.cmake b/build/cmake/test-deps/mongo-orchestration.cmake deleted file mode 100644 index f9e952fb2..000000000 --- a/build/cmake/test-deps/mongo-orchestration.cmake +++ /dev/null @@ -1,13 +0,0 @@ -set(MONGO_ORCHESTRATION_VERSION 0.6.11) - -add_custom_command( - OUTPUT ${TEST_INSTALL_PREFIX}/bin/pip - COMMAND virtualenv ${TEST_INSTALL_PREFIX} -) -add_custom_command( - OUTPUT ${TEST_INSTALL_PREFIX}/bin/mongo-orchestration - DEPENDS ${TEST_INSTALL_PREFIX}/bin/pip - COMMAND ${TEST_INSTALL_PREFIX}/bin/pip install --ignore-installed 'mongo-orchestration==${MONGO_ORCHESTRATION_VERSION}' -) - -add_custom_target(mongo-orchestration DEPENDS ${TEST_INSTALL_PREFIX}/bin/mongo-orchestration) diff --git a/build/cmake/test-deps/openldap.cmake b/build/cmake/test-deps/openldap.cmake deleted file mode 100644 index a6f8414a9..000000000 --- a/build/cmake/test-deps/openldap.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# OpenLDAP: For testing LDAP admin auth. - -set(OPENLDAP_VERSION 2.4.46) -set(OPENLDAP_HASH a9ae2273eb9bdd70090dafe0d018a3132606bef6) - -ExternalProject_Add( - openldap - EXCLUDE_FROM_ALL 1 - URL ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-${OPENLDAP_VERSION}.tgz - URL_HASH SHA1=${OPENLDAP_HASH} - CONFIGURE_COMMAND /configure --prefix=${TEST_INSTALL_PREFIX} --disable-backends --enable-mdb - BUILD_COMMAND make depend && make -) diff --git a/build/cmake/test-deps/phantomjs.cmake b/build/cmake/test-deps/phantomjs.cmake deleted file mode 100644 index 44a150817..000000000 --- a/build/cmake/test-deps/phantomjs.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# PhantomJS: Headless WebKit for testing. - -set(PHANTOMJS_VERSION 2.1.1) -set(PHANTOMJS_HASH 1c947d57fce2f21ce0b43fe2ed7cd361) - -ExternalProject_Add( - phantomjs - EXCLUDE_FROM_ALL 1 - URL https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2 - URL_HASH MD5=${PHANTOMJS_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND install -D -m 755 /bin/phantomjs ${TEST_INSTALL_PREFIX}/bin/phantomjs -) diff --git a/build/cmake/test-deps/shellcheck.cmake b/build/cmake/test-deps/shellcheck.cmake deleted file mode 100644 index 15aaee7e2..000000000 --- a/build/cmake/test-deps/shellcheck.cmake +++ /dev/null @@ -1,12 +0,0 @@ -set(SHELLCHECK_VERSION 0.5.0) -set(SHELLCHECK_HASH 475e14bf2705ad4a16d405fa64b94c2eb151a914d5a165ce13e8f9344e6145893f685a650cd32d45a7ab236dedf55f76b31db82e2ef76ad6175a87dd89109790) - -ExternalProject_Add( - shellcheck - EXCLUDE_FROM_ALL 1 - URL https://storage.googleapis.com/shellcheck/shellcheck-v${SHELLCHECK_VERSION}.linux.x86_64.tar.xz - URL_HASH SHA512=${SHELLCHECK_HASH} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND install -D -m 755 /shellcheck ${TEST_INSTALL_PREFIX}/bin/shellcheck -) diff --git a/build/cmake/test-deps/unbound.cmake b/build/cmake/test-deps/unbound.cmake deleted file mode 100644 index ecaa8fd7d..000000000 --- a/build/cmake/test-deps/unbound.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# Unbound: Local DNS server for testing DNS changes - -set(UNBOUND_VERSION 1.7.1) -set(UNBOUND_HASH 56e085ef582c5372a20207de179d0edb4e541e59f87be7d4ee1d00d12008628d) - -ExternalProject_Add( - unbound - EXCLUDE_FROM_ALL 1 - URL http://www.unbound.net/downloads/unbound-${UNBOUND_VERSION}.tar.gz - URL_HASH SHA256=${UNBOUND_HASH} - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND /configure --prefix=${TEST_INSTALL_PREFIX} -) diff --git a/build/cmake/test.cmake b/build/cmake/test.cmake deleted file mode 100644 index cc23b4cb2..000000000 --- a/build/cmake/test.cmake +++ /dev/null @@ -1,8 +0,0 @@ -add_custom_target(test DEPENDS - deps - build-deps - app-deps - test-deps - test-bundle - COMMAND env PATH=${STAGE_EMBEDDED_DIR}/bin:${DEFAULT_PATH} BUNDLE_GEMFILE=${CMAKE_SOURCE_DIR}/Gemfile BUNDLE_APP_CONFIG=${WORK_DIR}/.bundle bundle exec rake -) diff --git a/build/package/build_package b/build/package/build_package index 8c44c0cca..1d2054f44 100755 --- a/build/package/build_package +++ b/build/package/build_package @@ -41,7 +41,7 @@ if [ "$PACKAGE" == "core" ]; then fpm_args+=("-d" "$dep") done - fpm_args+=("-C" "$WORK_DIR/package-dest-core") + fpm_args+=("-C" "$WORK_DESTDIR") fpm_args+=("--name" "api-umbrella") fpm_args+=("--config-files" "etc/api-umbrella/api-umbrella.yml") fpm_args+=("--after-install" "$source_dir/build/package/scripts/after-install") diff --git a/build/package/docker_script b/build/package/docker_script index c019e03ca..a87fe6817 100755 --- a/build/package/docker_script +++ b/build/package/docker_script @@ -22,7 +22,7 @@ cd "$clean_source_dir" git clean -d -f -x # Install any system dependencies for building. -"$clean_source_dir/build/scripts/install_build_dependencies" +"$clean_source_dir/tasks/install-system-build-dependencies" # shellcheck disable=SC1091 if [ -f /etc/os-release ]; then diff --git a/build/package/scripts/after-install b/build/package/scripts/after-install index 9b3a9fdab..9ef76b8c5 100755 --- a/build/package/scripts/after-install +++ b/build/package/scripts/after-install @@ -33,69 +33,77 @@ if [ "$configure" = "true" ]; then group=api-umbrella deploy_user=api-umbrella-deploy deploy_group=api-umbrella-deploy - prefix_dir=/opt/api-umbrella + destdir="${DESTDIR:-}" + prefix_dir="$destdir${PREFIX:-/opt/api-umbrella}" embedded_dir=$prefix_dir/embedded + if [ -n "$destdir" ]; then + mkdir -p "$destdir/usr/bin" + mkdir -p "$destdir/var/log" + fi + # Create the main user & group. - if ! getent group $group > /dev/null; then - groupadd -r $group + if ! getent group "$group" > /dev/null; then + groupadd -r "$group" fi - if ! getent passwd $user > /dev/null; then - useradd -r -g $group -s /sbin/nologin \ - -d $prefix_dir -c "API Umbrella user" $user + if ! getent passwd "$user" > /dev/null; then + useradd -r -g "$group" -s /sbin/nologin \ + -d "$prefix_dir" -c "API Umbrella user" "$user" fi # Create the deploy user & group. - if ! getent group $deploy_group > /dev/null; then - groupadd -r $deploy_group + if ! getent group "$deploy_group" > /dev/null; then + groupadd -r "$deploy_group" fi - if ! getent passwd $deploy_user > /dev/null; then - useradd -r -g $deploy_group -s /bin/bash \ - -d /home/$deploy_user -c "API Umbrella deployment user" $deploy_user + if ! getent passwd "$deploy_user" > /dev/null; then + useradd -r -g "$deploy_group" -s /bin/bash \ + -d "$destdir/home/$deploy_user" -c "API Umbrella deployment user" "$deploy_user" fi # Add the deploy user to the app group, so the deploy user can read config # files. - if ! groups $deploy_user | grep -q -E "\\s$group(\\s|$)"; then - usermod -a -G $group $deploy_user + if ! groups "$deploy_user" | grep -q -E "\\s$group(\\s|$)"; then + usermod -a -G "$group" "$deploy_user" fi # Fix previously created deploy user that couldn't actually login. - if getent passwd $deploy_user | grep -q "/sbin/nologin"; then - usermod -d /home/$deploy_user -s /bin/bash $deploy_user + if getent passwd "$deploy_user" | grep -q "/sbin/nologin"; then + usermod -d "$destdir/home/$deploy_user" -s /bin/bash "$deploy_user" fi # Create an empty .ssh/authorized_keys file with proper permissions if it # doesn't already exist. - if [ ! -f /home/$deploy_user/.ssh/authorized_keys ]; then - mkdir -p /home/$deploy_user/.ssh - touch /home/$deploy_user/.ssh/authorized_keys - chown -R $deploy_user:$deploy_group /home/$deploy_user - chmod 700 /home/$deploy_user - chmod 700 /home/$deploy_user/.ssh - chmod 600 /home/$deploy_user/.ssh/authorized_keys + if [ ! -f "$destdir/home/$deploy_user/.ssh/authorized_keys" ]; then + mkdir -p "$destdir/home/$deploy_user/.ssh" + touch "$destdir/home/$deploy_user/.ssh/authorized_keys" + chown -R "$deploy_user:$deploy_group" "$destdir/home/$deploy_user" + chmod 700 "$destdir/home/$deploy_user" + chmod 700 "$destdir/home/$deploy_user/.ssh" + chmod 600 "$destdir/home/$deploy_user/.ssh/authorized_keys" fi # Set file permissions - chown -R $user:$group $prefix_dir/etc $prefix_dir/var - chown -R $deploy_user:$deploy_group $embedded_dir/apps + chown -R "$user:$group" "$prefix_dir/etc" "$prefix_dir/var" + chown -R "$deploy_user:$deploy_group" "$embedded_dir/apps" # Re-create symlinks that may have inadvertently been cleaned up by the API # Umbrella v0.8 and v0.9 after-remove scripts during upgrades (this should be # fixed by the v0.10 after-remove script, so at some point, we can probably # remove this logic). - if [ ! -f /usr/bin/api-umbrella ]; then - cd /usr/bin && ln -snf ../..$prefix_dir/bin/api-umbrella ./api-umbrella + if [ ! -f "$destdir/usr/bin/api-umbrella" ]; then + cd "$destdir/usr/bin" && ln -snf "../..$prefix_dir/bin/api-umbrella" ./api-umbrella fi - if [ ! -f /var/log/api-umbrella ]; then - cd /var/log && ln -snf ../..$prefix_dir/var/log ./api-umbrella + if [ ! -f "$destdir/var/log/api-umbrella" ]; then + cd "$destdir/var/log" && ln -snf "../..$prefix_dir/var/log" ./api-umbrella fi - # Install service, but don't activate. - if command -v chkconfig > /dev/null 2>&1; then - chkconfig --add api-umbrella - elif command -v update-rc.d > /dev/null 2>&1; then - update-rc.d api-umbrella defaults 85 15 > /dev/null + if [ -z "$destdir" ]; then + # Install service, but don't activate. + if command -v chkconfig > /dev/null 2>&1; then + chkconfig --add api-umbrella + elif command -v update-rc.d > /dev/null 2>&1; then + update-rc.d api-umbrella defaults 85 15 > /dev/null + fi fi fi diff --git a/build/package/verify/spec/localhost/service_spec.rb b/build/package/verify/spec/localhost/service_spec.rb index 674838047..641ebbfe9 100644 --- a/build/package/verify/spec/localhost/service_spec.rb +++ b/build/package/verify/spec/localhost/service_spec.rb @@ -252,7 +252,7 @@ def install_package(version) ].each do |service| # Make sure all the expected processes are reported as running and aren't # flapping up and down. - expect(command_result.stdout).to match(%r{^\[\+ \+\+\+ \+\+\+\] +#{service} +uptime: \d+s/\d+s +pids: \d+/\d+$}) + expect(output).to match(%r{^\[\+ \+\+\+ \+\+\+\] +#{service} +uptime: \d+s/\d+s +pids: \d+/\d+$}) end end diff --git a/build/scripts/distclean b/build/scripts/distclean deleted file mode 100755 index bb3298d41..000000000 --- a/build/scripts/distclean +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -set -e -u -x - -source_dir="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")")" - -if [ ! -f "$source_dir/CMakeLists.txt" ]; then - echo "Can't find root source directory" - exit 1 -fi - -rm -rf \ - "$source_dir/CMakeCache.txt" \ - "$source_dir/CMakeFiles"/* \ - "$source_dir/Makefile" \ - "$source_dir/build/package/.bundle" \ - "$source_dir/build/package/vendor" \ - "$source_dir/build/scripts/.bundle" \ - "$source_dir/build/scripts/vendor" \ - "$source_dir/build/work"/* \ - "$source_dir/cmake_install.cmake" \ - "$source_dir/install_manifest.txt" \ - "$source_dir/src/api-umbrella/web-app/.bundle" \ - "$source_dir/src/api-umbrella/web-app/brakeman.html" \ - "$source_dir/src/api-umbrella/web-app/log"/* \ - "$source_dir/src/api-umbrella/web-app/public/test-assets" \ - "$source_dir/src/api-umbrella/web-app/spec/reports" \ - "$source_dir/src/api-umbrella/web-app/tmp"/* \ - "$source_dir/test/config/.overrides.yml" \ - "$source_dir/test/tmp"/* diff --git a/build/scripts/download_cmake b/build/scripts/download_cmake deleted file mode 100755 index 5aeef1628..000000000 --- a/build/scripts/download_cmake +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -e -u - -version=3.11.1 -checksum=3aa8d3b53903563bdc13dfec80716c286b2228db36ef65c23bc616f9bb930367 - -build_dir=$(pwd) -work_dir="$build_dir/build/work" -version_stamp="$work_dir/cmake/version-$version" -prefix="$work_dir/cmake" - -if [[ ! -e "$prefix/bin/cmake" || ! -e "$version_stamp" ]]; then - rm -rf "$prefix" - mkdir -p "$prefix" - - download_filename="cmake-$version-Linux-x86_64.tar.gz" - minor_version=${version%.*} - download_url="https://cmake.org/files/v$minor_version/$download_filename" - download_path="$work_dir/$download_filename" - if [ ! -e "$download_path" ]; then - echo "Downloading CMake $version..." - curl -fL --retry 3 -o "$download_path" "$download_url" - fi - - actual_checksum=$(openssl sha256 "$download_path" | awk '{print $2}') - if [ "$actual_checksum" != "$checksum" ]; then - echo "SHA256 hash of" - echo " $download_path" - echo "does not match expected value" - echo " expected: '$checksum'" - echo " actual: '$actual_checksum'" - exit 1 - fi - - echo "Extracting CMake $version..." - tar --strip-components 1 -C "$prefix" -xf "$download_path" - rm -f "$download_path" - touch "$version_stamp" - echo "Completed local CMake $version installation into $prefix" -fi diff --git a/configure b/configure index 0a5416362..1ea985c19 100755 --- a/configure +++ b/configure @@ -1,343 +1,48 @@ #!/usr/bin/env bash -# Autotools-style (./configure) wrapper for CMake -# -# -# *** IMPORTANT *** -# -# You must include the GNUInstallDirs module (which comes with -# CMake) in your project. Just put "include (GNUInstallDirs)" in -# you CMakeLists.txt and you should be good. -# -# This script was originally written for Squash -# by Evan Nemerson -# , but has been spun off into a separate -# repository. Please feel free to copy it into your own repository, -# though I would appreciate it if you would post improvements, bugs, -# feature requests, etc. to the issue tracker at -# . -# -# To the extent possible under law, the author(s) hereby waive all -# copyright and related or neighboring rights to this work. For -# details, see +set -e -u -set -e +prefix="/opt/api-umbrella" -# Resolve the current path, taking into account symlinks. -# http://stackoverflow.com/a/246128/222487 -source="${BASH_SOURCE[0]}" -while [ -L "$source" ]; do - dir="$(cd -P "$(dirname "$source")" && pwd)" - source="$(readlink "$source")" - [[ $source != /* ]] && source="$dir/$source" -done -TOP_SRCDIR="$(cd -P "$(dirname "$source")" && pwd)" - -CMAKE_CMD="cmake ${TOP_SRCDIR}" - -BUILD_TYPE="Debug" -PREFIX=/usr/local -LIBDIR= -CMAKE_ARGS= - -if [ -e "${TOP_SRCDIR}/.configure-custom.sh" ]; then - . "${TOP_SRCDIR}/.configure-custom.sh" -fi - -PREFIX=/opt/api-umbrella - -quote() { - echo "$1" | sed -e "s|'|'\\\\''|g; 1s/^/'/; \$s/\$/'/" -} - -extract_var_string() { - VAR_NAME=$1 - VAR_NAME=$(echo $1 | sed -e 's/[ \t]*$//') - if [ "x$2" != "x" ]; then - VAR_VALUE=$2 - else - VAR_VALUE=yes - fi +usage() { + cat <&2 +Configuration: -h, --help display this help and exit - --pass-thru pass remaining arguments through to CMake +Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX - [$PREFIX] -EOF - - first=y - for varstring in ${ENABLE_VARS}; do - if [ $first = 'y' ]; then - echo "" - first=n - fi - extract_var_string $(echo "${varstring}" | tr '|' ' ') - var_doc_name="ENABLE_${VAR_UC_NAME}_DOC" - eval "docstring=\$$var_doc_name" - if [ "x${docstring}" = "x" ]; then - printf " --enable-%-14s enable %s support\n" "${VAR_NAME}" "$(echo -n "${VAR_NAME}" | tr '-' ' ')" - else - printf " --enable-%-14s %s\n" "${VAR_NAME}" "$docstring" - fi - done - - first=y - for varstring in ${DISABLE_VARS}; do - if [ $first = 'y' ]; then - echo "" - first=n - fi - extract_var_string $(echo "${varstring}" | tr '|' ' ') - var_doc_name="DISABLE_${VAR_UC_NAME}_DOC" - eval "docstring=\$$var_doc_name" - if [ "x${docstring}" = "x" ]; then - printf " --disable-%-13s disable %s support\n" "${VAR_NAME}" "$(echo -n "${VAR_NAME}" | tr '-' ' ')" - else - printf " --disable-%-13s %s\n" "${VAR_NAME}" "$docstring" - fi - done - - first=y - for varstring in ${WITH_VARS}; do - if [ $first = 'y' ]; then - echo "" - first=n - fi - extract_var_string $(echo "${varstring}" | tr '|' ' ') - var_doc_name="WITH_${VAR_UC_NAME}_DOC" - eval "docstring=\$$var_doc_name" - paraminfo="${VAR_NAME}=${VAR_VALUE}" - if [ "x${docstring}" = "x" ]; then - printf " --with-%-16s enable %s support\n" "$paraminfo" "$(echo -n "${VAR_NAME}" | tr '-' ' ')" - else - printf " --with-%-16s %s\n" "$paraminfo" "$docstring" - fi - done - - exit 0 + [$prefix] +EOS + exit 0 } -while [ $# != 0 ]; do - case "$1" in - "--prefix="*) - PREFIX="${1#*=}";; - "--prefix") - PREFIX="${2}"; shift;; - "--bindir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_BINDIR=$(quote "${1#*=}")";; - "--bindir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_BINDIR=$(quote "$2")"; shift;; - "--sbindir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SBINDIR=$(quote "${1#*=}")";; - "--sbindir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SBINDIR=$(quote "$2")"; shift;; - "--libexecdir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LIBEXECDIR=$(quote "${1#*=}")";; - "--libexecdir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LIBEXECDIR=$(quote "$2")"; shift;; - "--sysconfdir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SYSCONFDIR=$(quote "${1#*=}")";; - "--sysconfdir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SYSCONFDIR=$(quote "$2")"; shift;; - "--sharedstatedir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SHAREDSTATEDIR=$(quote "${1#*=}")";; - "--sharedstatedir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SHAREDSTATEDIR=$(quote "$2")"; shift;; - "--localstatedir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LOCALSTATEDIR=$(quote "${1#*=}")";; - "--localstatedir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LOCALSTATEDIR=$(quote "$2")"; shift;; - "--libdir="*) - LIBDIR="${1#*=}";; - "--libdir") - LIBDIR="${2}"; shift;; - "--includedir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_INCLUDEDIR=$(quote "${1#*=}")";; - "--includedir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_INCLUDEDIR=$(quote "$2")"; shift;; - "--oldincludedir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_OLDINCLUDEDIR=$(quote "${1#*=}")";; - "--oldincludedir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_OLDINCLUDEDIR=$(quote "$2")"; shift;; - "--datarootdir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DATAROOTDIR=$(quote "${1#*=}")";; - "--datarootdir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DATAROOTDIR=$(quote "$2")"; shift;; - "--datadir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DATADIR=$(quote "${1#*=}")";; - "--datadir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DATADIR=$(quote "$2")"; shift;; - "--infodir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_INFODIR=$(quote "${1#*=}")";; - "--infodir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_INFODIR=$(quote "$2")"; shift;; - "--localedir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LOCALEDIR=$(quote "${1#*=}")";; - "--localedir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LOCALEDIR=$(quote "$2")"; shift;; - "--mandir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_MANDIR=$(quote "${1#*=}")";; - "--mandir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_MANDIR=$(quote "$2")"; shift;; - "--docdir="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DOCDIR=$(quote "${1#*=}")";; - "--docdir") - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DOCDIR=$(quote "$2")"; shift;; - - "CC="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_COMPILER=$(quote "${1#*=}")";; - "CXX="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_COMPILER=$(quote "${1#*=}")";; - "CFLAGS="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_FLAGS=$(quote "${1#*=}")";; - "CXXFLAGS="*) - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_FLAGS=$(quote "${1#*=}")";; - "LDFLAGS="*) - LDFLAGS="$LDFLAGS ${1#*=}";; - - "--help") - print_help;; - "-h") - print_help;; - - # This flag is the only one which may be a bit surprising to - # people. Autotools always builds with debugging symbols enabled - # (AFAIK), but for cmake you have to do -DCMAKE_BUILD_TYPE=Debug. - # Unfortunately this can change other things as well, so although - # I realize there is no --disable-debug flag I thought it would be - # prudent to support one here. - "--disable-debug") - BUILD_TYPE="Release";; - - "--pass-thru") - shift; - while [ $# != 0 ]; do - CMAKE_ARGS="$CMAKE_ARGS $(quote "${1}")"; - shift; - done;; - - "--enable-"*) - set_config_var "$1" - ;; - - "--disable-"*) - set_config_var "$1" - ;; - - "--with-"*) - name=$(echo "${1#--with-}" | awk '{split($1,v,"="); print v[1]}') - case "${1}" in - "--with-${name}="*) - set_config_var "--with-${name}" "${1#--with-${name}=}";; - "--with-${name}") - set_config_var "$1" "$2"; - shift;; - esac - ;; - - *) - echo "$0: error: unrecognized option: \`$1'" >&2 - echo "Try \`$0 --help' for more information" >&2 - exit -1 - esac; - shift +while [ $# -gt 0 ]; do + key="$1" + case $key in + --prefix=*) + prefix="${key#*=}" + shift + ;; + --help|-h) + usage + shift + ;; + *) + echo "configure: error: unrecognized option: '$key'" + echo "Try './configure --help' for more information" + exit 1 + ;; + esac done -if [ "x${LIBDIR}" = "x" ]; then - LIBDIR="${PREFIX}/lib" -fi - -# Unlike CFLAGS/CXXFLAGS/CC/CXX, LDFLAGS isn't handled by CMake, so we -# need to parse it here. -if [ "x${LDFLAGS}" != "x" ]; then - for varname in EXE MODULE SHARED STATIC; do - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_${varname}_LINKER_FLAGS=$(quote "$LDFLAGS")" - done +if [ -z "$prefix" ]; then + echo "configure: error: missing argument to --prefix" + exit 1 fi -# If running in the docker development environment, always force the build to -# happen in the out-of source /build location. This helps ensure that even if -# you manually run "./configure" from inside the default /app directory, the -# generated files still assume /build as the build root. -if [ "${DOCKER_DEV:-}" == "true" ]; then - cd /build - - # Remove existing /app symlinks before running cmake again, or else the - # cached files might cause cmake to not consider this an out-of-source build. - # We'll re-create the symlinks after cmake has been executed. - rm -f /app/CMakeCache.txt \ - /app/CMakeFiles \ - /app/Makefile \ - /app/cmake_install.cmake -fi - -"$TOP_SRCDIR/build/scripts/download_cmake" -build_dir="$(pwd)" -PATH="$build_dir/build/work/cmake/bin:$PATH" -export PATH - -eval "cmake ${TOP_SRCDIR} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${PREFIX} ${CMAKE_ARGS}" - -# If running in the docker development environment, ensure symlinks are in -# place from the /app working directory to the /build location, so "make" -# commands can work from the default /app directory. -if [ "${DOCKER_DEV:-}" == "true" ]; then - ln -snf /build/CMakeCache.txt /app/CMakeCache.txt - ln -snf /build/CMakeFiles /app/CMakeFiles - ln -snf /build/Makefile /app/Makefile - ln -snf /build/cmake_install.cmake /app/cmake_install.cmake -fi +echo "configure: creating Makefile" +sed -e "s|@prefix@|$prefix|g" < Makefile.in > Makefile diff --git a/deploy/config/deploy.rb b/deploy/config/deploy.rb index c6de0c5b5..2739ab707 100644 --- a/deploy/config/deploy.rb +++ b/deploy/config/deploy.rb @@ -10,7 +10,7 @@ # repo out directly on the server). This allows for the deployments to work # from custom forks without having to update the URL. set :scm, :rsync -set :repo_url, "file://#{File.expand_path("../../../", __FILE__)}" +set :repo_url, "file://#{File.expand_path('../..', __dir__)}" # Default branch is :master # ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp diff --git a/docker/dev/docker-entrypoint b/docker/dev/docker-entrypoint index 0d73a9c06..1fa18d701 100755 --- a/docker/dev/docker-entrypoint +++ b/docker/dev/docker-entrypoint @@ -10,28 +10,24 @@ mkdir -p /etc/api-umbrella } > /etc/api-umbrella/api-umbrella.yml mkdir -p /build/build/work/stage/opt/api-umbrella/var/log -mkdir -p /build/CMakeFiles ln -snf /build/build/work/stage/opt/api-umbrella /opt/api-umbrella ln -snf /build/build/work/stage/opt/api-umbrella/var/log /var/log/api-umbrella ln -snf /build/build/work /app/build/work -ln -snf /build/CMakeCache.txt /app/CMakeCache.txt -ln -snf /build/CMakeFiles /app/CMakeFiles -ln -snf /build/Makefile /app/Makefile -ln -snf /build/cmake_install.cmake /app/cmake_install.cmake mkdir -p /build/test/tmp/run mkdir -p /app/test/tmp ln -snf /build/test/tmp/run /app/test/tmp/run -mkdir -p /app/build/work/src/api-umbrella-core/tmp/admin-ui-build/node_modules -ln -snf /app/build/work/src/api-umbrella-core/tmp/admin-ui-build/node_modules /app/src/api-umbrella/admin-ui/node_modules +mkdir -p /app/build/work/tasks/app-deps/admin-ui/yarn/_persist/node_modules +ln -snf /app/build/work/tasks/app-deps/admin-ui/yarn/_persist/node_modules /app/src/api-umbrella/admin-ui/node_modules -mkdir -p /app/build/work/.bundle -ln -snf /app/build/work/.bundle /app/.bundle +mkdir -p /app/build/work/tasks/test-deps/bundle/_persist/.bundle +ln -snf /app/build/work/tasks/test-deps/bundle/_persist/.bundle /app/.bundle -mkdir -p /app/build/work/src/web-app/.bundle -ln -snf /app/build/work/src/web-app/.bundle /app/src/api-umbrella/web-app/.bundle +mkdir -p /app/build/work/tasks/app-deps/web-app/bundle/_persist/.bundle +ln -snf /app/build/work/tasks/app-deps/web-app/bundle/_persist/.bundle /app/src/api-umbrella/web-app/.bundle +mkdir -p /app/src/api-umbrella/admin-ui/tmp chmod 1777 /app/src/api-umbrella/admin-ui/tmp exec "$@" diff --git a/docker/dev/docker-start b/docker/dev/docker-start index 8e41d1d5f..f378f9a70 100755 --- a/docker/dev/docker-start +++ b/docker/dev/docker-start @@ -2,8 +2,5 @@ set -e -u -x -(cd /build && env PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" make) - -chmod 1777 /app/src/api-umbrella/admin-ui/tmp - +make api-umbrella run diff --git a/docs/developer/compiling-from-source.md b/docs/developer/compiling-from-source.md index 21c6a2fff..627069fdd 100644 --- a/docs/developer/compiling-from-source.md +++ b/docs/developer/compiling-from-source.md @@ -6,7 +6,7 @@ Installing from a [binary package](../getting-started.html#installation) is reco - 64bit Linux distribution - It should be possible to run against other 64bit *nix operating systems, but our build script currently has some hard-coded assumptions to a 64bit linux environment. [File an issue](https://github.com/NREL/api-umbrella/issues/new) if you'd like to see other operating systems supported. -- Dependencies can automatically be installed for supported distributions by running the `./build/scripts/install_build_dependencies` script. For unsupported distributions, view the `./build/package_dependencies.sh` file for a list of required packages. +- Dependencies can automatically be installed for supported distributions by running the `./tasks/install-system-build-dependencies` script. For unsupported distributions, view the `./build/package_dependencies.sh` file for a list of required packages. ## Compiling & Installing @@ -14,7 +14,7 @@ Installing from a [binary package](../getting-started.html#installation) is reco $ curl -OLJ https://github.com/NREL/api-umbrella/archive/v0.14.4.tar.gz $ tar -xvf api-umbrella-0.14.4.tar.gz $ cd api-umbrella-0.14.4 -$ sudo ./build/scripts/install_build_dependencies +$ sudo ./tasks/install-system-build-dependencies $ ./configure $ make $ sudo make install diff --git a/docs/developer/deploying.md b/docs/developer/deploying.md index 9541c5354..aea235e9c 100644 --- a/docs/developer/deploying.md +++ b/docs/developer/deploying.md @@ -31,7 +31,7 @@ On each server you wish to deploy to, you must setup SSH keys so that you can de ### Install Build Dependencies -On each server you wish to deploy to, you must install the system packages needed for building dependencies (for example, make, gcc, etc). This can be automated through the `build/scripts/install_build_dependencies` shell script: +On each server you wish to deploy to, you must install the system packages needed for building dependencies (for example, make, gcc, etc). This can be automated through the `tasks/install-system-build-dependencies` shell script: - On each server: @@ -39,7 +39,7 @@ On each server you wish to deploy to, you must install the system packages neede $ curl -OLJ https://github.com/NREL/api-umbrella/archive/master.tar.gz $ tar -xvf api-umbrella-master.tar.gz $ cd api-umbrella-master - $ sudo ./build/scripts/install_build_dependencies + $ sudo ./tasks/install-system-build-dependencies ``` ## Deploying diff --git a/scripts/rake/lint.rake b/scripts/rake/lint.rake deleted file mode 100644 index ecf2e055e..000000000 --- a/scripts/rake/lint.rake +++ /dev/null @@ -1,82 +0,0 @@ -namespace :lint do - desc "Lint JavaScript files using eslint" - task :js do - require "childprocess" - require "rainbow" - - print "Checking admin-ui... " - process = ChildProcess.build("yarn", "run", "lint:js") - process.cwd = File.join(API_UMBRELLA_SRC_ROOT, "src/api-umbrella/admin-ui") - process.io.inherit! - process.start - process.wait - exit(process.exit_code) if(process.crashed?) - puts Rainbow("OK").green.bright - end - - desc "Lint Lua files using luacheck" - task :lua do - require "childprocess" - - lua_files = `git ls-files #{API_UMBRELLA_SRC_ROOT} | grep "\\.lua$"`.split("\n") - process = ChildProcess.build("build/work/test-env/vendor/bin/luacheck", *lua_files) - process.cwd = API_UMBRELLA_SRC_ROOT - process.environment["LUA_PATH"] = "build/work/test-env/vendor/share/lua/5.1/?.lua;build/work/test-env/vendor/share/lua/5.1/?/init.lua;;" - process.environment["LUA_CPATH"] = "build/work/test-env/vendor/lib/lua/5.1/?.so;;" - process.io.inherit! - process.start - process.wait - exit(process.exit_code) if(process.crashed?) - end - - require "rubocop/rake_task" - RuboCop::RakeTask.new(:ruby) do |t| - t.patterns = [ - File.join(API_UMBRELLA_SRC_ROOT, "src/api-umbrella/web-app/**/*.rb"), - File.join(API_UMBRELLA_SRC_ROOT, "test/**/*.rb"), - File.join(API_UMBRELLA_SRC_ROOT, "Rakefile"), - File.join(API_UMBRELLA_SRC_ROOT, "script/rake/*.rb"), - File.join(API_UMBRELLA_SRC_ROOT, "script/rake/*.rake"), - ] - t.options = [ - "--display-cop-names", - "--extra-details", - ] - end - - desc "Lint shell files using shellcheck" - task :shell do - require "childprocess" - require "rainbow" - - # Ignore certain vendored files for linting. - ignore_files = [ - "configure", - ] - - ["sh", "bash"].each do |shell| - shell_files = `git grep -l "^#\!/bin/#{shell}" #{API_UMBRELLA_SRC_ROOT}`.split("\n") - shell_files += `git grep -l "^#\!/usr/bin/env #{shell}" #{API_UMBRELLA_SRC_ROOT}`.split("\n") - shell_files -= ignore_files - - if(shell_files.any?) - print "Checking (#{shell}): #{shell_files.join(" ")}... " - process = ChildProcess.build("build/work/test-env/bin/shellcheck", "-s", shell, *shell_files) - process.cwd = API_UMBRELLA_SRC_ROOT - process.io.inherit! - process.start - process.wait - exit(process.exit_code) if(process.crashed?) - puts Rainbow("OK").green.bright - end - end - end -end - -desc "Lint all source code for errors and style" -task :lint do - Rake::Task["lint:lua"].invoke - Rake::Task["lint:ruby"].invoke - Rake::Task["lint:js"].invoke - Rake::Task["lint:shell"].invoke -end diff --git a/scripts/rake/maps.rake b/scripts/rake/maps.rake index bde40e70d..b3c85d837 100644 --- a/scripts/rake/maps.rake +++ b/scripts/rake/maps.rake @@ -1,4 +1,6 @@ namespace :maps do + # rubocop:disable Style/GlobalVars + task :download do [ "http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/cultural/ne_50m_admin_1_states_provinces_lakes.zip", @@ -89,10 +91,10 @@ namespace :maps do # individual country. countries = Oj.load(File.read(File.join($input_dir, "tmp/world-50m-combined.json"))) countries["features"].each do |feature| - File.open(File.join($output_dir, "#{feature["properties"]["iso_a2"]}.json"), "w") do |f| + File.open(File.join($output_dir, "#{feature["properties"]["iso_a2"]}.json"), "w") do |file| country = countries.dup country["features"] = [country["features"].detect { |f| f["properties"]["iso_a2"] == feature["properties"]["iso_a2"] }] - f.write(Oj.dump(country)) + file.write(Oj.dump(country)) end end end @@ -113,10 +115,10 @@ namespace :maps do feature["geometry"]["coordinates"].reject! { |c| c[0][0][0] < -177 } end - File.open(File.join($output_dir, "#{feature["properties"]["iso_3166_2"]}.json"), "w") do |f| + File.open(File.join($output_dir, "#{feature["properties"]["iso_3166_2"]}.json"), "w") do |file| state_data = data.dup state_data["features"] = [state_data["features"].detect { |f| f["properties"]["iso_3166_2"] == feature["properties"]["iso_3166_2"] }] - f.write(Oj.dump(state_data)) + file.write(Oj.dump(state_data)) end end File.open(output_path, "w") { |f| f.write(Oj.dump(data)) } @@ -180,4 +182,6 @@ namespace :maps do Rake::Task["maps:us"].invoke Rake::Task["maps:simplify"].invoke end + + # rubocop:enable Style/GlobalVars end diff --git a/scripts/rake/outdated_packages.rb b/scripts/rake/outdated_packages.rb index 8edb06452..fcfa6274a 100644 --- a/scripts/rake/outdated_packages.rb +++ b/scripts/rake/outdated_packages.rb @@ -1,6 +1,7 @@ require "json" -require "open-uri" +require "net/http" require "rainbow" +require "uri" class OutdatedPackages REPOS = { @@ -38,42 +39,46 @@ class OutdatedPackages "libgeoip" => { :git => "https://github.com/maxmind/geoip-api-c.git", }, - "luarocks" => { - :git => "https://github.com/keplerproject/luarocks.git", - }, - "luarock_argparse" => { + "lua_argparse" => { :luarock => "argparse", }, - "luarock_cmsgpack" => { + "lua_cmsgpack" => { :luarock => "lua-cmsgpack", }, - "luarock_iconv" => { + "lua_iconv" => { :luarock => "lua-iconv", }, - "luarock_inspect" => { + "lua_icu_date" => { + :git => "https://github.com/GUI/lua-icu-date.git", + :git_ref => "master", + }, + "lua_inspect" => { :luarock => "inspect", }, - "luarock_luacheck" => { + "lua_libcidr_ffi" => { + :git => "https://github.com/GUI/lua-libcidr-ffi.git", + }, + "lua_luacheck" => { :luarock => "luacheck", }, - "luarock_luaposix" => { + "lua_luaposix" => { :luarock => "luaposix", }, - "luarock_lustache" => { + "lua_luasocket" => { + :git => "https://github.com/diegonehab/luasocket.git", + :git_ref => "master", + }, + "lua_lustache" => { :luarock => "lustache", }, - "luarock_lyaml" => { + "lua_lyaml" => { :luarock => "lyaml", }, - "luarock_penlight" => { + "lua_penlight" => { :luarock => "penlight", }, - "luarock_resty_uuid" => { - :luarock => "lua-resty-uuid", - }, - "lua_luasocket" => { - :git => "https://github.com/diegonehab/luasocket.git", - :git_ref => "master", + "lua_resty_http" => { + :git => "https://github.com/pintsized/lua-resty-http.git", }, "lua_resty_logger_socket" => { :git => "https://github.com/cloudflare/lua-resty-logger-socket.git", @@ -83,6 +88,15 @@ class OutdatedPackages :git => "https://github.com/cloudflare/lua-resty-shcache.git", :git_ref => "master", }, + "lua_resty_txid" => { + :git => "https://github.com/GUI/lua-resty-txid.git", + }, + "lua_resty_uuid" => { + :luarock => "lua-resty-uuid", + }, + "luarocks" => { + :git => "https://github.com/keplerproject/luarocks.git", + }, "mailhog" => { :git => "https://github.com/mailhog/MailHog.git", }, @@ -111,19 +125,6 @@ class OutdatedPackages :git => "https://github.com/openssl/openssl.git", :string_version => true, }, - "opm_icu_date" => { - :git => "https://github.com/GUI/lua-icu-date.git", - :git_ref => "master", - }, - "opm_libcidr" => { - :git => "https://github.com/GUI/lua-libcidr-ffi.git", - }, - "opm_resty_http" => { - :git => "https://github.com/pintsized/lua-resty-http.git", - }, - "opm_resty_txid" => { - :git => "https://github.com/GUI/lua-resty-txid.git", - }, "pcre" => { :http => "https://ftp.pcre.org/pub/pcre/", }, @@ -149,6 +150,9 @@ class OutdatedPackages "shellcheck" => { :git => "https://github.com/koalaman/shellcheck.git", }, + "task" => { + :git => "https://github.com/go-task/task.git", + }, "trafficserver" => { :git => "https://github.com/apache/trafficserver.git", }, @@ -158,10 +162,10 @@ class OutdatedPackages "yarn" => { :git => "https://github.com/yarnpkg/yarn.git", }, - } + }.freeze def luarocks_manifest - @luarocks_manifest ||= JSON.load(open("https://luarocks.org/manifest.json")) + @luarocks_manifest ||= JSON.parse(Net::HTTP.get_response(URI.parse("https://luarocks.org/manifest.json")).body) end def luarock_version_to_semver(version) @@ -177,7 +181,7 @@ def tag_to_semver(name, tag) # Remove prefixes containing the project name. tag.gsub!(/^#{name}[\-_]/i, "") - tag.gsub!(/^#{name.gsub("_", "-")}[\-_]/i, "") + tag.gsub!(/^#{name.tr("_", "-")}[\-_]/i, "") # Remove trailing "^{}" at end of git tags. tag.chomp!("^{}") @@ -196,9 +200,9 @@ def tag_to_semver(name, tag) tag.gsub!(/-\d{8}$/, "") when "openldap" tag.gsub!(/^rel_eng_/, "") - tag.gsub!(/_/, ".") + tag.tr!("_", ".") when "openssl", "ruby" - tag.gsub!(/_/, ".") + tag.tr!("_", ".") end tag @@ -207,9 +211,9 @@ def tag_to_semver(name, tag) def initialize seen_names = [] versions = {} - versions_content = `git grep -h "^set.*_VERSION" build/cmake`.strip + versions_content = `git grep -hE "^\\w+_version=" tasks`.strip versions_content.each_line do |line| - current_version_matches = line.match(/set\((.+?)_VERSION (.+?)\)/) + current_version_matches = line.match(/^(.+?)_version=['"]([^'"]+)/) if(!current_version_matches) next end @@ -251,9 +255,9 @@ def initialize puts "#{name}: Could not parse latest commit: git ls-remote #{options[:git]} #{options[:git_ref]}" end - versions[name][:current_version] = current_commit[0,7] - versions[name][:latest_version] = latest_commit[0,7] - versions[name][:wanted_version] = latest_commit[0,7] + versions[name][:current_version] = current_commit[0, 7] + versions[name][:latest_version] = latest_commit[0, 7] + versions[name][:wanted_version] = latest_commit[0, 7] elsif(options[:git]) tags = `git ls-remote --tags #{options[:git]}`.lines tags.map! { |tag| tag_to_semver(name, tag.match(%r{refs/tags/(.+)$})[1]) } @@ -264,7 +268,7 @@ def initialize tags = luarocks_manifest["repository"][options[:luarock]].keys tags.map! { |tag| luarock_version_to_semver(tag) } elsif(options[:http]) - content = open(options[:http]).read + content = Net::HTTP.get_response(URI.parse(options[:http])).body tags = content.scan(/#{name}-[\d\.]+.tar/) tags.map! { |f| tag_to_semver(name, File.basename(f, ".tar")) } end @@ -299,7 +303,7 @@ def initialize versions[name][:wanted_version] = available_version end end - rescue ArgumentError => e + rescue ArgumentError unparsable_tags << tag end end @@ -347,4 +351,3 @@ def initialize end end end - diff --git a/src/api-umbrella/web-app/Rakefile b/src/api-umbrella/web-app/Rakefile index 9191afc6b..f8e67b061 100644 --- a/src/api-umbrella/web-app/Rakefile +++ b/src/api-umbrella/web-app/Rakefile @@ -1,7 +1,7 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require File.expand_path('config/application', __dir__) Rails.application.load_tasks diff --git a/src/api-umbrella/web-app/lib/tasks/i18n.rake b/src/api-umbrella/web-app/lib/tasks/i18n.rake index 5381e1383..753044e1c 100644 --- a/src/api-umbrella/web-app/lib/tasks/i18n.rake +++ b/src/api-umbrella/web-app/lib/tasks/i18n.rake @@ -2,7 +2,7 @@ namespace :i18n do task :to_gettext => :environment do def escape(string) string.gsub(/([\\"\t\n])/) do - special_character = $1 + special_character = Regexp.last_match(1) case special_character when "\t" "\\t" @@ -108,7 +108,7 @@ namespace :i18n do locale_data = I18n.with_locale(locale) { I18n.t(".") } gettext_data = i18n_to_gettext(en_data, locale_data) - lang = locale.to_s.gsub("-", "_") + lang = locale.to_s.tr("-", "_") File.open(File.join(root_dir, "locale/#{lang}.po"), "w") do |file| file.puts('msgid ""') file.puts('msgstr ""') diff --git a/tasks/app-deps/admin-ui/yarn b/tasks/app-deps/admin-ui/yarn new file mode 100755 index 000000000..ff4014b06 --- /dev/null +++ b/tasks/app-deps/admin-ui/yarn @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir + +# Install into the task's special _persist directory so the large node_modules +# directory isn't cleaned between runs for development purposes. +mkdir -p _persist +cd _persist + +# Copy the npm/yarn config files into the working directory and perform the +# installation here (so we're not creating/modifying files in the source +# directory). +cp "$SOURCE_DIR/src/api-umbrella/admin-ui/package.json" ./ +cp "$SOURCE_DIR/src/api-umbrella/admin-ui/yarn.lock" ./ +PATH="$DEV_PATH" yarn install --frozen-lockfile + +# Remove some unnecessary and large files that are shipped in a couple of the +# Ember npm packages (I think usually by accident). This just helps slim down +# the size of node_modules a bit. +rm -rf ./node_modules/*/.node_modules.ember-try + +stamp diff --git a/tasks/app-deps/lua/argparse b/tasks/app-deps/lua/argparse new file mode 100755 index 000000000..f69c8b4d9 --- /dev/null +++ b/tasks/app-deps/lua/argparse @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_argparse_version="0.6.0-1" + +set -e -u -x +source ./tasks/helpers.sh + +luarocks_install "argparse" "$lua_argparse_version" + +stamp diff --git a/tasks/app-deps/lua/cmsgpack b/tasks/app-deps/lua/cmsgpack new file mode 100755 index 000000000..d1115f6a1 --- /dev/null +++ b/tasks/app-deps/lua/cmsgpack @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_cmsgpack_version="0.4.0-0" + +set -e -u -x +source ./tasks/helpers.sh + +luarocks_install "lua-cmsgpack" "$lua_cmsgpack_version" + +stamp diff --git a/tasks/app-deps/lua/iconv b/tasks/app-deps/lua/iconv new file mode 100755 index 000000000..f497cecfe --- /dev/null +++ b/tasks/app-deps/lua/iconv @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_iconv_version="7-3" + +set -e -u -x +source ./tasks/helpers.sh + +luarocks_install "lua-iconv" "$lua_iconv_version" + +stamp diff --git a/tasks/app-deps/lua/icu-date b/tasks/app-deps/lua/icu-date new file mode 100755 index 000000000..592486e31 --- /dev/null +++ b/tasks/app-deps/lua/icu-date @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +lua_icu_date_version="857990ba72cf48f7ae20dfb861a783231b5a2e79" +lua_icu_date_hash="580f4a650782556266cc341630d39f63" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://github.com/GUI/lua-icu-date/archive/$lua_icu_date_version.tar.gz" "md5" "$lua_icu_date_hash" +extract_download "$lua_icu_date_version.tar.gz" + +cd "lua-icu-date-$lua_icu_date_version" +"${LUAROCKS_CMD[@]}" --tree="$APP_CORE_VENDOR_LUA_DIR" make --local icu-date-git-1.rockspec + +stamp diff --git a/tasks/app-deps/lua/inspect b/tasks/app-deps/lua/inspect new file mode 100755 index 000000000..619809c15 --- /dev/null +++ b/tasks/app-deps/lua/inspect @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_inspect_version="3.1.1-0" + +set -e -u -x +source ./tasks/helpers.sh + +luarocks_install "inspect" "$lua_inspect_version" + +stamp diff --git a/tasks/app-deps/lua/libcidr-ffi b/tasks/app-deps/lua/libcidr-ffi new file mode 100755 index 000000000..76729b41d --- /dev/null +++ b/tasks/app-deps/lua/libcidr-ffi @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_libcidr_ffi_version="0.1.3" + +set -e -u -x +source ./tasks/helpers.sh + +opm_install "GUI/lua-libcidr-ffi" "$lua_libcidr_ffi_version" + +stamp diff --git a/tasks/app-deps/lua/luaposix b/tasks/app-deps/lua/luaposix new file mode 100755 index 000000000..27a04e891 --- /dev/null +++ b/tasks/app-deps/lua/luaposix @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_luaposix_version="34.0.4-1" + +set -e -u -x +source ./tasks/helpers.sh + +luarocks_install "luaposix" "$lua_luaposix_version" + +stamp diff --git a/tasks/app-deps/lua/luasocket b/tasks/app-deps/lua/luasocket new file mode 100755 index 000000000..a1a4c28b1 --- /dev/null +++ b/tasks/app-deps/lua/luasocket @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +lua_luasocket_version="4df569e9f867432f25f0bfbfa56b0962feb3326e" +lua_luasocket_hash="8e95251f3aec7dc5bd732c78bb25192b" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://github.com/diegonehab/luasocket/archive/$lua_luasocket_version.tar.gz" "md5" "$lua_luasocket_hash" +extract_download "$lua_luasocket_version.tar.gz" + +# Just install the URL parsing library from luasocket (rather than the whole +# luarocks, since we don't need the other parts, and the luarock is somewhat +# outdated). In order to just install this one file, patch it to work without +# the base luasocket library present (it doesn't actually use the base stuff +# for anything). +cd "luasocket-$lua_luasocket_version" +sed -i -e "s%local socket = require.*%local socket = {}%" src/url.lua +install -D -m 644 src/url.lua "$APP_CORE_VENDOR_LUA_SHARE_DIR/socket/url.lua" + +stamp diff --git a/tasks/app-deps/lua/lustache b/tasks/app-deps/lua/lustache new file mode 100755 index 000000000..7253a5125 --- /dev/null +++ b/tasks/app-deps/lua/lustache @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_lustache_version="1.3.1-0" + +set -e -u -x +source ./tasks/helpers.sh + +luarocks_install "lustache" "$lua_lustache_version" + +stamp diff --git a/tasks/app-deps/lua/lyaml b/tasks/app-deps/lua/lyaml new file mode 100755 index 000000000..5d0be3ef3 --- /dev/null +++ b/tasks/app-deps/lua/lyaml @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_lyaml_version="6.2.2-1" + +set -e -u -x +source ./tasks/helpers.sh + +luarocks_install "lyaml" "$lua_lyaml_version" + +stamp diff --git a/tasks/app-deps/lua/penlight b/tasks/app-deps/lua/penlight new file mode 100755 index 000000000..ac04b4ad1 --- /dev/null +++ b/tasks/app-deps/lua/penlight @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_penlight_version="1.5.4-1" + +set -e -u -x +source ./tasks/helpers.sh + +luarocks_install "penlight" "$lua_penlight_version" + +stamp diff --git a/tasks/app-deps/lua/resty-http b/tasks/app-deps/lua/resty-http new file mode 100755 index 000000000..4602c2046 --- /dev/null +++ b/tasks/app-deps/lua/resty-http @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_resty_http_version="0.12" + +set -e -u -x +source ./tasks/helpers.sh + +opm_install "pintsized/lua-resty-http" "$lua_resty_http_version" + +stamp diff --git a/tasks/app-deps/lua/resty-logger-socket b/tasks/app-deps/lua/resty-logger-socket new file mode 100755 index 000000000..83a1f15a2 --- /dev/null +++ b/tasks/app-deps/lua/resty-logger-socket @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +lua_resty_logger_socket_version="15cc1c256e55b8e68ec9b220b6883c227a763d4e" +lua_resty_logger_socket_hash="efe14697a8c4be612c011f54fce06191" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://github.com/cloudflare/lua-resty-logger-socket/archive/$lua_resty_logger_socket_version.tar.gz" "md5" "$lua_resty_logger_socket_hash" +extract_download "$lua_resty_logger_socket_version.tar.gz" + +install -D -m 644 "lua-resty-logger-socket-$lua_resty_logger_socket_version/lib/resty/logger/socket.lua" "$APP_CORE_VENDOR_LUA_SHARE_DIR/resty/logger/socket.lua" + +stamp diff --git a/tasks/app-deps/lua/resty-shcache b/tasks/app-deps/lua/resty-shcache new file mode 100755 index 000000000..7be3a752c --- /dev/null +++ b/tasks/app-deps/lua/resty-shcache @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +lua_resty_shcache_version="fb2e275c2cdca08eaa34a7b73375e41ac3eff200" +lua_resty_shcache_hash="5d3cbcf8fbad1954cdcb3826afa41afe" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://github.com/cloudflare/lua-resty-shcache/archive/$lua_resty_shcache_version.tar.gz" "md5" "$lua_resty_shcache_hash" +extract_download "$lua_resty_shcache_version.tar.gz" + +install -D -m 644 "lua-resty-shcache-$lua_resty_shcache_version/shcache.lua" "$APP_CORE_VENDOR_LUA_SHARE_DIR/shcache.lua" + +stamp diff --git a/tasks/app-deps/lua/resty-txid b/tasks/app-deps/lua/resty-txid new file mode 100755 index 000000000..50a2f8f30 --- /dev/null +++ b/tasks/app-deps/lua/resty-txid @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_resty_txid_version="1.0.0" + +set -e -u -x +source ./tasks/helpers.sh + +opm_install "GUI/lua-resty-txid" "$lua_resty_txid_version" + +stamp diff --git a/tasks/app-deps/lua/resty-uuid b/tasks/app-deps/lua/resty-uuid new file mode 100755 index 000000000..f800e4164 --- /dev/null +++ b/tasks/app-deps/lua/resty-uuid @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_resty_uuid_version="1.1-1" + +set -e -u -x +source ./tasks/helpers.sh + +luarocks_install "lua-resty-uuid" "$lua_resty_uuid_version" + +stamp diff --git a/tasks/app-deps/web-app/bundle b/tasks/app-deps/web-app/bundle new file mode 100755 index 000000000..e8aec0092 --- /dev/null +++ b/tasks/app-deps/web-app/bundle @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir + +# Install into the task's special _persist directory so the installed gems dir +# isn't cleaned between runs for development purposes. +mkdir -p _persist +cd _persist + +# Install all the gems for use in development/test. +export PATH="$STAGE_EMBEDDED_PATH" +export BUNDLE_GEMFILE="$SOURCE_DIR/src/api-umbrella/web-app/Gemfile" +BUNDLE_APP_CONFIG="$(pwd)/.bundle" +export BUNDLE_APP_CONFIG +bundle config --local build.nokogiri --use-system-libraries +bundle config --local path "$(pwd)/bundle" +bundle config --local clean true +bundle install + +# Make a copy of the gems in the release directory for production purposes, and +# then remove all non-production gems. +mkdir -p "$APP_CORE_VENDOR_BUNDLE_DIR" +rsync -a --delete ./bundle/ "$APP_CORE_VENDOR_BUNDLE_DIR/" +rsync -a -v --delete ./.bundle/ ./.bundle-prod/ +BUNDLE_APP_CONFIG="$(pwd)/.bundle-prod" +export BUNDLE_APP_CONFIG +bundle config --local path "$APP_CORE_VENDOR_BUNDLE_DIR" +bundle config --local without "development:test:assets" +bundle config --local clean true +bundle config --local deployment true +bundle install + +# Purge gem files we don't need to make for a lighter package distribution. +rm -rf \ + "$APP_CORE_VENDOR_BUNDLE_DIR"/ruby/*/cache \ + "$APP_CORE_VENDOR_BUNDLE_DIR"/ruby/*/gems/*/test* \ + "$APP_CORE_VENDOR_BUNDLE_DIR"/ruby/*/gems/*/spec \ + "$APP_CORE_VENDOR_BUNDLE_DIR"/ruby/*/bundler/gems/*/test* \ + "$APP_CORE_VENDOR_BUNDLE_DIR"/ruby/*/bundler/gems/*/spec \ + "$APP_CORE_VENDOR_BUNDLE_DIR"/ruby/*/bundler/gems/*/.git + +stamp diff --git a/tasks/app/admin-ui/build b/tasks/app/admin-ui/build new file mode 100755 index 000000000..9c27b79dd --- /dev/null +++ b/tasks/app/admin-ui/build @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir + +# Install into the task's special _persist directory so that these dependencies +# for the tasks/app/core task are still present if core needs to be re-run, but +# not this task. +mkdir -p _persist +cd _persist + +rsync -a -v \ + --delete \ + --delete-excluded \ + --filter=":- $SOURCE_DIR/src/api-umbrella/admin-ui/.gitignore" \ + "$SOURCE_DIR/src/api-umbrella/admin-ui/" \ + ./ + +node_modules_dir="$WORK_DIR/tasks/app-deps/admin-ui/yarn/_persist/node_modules" +ln -s "$node_modules_dir" ./node_modules +PATH="$DEV_INSTALL_PREFIX/bin:$DEFAULT_PATH" ./node_modules/.bin/ember build \ + --environment=production \ + --output-path=./dist + +stamp diff --git a/tasks/app/core b/tasks/app/core new file mode 100755 index 000000000..92e39e6ca --- /dev/null +++ b/tasks/app/core @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh + +# Copy all the API Umbrella source into the release directory. +mkdir -p "$APP_CORE_RELEASE_DIR" +rsync -a \ + --delete-after \ + --delete-excluded \ + --filter=":- $SOURCE_DIR/.gitignore" \ + --include=/templates/etc/perp/.boot \ + --exclude=.* \ + --exclude=/templates/etc/test-env* \ + --exclude=/templates/etc/perp/test-env* \ + --exclude=/src/api-umbrella/web-app/spec \ + --exclude=/src/api-umbrella/web-app/app/assets \ + --include=/bin/*** \ + --include=/config/*** \ + --include=/LICENSE.txt \ + --include=/templates/*** \ + --include=/src/*** \ + --exclude=* \ + "$SOURCE_DIR/" \ + "$APP_CORE_RELEASE_DIR/" + +# Add build pieces from the other tasks into the release directory (eg, +# compiled assets). +mkdir -p "$APP_CORE_RELEASE_DIR/build/dist" +rsync -a --delete-after \ + "$WORK_DIR/tasks/app/admin-ui/build/_persist/dist/" \ + "$APP_CORE_RELEASE_DIR/build/dist/admin-ui/" +rsync -a --delete-after \ + "$SOURCE_DIR/src/api-umbrella/web-app/public/" \ + "$APP_CORE_RELEASE_DIR/build/dist/web-app-public/" +rsync -a --delete-after \ + "$WORK_DIR/tasks/app/web-app/precompile/_persist/public/web-assets/" \ + "$APP_CORE_RELEASE_DIR/build/dist/web-app-public/web-assets/" +rsync -a -v --delete-after \ + "$WORK_DIR/tasks/app-deps/web-app/bundle/_persist/.bundle-prod/" \ + "$APP_CORE_RELEASE_DIR/src/api-umbrella/web-app/.bundle/" + +# Fix the bundle path so it's relative and works within the release directory. +PATH="$STAGE_EMBEDDED_PATH" BUNDLE_APP_CONFIG="$APP_CORE_RELEASE_DIR/src/api-umbrella/web-app/.bundle" bundle config --local path "../../../vendor/bundle" + +# Add symlinks for the release. +(cd "$APP_CORE_DIR" && ln -snf releases/0 ./current) +(cd "$APP_CORE_DIR/releases/0" && ln -snf ../../shared/vendor ./vendor) + +# Add symlinks for bin files into the release. +mkdir -p "$STAGE_PREFIX_DIR/bin" +( + cd "$STAGE_PREFIX_DIR/bin" + ln -snf ../embedded/apps/core/current/bin/api-umbrella ./api-umbrella + ln -snf ../embedded/apps/core/current/bin/api-umbrella-env ./api-umbrella-env + ln -snf ../embedded/apps/core/current/bin/api-umbrella-exec ./api-umbrella-exec +) + +stamp diff --git a/tasks/app/static-site b/tasks/app/static-site new file mode 100755 index 000000000..13e0ab4c3 --- /dev/null +++ b/tasks/app/static-site @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +api_umbrella_static_site_version="c02b8869cafb063deb7f9436d0137b0ea6e652aa" +api_umbrella_static_site_hash="07dbd5e6d96e62a9ad6b725b14f727a1" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://github.com/NREL/api-umbrella-static-site/archive/$api_umbrella_static_site_version.tar.gz" "md5" "$api_umbrella_static_site_hash" +extract_download "$api_umbrella_static_site_version.tar.gz" + +cd "api-umbrella-static-site-$api_umbrella_static_site_version" +PATH="$STAGE_EMBEDDED_PATH" bundle config --local build.nokogiri --use-system-libraries +PATH="$STAGE_EMBEDDED_PATH" bundle config --local path "$(pwd)/vendor/bundle" +PATH="$STAGE_EMBEDDED_PATH" bundle install +PATH="$DEV_PATH" bundle exec middleman build +rm -rf "$STAGE_EMBEDDED_DIR/apps/static-site/releases" +mkdir -p "$STAGE_EMBEDDED_DIR/apps/static-site/releases/0/build" +rsync -a ./build/ "$STAGE_EMBEDDED_DIR/apps/static-site/releases/0/build/" +(cd "$STAGE_EMBEDDED_DIR/apps/static-site" && ln -snf releases/0 ./current) + +stamp diff --git a/tasks/app/web-app/precompile b/tasks/app/web-app/precompile new file mode 100755 index 000000000..351b8b631 --- /dev/null +++ b/tasks/app/web-app/precompile @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir + +# Install into the task's special _persist directory so that these dependencies +# for the tasks/app/core task are still present if core needs to be re-run, but +# not this task. +mkdir -p _persist +cd _persist + +export PATH="$STAGE_EMBEDDED_PATH" +export BUNDLE_GEMFILE="$SOURCE_DIR/src/api-umbrella/web-app/Gemfile" +export BUNDLE_APP_CONFIG="$WORK_DIR/tasks/app-deps/web-app/bundle/_persist/.bundle" +RAILS_TMP_PATH="$(pwd)/tmp" +export RAILS_TMP_PATH +RAILS_PUBLIC_PATH="$(pwd)/public" +export RAILS_PUBLIC_PATH +export RAILS_ENV=production +export RAILS_SECRET_TOKEN=temp +export RAILS_ASSETS_PRECOMPILE=true +bundle exec rake -f "$SOURCE_DIR/src/api-umbrella/web-app/Rakefile" assets:clobber assets:precompile + +stamp diff --git a/tasks/bootstrap-2.0.2 b/tasks/bootstrap-2.0.2 new file mode 100755 index 000000000..ce2e4832e --- /dev/null +++ b/tasks/bootstrap-2.0.2 @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +task_version="2.0.2" +task_hash="32fa0ca07d566c0384e513e5d6d108556866aac14d1e62dabf095833472e3651" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://github.com/go-task/task/releases/download/v$task_version/task_linux_amd64.tar.gz" "sha256" "$task_hash" +extract_download "task_linux_amd64.tar.gz" +cp ./task "$WORK_DIR/task" + +stamp diff --git a/tasks/build-deps/nodejs b/tasks/build-deps/nodejs new file mode 100755 index 000000000..435029682 --- /dev/null +++ b/tasks/build-deps/nodejs @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +nodejs_version="8.11.2" +nodejs_hash="213599127d24496cbf1cbb2a7c51060a3506d6b11132c59bb7f9f8a0edd210a7" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://nodejs.org/dist/v$nodejs_version/node-v$nodejs_version-linux-x64.tar.xz" "sha256" "$nodejs_hash" +extract_download "node-v$nodejs_version-linux-x64.tar.xz" + +rsync -a -v "node-v$nodejs_version-linux-x64/" "$DEV_INSTALL_PREFIX/" + +stamp diff --git a/tasks/build-deps/yarn b/tasks/build-deps/yarn new file mode 100755 index 000000000..178f7ac5c --- /dev/null +++ b/tasks/build-deps/yarn @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +yarn_version="1.7.0" +yarn_hash="e149b4cc0c2cb903551a0b857a2b3c78" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://github.com/yarnpkg/yarn/releases/download/v$yarn_version/yarn-v$yarn_version.tar.gz" "md5" "$yarn_hash" +extract_download "yarn-v$yarn_version.tar.gz" + +rsync -a -v --delete "yarn-v$yarn_version/" "$DEV_INSTALL_PREFIX/yarn/" +cd "$DEV_INSTALL_PREFIX/bin" && ln -snf ../yarn/bin/yarn ./yarn + +# Remove the previous bin symlink that was necessary. +rm -f "$DEV_INSTALL_PREFIX/bin/yarn.js" + +stamp diff --git a/tasks/deps/bundler b/tasks/deps/bundler new file mode 100755 index 000000000..ed739d781 --- /dev/null +++ b/tasks/deps/bundler @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +bundler_version="1.16.2" + +set -e -u -x +source ./tasks/helpers.sh + +PATH=$STAGE_EMBEDDED_PATH gem install bundler --version $bundler_version --no-document --env-shebang --force + +stamp diff --git a/tasks/deps/elasticsearch b/tasks/deps/elasticsearch new file mode 100755 index 000000000..e58dfd7c8 --- /dev/null +++ b/tasks/deps/elasticsearch @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +elasticsearch_version="2.4.6" +elasticsearch_hash="c3441bef89cd91206edf3cf3bd5c4b62550e60a9" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-$elasticsearch_version.tar.gz" "sha1" "$elasticsearch_hash" +extract_download "elasticsearch-$elasticsearch_version.tar.gz" + +rsync -a -v --checksum --delete-after "elasticsearch-$elasticsearch_version/" "$STAGE_EMBEDDED_DIR/elasticsearch/" +mkdir -p "$STAGE_EMBEDDED_DIR/elasticsearch/plugins" + +stamp diff --git a/tasks/deps/geolitecity b/tasks/deps/geolitecity new file mode 100755 index 000000000..c1bd0464e --- /dev/null +++ b/tasks/deps/geolitecity @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e -u +source ./tasks/helpers.sh +set +x + +# If the file exists and was created within the past day, then skip doing +# anything else. This approach ensures that new files are downloaded, but only +# once per day. +if [[ $(find "$STAGE_EMBEDDED_DIR/var/db/geoip/city-v6.dat" -mmin -1440) ]]; then + exit 0 +fi + +set -x + +task_working_dir +curl --location --retry 3 --fail --remote-name https://geolite.maxmind.com/download/geoip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz +gunzip -c GeoLiteCityv6.dat.gz > GeoLiteCityv6.dat +install -D -m 644 ./GeoLiteCityv6.dat "$STAGE_EMBEDDED_DIR/var/db/geoip/city-v6.dat" + +stamp diff --git a/tasks/deps/golang b/tasks/deps/golang new file mode 100755 index 000000000..559b8c5fd --- /dev/null +++ b/tasks/deps/golang @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +golang_version="1.10.2" +golang_hash="4b677d698c65370afa33757b6954ade60347aaca310ea92a63ed717d7cb0c2ff" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://dl.google.com/go/go$golang_version.linux-amd64.tar.gz" "sha256" "$golang_hash" +extract_download "go$golang_version.linux-amd64.tar.gz" + +stamp diff --git a/tasks/deps/libcidr b/tasks/deps/libcidr new file mode 100755 index 000000000..e33ba2865 --- /dev/null +++ b/tasks/deps/libcidr @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +libcidr_version="1.2.3" +libcidr_hash="c5efcc7ae114fdaa5583f58dacecd9de" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://www.over-yonder.net/~fullermd/projects/libcidr/libcidr-$libcidr_version.tar.xz" "md5" "$libcidr_hash" +extract_download "libcidr-$libcidr_version.tar.xz" + +cd "libcidr-$libcidr_version" +make PREFIX="$INSTALL_PREFIX_EMBEDDED" +make install NO_DOCS=1 NO_EXAMPLES=1 PREFIX="$INSTALL_PREFIX_EMBEDDED" DESTDIR="$STAGE_DIR" + +stamp diff --git a/tasks/deps/libestr b/tasks/deps/libestr new file mode 100755 index 000000000..a067309e6 --- /dev/null +++ b/tasks/deps/libestr @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +libestr_version="0.1.10" +libestr_hash="bd655e126e750edd18544b88eb1568d200a424a0c23f665eb14bbece07ac703c" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "http://libestr.adiscon.com/files/download/libestr-$libestr_version.tar.gz" "sha256" "$libestr_hash" +extract_download "libestr-$libestr_version.tar.gz" + +cd "libestr-$libestr_version" +./configure --prefix="$INSTALL_PREFIX_EMBEDDED" +make +make install DESTDIR="$STAGE_DIR" + +stamp diff --git a/tasks/deps/libfastjson b/tasks/deps/libfastjson new file mode 100755 index 000000000..db8014eb6 --- /dev/null +++ b/tasks/deps/libfastjson @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +libfastjson_version="0.99.8" +libfastjson_hash="730713ad1d851def7ac8898f751bbfdd" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://github.com/rsyslog/libfastjson/archive/v$libfastjson_version.tar.gz" "md5" "$libfastjson_hash" +extract_download "v$libfastjson_version.tar.gz" + +cd "libfastjson-$libfastjson_version" +sh autogen.sh +./configure --prefix="$INSTALL_PREFIX_EMBEDDED" +make +make install DESTDIR="$STAGE_DIR" + +stamp diff --git a/tasks/deps/libgeoip b/tasks/deps/libgeoip new file mode 100755 index 000000000..c3ab33fb5 --- /dev/null +++ b/tasks/deps/libgeoip @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +libgeoip_version="1.6.12" +libgeoip_hash="77d496cc40daa1dbc2b97365807d64d7" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://github.com/maxmind/geoip-api-c/releases/download/v$libgeoip_version/GeoIP-$libgeoip_version.tar.gz" "md5" "$libgeoip_hash" +extract_download "GeoIP-$libgeoip_version.tar.gz" + +cd "GeoIP-$libgeoip_version" +./configure --prefix="$INSTALL_PREFIX_EMBEDDED" +make +make install DESTDIR="$STAGE_DIR" +find "$STAGE_EMBEDDED_DIR/bin/" -name "geoiplookup*" -exec chrpath -d {} \; + +stamp diff --git a/tasks/deps/luarocks b/tasks/deps/luarocks new file mode 100755 index 000000000..fae032b24 --- /dev/null +++ b/tasks/deps/luarocks @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +luarocks_version="2.4.4" +luarocks_hash="04e8b19d565e86b1d08f745adc4b1a56" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "http://luarocks.org/releases/luarocks-$luarocks_version.tar.gz" "md5" "$luarocks_hash" +extract_download "luarocks-$luarocks_version.tar.gz" + +cd "luarocks-$luarocks_version" +./configure \ + --prefix="$INSTALL_PREFIX_EMBEDDED/openresty/luajit" \ + --with-lua="$STAGE_EMBEDDED_DIR/openresty/luajit" \ + --with-lua-include="$STAGE_EMBEDDED_DIR/openresty/luajit/include/luajit-2.1" \ + --lua-suffix=jit +make build +make install DESTDIR="$STAGE_DIR" +(cd "$STAGE_EMBEDDED_DIR/bin" && ln -snf ../openresty/luajit/bin/luarocks ./luarocks) + +stamp diff --git a/tasks/deps/mongodb b/tasks/deps/mongodb new file mode 100755 index 000000000..9e4513704 --- /dev/null +++ b/tasks/deps/mongodb @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +mongodb_version="3.2.20" +mongodb_hash="01f7660d86b3de679ce388eaa681286a" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-$mongodb_version.tgz" "md5" "$mongodb_hash" +extract_download "mongodb-linux-x86_64-$mongodb_version.tgz" + +rsync -a -v "mongodb-linux-x86_64-$mongodb_version/" "$STAGE_EMBEDDED_DIR/" + +# Trim our own distribution by removing some larger files we don't need for API +# Umbrella. +rm -f "$STAGE_EMBEDDED_DIR/bin/bsondump" \ + "$STAGE_EMBEDDED_DIR/bin/mongoexport" \ + "$STAGE_EMBEDDED_DIR/bin/mongofiles" \ + "$STAGE_EMBEDDED_DIR/bin/mongoimport" \ + "$STAGE_EMBEDDED_DIR/bin/mongooplog" \ + "$STAGE_EMBEDDED_DIR/bin/mongoperf" \ + "$STAGE_EMBEDDED_DIR/bin/mongos" + +stamp diff --git a/tasks/deps/mora b/tasks/deps/mora new file mode 100755 index 000000000..4c5f91299 --- /dev/null +++ b/tasks/deps/mora @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +mora_version="8127901857cf88d3f0902708b25ad930354973a3" +mora_hash="b86cea913596370cd58fce89b23acd97" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://github.com/emicklei/mora/archive/$mora_version.tar.gz" "md5" "$mora_hash" +gopath="$(pwd)/gocode" +mora_dir="$gopath/src/github.com/emicklei/mora" +mkdir -p "$mora_dir" +tar -xf "_persist/downloads/$mora_version.tar.gz" -C "$mora_dir" --strip-components 1 + +golang_source_dir="$WORK_DIR/tasks/deps/golang/go" +(cd "$mora_dir" && PATH="$golang_source_dir/bin:$DEFAULT_PATH" GOPATH="$gopath" GOROOT="$golang_source_dir" go install) +install -D -m 755 "$gopath/bin/mora" "$STAGE_EMBEDDED_DIR/bin/mora" + +stamp diff --git a/tasks/deps/openresty b/tasks/deps/openresty new file mode 100755 index 000000000..425a16b42 --- /dev/null +++ b/tasks/deps/openresty @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +openresty_version="1.13.6.2" +openresty_hash="d95bc4bbe15e4b045a0593b4ecc0db38" +openssl_version="1.0.2o" +openssl_hash="ec3f5c9714ba0fd45cb4e087301eb1336c317e0d20b575a125050470e8089e4d" +pcre_version="8.42" +pcre_hash="085b6aa253e0f91cae70b3cdbe8c1ac2" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir + +download "https://ftp.pcre.org/pub/pcre/pcre-$pcre_version.tar.bz2" "md5" "$pcre_hash" +extract_download "pcre-$pcre_version.tar.bz2" + +download "https://www.openssl.org/source/openssl-$openssl_version.tar.gz" "sha256" "$openssl_hash" +extract_download "openssl-$openssl_version.tar.gz" + +download "https://openresty.org/download/openresty-$openresty_version.tar.gz" "md5" "$openresty_hash" +extract_download "openresty-$openresty_version.tar.gz" + +cd "openresty-$openresty_version" +patch -p1 < "$SOURCE_DIR/build/patches/openresty-opm.patch" +patch -p1 < "$SOURCE_DIR/build/patches/openresty-cli.patch" + +./configure \ + --prefix="$INSTALL_PREFIX_EMBEDDED/openresty" \ + --with-cc-opt="-I$STAGE_EMBEDDED_DIR/include" \ + --with-ld-opt="-L$STAGE_EMBEDDED_DIR/lib" \ + --error-log-path=stderr \ + --with-ipv6 \ + --with-openssl="../openssl-$openssl_version" \ + --with-pcre="../pcre-$pcre_version" \ + --with-pcre-opt=-g \ + --with-pcre-conf-opt=--enable-unicode-properties \ + --with-pcre-jit \ + --with-http_geoip_module \ + --with-http_gunzip_module \ + --with-http_gzip_static_module \ + --with-http_realip_module \ + --with-http_ssl_module \ + --with-http_stub_status_module +make +make install DESTDIR="$STAGE_DIR" +chrpath -d "$STAGE_EMBEDDED_DIR/openresty/nginx/sbin/nginx" +( + cd "$STAGE_EMBEDDED_DIR/bin" + ln -snf ../openresty/bin/opm ./opm + ln -snf ../openresty/bin/resty ./resty + ln -snf ../openresty/luajit/bin/luajit ./luajit +) +mkdir -p "$STAGE_EMBEDDED_DIR/sbin" +(cd "$STAGE_EMBEDDED_DIR/sbin" && ln -snf ../openresty/nginx/sbin/nginx ./nginx) + +stamp diff --git a/tasks/deps/perp b/tasks/deps/perp new file mode 100755 index 000000000..64cc6f7e8 --- /dev/null +++ b/tasks/deps/perp @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +perp_version="2.07" +perp_hash="a2acc7425d556d9635a25addcee9edb5" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "http://b0llix.net/perp/distfiles/perp-$perp_version.tar.gz" "md5" "$perp_hash" +extract_download "perp-$perp_version.tar.gz" + +cd "perp-$perp_version" +sed -i -e "s%BINDIR.*%BINDIR = $INSTALL_PREFIX_EMBEDDED/bin%" conf.mk +sed -i -e "s%SBINDIR.*%SBINDIR = $INSTALL_PREFIX_EMBEDDED/sbin%" conf.mk +sed -i -e "s%MANDIR.*%MANDIR = $INSTALL_PREFIX_EMBEDDED/share/man%" conf.mk +make +make strip +make install DESTDIR="$STAGE_DIR" + +stamp diff --git a/tasks/deps/rsyslog b/tasks/deps/rsyslog new file mode 100755 index 000000000..76bfc57c0 --- /dev/null +++ b/tasks/deps/rsyslog @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +rsyslog_version="8.35.0" +rsyslog_hash="d216a7f7c88341d5964657e61a33193c13d884c988822fced9fce3ab0b1f1082" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "http://www.rsyslog.com/download/files/download/rsyslog/rsyslog-$rsyslog_version.tar.gz" "sha256" "$rsyslog_hash" +extract_download "rsyslog-$rsyslog_version.tar.gz" + +cd "rsyslog-$rsyslog_version" +LIBESTR_CFLAGS="-I$STAGE_EMBEDDED_DIR/include" \ +LIBESTR_LIBS="-L$STAGE_EMBEDDED_DIR/lib -lestr" \ +LIBFASTJSON_CFLAGS="-I$STAGE_EMBEDDED_DIR/include/libfastjson" \ +LIBFASTJSON_LIBS="-L$STAGE_EMBEDDED_DIR/lib -lfastjson" \ +./configure \ + --prefix="$INSTALL_PREFIX_EMBEDDED" \ + --disable-liblogging-stdlog \ + --disable-libgcrypt \ + --enable-imptcp \ + --enable-impstats \ + --enable-mmjsonparse \ + --enable-mmutf8fix \ + --enable-elasticsearch +make +make install DESTDIR="$STAGE_DIR" +chrpath -d "$STAGE_EMBEDDED_DIR/sbin/rsyslogd" +find "$STAGE_EMBEDDED_DIR/lib/rsyslog/" -name "*.so" -exec chrpath -d {} \; + +stamp diff --git a/tasks/deps/ruby b/tasks/deps/ruby new file mode 100755 index 000000000..5a32f0b44 --- /dev/null +++ b/tasks/deps/ruby @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +ruby_version="2.4.4" +ruby_hash="45a8de577471b90dc4838c5ef26aeb253a56002896189055a44dc680644243f1" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://cache.ruby-lang.org/pub/ruby/ruby-$ruby_version.tar.bz2" "sha256" "$ruby_hash" +extract_download "ruby-$ruby_version.tar.bz2" + +cd "ruby-$ruby_version" +./configure \ + --prefix="$INSTALL_PREFIX_EMBEDDED" \ + --enable-load-relative \ + --disable-rpath \ + --disable-install-doc +make +make install DESTDIR="$STAGE_DIR" + +stamp diff --git a/tasks/deps/rubygems b/tasks/deps/rubygems new file mode 100755 index 000000000..29a5fef5a --- /dev/null +++ b/tasks/deps/rubygems @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +rubygems_version="2.7.7" + +set -e -u -x +source ./tasks/helpers.sh + +PATH=$STAGE_EMBEDDED_PATH gem update --system $rubygems_version --no-document --env-shebang + +stamp diff --git a/tasks/deps/runit_svlogd b/tasks/deps/runit_svlogd new file mode 100755 index 000000000..8800c9cac --- /dev/null +++ b/tasks/deps/runit_svlogd @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +runit_version="2.1.2" +runit_hash="6c985fbfe3a34608eb3c53dc719172c4" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "http://smarden.org/runit/runit-$runit_version.tar.gz" "md5" "$runit_hash" +extract_download "runit-$runit_version.tar.gz" + +cd "admin/runit-$runit_version/src" +make svlogd +install -D -m 755 svlogd "$STAGE_EMBEDDED_DIR/bin/svlogd" + +stamp diff --git a/tasks/deps/trafficserver b/tasks/deps/trafficserver new file mode 100755 index 000000000..9fe03d7a1 --- /dev/null +++ b/tasks/deps/trafficserver @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +trafficserver_version="7.1.3" +trafficserver_hash="1ddb23a1c0564929d2246ff3cd97595a9d0b1891736a9d0ef8ca56f52a7b86159b657bbc22f2e64aaccee13009ceff2a47c92b8b25121d65c7ccfdedf8b084ea" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "http://mirror.olnevhost.net/pub/apache/trafficserver/trafficserver-$trafficserver_version.tar.bz2" "sha512" "$trafficserver_hash" +extract_download "trafficserver-$trafficserver_version.tar.bz2" + +cd "trafficserver-$trafficserver_version" +SPHINXBUILD=false ./configure \ + --prefix="$INSTALL_PREFIX_EMBEDDED" \ + --enable-experimental-plugins +make +make install DESTDIR="$STAGE_DIR" +chrpath -d "$STAGE_EMBEDDED_DIR/lib/libtsmgmt.so" +find "$STAGE_EMBEDDED_DIR/libexec/trafficserver/" -name "*.so" -exec chrpath -d {} \; +find "$STAGE_EMBEDDED_DIR/bin/" -name "traffic_*" -exec chrpath -d {} \; + +stamp diff --git a/tasks/distclean b/tasks/distclean new file mode 100755 index 000000000..8b4cbea35 --- /dev/null +++ b/tasks/distclean @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh + +if [ ! -f "$SOURCE_DIR/Taskfile.yml" ]; then + echo "Can't find root source directory" + exit 1 +fi + +rm -rf \ + "$SOURCE_DIR/.bundle" \ + "$SOURCE_DIR/build/work"/* \ + "$SOURCE_DIR/src/api-umbrella/admin-ui/node_modules" \ + "$SOURCE_DIR/src/api-umbrella/web-app/.bundle" \ + "$SOURCE_DIR/src/api-umbrella/web-app/tmp"/* \ + "$SOURCE_DIR/test/config/.overrides.yml" \ + "$SOURCE_DIR/test/tmp"/* diff --git a/tasks/helpers.sh b/tasks/helpers.sh new file mode 100644 index 000000000..9965549ad --- /dev/null +++ b/tasks/helpers.sh @@ -0,0 +1,181 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2034 + +set +x + +SOURCE_DIR="$(cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" && pwd)" + +INSTALL_PREFIX=/opt/api-umbrella +INSTALL_PREFIX_EMBEDDED="$INSTALL_PREFIX/embedded" +WORK_DIR="$SOURCE_DIR/build/work" +PACKAGE_WORK_DIR="$SOURCE_DIR/build/package/work" + +# Where to stage installations during "make" phase. +STAGE_DIR="$WORK_DIR/stage" +STAGE_PREFIX_DIR="$STAGE_DIR$INSTALL_PREFIX" +STAGE_EMBEDDED_DIR="$STAGE_DIR$INSTALL_PREFIX_EMBEDDED" + +# Where to install development-only dependencies. +DEV_INSTALL_PREFIX="$WORK_DIR/dev-env" +DEV_VENDOR_DIR="$DEV_INSTALL_PREFIX/vendor" + +# Where to install test-only dependencies. +TEST_INSTALL_PREFIX="$WORK_DIR/test-env" +TEST_VENDOR_DIR="$TEST_INSTALL_PREFIX/vendor" +TEST_VENDOR_LUA_SHARE_DIR="$TEST_VENDOR_DIR/share/lua/5.1" +TEST_VENDOR_LUA_LIB_DIR="$TEST_VENDOR_DIR/lib/lua/5.1" + +# PATH variables to use when executing other commands. Note that we use a +# hard-coded base default path (instead of $ENV{PATH}), since using $ENV{PATH} +# makes cmake think there have been PATH changes which trigger rebuilds, even +# when the path hasn't changed. +DEFAULT_PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" +STAGE_EMBEDDED_PATH="$STAGE_EMBEDDED_DIR/bin:$DEFAULT_PATH" +DEV_PATH="$DEV_INSTALL_PREFIX/bin:$STAGE_EMBEDDED_PATH" + +# Where to install app-level vendor dependencies. +APP_CORE_DIR="$STAGE_EMBEDDED_DIR/apps/core" +APP_CORE_RELEASE_DIR="$APP_CORE_DIR/releases/0" +APP_CORE_VENDOR_DIR="$APP_CORE_DIR/shared/vendor" +APP_CORE_VENDOR_BUNDLE_DIR="$APP_CORE_VENDOR_DIR/bundle" +APP_CORE_VENDOR_LUA_DIR="$APP_CORE_VENDOR_DIR/lua" +APP_CORE_VENDOR_LUA_SHARE_DIR="$APP_CORE_VENDOR_LUA_DIR/share/lua/5.1" +LUA_PREFIX="$STAGE_EMBEDDED_DIR" +LUAROCKS_CMD=(env "LUA_PATH=$LUA_PREFIX/openresty/luajit/share/lua/5.1/?.lua;$LUA_PREFIX/openresty/luajit/share/lua/5.1/?/init.lua;;" "$LUA_PREFIX/bin/luarocks") +OPM_CMD=(env "LUA_PATH=$LUA_PREFIX/openresty/lualib/?.lua;$LUA_PREFIX/openresty/lualib/?/init.lua;;" "PATH=$STAGE_EMBEDDED_PATH" "LD_LIBRARY_PATH=$STAGE_EMBEDDED_DIR/openresty/luajit/lib:$STAGE_EMBEDDED_DIR/lib" opm) + +# Determine the sub-path for the currently executing task. This can be used for +# generating unique directories for the current task. +# +# For example, ./tasks/deps/openresty's subpath would be "deps/openresty" +TASK_SUBPATH="${BASH_SOURCE[1]#*tasks/}" + +# Creating a working directory for the currently running task under +# ./build/work/tasks/* +# +# For example, ./tasks/deps/openresty's working directory would be +# ./build/work/tasks/deps/openresty +task_working_dir() { + set +x + dir="$WORK_DIR/tasks/$TASK_SUBPATH" + set -x + + # Make the directory and cd into it. + mkdir -p "$dir" + cd "$dir" || exit 1 + + # Cleanup any files not in the special "_persist" directory before running + # the rest of the task. This ensures clean builds if a task is being executed + # (since we assume the task script is only being executed if the checksum has + # changed). The persist directory is used for some items, like downloads, + # just to speed-up development rebuilds a bit. + find "$dir" -mindepth 1 -maxdepth 1 -not -name "_persist" -print -exec rm -rf {} \; +} + +# Generate a stamp file indicating a task has successfully run. This should be +# the last line in each task file. +# +# In conjunction with go-task's checksum and dependency functionality, these +# stamp files ensure that each task has an output file that can be setup as a +# dependency for other tasks. Since each task will only run if necessary (due +# to go-tasks's checksumming), these stamp files should change on every +# successful run so that any dependencies of the current task also get +# triggered (in a cascading fashion). +stamp() { + set +x + stamp_path="$WORK_DIR/stamp/$TASK_SUBPATH" + stamp_dir=$(dirname "$stamp_path") + + # Remove the previous stamp. Also try removing the parent stamp_dir if it's + # actually a file (to handle situations where the task is shifted into or out + # of a subdirectory). + rm -rf "$stamp_path" + if [ -f "$stamp_dir" ]; then + rm -f "$stamp_dir" + fi + mkdir -p "$stamp_dir" + + # Generate random content within the stamp file to ensure it's checksum will + # change on each successful run. + echo "Stamp: $stamp_path" + date > "$stamp_path" + openssl rand -hex 64 >> "$stamp_path" + + set -x +} + +download() { + set +x + url=$1 + hash_algorithm=$2 + expected_hash=$3 + + # Download the file. + filename=$(basename "$url") + downloads_dir="$(pwd)/_persist/downloads" + download_path="$downloads_dir/$filename" + mkdir -p "$downloads_dir" + if [ ! -f "$download_path" ]; then + set -x + curl --location --retry 3 --fail --output "$download_path" "$url" + set +x + fi + + # Verify the checksum of the downloaded file. + actual_hash=$(openssl dgst -"$hash_algorithm" "$download_path" | awk '{print $2}') + if [ "$expected_hash" != "$actual_hash" ]; then + echo "Checksum for $download_path did not match" + echo " Expected hash: $expected_hash" + echo " Actual hash: $actual_hash" + exit 1 + fi + + set -x +} + +extract_download() { + tar -xf "_persist/downloads/$1" +} + +_luarocks_install() { + tree_dir="$1" + package="$2" + version="$3" + + set -x + "${LUAROCKS_CMD[@]}" --tree="$tree_dir" install "$package" "$version" + find "$tree_dir/lib" -name "*.so" -exec chrpath -d {} \; +} + +luarocks_install() { + set +x + _luarocks_install "$APP_CORE_VENDOR_LUA_DIR" "$@" +} + +test_luarocks_install() { + set +x + _luarocks_install "$TEST_VENDOR_DIR" "$@" +} + +_opm_install() { + tree_dir="$1" + package="$2" + version="$3" + + set -x + mkdir -p "$tree_dir" + (cd "$tree_dir" && "${OPM_CMD[@]}" --cwd get "$package=$version") + find "$tree_dir/resty_modules" -name "*.so" -exec chrpath -d {} \; +} + +opm_install() { + set +x + _opm_install "$APP_CORE_VENDOR_LUA_DIR" "$@" +} + +test_opm_install() { + set +x + _opm_install "$TEST_VENDOR_DIR" "$@" +} + +set -x diff --git a/tasks/install b/tasks/install new file mode 100755 index 000000000..94daa89f5 --- /dev/null +++ b/tasks/install @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh + +destdir="${DESTDIR:-}" +install_prefix="$PREFIX" + +# Define a timestamped release name for our app installations. Base this on the +# last git commit timestamp so installs are consistent for each git commit. +release_timestamp=$(date -d "$(git log --max-count=1 --date=iso --format=%cd)" -u "+%Y%m%d%H%M%S") + +mkdir -p "$destdir$install_prefix" +rsync -a -v "$STAGE_PREFIX_DIR/" "$destdir$install_prefix/" +install -D -m 755 "$SOURCE_DIR/build/package/files/etc/init.d/api-umbrella" "$destdir/etc/init.d/api-umbrella" +install -D -m 644 "$SOURCE_DIR/build/package/files/etc/logrotate.d/api-umbrella" "$destdir/etc/logrotate.d/api-umbrella" +install -D -m 440 "$SOURCE_DIR/build/package/files/etc/sudoers.d/api-umbrella" "$destdir/etc/sudoers.d/api-umbrella" + +# If /etc/api-umbrella/api-umbrella.yml doesn't exist, install it. +# +# If /etc/api-umbrella/api-umbrella.yml does exist, install the default version +# to api-umbrella.yml.default (so it's available for reference, but we don't +# overwrite any local changes). +if [ -f "$destdir/etc/api-umbrella/api-umbrella.yml" ]; then + install -D -m 644 "$SOURCE_DIR/build/package/files/etc/api-umbrella/api-umbrella.yml" "$destdir/etc/api-umbrella/api-umbrella.yml.default" +else + install -D -m 644 "$SOURCE_DIR/build/package/files/etc/api-umbrella/api-umbrella.yml" "$destdir/etc/api-umbrella/api-umbrella.yml" +fi + +( + cd "$destdir$install_prefix/embedded/apps/core" + rm -rf "releases/$release_timestamp" + mv releases/0 "releases/$release_timestamp" + ln -snf "releases/$release_timestamp" ./current +) + +( + cd "$destdir$install_prefix/embedded/apps/static-site" + rm -rf "releases/$release_timestamp" + mv releases/0 "releases/$release_timestamp" + ln -snf "releases/$release_timestamp" ./current +) + +mkdir -p \ + "$destdir/usr/bin" \ + "$destdir/var/log" \ + "$destdir$install_prefix/etc" \ + "$destdir$install_prefix/var/db" \ + "$destdir$install_prefix/var/log" \ + "$destdir$install_prefix/var/run" \ + "$destdir$install_prefix/var/tmp" + +( + cd "$destdir/usr/bin" + ln -snf "../..$install_prefix/bin/api-umbrella" ./api-umbrella +) + +( + cd "$destdir/var/log" + ln -snf "../..$install_prefix/var/log" ./api-umbrella +) + +sed -i "s#$STAGE_DIR##g" \ + "$destdir$install_prefix/embedded/openresty/luajit/bin/luarocks-5.1" \ + "$destdir$install_prefix/embedded/openresty/luajit/bin/luarocks-admin-5.1" \ + "$destdir$install_prefix/embedded/openresty/luajit/share/lua/5.1/luarocks/site_config.lua" + +chmod 1777 "$destdir$install_prefix/var/tmp" + +"$SOURCE_DIR/build/package/scripts/after-install" 1 diff --git a/build/scripts/install_build_dependencies b/tasks/install-system-build-dependencies similarity index 92% rename from build/scripts/install_build_dependencies rename to tasks/install-system-build-dependencies index e2a3b7f43..72db4156b 100755 --- a/build/scripts/install_build_dependencies +++ b/tasks/install-system-build-dependencies @@ -1,11 +1,10 @@ #!/usr/bin/env bash set -e -u -x - -source_dir="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")")" +source ./tasks/helpers.sh # shellcheck source=build/package_dependencies.sh -source "$source_dir/build/package_dependencies.sh" +source "$SOURCE_DIR/build/package_dependencies.sh" install_dependencies=("${all_build_dependencies[@]}") if [ "${INSTALL_TEST_DEPENDENCIES:-}" == "true" ]; then diff --git a/tasks/lint/js b/tasks/lint/js new file mode 100755 index 000000000..a312db25a --- /dev/null +++ b/tasks/lint/js @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh + +set -x +( + cd "$SOURCE_DIR/src/api-umbrella/admin-ui" + PATH="$DEV_PATH" yarn run lint:js +) diff --git a/tasks/lint/lua b/tasks/lint/lua new file mode 100755 index 000000000..df8e13f90 --- /dev/null +++ b/tasks/lint/lua @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh +set +x + +export LUA_PATH="$TEST_VENDOR_LUA_SHARE_DIR/?.lua;$TEST_VENDOR_LUA_SHARE_DIR/?/init.lua;;" +export LUA_CPATH="$TEST_VENDOR_LUA_LIB_DIR/?.so;;" + +mapfile -t files < <(git ls-files | grep '\.lua$') +set -x +"$TEST_VENDOR_DIR/bin/luacheck" "${files[@]}" diff --git a/tasks/lint/ruby b/tasks/lint/ruby new file mode 100755 index 000000000..78166f84c --- /dev/null +++ b/tasks/lint/ruby @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh +set +x + +export PATH="$STAGE_EMBEDDED_PATH" +export BUNDLE_APP_CONFIG="$WORK_DIR/tasks/test-deps/bundle/_persist/.bundle" + +mapfile -t files < <(git ls-files | grep -E '(Rakefile|\.(rb|rake))$') +set -x +bundle exec rubocop --display-cop-names --extra-details "${files[@]}" diff --git a/tasks/lint/shell b/tasks/lint/shell new file mode 100755 index 000000000..f658ef888 --- /dev/null +++ b/tasks/lint/shell @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh +set +x + +mapfile -t files < <(git grep -El "^#!(/bin/sh|/bin/bash|/usr/bin/env sh|/usr/bin/env sh)" || true) +if [ -n "${files:-}" ]; then + echo "Use '/usr/bin/env bash' shebang for following files:" + printf ' %s\n' "${files[@]}" + exit 1 +fi + +mapfile -t files < <(git grep -El "^#!/usr/bin/env bash") +set -x +"$TEST_INSTALL_PREFIX/bin/shellcheck" "${files[@]}" diff --git a/tasks/outdated b/tasks/outdated new file mode 100755 index 000000000..88263a07b --- /dev/null +++ b/tasks/outdated @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh + +export PATH="$STAGE_EMBEDDED_DIR/bin:$DEFAULT_PATH" +export BUNDLE_GEMFILE="$SOURCE_DIR/Gemfile" +export BUNDLE_APP_CONFIG="$WORK_DIR/tasks/test-deps/bundle/_persist/.bundle" +bundle exec rake outdated diff --git a/tasks/package b/tasks/package new file mode 100755 index 000000000..f1ce008fa --- /dev/null +++ b/tasks/package @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir + + +export PATH="$STAGE_EMBEDDED_PATH" +export BUNDLE_GEMFILE="$SOURCE_DIR/build/package/Gemfile" +BUNDLE_APP_CONFIG="$(pwd)/_persist/.bundle" +export BUNDLE_APP_CONFIG + +( + # Install into the task's special _persist directory so the installed gems + # dir isn't cleaned between runs for development purposes. + mkdir -p _persist + cd _persist + + # Install all the gems for use in packaging. + bundle config --local build.nokogiri --use-system-libraries + bundle config --local path "$(pwd)/bundle" + bundle config --local clean true + bundle install +) + +work_destdir="$(pwd)/destdir" +rm -rf "$work_destdir" +( + cd "$SOURCE_DIR" + make + make install DESTDIR="$work_destdir" +) +PACKAGE=core WORK_DESTDIR="$work_destdir" PACKAGE_WORK_DIR="$PACKAGE_WORK_DIR" "$SOURCE_DIR/build/package/build_package" +rm -rf "$work_destdir" diff --git a/tasks/test-deps/bundle b/tasks/test-deps/bundle new file mode 100755 index 000000000..750012168 --- /dev/null +++ b/tasks/test-deps/bundle @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir + +# Install into the task's special _persist directory so the installed gems dir +# isn't cleaned between runs for development purposes. +mkdir -p _persist +cd _persist + +# Install all the gems for use in development/test. +export PATH="$STAGE_EMBEDDED_PATH" +export BUNDLE_GEMFILE="$SOURCE_DIR/Gemfile" +BUNDLE_APP_CONFIG="$(pwd)/.bundle" +export BUNDLE_APP_CONFIG +bundle config --local build.nokogiri --use-system-libraries +bundle config --local path "$(pwd)/bundle" +bundle config --local clean true +bundle install + +stamp diff --git a/tasks/test-deps/elasticsearch5 b/tasks/test-deps/elasticsearch5 new file mode 100755 index 000000000..c664f76c4 --- /dev/null +++ b/tasks/test-deps/elasticsearch5 @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +elasticsearch5_version="5.6.9" +elasticsearch5_hash="9dae4794cad7b804bffe09d03c94ab25b3e9c586" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$elasticsearch5_version.tar.gz" "sha1" "$elasticsearch5_hash" +extract_download "elasticsearch-$elasticsearch5_version.tar.gz" + +mkdir -p "$TEST_INSTALL_PREFIX" +rsync -a -v --checksum --delete-after "elasticsearch-$elasticsearch5_version/" "$TEST_INSTALL_PREFIX/elasticsearch5/" +chown -R nobody "$TEST_INSTALL_PREFIX/elasticsearch5" + +stamp diff --git a/tasks/test-deps/elasticsearch6 b/tasks/test-deps/elasticsearch6 new file mode 100755 index 000000000..cc017d538 --- /dev/null +++ b/tasks/test-deps/elasticsearch6 @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +elasticsearch6_version="6.2.4" +elasticsearch6_hash="8db5931278fd7a8687659ebcfaeab0d0f87f7d22" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$elasticsearch6_version.tar.gz" "sha1" "$elasticsearch6_hash" +extract_download "elasticsearch-$elasticsearch6_version.tar.gz" + +mkdir -p "$TEST_INSTALL_PREFIX" +rsync -a -v --checksum --delete-after "elasticsearch-$elasticsearch6_version/" "$TEST_INSTALL_PREFIX/elasticsearch6/" +chown -R nobody "$TEST_INSTALL_PREFIX/elasticsearch6" + +stamp diff --git a/tasks/test-deps/luacheck b/tasks/test-deps/luacheck new file mode 100755 index 000000000..5d8463ea2 --- /dev/null +++ b/tasks/test-deps/luacheck @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +lua_luacheck_version="0.22.0-1" + +set -e -u -x +source ./tasks/helpers.sh + +test_luarocks_install "luacheck" "$lua_luacheck_version" + +stamp diff --git a/tasks/test-deps/mailhog b/tasks/test-deps/mailhog new file mode 100755 index 000000000..bb4beb779 --- /dev/null +++ b/tasks/test-deps/mailhog @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +mailhog_version="1.0.0" +mailhog_hash="3b758c81bfe2c9110911511daca1a7bc" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://github.com/mailhog/MailHog/releases/download/v$mailhog_version/MailHog_linux_amd64" "md5" "$mailhog_hash" + +install -D -m 755 _persist/downloads/MailHog_linux_amd64 "$TEST_INSTALL_PREFIX/bin/mailhog" + +stamp diff --git a/tasks/test-deps/mongo-orchestration b/tasks/test-deps/mongo-orchestration new file mode 100755 index 000000000..87a601ec1 --- /dev/null +++ b/tasks/test-deps/mongo-orchestration @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +mongo_orchestration_version="0.6.11" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir + +rm -rf "$TEST_INSTALL_PREFIX/mongo-orchestration" +virtualenv "$TEST_INSTALL_PREFIX/mongo-orchestration" +"$TEST_INSTALL_PREFIX/mongo-orchestration/bin/pip" install --ignore-installed "mongo-orchestration==$mongo_orchestration_version" +ln -snf "$TEST_INSTALL_PREFIX/mongo-orchestration/bin/mongo-orchestration" "$TEST_INSTALL_PREFIX/bin/mongo-orchestration" + +stamp diff --git a/tasks/test-deps/openldap b/tasks/test-deps/openldap new file mode 100755 index 000000000..dba1ab0ea --- /dev/null +++ b/tasks/test-deps/openldap @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +openldap_version="2.4.46" +openldap_hash="a9ae2273eb9bdd70090dafe0d018a3132606bef6" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-$openldap_version.tgz" "sha1" "$openldap_hash" +extract_download "openldap-$openldap_version.tgz" + +cd "openldap-$openldap_version" +./configure --prefix="$TEST_INSTALL_PREFIX" --disable-backends --enable-mdb +make +make depend +make install + +stamp diff --git a/tasks/test-deps/phantomjs b/tasks/test-deps/phantomjs new file mode 100755 index 000000000..580c3658c --- /dev/null +++ b/tasks/test-deps/phantomjs @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +phantomjs_version="2.1.1" +phantomjs_hash="1c947d57fce2f21ce0b43fe2ed7cd361" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$phantomjs_version-linux-x86_64.tar.bz2" "md5" "$phantomjs_hash" +extract_download "phantomjs-$phantomjs_version-linux-x86_64.tar.bz2" + +install -D -m 755 "phantomjs-$phantomjs_version-linux-x86_64/bin/phantomjs" "$TEST_INSTALL_PREFIX/bin/phantomjs" + +stamp diff --git a/tasks/test-deps/shellcheck b/tasks/test-deps/shellcheck new file mode 100755 index 000000000..b029a5645 --- /dev/null +++ b/tasks/test-deps/shellcheck @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +shellcheck_version="0.5.0" +shellcheck_hash="475e14bf2705ad4a16d405fa64b94c2eb151a914d5a165ce13e8f9344e6145893f685a650cd32d45a7ab236dedf55f76b31db82e2ef76ad6175a87dd89109790" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "https://storage.googleapis.com/shellcheck/shellcheck-v$shellcheck_version.linux.x86_64.tar.xz" "sha512" "$shellcheck_hash" +extract_download "shellcheck-v$shellcheck_version.linux.x86_64.tar.xz" + +install -D -m 755 "shellcheck-v$shellcheck_version/shellcheck" "$TEST_INSTALL_PREFIX/bin/shellcheck" + +stamp diff --git a/tasks/test-deps/unbound b/tasks/test-deps/unbound new file mode 100755 index 000000000..79b28d88e --- /dev/null +++ b/tasks/test-deps/unbound @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +unbound_version="1.7.1" +unbound_hash="56e085ef582c5372a20207de179d0edb4e541e59f87be7d4ee1d00d12008628d" + +set -e -u -x +source ./tasks/helpers.sh + +task_working_dir +download "http://www.unbound.net/downloads/unbound-$unbound_version.tar.gz" "sha256" "$unbound_hash" +extract_download "unbound-$unbound_version.tar.gz" + +cd "unbound-$unbound_version" +./configure --prefix="$TEST_INSTALL_PREFIX" +make +make install + +stamp diff --git a/test/scripts/circle-ci b/tasks/test/circle-ci similarity index 75% rename from test/scripts/circle-ci rename to tasks/test/circle-ci index e39d6df3b..fc9eb02f6 100755 --- a/test/scripts/circle-ci +++ b/tasks/test/circle-ci @@ -1,13 +1,12 @@ #!/usr/bin/env bash set -e -u -x -shopt -s globstar +source ./tasks/helpers.sh -export PATH="build/work/stage/opt/api-umbrella/embedded/bin:$PATH" -export BUNDLE_APP_CONFIG=build/work/.bundle +shopt -s globstar -ln -snf "$(pwd)/build/work/src/api-umbrella-core/tmp/admin-ui-build/node_modules" src/api-umbrella/admin-ui/node_modules -ln -snf "$(pwd)/build/work/src/web-app/.bundle" src/api-umbrella/web-app/.bundle +ln -snf "$WORK_DIR/tasks/app-deps/admin-ui/yarn/_persist/node_modules" "$SOURCE_DIR/src/api-umbrella/admin-ui/node_modules" +ln -snf "$WORK_DIR/tasks/app-deps/web-app/bundle/_persist/.bundle" "$SOURCE_DIR/src/api-umbrella/web-app/.bundle" # Due to some of our hard-coded assumptions about running things on specific # nodes, ensure that the CI is at least running on the number of nodes @@ -20,20 +19,20 @@ fi # Always run the lint tests on the first node (since these are quick and only # need to be run on a single node). if [ "$CIRCLE_NODE_INDEX" -eq "0" ]; then - time bundle exec rake lint + time make lint fi # Circle's parallel command will pass this script a list of test files to run # on this node as arguments. Pass those along to the rake task via the TESTS # environment variable. tests="$(circleci tests glob test/**/test_*.rb | circleci tests split --split-by=timings)" -env TESTOPTS="--ci-dir=./test/tmp/reports" TESTS="${tests[*]}" N=12 bundle exec rake test +env TESTOPTS="--ci-dir=./test/tmp/reports" TESTS="${tests[*]}" N=12 make test # Run a smaller suite of elasticsearch-related tests against other versions of # elasticsearch. elasticsearch_tests=(test/admin_ui/**/test_stats_*.rb test/admin_ui/**/test_stats_*.rb test/apis/admin/stats/**/test_*.rb test/apis/v0/test_analytics.rb test/apis/v1/analytics/**/test_*.rb test/proxy/logging/**/test_*.rb) if [ "$CIRCLE_NODE_INDEX" -eq "1" ]; then - env ELASTICSEARCH_TEST_API_VERSION=5 TESTS="${elasticsearch_tests[*]}" N=12 bundle exec rake test + env ELASTICSEARCH_TEST_API_VERSION=5 TESTS="${elasticsearch_tests[*]}" N=12 make test elif [ "$CIRCLE_NODE_INDEX" -eq "2" ]; then - env ELASTICSEARCH_TEST_API_VERSION=6 TESTS="${elasticsearch_tests[*]}" N=12 bundle exec rake test + env ELASTICSEARCH_TEST_API_VERSION=6 TESTS="${elasticsearch_tests[*]}" N=12 make test fi diff --git a/tasks/test/default b/tasks/test/default new file mode 100755 index 000000000..23ccec026 --- /dev/null +++ b/tasks/test/default @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e -u -x +source ./tasks/helpers.sh + +export PATH="$STAGE_EMBEDDED_DIR/bin:$DEFAULT_PATH" +export BUNDLE_GEMFILE="$SOURCE_DIR/Gemfile" +export BUNDLE_APP_CONFIG="$WORK_DIR/tasks/test-deps/bundle/_persist/.bundle" +bundle exec rake diff --git a/templates/etc/perp/.boot/rc.log b/templates/etc/perp/.boot/rc.log index f2487aeaa..e5583054a 100755 --- a/templates/etc/perp/.boot/rc.log +++ b/templates/etc/perp/.boot/rc.log @@ -1,2 +1,2 @@ -#!/bin/bash +#!/usr/bin/env bash exec ../rc.log start perpd diff --git a/templates/etc/perp/.boot/rc.perp.mustache b/templates/etc/perp/.boot/rc.perp.mustache index 37128d0b5..10d5a696e 100755 --- a/templates/etc/perp/.boot/rc.perp.mustache +++ b/templates/etc/perp/.boot/rc.perp.mustache @@ -1,4 +1,5 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e # rc.perp: perpd startup script for perpboot # === diff --git a/test/processes/test_rpaths.rb b/test/processes/test_rpaths.rb index 347be3969..ee61dde8b 100644 --- a/test/processes/test_rpaths.rb +++ b/test/processes/test_rpaths.rb @@ -38,7 +38,7 @@ def test_binary_rpaths "/embedded/openresty/nginx/sbin/nginx", "/embedded/libexec/trafficserver/ssl_cert_loader.so", # LuaRock - "/embedded/apps/core/shared/vendor/lib/lua/5.1/iconv.so", + "/embedded/apps/core/shared/vendor/lua/lib/lua/5.1/iconv.so", # Rubygem "/oj/oj.so", ].each do |expected_path_end| diff --git a/test/test_helper.rb b/test/test_helper.rb index cf5aafb70..0d326c9d8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -24,7 +24,6 @@ "#{API_UMBRELLA_SRC_ROOT}/build/work/test-env/sbin", "#{API_UMBRELLA_SRC_ROOT}/build/work/dev-env/bin", "#{API_UMBRELLA_SRC_ROOT}/build/work/dev-env/sbin", - "#{API_UMBRELLA_SRC_ROOT}/build/work/cmake/bin", ENV["PATH"], ].join(":") diff --git a/website/Rakefile b/website/Rakefile index e148706fb..7748d19e8 100644 --- a/website/Rakefile +++ b/website/Rakefile @@ -1,3 +1,3 @@ -ENV["PROJECT_ROOT"] = File.expand_path("../", __FILE__) +ENV["PROJECT_ROOT"] = File.expand_path(__dir__) require "middleman-gh-pages"