-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (87 loc) · 2.67 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
NAME=java-1.9.0-oracle
MAJOR_VERSION=9.0.1
MINOR_VERSION=11
VERSION=$(shell echo $(MAJOR_VERSION))
ITERATION=1.lru
PREFIX=/opt/java
LICENSE="BSL"
VENDOR="Oracle"
MAINTAINER="Ryan Parman"
DESCRIPTION="The Oracle Java Runtime Environment."
URL=https://oracle.com/java/
RHEL=$(shell rpm -q --queryformat '%{VERSION}' centos-release)
define AFTER_INSTALL
update-alternatives --install /usr/bin/java java /opt/java/latest/jre/bin/java 100
update-alternatives --install /usr/bin/javac javac /opt/java/latest/jre/bin/javac 100
echo "source /opt/java/exports" >> /etc/bashrc
source /etc/bashrc
endef
define AFTER_REMOVE
update-alternatives --remove java /opt/java/latest/jre/bin/java
update-alternatives --remove javac /opt/java/latest/jre/bin/javac
endef
export AFTER_INSTALL
export AFTER_REMOVE
.PHONY: package
package: clean
@ echo "NAME: $(NAME)"
@ echo "MAJOR_VERSION: $(MAJOR_VERSION)"
@ echo "MINOR_VERSION: $(MINOR_VERSION)"
@ echo "VERSION: $(VERSION)"
@ echo "ITERATION: $(ITERATION)"
@ echo "PREFIX: $(PREFIX)"
@ echo "LICENSE: $(LICENSE)"
@ echo "VENDOR: $(VENDOR)"
@ echo "MAINTAINER: $(MAINTAINER)"
@ echo "DESCRIPTION: $(DESCRIPTION)"
@ echo "URL: $(URL)"
@ echo "RHEL: $(RHEL)"
@ echo " "
mkdir -p /tmp/installdir-$(NAME)-$(VERSION)
# Download JDK
wget -O jdk-$(VERSION)-linux-x64.tar.gz \
--no-cookies \
--no-check-certificate \
--header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/$(MAJOR_VERSION)+$(MINOR_VERSION)/jdk-$(VERSION)_linux-x64_bin.tar.gz" \
;
# Unpack JDK
tar -zxf jdk-$(VERSION)-linux-x64.tar.gz -C /tmp/installdir-$(NAME)-$(VERSION)
cd /tmp/installdir-$(NAME)-$(VERSION) && ln -s jdk-$(MAJOR_VERSION) latest
cp exports /tmp/installdir-$(NAME)-$(VERSION)/exports
chmod -f 0644 /tmp/installdir-$(NAME)-$(VERSION)/exports
echo "$$AFTER_INSTALL" > after-install.sh
echo "$$AFTER_REMOVE" > after-remove.sh
# Main package
fpm \
-s dir \
-t rpm \
-n $(NAME) \
-v $(VERSION) \
-C /tmp/installdir-$(NAME)-$(VERSION) \
-m $(MAINTAINER) \
--iteration $(ITERATION) \
--epoch 1 \
--license $(LICENSE) \
--vendor $(VENDOR) \
--prefix $(PREFIX) \
--url $(URL) \
--description $(DESCRIPTION) \
--rpm-defattrdir 0755 \
--rpm-digest md5 \
--rpm-compression gzip \
--rpm-os linux \
--rpm-changelog CHANGELOG.txt \
--rpm-auto-add-directories \
--template-scripts \
--after-install after-install.sh \
--after-remove after-remove.sh \
jdk-$(MAJOR_VERSION) \
latest \
exports \
;
mv *.rpm /vagrant/repo
.PHONY: clean
clean:
rm -Rf java*.rpm jdk* after*.sh
rm -Rf /tmp/installdir*