mirror of
https://github.com/Jguer/yay.git
synced 2026-05-05 20:36:09 +02:00
Make makefile more targeted by refactoring. Add new multistage dockerfile
Remove separate targets for release. Replace travis-ci with github-actions Signed-off-by: Jguer <me@jguer.space>
This commit is contained in:
parent
de95a0e253
commit
d0705a6d6b
15
.github/workflows/docker-ci.yml
vendored
Normal file
15
.github/workflows/docker-ci.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
name: Docker CI build
|
||||
# This workflow is triggered on pushes to the repository.
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# Job name is Greeting
|
||||
name: Build and test yay
|
||||
# This job runs on Linux
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1#
|
||||
- name: Run Build and tests
|
||||
run: ./testdata/travis.sh
|
||||
20
.travis.yml
20
.travis.yml
@ -1,20 +0,0 @@
|
||||
sudo: required
|
||||
notifications:
|
||||
email: false
|
||||
language: generic
|
||||
services:
|
||||
- docker
|
||||
|
||||
arch:
|
||||
packages:
|
||||
- git
|
||||
- go
|
||||
script:
|
||||
- go vet .
|
||||
- diff -u <(echo -n) <(gofmt -d ./)
|
||||
- make
|
||||
- make test
|
||||
- ./testdata/install_test.sh
|
||||
|
||||
script:
|
||||
- "curl -s https://raw.githubusercontent.com/mikkeloscar/arch-travis/master/arch-travis.sh | bash"
|
||||
41
Dockerfile
Normal file
41
Dockerfile
Normal file
@ -0,0 +1,41 @@
|
||||
ARG BUILD_ARCH=x86_64
|
||||
FROM sapk/archlinux:$BUILD_ARCH AS builder_env
|
||||
LABEL maintainer="Jguer,joaogg3 at google mail"
|
||||
|
||||
ENV GO111MODULE=on
|
||||
WORKDIR /app
|
||||
|
||||
RUN pacman -Syu --overwrite=* --needed --noconfirm \
|
||||
gcc gnupg libldap go git tar make awk linux-api-headers pacman-contrib && paccache -rfk0
|
||||
|
||||
# Dependency for linting
|
||||
RUN go get golang.org/x/lint/golint && mv /root/go/bin/golint /bin/
|
||||
|
||||
ENV ARCH=$BUILD_ARCH
|
||||
ADD . .
|
||||
|
||||
FROM builder_env AS builder
|
||||
|
||||
# Change to include packages individually. Helps caching
|
||||
RUN make build
|
||||
|
||||
FROM archlinux/base:latest
|
||||
|
||||
RUN pacman -Syu --overwrite=* --needed --noconfirm \
|
||||
git base-devel awk pacman-contrib && paccache -rfk0
|
||||
|
||||
# Gracefully removed from https://github.com/Cognexa/dockerfiles/blob/master/dockerfiles/archlinux
|
||||
RUN useradd -m -s /bin/bash aur \
|
||||
&& passwd -d aur \
|
||||
&& echo 'aur ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/aur \
|
||||
&& echo 'Defaults env_keep += "EDITOR"' >> /etc/sudoers.d/aur
|
||||
|
||||
ENV EDITOR vim
|
||||
|
||||
# set UTF-8 locale
|
||||
RUN echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen && locale-gen
|
||||
ENV LANG en_US.UTF-8
|
||||
|
||||
WORKDIR /work/
|
||||
|
||||
COPY --from=builder /app/yay .
|
||||
154
Makefile
154
Makefile
@ -1,92 +1,104 @@
|
||||
.PHONY: all default install uninstall test build release clean package
|
||||
export GO111MODULE=on
|
||||
|
||||
PKGNAME := yay
|
||||
BIN := yay
|
||||
PREFIX := /usr/local
|
||||
DESTDIR :=
|
||||
GO ?= go
|
||||
GOFLAGS := -v
|
||||
EXTRA_GOFLAGS ?=
|
||||
LDFLAGS := $(LDFLAGS) -X "main.version=${VERSION}"
|
||||
|
||||
MAJORVERSION := 9
|
||||
MINORVERSION ?= 3
|
||||
PATCHVERSION := 1
|
||||
MINORVERSION := 3
|
||||
PATCHVERSION := 2
|
||||
|
||||
ARCH ?= $(shell uname -m)
|
||||
|
||||
VERSION ?= ${MAJORVERSION}.${MINORVERSION}.${PATCHVERSION}
|
||||
|
||||
LDFLAGS := -gcflags=all=-trimpath=${PWD} -asmflags=all=-trimpath=${PWD} -ldflags=-extldflags=-zrelro -ldflags=-extldflags=-znow -ldflags '-s -w -X main.version=${VERSION}'
|
||||
MOD := -mod=vendor
|
||||
export GO111MODULE=on
|
||||
ARCH := $(shell uname -m)
|
||||
GOCC := $(shell go version)
|
||||
PKGNAME := yay
|
||||
BINNAME := yay
|
||||
PACKAGE := ${PKGNAME}_${VERSION}_${ARCH}
|
||||
|
||||
ifneq (,$(findstring gccgo,$(GOCC)))
|
||||
export GOPATH=$(shell pwd)/.go
|
||||
LDFLAGS := -gccgoflags '-s -w'
|
||||
MOD :=
|
||||
endif
|
||||
|
||||
default: build
|
||||
RELEASE_DIR := ${PKGNAME}_${VERSION}_${ARCH}
|
||||
PACKAGE := $(RELEASE_DIR).tar.gz
|
||||
SOURCES ?= $(shell find . -name "*.go" -type f)
|
||||
|
||||
.PHONY: all
|
||||
all: | clean package
|
||||
|
||||
.PHONY: default
|
||||
default: build
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(GO) clean -i ./...
|
||||
rm -rf $(BIN) $(PKGNAME)_$(VERSION)_*
|
||||
|
||||
.PHONY: test
|
||||
test: test-vendor
|
||||
$(GO) vet .
|
||||
@test -z "$$(gofmt -l $(SRC))" || (echo "Files need to be linted. Use make fmt" && false)
|
||||
$(GO) test -mod=vendor --race -covermode=atomic -v . ./pkg/...
|
||||
|
||||
.PHONY: build
|
||||
build: $(BIN)
|
||||
|
||||
.PHONY: release
|
||||
release: $(PACKAGE)
|
||||
|
||||
$(BIN): $(SOURCES)
|
||||
$(GO) build -mod=vendor -ldflags '-s -w $(LDFLAGS)' $(GOFLAGS) $(EXTRA_GOFLAGS) -o $@
|
||||
|
||||
$(RELEASE_DIR):
|
||||
mkdir $(RELEASE_DIR)
|
||||
|
||||
$(PACKAGE): $(BIN) $(RELEASE_DIR)
|
||||
cp -t $(RELEASE_DIR) ${BIN} doc/${PKGNAME}.8 completions/*
|
||||
tar -czvf $(PACKAGE) $(RELEASE_DIR)
|
||||
|
||||
.PHONY: docker-release-all
|
||||
docker-release-all:
|
||||
make docker-release ARCH=x86_64
|
||||
make docker-release ARCH=armv7h
|
||||
make docker-release ARCH=aarch64
|
||||
|
||||
.PHONY: docker-release
|
||||
docker-release:
|
||||
docker build --target builder_env --build-arg BUILD_ARCH="$(ARCH)" -t yay-$(ARCH):${VERSION} .
|
||||
docker run -e="ARCH=$(ARCH)" --name yay-$(ARCH) yay-$(ARCH):${VERSION} make release
|
||||
docker cp yay-$(ARCH):/app/${PACKAGE} $(PACKAGE)
|
||||
docker container rm yay-$(ARCH)
|
||||
|
||||
.PHONY: docker-build
|
||||
docker-build:
|
||||
docker build --target builder --build-arg BUILD_ARCH="$(ARCH)" -t yay-$(ARCH):${VERSION} .
|
||||
docker create --name yay-build-${ARCH} yay-build-${ARCH}:${VERSION}
|
||||
docker cp yay-build-${ARCH}:/app/${BIN} ${BIN}
|
||||
docker container rm yay-build-${ARCH}
|
||||
|
||||
.PHONY: test-vendor
|
||||
test-vendor: vendor
|
||||
@diff=$$(git diff vendor/); \
|
||||
if [ -n "$$diff" ]; then \
|
||||
echo "Please run 'make vendor' and commit the result:"; \
|
||||
echo "$${diff}"; \
|
||||
exit 1; \
|
||||
fi;
|
||||
|
||||
.PHONY: vendor
|
||||
vendor:
|
||||
$(GO) mod tidy && $(GO) mod vendor
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
install -Dm755 ${BINNAME} $(DESTDIR)$(PREFIX)/bin/${BINNAME}
|
||||
install -Dm755 ${BIN} $(DESTDIR)$(PREFIX)/bin/${BIN}
|
||||
install -Dm644 doc/${PKGNAME}.8 $(DESTDIR)$(PREFIX)/share/man/man8/${PKGNAME}.8
|
||||
install -Dm644 completions/bash $(DESTDIR)$(PREFIX)/share/bash-completion/completions/${PKGNAME}
|
||||
install -Dm644 completions/zsh $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_${PKGNAME}
|
||||
install -Dm644 completions/fish $(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d/${PKGNAME}.fish
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)$(PREFIX)/bin/${BINNAME}
|
||||
rm -f $(DESTDIR)$(PREFIX)/bin/${BIN}
|
||||
rm -f $(DESTDIR)$(PREFIX)/share/man/man8/${PKGNAME}.8
|
||||
rm -f $(DESTDIR)$(PREFIX)/share/bash-completion/completions/${PKGNAME}
|
||||
rm -f $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_${PKGNAME}
|
||||
rm -f $(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d/${PKGNAME}.fish
|
||||
|
||||
test:
|
||||
gofmt -l *.go
|
||||
@test -z "$$(gofmt -l *.go)" || (echo "Files need to be linted" && false)
|
||||
go vet
|
||||
go test -v
|
||||
|
||||
build:
|
||||
go build -v ${LDFLAGS} -o ${BINNAME} ${MOD}
|
||||
|
||||
release: | test build
|
||||
mkdir ${PACKAGE}
|
||||
cp ./${BINNAME} ${PACKAGE}/
|
||||
cp ./doc/${PKGNAME}.8 ${PACKAGE}/
|
||||
cp ./completions/zsh ${PACKAGE}/
|
||||
cp ./completions/fish ${PACKAGE}/
|
||||
cp ./completions/bash ${PACKAGE}/
|
||||
|
||||
docker-release-aarch64:
|
||||
docker build -f build/aarch64.Dockerfile -t yay-aarch64:${VERSION} .
|
||||
docker run --name yay-aarch64 yay-aarch64:${VERSION}
|
||||
docker cp yay-aarch64:${PKGNAME}_${VERSION}_aarch64.tar.gz ${PKGNAME}_${VERSION}_aarch64.tar.gz
|
||||
docker container rm yay-aarch64
|
||||
|
||||
docker-release-armv7h:
|
||||
docker build -f build/armv7h.Dockerfile -t yay-armv7h:${VERSION} .
|
||||
docker create --name yay-armv7h yay-armv7h:${VERSION}
|
||||
docker cp yay-armv7h:${PKGNAME}_${VERSION}_armv7l.tar.gz ${PKGNAME}_${VERSION}_armv7h.tar.gz
|
||||
docker container rm yay-armv7h
|
||||
|
||||
docker-release-x86_64:
|
||||
docker build -f build/x86_64.Dockerfile -t yay-x86_64:${VERSION} .
|
||||
docker create --name yay-x86_64 yay-x86_64:${VERSION}
|
||||
docker cp yay-x86_64:${PKGNAME}_${VERSION}_x86_64.tar.gz ${PKGNAME}_${VERSION}_x86_64.tar.gz
|
||||
docker container rm yay-x86_64
|
||||
|
||||
docker-release: | docker-release-x86_64 docker-release-aarch64 docker-release-armv7h
|
||||
|
||||
docker-build:
|
||||
docker build -f build/${ARCH}.Dockerfile --build-arg MAKE_ARG=build -t yay-build-${ARCH}:${VERSION} .
|
||||
docker create --name yay-build-${ARCH} yay-build-${ARCH}:${VERSION}
|
||||
docker cp yay-build-${ARCH}:${BINNAME} ${BINNAME}
|
||||
docker container rm yay-build-${ARCH}
|
||||
|
||||
package: release
|
||||
tar -czvf ${PACKAGE}.tar.gz ${PACKAGE}
|
||||
clean:
|
||||
rm -rf ${PKGNAME}_*
|
||||
rm -f ${BINNAME}
|
||||
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
FROM agners/archlinuxarm-arm64v8
|
||||
|
||||
LABEL maintainer="Jguer,joaogg3 at google mail"
|
||||
|
||||
ARG QEMU_STATIC=build/qemu-aarch64-static
|
||||
ADD ${QEMU_STATIC} /usr/bin
|
||||
|
||||
RUN pacman -Sy; pacman --noconfirm -S gcc go git tar make
|
||||
|
||||
ADD . .
|
||||
|
||||
ARG MAKE_ARG="package"
|
||||
RUN make ${MAKE_ARG}
|
||||
@ -1,13 +0,0 @@
|
||||
FROM lopsided/archlinux-arm32v7:devel
|
||||
|
||||
ARG QEMU_STATIC=build/qemu-arm-static
|
||||
ADD ${QEMU_STATIC} /usr/bin
|
||||
|
||||
LABEL maintainer="Jguer,joaogg3 at google mail"
|
||||
|
||||
RUN pacman -Sy; pacman --noconfirm -S go git ca-certificates-utils
|
||||
|
||||
ADD . .
|
||||
|
||||
ARG MAKE_ARG=package
|
||||
RUN make ${MAKE_ARG}
|
||||
@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd "$( dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
|
||||
wget https://github.com/multiarch/qemu-user-static/releases/download/v3.1.0-3/qemu-aarch64-static
|
||||
wget https://github.com/multiarch/qemu-user-static/releases/download/v3.1.0-3/qemu-arm-static
|
||||
|
||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
FROM archlinux/base
|
||||
|
||||
LABEL maintainer="Jguer,joaogg3 at google mail"
|
||||
|
||||
RUN pacman -Sy; pacman --noconfirm -S gcc go git tar make
|
||||
|
||||
ADD . .
|
||||
|
||||
ARG MAKE_ARG=package
|
||||
RUN make ${MAKE_ARG}
|
||||
33
testdata/travis.sh
vendored
Executable file
33
testdata/travis.sh
vendored
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
set -evx
|
||||
|
||||
# Objective of this script is to be the most vendor agnostic possible
|
||||
# It builds and tests yay independently of hardware
|
||||
|
||||
export VERSION=$(git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')
|
||||
export ARCH="x86_64"
|
||||
|
||||
docker build --build-arg BUILD_ARCH=${ARCH} --target builder_env -t yay-builder_env .
|
||||
docker build --build-arg BUILD_ARCH=${ARCH} --target builder -t yay-builder .
|
||||
|
||||
# Our unit test and packaging container
|
||||
docker run --name yay-go-tests yay-builder_env:latest make test
|
||||
docker rm yay-go-tests
|
||||
|
||||
# docker run yay-builder make lint
|
||||
|
||||
# Build image for integration testing
|
||||
docker build -t yay .
|
||||
|
||||
# Do integration testing
|
||||
# TODO
|
||||
|
||||
# Create a release asset
|
||||
docker run --name artifact_factory yay-builder make release ARCH=${ARCH} VERSION=${VERSION}
|
||||
|
||||
# Copy bin and release to workdir
|
||||
docker cp artifact_factory:/app/yay yay
|
||||
docker cp artifact_factory:/app/yay_${VERSION}_${ARCH}.tar.gz .
|
||||
|
||||
# Cleanup docker
|
||||
docker rm artifact_factory
|
||||
4
vendor/github.com/Morganamilo/go-pacmanconf/ini/ini.go
generated
vendored
4
vendor/github.com/Morganamilo/go-pacmanconf/ini/ini.go
generated
vendored
@ -1,8 +1,8 @@
|
||||
package ini
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
type Callback func(fileName string, line int, section string,
|
||||
@ -35,7 +35,7 @@ func parse(fileName string, ini string, cb Callback, data interface{}) error {
|
||||
if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") {
|
||||
runes := []rune(line)
|
||||
header = string(runes[1 : len(runes)-1])
|
||||
|
||||
|
||||
if err := cb(fileName, n, header, "", "", data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user