diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..0d83722f --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,303 @@ +name: Build packages + +on: + pull_request: + push: + release: + types: + - published + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: install erlang + env: + OTP_VERSION: 22.3 + run: | + curl -L -o /tmp/erlang-solutions_2.0_all.deb https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb \ + && sudo dpkg -i /tmp/erlang-solutions_2.0_all.deb \ + && curl -L -o /tmp/erlang_solutions.asc https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc \ + && sudo apt-key add /tmp/erlang_solutions.asc \ + && sudo apt update \ + && version=$(apt-cache madison esl-erlang |grep ${OTP_VERSION} | sed -n '1, 1p' | awk '{print $3}') \ + && sudo apt install --allow-downgrades esl-erlang=${version} + - name: set LC_ALL + run: | + sudo apt update && sudo apt install -y locales + sudo locale-gen en_US.UTF-8 + echo "::set-env name=LC_ALL::en_US.UTF-8" + - name: install library + run: | + sudo apt update && sudo apt install -y libtinfo-dev ghc + echo "::add-path::~/.local/bin" + curl -sSL https://get.haskellstack.org/ | sh -s - -f + - uses: actions/checkout@v2 + - name: make + run: | + sed -i -r 's:^path (.*):path /usr/lib/hamler:g' Env + make + make test + sudo make install + - name: tests + run: | + mkdir test + cd test + hamler init + hamler build + hamler run + echo ":q" | hamler repl + - name: create tgz file + run: | + version=$(echo ${{ github.ref }} | sed -r "s .*/.*/(.*) \1 g") + cd /usr/lib && sudo tar cvf hamler-${version}.tgz hamler && cd - + mkdir -p _packages + sudo mv /usr/lib/hamler-${version}.tgz _packages + cd _packages && for var in $(ls *.tgz); do bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"; done && cd - + - uses: actions/upload-artifact@v1 + with: + name: linux + path: _packages/. + - name: update github release + if: github.event_name == 'release' + run: | + version=$(echo ${{ github.ref }} | sed -r "s .*/.*/(.*) \1 g") + for var in $(ls _packages) ; do + .github/workflows/script/upload_github_release_asset.sh owner=hamler-lang repo=hamler tag=$version filename=_packages/$var github_api_token=$(echo ${{ secrets.AccessToken }}) + done + + build_deb: + runs-on: ubuntu-latest + + container: + image: debian:9 + + steps: + - name: install erlang + env: + OTP_VERSION: 22.3 + run: | + apt-get update && apt-get install -y wget git curl build-essential debhelper + wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb + dpkg -i erlang-solutions_2.0_all.deb + wget https://packages.erlang-solutions.com/debian/erlang_solutions.asc + apt-key add erlang_solutions.asc + apt update + version=$(apt-cache madison esl-erlang |grep ${OTP_VERSION} | sed -n '1, 1p' | awk '{print $3}') + apt-get install -y esl-erlang=${version} + - name: set env + run: | + apt update && apt install -y locales + echo "LC_ALL=en_US.UTF-8" >> /etc/environment + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen + echo "LANG=en_US.UTF-8" > /etc/locale.conf + locale-gen en_US.UTF-8 + echo "::set-env name=LC_ALL::en_US.UTF-8" + echo "::set-env name=STACK_ROOT::$(pwd)" + echo "::add-path::~/.local/bin" + - name: install library + run: | + apt update && apt install -y libtinfo-dev ghc + curl -sSL https://get.haskellstack.org/ | sh -s - -f + - uses: actions/checkout@v1 + - name: make + run: | + sed -i -r 's:^path (.*):path /usr/lib/hamler:g' Env + make pkg + cd deploy/packages/deb/_packages && for var in $(ls *.deb); do bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"; done && cd - + rm -rf /usr/lib/hamler + rm -rf /usr/bin/hamler + - name: install pkg + run: | + dpkg -i deploy/packages/deb/_packages/*.deb + if [ $(dpkg -l |grep hamler |awk '{print $1}') != "ii" ]; then + echo "package install error" + exit 1 + fi + - name: run tests + run: | + mkdir test + cd test + hamler init + hamler build + hamler run + echo ":q" | hamler repl + - name: uninstall pkg + shell: bash + run: | + dpkg -r hamler + if [ $(dpkg -l |grep hamler |awk '{print $1}') != "rc" ]; then + echo "package remove error" + exit 1 + fi + dpkg -P hamler + if [ ! -z "$(dpkg -l |grep hamler)" ]; then + echo "package uninstall error" + exit 1 + fi + - uses: actions/upload-artifact@v1 + with: + name: deb + path: deploy/packages/deb/_packages/. + - name: update github release + if: github.event_name == 'release' + run: | + version=$(echo ${{ github.ref }} | sed -r "s .*/.*/(.*) \1 g") + for var in $(ls deploy/packages/deb/_packages) ; do + .github/workflows/script/upload_github_release_asset.sh owner=hamler-lang repo=hamler tag=$version filename=deploy/packages/deb/_packages/$var github_api_token=$(echo ${{ secrets.AccessToken }}) + done + + build_rpm: + runs-on: ubuntu-latest + + container: + image: centos:7 + + steps: + - name: install erlang + env: + OTP_VERSION: 22.3 + run: | + yum groupinstall -y "Development Tools" + yum install -y wget git curl which ncurses-devel openssl-devel https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + wget https://packages.erlang-solutions.com/erlang-solutions-2.0-1.noarch.rpm + rpm -Uvh erlang-solutions-2.0-1.noarch.rpm + rpm --import https://packages.erlang-solutions.com/rpm/erlang_solutions.asc + yum install -y erlang-${OTP_VERSION} + - name: set env + run: | + echo "::set-env name=LC_ALL::en_US.UTF-8" + echo "::set-env name=STACK_ROOT::$(pwd)" + echo "::add-path::~/.local/bin" + - name: install library + run: | + yum install -y ghc + curl -sSL https://get.haskellstack.org/ | sh -s - -f + - uses: actions/checkout@v1 + - name: make + run: | + sed -i -r 's:^path (.*):path /usr/lib/hamler:g' Env + make pkg + cd deploy/packages/rpm/_packages && for var in $(ls *.rpm); do bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"; done && cd - + rm -rf /usr/lib/hamler + rm -rf /usr/bin/hamler + - name: install pkg + run: | + rpm -ivh deploy/packages/rpm/_packages/*.rpm + if [ -z $(rpm -q hamler | grep -o hamler) ];then + echo "package install error" + exit 1 + fi + - name: run tests + run: | + mkdir test + cd test + hamler init + hamler build + hamler run + echo ":q" | hamler repl + - name: uninstall pkg + run: | + rpm -e hamler + if [ "$(rpm -q hamler)" != "package hamler is not installed" ];then + echo "package uninstall error" + exit 1 + fi + - uses: actions/upload-artifact@v1 + with: + name: rpm + path: deploy/packages/rpm/_packages/. + - name: update github release + if: github.event_name == 'release' + run: | + version=$(echo ${{ github.ref }} | sed -r "s .*/.*/(.*) \1 g") + for var in $(ls deploy/packages/rpm/_packages) ; do + .github/workflows/script/upload_github_release_asset.sh owner=hamler-lang repo=hamler tag=$version filename=deploy/packages/rpm/_packages/$var github_api_token=$(echo ${{ secrets.AccessToken }}) + done + + build_mac: + runs-on: macos-latest + + steps: + - name: prepare + run: | + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + brew install gnu-sed erlang@22 haskell-stack + ln -s /usr/local/bin/gsed /usr/local/bin/sed + echo "::add-path::/usr/local/opt/erlang@22/bin" + echo "::add-path::/usr/local/lib/hamler/bin" + echo "::add-path::/usr/local/bin" + - uses: actions/checkout@v2 + - name: make + run: | + sed -i -r 's:^path (.*):path /usr/local/lib/hamler:g' Env + make + make test + sudo make install + - name: tests + run: | + mkdir test + cd test + hamler init + hamler build + hamler run + echo ":q" | hamler repl + - name: create tgz file + run: | + version=$(echo ${{ github.ref }} | gsed -r "s .*/.*/(.*) \1 g") + cd /usr/local/lib && sudo tar cvf hamler-${version}.tgz hamler && cd - + mkdir -p _packages + sudo mv /usr/local/lib/hamler-${version}.tgz _packages + - uses: actions/upload-artifact@v1 + with: + name: mac + path: _packages/. + - name: set aws cli + if: github.event_name == 'release' + run: | + curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg" + sudo installer -pkg AWSCLIV2.pkg -target / + aws --version + aws configure set aws_access_key_id ${{ secrets.AwsAccessKeyId }} + aws configure set aws_secret_access_key ${{ secrets.AwsSecretAccessKey }} + aws configure set default.region us-west-2 + - name: set git access + if: github.event_name == 'release' + run: | + echo "https://rory-z%40outlook.com:${{ secrets.AccessToken }}@github.com" >> ~/.git-credentials + git config --global credential.helper store + git config --global user.name "Rory Z" + git config --global user.email rory-z@outlook.com + - name: update homebrew + if: github.event_name == 'release' + run: | + git clone https://github.com/hamler-lang/homebrew-hamler homebrew-hamler + version=$(echo ${{ github.ref }} | sed -r "s .*/.*/(.*) \1 g") + pkg=hamler-${version}.tgz + aws s3 cp _packages/$pkg s3://packages.emqx.io/hamler/homebrew/ + download="https://s3-us-west-2.amazonaws.com/packages.emqx.io/hamler/homebrew/$pkg" + sha256=$(openssl dgst -sha256 _packages/$pkg | awk '{print $2}') + cd homebrew-hamler + gsed -i "/url/c\ url \"$download\"" ./Formula/hamler.rb + gsed -i "/sha256/c\ sha256 \"$sha256\"" ./Formula/hamler.rb + gsed -i "/version /c\ version \"${version##v}\"" ./Formula/hamler.rb + git add ./Formula/hamler.rb + git commit -m "chore: update $version" + git push origin master + git tag $version + git push origin $version + + build_docker: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: make docker image + run: make docker + - name: push docker image + if: github.event_name == 'release' + run: | + echo ${{ secrets.DockerHubPassword }} | docker login -u ${{ secrets.DockerHubUser }} --password-stdin + version=$(echo ${{ github.ref }} | sed -r "s .*/.*/(.*) \1 g") + docker push hamlerlang/hamler:$version diff --git a/.github/workflows/script/upload_github_release_asset.sh b/.github/workflows/script/upload_github_release_asset.sh new file mode 100755 index 00000000..4e92fdb5 --- /dev/null +++ b/.github/workflows/script/upload_github_release_asset.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +# +# Author: Stefan Buck +# License: MIT +# https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447 +# +# +# This script accepts the following parameters: +# +# * owner +# * repo +# * tag +# * filename +# * github_api_token +# +# Script to upload a release asset using the GitHub API v3. +# +# Example: +# +# upload_github_release_asset.sh github_api_token=TOKEN owner=stefanbuck repo=playground tag=v0.1.0 filename=./build.zip +# + +# Check dependencies. +set -e +xargs=$(which gxargs || which xargs) + +# Validate settings. +[ "$TRACE" ] && set -x + +CONFIG=$@ + +for line in $CONFIG; do + eval "$line" +done + +# Define variables. +GH_API="https://api.github.com" +GH_REPO="$GH_API/repos/$owner/$repo" +GH_TAGS="$GH_REPO/releases/tags/$tag" +AUTH="Authorization: token $github_api_token" +WGET_ARGS="--content-disposition --auth-no-challenge --no-cookie" +CURL_ARGS="-LJO#" + +if [[ "$tag" == 'LATEST' ]]; then + GH_TAGS="$GH_REPO/releases/latest" +fi + +# Validate token. +curl -o /dev/null -sH "$AUTH" $GH_REPO || { echo "Error: Invalid repo, token or network issue!"; exit 1; } + +# Read asset tags. +response=$(curl -sH "$AUTH" $GH_TAGS) + +# Get ID of the asset based on given filename. +eval $(echo "$response" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=') +[ "$id" ] || { echo "Error: Failed to get release id for tag: $tag"; echo "$response" | awk 'length($0)<100' >&2; exit 1; } + +# Upload asset +echo "Uploading asset... " + +# Construct url +GH_ASSET="https://uploads.github.com/repos/$owner/$repo/releases/$id/assets?name=$(basename $filename)" + +curl "$GITHUB_OAUTH_BASIC" --data-binary @"$filename" -H "Authorization: token $github_api_token" -H "Content-Type: application/octet-stream" $GH_ASSET diff --git a/Env b/Env index 64246e1e..a561e307 100644 --- a/Env +++ b/Env @@ -1 +1 @@ -path /usr/local/lib/hamler \ No newline at end of file +path /usr/lib/hamler \ No newline at end of file diff --git a/Makefile b/Makefile index d424cced..d805ace5 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ exe_target = hamler stack_yaml = STACK_YAML="stack.yaml" stack = $(stack_yaml) stack +hamler_lib := $(shell sed -r 's/^path (.*)/\1/g' $(CURDIR)/Env) + all: build build: @@ -12,7 +14,13 @@ run: $(stack) build --fast && $(stack) exec -- $(exe_target) install: - $(stack) install +ifeq ($(shell uname -s),Linux) + $(stack) install --local-bin-path /usr/bin --allow-different-user +endif + $(stack) install --local-bin-path $(hamler_lib)/bin --allow-different-user + @cp repl/replsrv $(hamler_lib)/bin/replsrv + @cp -r ebin $(hamler_lib)/ebin + @cp -r lib $(hamler_lib)/lib test: $(stack) test --fast $(package) @@ -20,5 +28,10 @@ test: repl: $(stack) run repldev +docker: + docker build -t hamlerlang/hamler:$$(git describe --tags --always) -f deploy/docker/Dockerfile . + +pkg:build test install + make -C deploy/packages -.PHONY : build run install test repl +.PHONY : build run install test repl docker pkg diff --git a/deploy/docker/Dockerfile b/deploy/docker/Dockerfile new file mode 100644 index 00000000..df4a9fda --- /dev/null +++ b/deploy/docker/Dockerfile @@ -0,0 +1,32 @@ +FROM erlang:22.3 + +RUN apt update && apt install -y locales \ + && echo "LC_ALL=en_US.UTF-8" >> /etc/environment \ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + && echo "LANG=en_US.UTF-8" > /etc/locale.conf \ + && locale-gen en_US.UTF-8 + +ENV LC_ALL=en_US.UTF-8 + +RUN apt update && apt install -y libtinfo-dev ghc + +RUN wget -qO- https://get.haskellstack.org/ | sh + +ENV PATH=/root/.local/bin:$PATH + +COPY . hamler +RUN sed -i -r 's:^path (.*):path /usr/lib/hamler:g' hamler/Env \ + && make -C hamler \ + && make -C hamler test \ + && make -C hamler install + +WORKDIR /tmp/tests + +RUN hamler init \ + && hamler build \ + && hamler run \ + && echo ":q" | hamler repl + +WORKDIR / + +CMD [ "hamler" ] \ No newline at end of file diff --git a/deploy/packages/Makefile b/deploy/packages/Makefile new file mode 100644 index 00000000..e0fe2eb7 --- /dev/null +++ b/deploy/packages/Makefile @@ -0,0 +1,36 @@ +export + +ifneq ($(shell uname -s),Linux) + $(shell echo "Please execute this script under Linux") + exit +endif + +# The version-release used for package +PKG_VSN := $(shell git describe --tags --always) + +## +## Support RPM and Debian based linux systems +## +ifneq ($(shell cat /etc/*-release |grep -o -i centos),) + PKGERDIR := rpm +else + PKGERDIR := deb +endif + +.PHONY: all +all: clean + $(if $(PKGERDIR),,$(error "Operating system '$(OS)' not supported")) + cd $(PKGERDIR) && $(MAKE) + +clean: + make -C rpm clean + make -C deb clean + +.PHONY: deb +deb: + make -C deb + +.PHONY: rpm +rpm: + make -C rpm + diff --git a/deploy/packages/deb/Makefile b/deploy/packages/deb/Makefile new file mode 100644 index 00000000..3ebd9fff --- /dev/null +++ b/deploy/packages/deb/Makefile @@ -0,0 +1,24 @@ +# Keep this short to avoid bloating beam files with long file path info +TOPDIR := /tmp/hamler +SRCDIR := $(TOPDIR)/$(PKG_VSN) +BUILT := $(SRCDIR)/BUILT + +HAMLER_LIB=$(shell sed -r 's:^path (.*):/usr/lib/hamler:g' ../../../Env) + +.PHONY: all +all: | $(BUILT) + cp -r debian $(SRCDIR)/ + sed -i "s##$(shell date -u '+%a, %d %b %Y %T %z')#g" $(SRCDIR)/debian/changelog + sed -i "s##$(PKG_VSN)#g" $(SRCDIR)/debian/changelog + cd $(SRCDIR) && dpkg-buildpackage -us -uc + mkdir _packages + cp $(TOPDIR)/$(SOURCE_PKG)/*.deb _packages/ + +$(BUILT): + mkdir -p $(TOPDIR) $(SRCDIR) + cp -r $(HAMLER_LIB)/bin $(SRCDIR)/ + cp -r $(HAMLER_LIB)/lib $(SRCDIR)/ + cp -r $(HAMLER_LIB)/ebin $(SRCDIR) + +clean: + rm -rf $(SRCDIR) diff --git a/deploy/packages/deb/debian/changelog b/deploy/packages/deb/debian/changelog new file mode 100644 index 00000000..0474a62a --- /dev/null +++ b/deploy/packages/deb/debian/changelog @@ -0,0 +1,5 @@ +hamler () unstable; urgency=medium + + * See github commit history: https://github.com/hamler-lang/hamler + + -- hamler diff --git a/deploy/packages/deb/debian/compat b/deploy/packages/deb/debian/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/deploy/packages/deb/debian/compat @@ -0,0 +1 @@ +9 diff --git a/deploy/packages/deb/debian/control b/deploy/packages/deb/debian/control new file mode 100644 index 00000000..3a43ce18 --- /dev/null +++ b/deploy/packages/deb/debian/control @@ -0,0 +1,12 @@ +Source: hamler +Section: unknown +Priority: optional +Maintainer: hamler +Build-Depends: debhelper (>=9) +Standards-Version: 3.9.6 +Homepage: https://www.hamler-lang.org + +Package: hamler +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, esl-erlang(>= 22.3) | erlang(>= 22.3) +Description: Hamler - Haskell-style functional programming language running on Erlang VM. Hamler is a strongly-typed language with compile-time typechecking and built-in support for concurrency and distribution. \ No newline at end of file diff --git a/deploy/packages/deb/debian/copyright b/deploy/packages/deb/debian/copyright new file mode 100644 index 00000000..8f71f43f --- /dev/null +++ b/deploy/packages/deb/debian/copyright @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/deploy/packages/deb/debian/rules b/deploy/packages/deb/debian/rules new file mode 100755 index 00000000..4cf5acf4 --- /dev/null +++ b/deploy/packages/deb/debian/rules @@ -0,0 +1,57 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# modified for node_package by dizzyd@basho.com and jared@basho.com + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=1 + + +## Clear variables that may confound our build of sub-projects; also +## note that it is necessary to use overlay_vars relative to .. as +## the generate command EXECUTES in rel/ +build: + +clean: + dh_clean + rm -f build + # make clean + +## dh_shlibdeps was added to figure out the dependencies on shared libraries +## and will populate the ${shlibs:Depends} callout in the control file +install: build + dh_testdir + dh_testroot + dh_prep + dh_installdirs + + mkdir -p debian/hamler/usr/bin + mkdir -p debian/hamler/usr/lib/hamler + + cp bin/hamler debian/hamler/usr/bin/hamler + cp -r bin debian/hamler/usr/lib/hamler/ + cp -r ebin debian/hamler/usr/lib/hamler/ + cp -r lib debian/hamler/usr/lib/hamler/ + + # stack install --local-bin-path debian/hamler/usr/bin + + dh_shlibdeps + +# We have nothing to do by default. +binary-indep: install build-stamp +build-stamp: + +# Build architecture-dependent files here. +binary-arch: install + dh_strip -a + dh_compress -a + dh_installdeb + dh_gencontrol + dh_builddeb + +binary: binary-indep binary-arch diff --git a/deploy/packages/rpm/Makefile b/deploy/packages/rpm/Makefile new file mode 100644 index 00000000..508fa9af --- /dev/null +++ b/deploy/packages/rpm/Makefile @@ -0,0 +1,45 @@ +# Keep this short to avoid bloating beam files with long file path info +TOPDIR := /tmp/hamler +SRCDIR := $(TOPDIR)/$(PKG_VSN) +BUILT := $(SRCDIR)/BUILT +dash := - +none := +space := $(none) $(none) + +RPM_VSN ?= $(shell echo $(PKG_VSN) | grep -oE "[0-9]+\.[0-9]+(\.[0-9]+)?") +RPM_REL ?= $(shell echo $(PKG_VSN) | grep -oE "(alpha|beta|rc)\.[0-9]") + +ifeq ($(RPM_REL),) + # no tail + RPM_REL := 1 +endif + +ARCH:=$(shell uname -m) +ifeq ($(ARCH),mips64) + ARCH:=mips64el +endif + +HAMLER_LIB=$(shell sed -r 's:^path (.*):/usr/lib/hamler:g' ../../../Env) + +.PHONY: all +all: | $(BUILT) + rpmbuild -v -bb \ + --define "_package_name hamler" \ + --define "_name hamler" \ + --define "_topdir $(TOPDIR)" \ + --define "_srcdir $(SRCDIR)" \ + --define "_version $(RPM_VSN)" \ + --define "_release $(RPM_REL)" \ + --define "_ostype -$(SYSTEM)" \ + hamler.spec + mkdir -p _packages + cp $(TOPDIR)/RPMS/$(ARCH)/*.rpm _packages/ + +$(BUILT): + mkdir -p $(TOPDIR) $(SRCDIR) + cp -r $(HAMLER_LIB)/bin $(SRCDIR)/ + cp -r $(HAMLER_LIB)/lib $(SRCDIR)/ + cp -r $(HAMLER_LIB)/ebin $(SRCDIR)/ + +clean: + rm -rf $(SRCDIR) diff --git a/deploy/packages/rpm/hamler.spec b/deploy/packages/rpm/hamler.spec new file mode 100644 index 00000000..1d463c0d --- /dev/null +++ b/deploy/packages/rpm/hamler.spec @@ -0,0 +1,47 @@ +%define debug_package %{nil} +%define _lib_home /usr/lib/%{_name} +%define _build_id_links none + +Name: %{_package_name} +Version: %{_version} +Release: %{_release}%{?dist} +Summary: hamler +Group: System Environment/Daemons +License: Apache License Version 2.0 +URL: https://www.hamler-lang.org +BuildRoot: %{_tmppath}/%{_name}-%{_version}-root +Provides: %{_name} +AutoReq: 0 + +%description +Hamler - Haskell-style functional programming language running on Erlang VM. Hamler is a strongly-typed language with compile-time typechecking and built-in support for concurrency and distribution. + +%prep + +%build + +%install +mkdir -p %{buildroot}%{_lib_home} + +cp -r %{_srcdir}/bin %{buildroot}%{_lib_home}/ +cp -r %{_srcdir}/ebin %{buildroot}%{_lib_home}/ +cp -r %{_srcdir}/lib %{buildroot}%{_lib_home}/ + +%pre + +%post +if [ $1 = 1 ]; then + ln -s %{_lib_home}/bin/hamler %{_bindir}/hamler +fi + +%preun + +%files +%defattr(-,root,root) +%{_lib_home} + +%clean +rm -rf %{buildroot} + +%changelog + diff --git a/hamler.cabal b/hamler.cabal index 935b28ed..75434f28 100644 --- a/hamler.cabal +++ b/hamler.cabal @@ -12,7 +12,7 @@ synopsis: The Hamler Programming Language description: Hamler is a functional programming language inspired by Haskell and Stardard ML, that compiles to Core Erlang. category: Language, Compiler stability: experimental -homepage: http://www.hamler.io/ +homepage: http://www.hamler-lang.org/ bug-reports: https://github.com/hamler-lang/hamler/issues author: Feng Lee maintainer: Feng Lee diff --git a/package.yaml b/package.yaml index 1324dfc1..990be070 100644 --- a/package.yaml +++ b/package.yaml @@ -9,7 +9,7 @@ maintainer: Feng Lee copyright: (c) 2013-17 Phil Freeman, (c) 2014-19 Gary Burgess, (c) other contributors (see CONTRIBUTORS.md) license: BSD3 github: hamler-lang/hamler -homepage: http://www.hamler.io/ +homepage: http://www.hamler-lang.org/ extra-source-files: - README.md - stack.yaml diff --git a/stack.yaml b/stack.yaml index aa7a2a2b..ce209ea5 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,3 +1,4 @@ +allow-different-user: true resolver: lts-13.26 pvp-bounds: upper packages: