Skip to content

Commit 6a26d17

Browse files
Rpm pkg support (#228)
* rpm pkg support Signed-off-by: Ashima-Ashima1 <[email protected]> * Remove mount.share dependency to fix rpm package creation issue (#232) Signed-off-by: Mayank Sachan <[email protected]> --------- Signed-off-by: Mayank Sachan <[email protected]> --------- Signed-off-by: Ashima-Ashima1 <[email protected]> Signed-off-by: Mayank Sachan <[email protected]> Co-authored-by: Mayank Sachan <[email protected]>
1 parent a9c2a65 commit 6a26d17

File tree

4 files changed

+74
-16
lines changed

4 files changed

+74
-16
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- cos-csi-mounter
1717

1818
env:
19-
IS_LATEST_RELEASE: 'true'
19+
IS_LATEST_RELEASE: 'false'
2020
APP_VERSION: 1.0.1
2121

2222
steps:
@@ -34,7 +34,7 @@ jobs:
3434
- name: Run Unit Tests for cos csi mounter
3535
run: sudo make ut-coverage -C ${{ matrix.package_dir }}
3636

37-
- name: Build Debian Package for cos csi mounter container
37+
- name: Build Debian and RPM packages for cos-csi-mounter systemd service
3838
run: |
3939
cd ${{ matrix.package_dir }}
4040
make packages
@@ -61,9 +61,11 @@ jobs:
6161
files: |
6262
/home/runner/work/ibm-object-csi-driver/ibm-object-csi-driver/cos-csi-mounter/cos-csi-mounter-${{ env.APP_VERSION }}.deb.tar.gz
6363
/home/runner/work/ibm-object-csi-driver/ibm-object-csi-driver/cos-csi-mounter/cos-csi-mounter-${{ env.APP_VERSION }}.deb.tar.gz.sha256
64+
/home/runner/work/ibm-object-csi-driver/ibm-object-csi-driver/cos-csi-mounter/cos-csi-mounter-${{ env.APP_VERSION }}.rpm.tar.gz
65+
/home/runner/work/ibm-object-csi-driver/ibm-object-csi-driver/cos-csi-mounter/cos-csi-mounter-${{ env.APP_VERSION }}.rpm.tar.gz.sha256
6466
tag_name: v1.0.1
6567
name: v1.0.1
66-
body: Generate debian package
68+
body: Generate debian and rpm packages
6769
prerelease: ${{ env.IS_LATEST_RELEASE != 'true' }}
6870

6971
- name: Perform CodeQL Analysis

cos-csi-mounter/Makefile

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ MAINTAINER := "IKS Storage"
88
DEB_ARCH := all
99
DESCRIPTION := "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

1421
test:
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

4799
tar-package:
48100
tar-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

55111
clean:
56112
rm -rf ${BIN_DIR}
57-
rm *.deb
113+
rm *.deb *.rpm
58114
rm -rf packages
59115

60116
packages:
61-
packages: deb-build tar-package clean
117+
packages: deb-build rpm-build tar-package clean

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/IBM/go-sdk-core/v5 v5.20.1
77
github.com/IBM/ibm-cos-sdk-go v1.12.2
88
github.com/IBM/ibm-cos-sdk-go-config/v2 v2.3.0
9-
github.com/IBM/ibm-csi-common v1.1.20
9+
github.com/IBM/ibm-csi-common v1.1.21
1010
github.com/IBM/ibmcloud-volume-interface v1.2.20
1111
github.com/aws/aws-sdk-go v1.55.7
1212
github.com/container-storage-interface/spec v1.11.0
@@ -33,7 +33,7 @@ require (
3333
require (
3434
cel.dev/expr v0.23.0 // indirect
3535
github.com/BurntSushi/toml v1.0.0 // indirect
36-
github.com/IBM/secret-utils-lib v1.1.13 // indirect
36+
github.com/IBM/secret-utils-lib v1.1.14 // indirect
3737
github.com/JeffAshton/win_pdh v0.0.0-20161109143554-76bb4ee9f0ab // indirect
3838
github.com/Microsoft/go-winio v0.6.2 // indirect
3939
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ github.com/IBM/ibm-cos-sdk-go v1.12.2 h1:71A4tDl8u6BZ548h71ecEe7fw5bBA7ECTVqYmeS
88
github.com/IBM/ibm-cos-sdk-go v1.12.2/go.mod h1:ODYcmrmdpjo5hVguq9RbD6xmC8xb1XZMG7NefUbJNcc=
99
github.com/IBM/ibm-cos-sdk-go-config/v2 v2.3.0 h1:956Nqk0eKI3lq+AkzWXZDid4UZHRz0wWh1LwkleBsWk=
1010
github.com/IBM/ibm-cos-sdk-go-config/v2 v2.3.0/go.mod h1:chnQxV+i38wD0aIi4KNU5bP2uzPtc7EHqB3/8Rhyjlg=
11-
github.com/IBM/ibm-csi-common v1.1.20 h1:83tWmb+39G/Mm4E9nZwn5/EL0SMcyEyLJDN6hAS4eg4=
12-
github.com/IBM/ibm-csi-common v1.1.20/go.mod h1:z9U3OmpKN92eUVdhhdbrr5kAT3MPRT9xwr6MVltLBFI=
11+
github.com/IBM/ibm-csi-common v1.1.21 h1:/OmjpF+YgmkLmtehFmmfWp9kHGP9iMNkTU/KQDYXzrY=
12+
github.com/IBM/ibm-csi-common v1.1.21/go.mod h1:AgjHhkYgDwYz1OmFGTgtOv+GCMsD67Yel+ZKsY90PYY=
1313
github.com/IBM/ibmcloud-volume-interface v1.2.20 h1:VZlP9fhFLX3evH9QlcXulYX4v4GNeTtbW7nl4Chg+ls=
1414
github.com/IBM/ibmcloud-volume-interface v1.2.20/go.mod h1:PMe4wOp+EEkVNwlo/iJahh+6/aIvjWo+nAdHB1oGBFE=
15-
github.com/IBM/secret-utils-lib v1.1.13 h1:osQPjQh16fx8N0fZiPeZyXCyPYtuB1VoV/3HAxZ+Ep4=
16-
github.com/IBM/secret-utils-lib v1.1.13/go.mod h1:oQLxbIMLCk8tVFxp0SEQqa80VTOyY52ZP10ZY2AuD98=
15+
github.com/IBM/secret-utils-lib v1.1.14 h1:Gv5Ca2hZTQMr9+PkOq7AE2lUUnNEeQJ0uiKaxKT1Sdk=
16+
github.com/IBM/secret-utils-lib v1.1.14/go.mod h1:wAAmS6JOrgcASOuyDkclmxWdKMcbVxshW5QWlMn21X8=
1717
github.com/JeffAshton/win_pdh v0.0.0-20161109143554-76bb4ee9f0ab h1:UKkYhof1njT1/xq4SEg5z+VpTgjmNeHwPGRQl7takDI=
1818
github.com/JeffAshton/win_pdh v0.0.0-20161109143554-76bb4ee9f0ab/go.mod h1:3VYc5hodBMJ5+l/7J4xAyMeuM2PNuepvHlGs8yilUCA=
1919
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=

0 commit comments

Comments
 (0)