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
|
PKG_SOURCE_URL:=${DL_MIRROR}/${REPO_DIR}${PKG_SOURCE}
DL_DIR=/var/cache/google-android-${PKG_NAME}-installer
INSTALL_DIR=/usr/lib/${INS_DIR}
DOC_DIR=/usr/share/doc/google-android-${PKG_NAME}
all: $(UNPACK_DIR)/source.properties
install: all
$(eval UNPACK_DIR=$(DL_DIR)/$(shell \
if [ $$(unzip -Z -1 $(DL_DIR)/$(PKG_SOURCE) | cut -d '/' -f1 | sort -u | wc -l) -gt 1 ]; then \
echo $(TRG_DIR) ;\
else \
unzip -Z -1 $(DL_DIR)/$(PKG_SOURCE) | head -1 | cut -d '/' -f 1 ;\
fi)/)
install -d -m0755 $(DOC_DIR)
@if [ -f $(UNPACK_DIR)source.properties ]; then \
install -m0644 $(UNPACK_DIR)source.properties $(DOC_DIR)/ ; \
fi
@if [ -f $(UNPACK_DIR)NOTICE.txt ]; then \
gzip -9 --stdout $(UNPACK_DIR)/NOTICE.txt > $(DOC_DIR)/copyright.gz ; \
fi
find ${DOC_DIR} | sort >> /var/lib/dpkg/info/google-android-${PKG_NAME}-installer.list
chmod -R a+rX $(UNPACK_DIR)
chmod -R go-w $(UNPACK_DIR)
install -d -m0755 $(INSTALL_DIR)
@if [ ! -d $(INSTALL_DIR)$(TRG_DIR) ]; then \
mv $(UNPACK_DIR) $(INSTALL_DIR)${TRG_DIR} ;\
if [ -e "/usr/share/google-android-${PKG_NAME}-installer/package.xml" ]; then \
ln -s $$(realpath /usr/share/google-android-${PKG_NAME}-installer/package.xml --relative-to=$(INSTALL_DIR)${TRG_DIR} ) $(INSTALL_DIR)${TRG_DIR}/package.xml ;\
fi ;\
TMPDIR=$$(realpath $(INSTALL_DIR)${TRG_DIR} --relative-to=/usr/lib) ;\
(while [ "$$(dirname "$$TMPDIR")" != "." ]; do \
TMPDIR="$$(dirname "$$TMPDIR")" ;\
echo "/usr/lib/$$TMPDIR" ;\
done) | tac >> /var/lib/dpkg/info/google-android-${PKG_NAME}-installer.list ;\
find ${INSTALL_DIR}${TRG_DIR} | sort >> /var/lib/dpkg/info/google-android-${PKG_NAME}-installer.list ;\
else\
echo "\033[0;31m$(INSTALL_DIR)${TRG_DIR} already exists.\033[0m" ; \
exit 1 ; \
fi
$(UNPACK_DIR)/source.properties: $(DL_DIR)/$(PKG_SOURCE)
@echo "\n Unzipping $(PKG_SOURCE). Please be patient, this may take some time."
@if [ $$(unzip -Z -1 $(DL_DIR)/$(PKG_SOURCE) | cut -d '/' -f1 | sort -u | wc -l) -gt 1 ]; then \
mkdir -p ${DL_DIR}/${TRG_DIR}; \
cd $(DL_DIR)/${TRG_DIR} && unzip -ouq $(DL_DIR)/$(PKG_SOURCE); \
else \
cd $(DL_DIR) && unzip -ouq $(DL_DIR)/$(PKG_SOURCE); \
fi
# Search for broken symbolic links & fix them
@if [ $$(unzip -Z -1 $(DL_DIR)/$(PKG_SOURCE) | cut -d '/' -f1 | sort -u | wc -l) -gt 1 ]; then \
ZIP_ROOT_DIR=$(TRG_DIR) ;\
else \
ZIP_ROOT_DIR=$$(unzip -Z -1 $(DL_DIR)/$(PKG_SOURCE) | head -1 | cut -d '/' -f 1) ;\
fi && \
BROKEN_SYMLINKS=$$(cd $(DL_DIR)/$$ZIP_ROOT_DIR && find -xtype l -exec ls {} \;) && \
if [ -n "$$BROKEN_SYMLINKS" ]; then \
echo "\n Fixing broken symbolic links."; \
fi && \
for file in $$BROKEN_SYMLINKS; do \
cd $(DL_DIR)/$$ZIP_ROOT_DIR && \
LINK_TARGET=$$(readlink "$$file") && \
REL_PATH_TO_TARGET=$$(echo "$$LINK_TARGET" | sed "s|.*$$ZIP_ROOT_DIR/\(.*\)|\1|") && \
echo " Replacing symbolic link: $$file" && \
echo " Original target: $$LINK_TARGET" && \
echo " New target: $$REL_PATH_TO_TARGET" && \
ln -fsr "$$REL_PATH_TO_TARGET" "$$file"; \
done; \
BROKEN_SYMLINKS_AFTER=$$(cd $(DL_DIR)/$$ZIP_ROOT_DIR && find -xtype l -exec ls {} \;) && \
if [ -n "$$BROKEN_SYMLINKS_AFTER" ]; then \
echo "\n Some files have broken symbolic links. Please report a bug to the package maintainer\n"; \
for item in $$BROKEN_SYMLINKS_AFTER; do \
echo " $$item"; \
done && \
exit 1 ;\
fi
$(DL_DIR)/$(PKG_SOURCE):
cd $(DL_DIR) && \
if [ -e $(PKG_SOURCE).in ]; then \
mv $(PKG_SOURCE).in $(PKG_SOURCE) && \
chown nobody:nogroup $(PKG_SOURCE) ;\
else \
su nobody -s /bin/sh -c "\
wget --continue $(PKG_SOURCE_URL) -O $(PKG_SOURCE).tmp; \
RETURN_CODE=\$$?; \
if [ \$$RETURN_CODE -ge 4 ]; then \
echo '\n\e[31;1mError:\e[0m wget failed with exit code '\$$RETURN_CODE'. Check that mirror URL '\"'${DL_MIRROR}'\"' is still valid.\nYou may change it by running:\n dpkg-reconfigure --force google-android-${PKG_NAME}-installer\nThen try installing the package again.\n'; \
exit \$$RETURN_CODE; \
else \
mv $(PKG_SOURCE).tmp $(PKG_SOURCE); \
fi" ; \
fi
sha1sum -c $(PKG_SOURCE).sha1
clean:
-rm -rf -- $(UNPACK_DIR)
distclean: clean
-rm -rf -- $(DL_DIR)
.PHONY: install clean
|