github.com/dctrud/umoci@v0.4.3-0.20191016193643-05a1d37de015/contrib/pkg/suse/make_spec.sh (about) 1 #!/bin/bash 2 3 if [ -z "$1" ]; then 4 cat <<EOF 5 usage: 6 ./make_spec.sh PACKAGE [BRANCH] 7 EOF 8 exit 1 9 fi 10 11 cd $(dirname $0) 12 13 YEAR=$(date +%Y) 14 VERSION=$(cat ../../../VERSION) 15 COMMIT_UNIX_TIME=$(git show -s --format=%ct) 16 VERSION="${VERSION%+*}+$(date -d @$COMMIT_UNIX_TIME +%Y%m%d).$(git rev-parse --short HEAD)" 17 NAME=$1 18 BRANCH=${2:-master} 19 SAFE_BRANCH=${BRANCH//\//-} 20 21 cat <<EOF > ${NAME}.spec 22 # 23 # spec file for package $NAME 24 # 25 # Copyright (c) $YEAR SUSE LINUX GmbH, Nuernberg, Germany. 26 # 27 # All modifications and additions to the file contributed by third parties 28 # remain the property of their copyright owners, unless otherwise agreed 29 # upon. The license for this file, and modifications and additions to the 30 # file, is the same license as for the pristine package itself (unless the 31 # license for the pristine package is not an Open Source License, in which 32 # case the license is the MIT License). An "Open Source License" is a 33 # license that conforms to the Open Source Definition (Version 1.9) 34 # published by the Open Source Initiative. 35 36 # Please submit bugfixes or comments via http://bugs.opensuse.org/ 37 # 38 # nodebuginfo 39 40 # Handle all Go arches. 41 %{!?go_arches: %global go_arches %ix86 x86_64 aarch64 ppc64le} 42 43 # Remove stripping of Go binaries. 44 %define __arch_install_post export NO_BRP_STRIP_DEBUG=true 45 46 # Project name when using go tooling. 47 %define project github.com/openSUSE/umoci 48 49 Name: $NAME 50 Version: $VERSION 51 Release: 0 52 Summary: Open Container Image manipulation tool 53 License: Apache-2.0 54 Group: System/Management 55 Url: https://github.com/openSUSE/umoci 56 Source: ${SAFE_BRANCH}.tar.gz 57 %ifarch %{go_arches} 58 BuildRequires: go >= 1.6 59 BuildRequires: go-go-md2man 60 %else 61 BuildRequires: gcc6-go >= 6.1 62 %endif 63 BuildRequires: fdupes 64 BuildRoot: %{_tmppath}/%{name}-%{raw_version}-build 65 %if 0%{?is_opensuse} 66 ExcludeArch: s390x 67 %endif 68 69 %description 70 umoci modifies Open Container images. 71 72 umoci is a manipulation tool for OCI images. In particular, it is an 73 alternative to oci-image-tools provided by the OCI. 74 75 %prep 76 %setup -q -n $NAME-${SAFE_BRANCH} 77 78 %build 79 80 # We can't use symlinks here because go-list gets confused by symlinks, so we 81 # have to copy the source to \$HOME/go and then use that as the GOPATH. 82 export GOPATH=\$HOME/go 83 mkdir -pv \$HOME/go/src/%{project} 84 rm -rf \$HOME/go/src/%{project}/* 85 cp -avr * \$HOME/go/src/%{project} 86 87 export VERSION="\$(cat ./VERSION)" 88 if [ "\$VERSION" != "%{version}" ]; then 89 VERSION="%{version}_suse" 90 fi 91 92 # Build the binary. 93 make VERSION="\$VERSION" umoci 94 95 # Build the docs if we have go-md2man. 96 %ifarch %{go_arches} 97 make doc 98 %endif 99 100 %install 101 # Install the binary. 102 install -D -m 0755 %{name} "%{buildroot}/%{_bindir}/%{name}" 103 104 # Install all of the docs. 105 %ifarch %{go_arches} 106 for file in doc/man/*.1; do 107 install -D -m 0644 \$file "%{buildroot}/%{_mandir}/man1/\$(basename \$file)" 108 done 109 %endif 110 111 %fdupes %{buildroot}/%{_prefix} 112 113 %check 114 export GOPATH=\$HOME/go 115 hack/test-unit.sh 116 117 %files 118 %defattr(-,root,root) 119 %doc COPYING README.md doc/* 120 %{_bindir}/%{name} 121 %ifarch %{go_arches} 122 %{_mandir}/man1/umoci* 123 %endif 124 125 %changelog 126 EOF