@@ -8,8 +8,15 @@ MAINTAINER := "IKS Storage"
88DEB_ARCH := all
99DESCRIPTION := "IBM cos-csi-mounter service"
1010
11- INSTALL_TAR_FILE := "$(NAME ) -$(APP_VERSION ) .deb.tar.gz"
12- CHECKSUM_FILE := "$(INSTALL_TAR_FILE ) .sha256"
11+ INSTALL_TAR_FILE_DEB := "$(NAME ) -$(APP_VERSION ) .deb.tar.gz"
12+ INSTALL_TAR_FILE_RPM := "$(NAME ) -$(APP_VERSION ) .rpm.tar.gz"
13+ CHECKSUM_FILE_DEB := "$(INSTALL_TAR_FILE_DEB ) .sha256"
14+ CHECKSUM_FILE_RPM := "$(INSTALL_TAR_FILE_RPM ) .sha256"
15+
16+ LICENSE := "IBM"
17+ RPM_ARCH := x86_64
18+ RPM_RELEASE_NUM := 1
19+ REDHAT_SPEC := $(BUILD_DIR ) /red-hat.spec
1320
1421test :
1522 go test -v -timeout 1800s -coverprofile=cover.out ./...
@@ -43,19 +50,68 @@ deb-build: build-linux
4350 dpkg-deb --build $(BUILD_DIR)
4451 rm -rf $(BUILD_DIR)
4552
53+ rpm-build :
54+ rpm-build : build-linux
55+ rm -rf $(BUILD_DIR )
56+ mkdir -p $(BUILD_DIR ) /
57+ mkdir -p $(BUILD_DIR ) /rpm/SOURCES/usr/local/bin $(BUILD_DIR ) /rpm/SOURCES/etc/systemd/system $(BUILD_DIR ) /rpm/SOURCES/etc/ibmcloud
58+ cp install/cos-csi-mounter.service $(BUILD_DIR ) /rpm/SOURCES/etc/systemd/system
59+ cp install/share.conf $(BUILD_DIR ) /rpm/SOURCES/etc/ibmcloud
60+ cp ${BIN_DIR} /cos-csi-mounter-server $(BUILD_DIR ) /rpm/SOURCES/usr/local/bin
61+
62+ echo "Name: $(NAME)" > $(REDHAT_SPEC)
63+ echo "Version: $(APP_VERSION)" >> $(REDHAT_SPEC)
64+ echo "Release: $(RPM_RELEASE_NUM)" >> $(REDHAT_SPEC)
65+ echo 'Summary: $(DESCRIPTION)' >> $(REDHAT_SPEC)
66+ echo 'License: $(LICENSE)' >> $(REDHAT_SPEC)
67+ echo "BuildArch: $(RPM_ARCH)" >> $(REDHAT_SPEC)
68+ echo "%global _build_id_links none" >> $(REDHAT_SPEC)
69+ echo "%define _rpmfilename $(NAME)-$(APP_VERSION).rpm" >> $(REDHAT_SPEC)
70+ echo "%build" >> $(REDHAT_SPEC)
71+
72+ echo "%install" >> $(REDHAT_SPEC)
73+ echo "rm -rf %{buildroot}" >> $(REDHAT_SPEC)
74+ echo "mkdir -p %{buildroot}/etc/systemd/system/" >> $(REDHAT_SPEC)
75+ echo "mkdir -p %{buildroot}/usr/local/bin/" >> $(REDHAT_SPEC)
76+ echo "mkdir -p %{buildroot}/etc/ibmcloud/" >> $(REDHAT_SPEC)
77+ echo "cp -r %{_sourcedir}/* %{buildroot}/" >> $(REDHAT_SPEC)
78+
79+ echo "%description" >> $(REDHAT_SPEC)
80+ echo "This package provides the COS CSI Mounter service." >> $(REDHAT_SPEC)
81+
82+ echo "%files" >> $(REDHAT_SPEC)
83+ echo "/etc/systemd/system/cos-csi-mounter.service" >> $(REDHAT_SPEC)
84+ echo "/usr/local/bin/cos-csi-mounter-server" >> $(REDHAT_SPEC)
85+ echo "/etc/ibmcloud/share.conf" >> $(REDHAT_SPEC)
86+
87+ echo "%post" >> $(REDHAT_SPEC)
88+ echo "systemctl enable cos-csi-mounter.service" >> $(REDHAT_SPEC)
89+ echo "systemctl start cos-csi-mounter.service" >> $(REDHAT_SPEC)
90+
91+ echo "%preun" >> $(REDHAT_SPEC)
92+ echo "systemctl stop cos-csi-mounter.service || true" >> $(REDHAT_SPEC)
93+ echo "systemctl disable cos-csi-mounter.service || true" >> $(REDHAT_SPEC)
94+
95+ rpmbuild -ba --build-in-place --define "_topdir $(PWD)/$(BUILD_DIR)/rpm" $(REDHAT_SPEC)
96+ cp $(BUILD_DIR)/rpm/RPMS/* ./
97+ rm -rf $(BUILD_DIR)
4698
4799tar-package :
48100tar-package :
49101 mkdir packages
50102 cp ${NAME} -* packages/
51- cd packages && tar -czvf ../$(INSTALL_TAR_FILE ) *
52- sha256sum $(INSTALL_TAR_FILE ) > $(CHECKSUM_FILE )
53- @printf " Production - Install package created ok: $( INSTALL_TAR_FILE) \n"
103+ cd packages && \
104+ tar -czvf ../$(INSTALL_TAR_FILE_DEB ) * .deb && \
105+ tar -czvf ../$(INSTALL_TAR_FILE_RPM ) * .rpm
106+ sha256sum $(INSTALL_TAR_FILE_DEB ) > $(CHECKSUM_FILE_DEB )
107+ sha256sum $(INSTALL_TAR_FILE_RPM ) > $(CHECKSUM_FILE_RPM )
108+ @printf " Production - Install package created ok: $( INSTALL_TAR_FILE_DEB) and $( INSTALL_TAR_FILE_RPM) \n"
109+ rpm -qlp cos-csi-mounter-$(APP_VERSION ) .rpm
54110
55111clean :
56112 rm -rf ${BIN_DIR}
57- rm * .deb
113+ rm * .deb * .rpm
58114 rm -rf packages
59115
60116packages :
61- packages : deb-build tar-package clean
117+ packages : deb-build rpm-build tar-package clean
0 commit comments