forked from WithSecureLabs/drozer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
117 lines (102 loc) · 4.09 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
NATIVES = $(shell find src/drozer/modules -name Android.mk)
SOURCES = $(shell find src/drozer/modules -name *.java)
DX = $(CURDIR)/src/drozer/lib/dx
JAVAC = javac
NDKBUILD = ndk-build
PYTHON = python
CP=cp
SED=sed
CD=cd
MD5=md5sum
FIND=find
GREP=grep
VERSION=`git describe --tags | cut -c 1-5`
TAR=tar
SDK = $(CURDIR)/src/drozer/lib/android.jar
all: sources deb rpm
@echo
@echo "----------------------------------------"
@echo
@echo "drozer"
@echo "You are almost ready to run drozer..."
@echo
@echo "To finish preparing your environment run:"
@echo
@echo " $$ source ENVIRONMENT"
@echo
@echo "Then you should be able to run 'drozer' to see the available commands."
@echo
@echo "----------------------------------------"
@echo
apks: $(SOURCES:.java=.apk)
clean:
find -name *.pyc |xargs rm -f
rm -f $(SOURCES:.java=.class) $(SOURCES:.java=.apk)
native-libraries: $(NATIVES)
sources: src/pydiesel/api/protobuf_pb2.py
test: force
$(PYTHON) test/mwr_test/all.py
%.apk: %.class
cd $(dir $^); $(DX) --dex --output=$(notdir $(^:.class=.apk) $(^:.class=*.class))
%.class: %.java
cd $(dir $^); $(JAVAC) -cp $(SDK) $(notdir $^)
%.mk: force
cd $(dir $@); $(NDKBUILD)
common/protobuf.proto:
git submodule init && git submodule update
src/pydiesel/api/protobuf_pb2.py: common/protobuf.proto
cd common; protoc --python_out=../src/pydiesel/api/ protobuf.proto
drozer-prepared: src/pydiesel/api/protobuf_pb2.py apks
mkdir -p dist
deb: drozer-deb-structure debian/DEBIAN/control debian/DEBIAN/md5sums
dpkg -b debian
mv debian.deb dist/drozer_${VERSION}.deb
drozer-deb-structure: drozer-prepared
mkdir -p debian/etc/bash_completion.d
mkdir -p debian/usr/bin
mkdir -p debian/usr/lib/python2.7/dist-packages
mkdir -p debian/usr/share/doc/drozer
mkdir -p debian/DEBIAN
# copy drozer components into the debian archive
$(CP) scripts/drozer debian/etc/bash_completion.d/drozer
$(CP) bin/* debian/usr/bin/
$(CP) LICENSE debian/usr/share/doc/drozer/LICENSE
$(CP) README.md debian/usr/share/doc/drozer/README.md
$(CP) -r src/drozer debian/usr/lib/python2.7/dist-packages/drozer
$(CP) -r src/mwr debian/usr/lib/python2.7/dist-packages/mwr
$(CP) -r src/pydiesel debian/usr/lib/python2.7/dist-packages/pydiesel
debian/DEBIAN/control:
$(CP) scripts/deb/control.template debian/DEBIAN/control
$(CP) scripts/deb/postinst debian/DEBIAN/postinst
$(CP) scripts/deb/prerm debian/DEBIAN/prerm
# overwrite the Installed-size: field with the correct size
$(SED) -i s/\<FILE_SIZE\>/${shell du -s debian --exclude=DEBIAN debian |cut -f 1}/g debian/DEBIAN/control
debian/DEBIAN/md5sums:
$(CD) debian && $(MD5) `$(FIND) . -type f |$(GREP) -v '^[.]/DEBIAN/'` > DEBIAN/md5sums
rpm: drozer-rpm-structure
$(CD) redhat && rpmbuild --define "_topdir `pwd`" -bb SPECS/drozer.spec
mv redhat/RPMS/noarch/*.rpm ./dist/
drozer-rpm-structure: drozer-prepared
mkdir -p dist
mkdir -p redhat/SPECS
mkdir -p redhat/SOURCES/drozer-${VERSION}
mkdir -p redhat/SOURCES/drozer-${VERSION}/etc/bash_completion.d
mkdir -p redhat/SOURCES/drozer-${VERSION}/usr/bin
mkdir -p redhat/SOURCES/drozer-${VERSION}/usr/share/applications
mkdir -p redhat/SOURCES/drozer-${VERSION}/usr/share/doc/drozer
mkdir -p redhat/SOURCES/drozer-${VERSION}/usr/lib/python2.7/dist-packages
# copy drozer components into the rehat archive
touch redhat/SOURCES/drozer-${VERSION}/configure
$(CP) scripts/drozer redhat/SOURCES/drozer-${VERSION}/etc/bash_completion.d/drozer
$(CP) bin/* redhat/SOURCES/drozer-${VERSION}/usr/bin
$(CP) LICENSE redhat/SOURCES/drozer-${VERSION}/usr/share/doc/drozer/LICENSE
$(CP) README.md redhat/SOURCES/drozer-${VERSION}/usr/share/doc/drozer/README.md
$(CP) -r src/drozer redhat/SOURCES/drozer-${VERSION}/usr/lib/python2.7/dist-packages/drozer
$(CP) -r src/mwr redhat/SOURCES/drozer-${VERSION}/usr/lib/python2.7/dist-packages/mwr
$(CP) -r src/pydiesel redhat/SOURCES/drozer-${VERSION}/usr/lib/python2.7/dist-packages/pydiesel
# compress the structure into a tarball
$(TAR) czvf redhat/SOURCES/drozer-${VERSION}.tar.gz -C redhat/SOURCES drozer-${VERSION}
rm -rf redhat/SOURCES/drozer-${VERSION}
# Copy spec file to
$(CP) scripts/rpm/drozer.spec redhat/SPECS/
force: ;