forked from trygvis/intellij-idea-dpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (81 loc) · 2.97 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
99
100
101
# Written by Trygve Laugstøl <[email protected]>
# TODO: Support publishing the packages and run dpkg-scanpackages
# TODO: Write notes on how to use
# TODO: Support for signing the packages
REPO ?= intellij-idea
ifeq ($(FLAVOR),IC)
FLAVOR_LOWER=ic
OTHER_FLAVOR=IU
OTHER_FLAVOR_LOWER=iu
else
FLAVOR_LOWER=iu
OTHER_FLAVOR=IC
OTHER_FLAVOR_LOWER=ic
endif
COUNT=$(words $(wildcard $(REPO)/intellij-idea-$(FLAVOR_LOWER)-$(VERSION)-*.deb))
REVISION=$(shell perl -e "print $(COUNT)+1")
V=$(VERSION)-$(REVISION)
PWD=$(shell pwd)
FAKEROOT=fakeroot -i fakeroot.save -s fakeroot.save
.PHONY: check-settings clean download $(REPO)/Packages.gz
all: check-settings $(REPO)/intellij-idea-$(FLAVOR_LOWER)-$(V).deb $(REPO)/Packages.gz
check-settings:
@if [ -z "$(FLAVOR)" ]; then echo "Make sure FLAVOR is set when running make; for example: make FLAVOR=IU VERSION=90.162"; exit 1; fi
@if [ "$(FLAVOR)" != "IU" -a "$(FLAVOR)" != "IC" ]; then echo "Make sure FLAVOR is set to either 'IU' or 'IC'."; exit 1; fi
@if [ -z "$(VERSION)" ]; then echo "Make sure VERSION is set when running make; for example: make FLAVOR=IU VERSION=90.162"; exit 1; fi
@echo Parameters: version=$(VERSION), flavor=$(FLAVOR), revision=$(REVISION)
clean:
@echo Cleaning
@rm -rf root *.save
%.gz:%
@echo GZ $<
@gzip -c $< > $@
######################################################################
# Package Creation
download: download/idea-$(FLAVOR)-$(VERSION).tar.gz
download/idea-$(FLAVOR)-$(VERSION).tar.gz:
@mkdir -p $(shell dirname $@)
wget -O $@ http://download.jetbrains.com/idea/idea$(FLAVOR)-$(VERSION).tar.gz
root/usr/share/jetbrains/intellij-idea: download/idea-$(FLAVOR)-$(VERSION).tar.gz
@echo Unpacking $?
@mkdir -p $@
@(cd $@; tar --strip-components 1 -zxf $(PWD)/$<)
root/usr/bin/idea: idea.in
@echo Creating $@
@mkdir -p $(shell dirname $@)
@sed \
-e "s,FLAVOR,$(FLAVOR)," \
-e "s,VERSION,$(VERSION)," \
$< > $@
@chmod +x $@
root/DEBIAN/control: control.in
@echo Creating $@
@mkdir -p $(shell dirname $@)
@sed \
-e "s,OTHER_FLAVOR_LOWER,$(OTHER_FLAVOR_LOWER)," \
-e "s,OTHER_FLAVOR,$(OTHER_FLAVOR)," \
-e "s,FLAVOR_LOWER,$(FLAVOR_LOWER)," \
-e "s,FLAVOR,$(FLAVOR)," \
-e "s,VERSION,$(V)," \
$< > $@
root/usr/share/applications/intellij-idea.desktop:
@echo Installing $@
@mkdir -p $(shell dirname $@)
@cp intellij-idea.desktop $@
$(REPO)/intellij-idea-$(FLAVOR_LOWER)-$(V).deb: \
clean \
root/DEBIAN/control \
root/usr/bin/idea \
root/usr/share/applications/intellij-idea.desktop \
root/usr/share/jetbrains/intellij-idea
@mkdir -p $(REPO)
@touch fakeroot.save
@$(FAKEROOT) -- chown -R root:root root/
@$(FAKEROOT) -- dpkg-deb -b root $@
######################################################################
# Package Repository
# (cd $(REPO) && dpkg-scanpackages -m $(dir $@) /dev/null) > [email protected]
$(REPO)/Packages:
(cd $(REPO)/.. && dpkg-scanpackages -m $(shell basename $(abspath $(REPO))) /dev/null) > [email protected]
mv [email protected] $@
$(REPO)/Packages.gz: $(REPO)/Packages