File longhorn-instance-manager.spec of Package longhorn-instance-manager

# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
 
# Please submit bugfixes or comments via https://bugs.opensuse.org/
# 

Name:           longhorn-instance-manager
Version:        1.9.1+git.0.b228e39c
Release:        0
License:        Apache-2.0
Summary:        Longhorn Instance Manager
Url:            https://github.com/longhorn/longhorn-instance-manager
Group:          Development/Languages/Other
Source0:        %{name}-%{version}.tar.xz
Source1:        vendor.tar.xz
BuildRequires:  golang-packaging
BuildRequires:  xz
BuildRequires:  zlib-devel
BuildRequires:  libqcow-devel
Requires:       libqcow1
#BuildRequires:  glibc-devel-static
Requires(post): %fillup_prereq

%{go_nostrip}
%{go_provides}

%description
Longhorn Instance Manager manages engine and replica instances on the node.

%prep
%autosetup -a1

%build
REV="%{version}"
#export REV="${REV##*.}"
#go build \
#  -mod=vendor \
#  -buildmode=pie 
#  -ldflags "-X main.VERSION=%{version}"
VERSION="${REV%%+*}"
GITCOMMIT="${REV##*.}"
BUILDDATE=$(date -u --rfc-3339=seconds)
BUILDDATE=${BUILDDATE// /T}
LDFLAGS="-X main.Version=$VERSION
         -X main.GitCommit=$GITCOMMIT
         -X main.BuildDate=$BUILDDATE
         -linkmode external"
%{goprep} github.com/longhorn/longhorn-instance-manager
%{gobuild} -ldflags="$LDFLAGS" ""

%install
%{goinstall}
install -D -m 0755 package/instance-manager %{buildroot}%{_bindir}/instance-manager
install -D -m 0755 package/instance-manager-v2-prestop %{buildroot}%{_bindir}/instance-manager-v2-prestop

%check
mkdir -p ./bin
echo -e '#!/bin/sh\necho "Dummy binary"' > ./bin/longhorn-engine
chmod +x ./bin/longhorn-engine
export PATH=$PWD/bin:$PATH
go test -v ./... ||:

%files
%doc README.md
%license LICENSE
%{_bindir}/longhorn-instance-manager
%{_bindir}/instance-manager
%{_bindir}/instance-manager-v2-prestop
openSUSE Build Service is sponsored by