Skip to content

Commit

Permalink
Merge pull request #250 from yzewei/main
Browse files Browse the repository at this point in the history
add longhornio/longhorn-engine/1.6.2
  • Loading branch information
yzewei authored Jul 17, 2024
2 parents 5b9c1a2 + 6205e7b commit 3eec9ad
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 5 deletions.
121 changes: 121 additions & 0 deletions longhornio/longhorn-engine/1.6.2/0001-port-to-loong64.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
diff --git a/go.mod b/go.mod
index 317bc51..dfac060 100644
--- a/go.mod
+++ b/go.mod
@@ -1,8 +1,6 @@
module github.com/longhorn/longhorn-engine

-go 1.22.0
-
-toolchain go1.22.3
+go 1.22

require (
github.com/docker/go-units v0.3.3
diff --git a/package/Dockerfile b/package/Dockerfile
index 7d9dd93..d32e88a 100644
--- a/package/Dockerfile
+++ b/package/Dockerfile
@@ -1,17 +1,14 @@
-FROM registry.suse.com/bci/bci-base:15.5 AS builder
+FROM cr.loongnix.cn/openanolis/anolisos:8.9 AS builder

-ARG ARCH=amd64
-
-RUN zypper -n addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/SLE_15/system:snappy.repo && \
- zypper -n addrepo --refresh https://download.opensuse.org/repositories/network:/utilities/SLE_15_SP5/network:utilities.repo && \
- zypper --gpg-auto-import-keys ref
+ARG ARCH=loongarch64

-RUN zypper -n install cmake curl git gcc wget xsltproc docbook-xsl-stylesheets && \
- rm -rf /var/cache/zypp/*
+#RUN yum install -y cmake curl git gcc wget xsltproc docbook-xsl-stylesheets
+RUN yum install -y cmake curl git gcc wget libxslt-devel docbook-style-xsl

# Build liblonghorn
ENV LIBLONGHORN_COMMIT_ID 53d1c063b95efc8d949b095bd4bf04637230265f
-RUN cd /usr/src && \
+RUN mkdir -p /usr/src && \
+ cd /usr/src && \
git clone https://github.com/rancher/liblonghorn.git && \
cd liblonghorn && \
git checkout ${LIBLONGHORN_COMMIT_ID} && \
@@ -28,20 +25,16 @@ RUN cd /usr/src && \
make install

# Install grpc_health_probe
-RUN wget https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.4.24/grpc_health_probe-linux-${ARCH} -O /usr/local/bin/grpc_health_probe && \
+RUN wget https://github.com/Loongson-Cloud-Community/grpc-health-probe/releases/download/v0.4.24/grpc_health_probe-linux-loongarch64 -O /usr/local/bin/grpc_health_probe && \
chmod +x /usr/local/bin/grpc_health_probe

-FROM registry.suse.com/bci/bci-base:15.5 AS release
+FROM cr.loongnix.cn/openanolis/anolisos:8.9 AS release

ARG ARCH=amd64

-RUN zypper -n addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/SLE_15/system:snappy.repo && \
- zypper -n addrepo --refresh https://download.opensuse.org/repositories/network:/utilities/SLE_15_SP5/network:utilities.repo && \
- zypper --gpg-auto-import-keys ref

-RUN zypper -n install nfs-client nfs4-acl-tools cifs-utils libaio1 sg3_utils \
- iputils iproute2 qemu-tools e2fsprogs && \
- rm -rf /var/cache/zypp/*
+RUN yum install -y nfs-utils nfs4-acl-tools cifs-utils libaio-devel sg3_utils \
+ iputils iproute qemu-kvm e2fsprogs

# Copy pre-built binaries from builder
COPY --from=builder \
@@ -61,7 +54,8 @@ VOLUME /usr/local/bin

# Add Tini
ENV TINI_VERSION v0.19.0
-ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${ARCH} /tini
+#ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${ARCH} /tini
+ADD https://github.com/Loongson-Cloud-Community/tini/releases/download/v0.19.0/tini-static /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]

diff --git a/scripts/build b/scripts/build
index 21106ff..4d02565 100755
--- a/scripts/build
+++ b/scripts/build
@@ -20,3 +20,4 @@ cd $(dirname $0)/..

mkdir -p bin
go build -o bin/longhorn -tags netgo -ldflags "$LINKFLAGS" $COVER $COVERPKG
+#go build -o bin/longhorn -ldflags "$LINKFLAGS" $COVER $COVERPKG
diff --git a/scripts/package b/scripts/package
index ec3d882..6a0e83b 100755
--- a/scripts/package
+++ b/scripts/package
@@ -8,8 +8,8 @@ cd $(dirname $0)/..
PROJECT=`basename "$PWD"`

TAG=${TAG:-${VERSION}}
-REPO=${REPO:-longhornio}
-IMAGE=${REPO}/${PROJECT}:${TAG}
+REPO=${REPO:-cr.loongnix.cn/longhornio}
+IMAGE=${REPO}/${PROJECT}:1.6.2

case $(uname -m) in
aarch64 | arm64)
@@ -20,6 +20,9 @@ case $(uname -m) in
;;
s390x)
ARCH=s390x
+ ;;
+ loongarch64)
+ ARCH=loong64
;;
*)
echo "$(uname -a): unsupported architecture"
@@ -30,7 +33,8 @@ if [ ! -x ./bin/longhorn ]; then
./scripts/build
fi

-cp /usr/local/bin/longhorn-instance-manager ./bin/
+wget https://github.com/Loongson-Cloud-Community/longhorn-instance-manager/releases/download/v1.6.2/longhorn-instance-manager -O ./bin/longhorn-instance-manager
+#cp /usr/local/bin/longhorn-instance-manager ./bin/

# update base image to get latest changes
grep FROM package/Dockerfile | awk '{print $2}' | while read -r BASE_IMAGE
57 changes: 57 additions & 0 deletions longhornio/longhorn-engine/1.6.2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This file is generated by the template.

REGISTRY?=cr.loongnix.cn
ORGANIZATION?=longhornio
REPOSITORY?=longhorn-engine
TAG?=1.6.2
LATEST?=true

IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG)
LATEST_IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest

# SOURCE_URL is a url to download source, such as https://github.com/merore/merore.git.
# SOURCE is project sources, its located at src/$(SORUCE).
# PATCH is a patch that supports loong64 to $(SOURCE).
# Be sure to fill in the follows!!!
SOURCE_URL=https://github.com/longhorn/$(REPOSITORY)
SOURCE=$(shell echo $(SOURCE_URL) | awk -F '/' '{print $$NF}' | awk -F '.' '{print $$1}')
PATCH=0001-port-to-loong64.patch

default: image

image: go-env src/$(SOURCE)
cd src/$(SOURCE) && \
wget https://github.com/Loongson-Cloud-Community/longhorn-engine/releases/download/v1.6.2/longhorn && \
chmod +x longhorn && mkdir bin && mv longhorn bin/ && \
bash scripts/package

go-env:
cd /usr/local && \
wget http://ftp.loongnix.cn/toolchain/golang/go-1.22/abi1.0/go1.22.4.linux-loong64.tar.gz && tar xf go1.22.4.linux-loong64.tar.gz && \
export PATH=/usr/local/go/bin:$(PATH)

src/$(SOURCE): libqcow
git clone -b v$(TAG) --depth=1 $(SOURCE_URL) $@
cd $@ && \
git apply ../../$(PATCH)

libqcow:
wget https://s3-us-west-1.amazonaws.com/rancher-longhorn/libqcow-alpha-20181117.tar.gz && tar xf libqcow-alpha-20181117.tar.gz && \
cd libqcow-20181117 && \
wget -O config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' && \
wget -O config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' && \
./configure && \
make -j$(nproc) && \
make install && \
ldconfig

push:
docker push $(IMAGE)
@if [ $(LATEST) = "true" ]; \
then\
docker tag $(IMAGE) $(LATEST_IMAGE); \
docker push $(LATEST_IMAGE); \
fi

clean:
rm -rf src libqcow* /usr/local/go1.22.4.linux-loong64.tar.gz /usr/local/go
12 changes: 12 additions & 0 deletions longhornio/longhorn-manager/1.6.2/0001-port-to-loong64.patch
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ index 78839b9..2200d04 100644
@@chmod +x .dapper.tmp
@./.dapper.tmp -v
@mv .dapper.tmp .dapper
diff --git a/go.mod b/go.mod
index c53c513..96347c9 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/longhorn/longhorn-manager

-go 1.22.2
+go 1.22

toolchain go1.22.3

diff --git a/package/Dockerfile b/package/Dockerfile
index 53a7649..3573173 100644
--- a/package/Dockerfile
Expand Down
17 changes: 12 additions & 5 deletions longhornio/longhorn-manager/1.6.2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ REGISTRY?=cr.loongnix.cn
ORGANIZATION?=longhornio
REPOSITORY?=longhorn-manager
TAG?=1.6.2
LATEST?=true
LATEST?=false

IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG)
LATEST_IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest
Expand All @@ -19,9 +19,16 @@ PATCH=0001-port-to-loong64.patch

default: image

image: src/$(SOURCE)
# Commands for building.
cd src/$(SOURCE) && bash scripts/package
image: go-env src/$(SOURCE)
cd src/$(SOURCE) && \
wget https://github.com/Loongson-Cloud-Community/longhorn-manager/releases/download/v1.6.2/longhorn-manager && \
chmod +x longhorn-manager && mkdir bin && mv longhorn-manager bin/ && \
bash scripts/package

go-env:
cd /usr/local && \
wget http://ftp.loongnix.cn/toolchain/golang/go-1.22/abi1.0/go1.22.4.linux-loong64.tar.gz && tar xf go1.22.4.linux-loong64.tar.gz && \
export PATH=/usr/local/go/bin:$(PATH)

src/$(SOURCE):
git clone -q -b v$(TAG) --depth=1 $(SOURCE_URL) $@
Expand All @@ -37,4 +44,4 @@ push:
fi

clean:
rm -rf src
rm -rf src /usr/local/go1.22.4.linux-loong64.tar.gz /usr/local/go

0 comments on commit 3eec9ad

Please sign in to comment.