1# Create .deb without using dpkg tools. 2# 3# Author: Tim Wegener <twegener@madabar.com> 4# 5# Use 'include deb_hand.mak' after defining the user variables in a local 6# makefile. 7# 8# The 'data' rule must be customised in the local make file. 9# This rule should make a 'data' directory containing the full file 10# layout of the installed package. 11# 12# This makefile will create a debian-binary file a control directory and a 13# a build directory in the current directory. 14# Do 'make clobber' to remove these generated files. 15# 16# Destination: 17# PACKAGE_DIR - directory where package (and support files) will be built 18# defaults to the current directory 19# 20# Sources: 21# SOURCE_DIR - directory containing files to be packaged 22# ICON_SOURCE - 26x26 icon file for maemo 23# DESCR - description with summary on first line 24# preinst, postinst, prerm, postrm - optional control shell scripts 25 26# These fields are used to build the control file: 27# PACKAGE = 28# VERSION = 29# ARCH = 30# SECTION = 31# PRIORITY = 32# MAINTAINER = 33# DEPENDS = 34# 35# SOURCE_DIR = 36# ICON_SOURCE = 37# (ICON_SOURCE is optional) 38 39# *** NO USER CHANGES REQUIRED BEYOND THIS POINT *** 40ifeq ($(shell uname),Darwin) 41MD5SUM=md5 42else 43MD5SUM=md5sum 44endif 45 46GAWK=awk 47PACKAGE_DIR?=$(shell pwd) 48CONTROL_EXTRAS ?= ${wildcard preinst postinst prerm postrm} 49 50${PACKAGE_DIR}/control: ${PACKAGE_DIR}/data ${CONTROL_EXTRAS} DESCR \ 51 ${ICON_SOURCE} 52 #rm -rf $@ 53 mkdir -p $@ 54ifneq (${CONTROL_EXTRAS},) 55 cp ${CONTROL_EXTRAS} $@ 56endif 57# Make control file. 58 echo "Name: ${PACKAGE}" > $@/control 59 echo "Package: ${PACKAGE}" >> $@/control 60 echo "Version: ${VERSION}" >> $@/control 61 echo "Section: ${SECTION}" >> $@/control 62 echo "Priority: ${PRIORITY}" >> $@/control 63 echo "Architecture: ${ARCH}" >> $@/control 64ifneq (${DEPENDS},) 65 echo "Depends: ${DEPENDS}" >> $@/control 66endif 67 echo "Installed-Size: ${shell du -s ${PACKAGE_DIR}/data|cut -f1}" \ 68 >> $@/control 69 echo "Maintainer: ${MAINTAINER}" >> $@/control 70 printf "Description:" >> $@/control 71 cat DESCR | ${GAWK} '{print " "$$0;}' >> $@/control 72#ifneq (${ICON_SOURCE},) 73# echo "Maemo-Icon-26:" >> $@/control 74# base64 ${ICON_SOURCE} | ${GAWK} '{print " "$$0;}' >> $@/control 75#endif 76# Make md5sums. 77 cd ${PACKAGE_DIR}/data && find . -type f -exec ${MD5SUM} {} \; \ 78 | sed -e 's| \./||' \ 79 > $@/md5sums 80 81${PACKAGE_DIR}/debian-binary: 82 echo "2.0" > $@ 83 84${PACKAGE_DIR}/clean: 85 rm -rf ${PACKAGE_DIR}/data ${PACKAGE_DIR}/control ${PACKAGE_DIR}/build *.deb 86 87${PACKAGE_DIR}/build: ${PACKAGE_DIR}/debian-binary ${PACKAGE_DIR}/control \ 88 ${PACKAGE_DIR}/data 89 rm -rf $@ 90 mkdir $@ 91 cp ${PACKAGE_DIR}/debian-binary $@/ 92 cd ${PACKAGE_DIR}/control && tar czvf $@/control.tar.gz * 93 cd ${PACKAGE_DIR}/data && \ 94 COPY_EXTENDED_ATTRIBUTES_DISABLE=true \ 95 COPYFILE_DISABLE=true \ 96 tar cpzvf $@/data.tar.gz ./* 97 98# Convert GNU ar to BSD ar that debian requires. 99# Note: Order of files within ar archive is important! 100${PACKAGE_DIR}/${PACKAGE}_${VERSION}_${ARCH}.deb: ${PACKAGE_DIR}/build 101 ${AR} -rc $@ $</debian-binary $</control.tar.gz $</data.tar.gz 102 #sed -e 's|^\([^/]\+\)/ \(.*\)|\1 \2|g' $@tmp > $@fail 103 #rm -f $@tmp 104 #mv $@fail $@ 105 106.PHONY: data 107data: ${PACKAGE_DIR}/data 108 109.PHONY: control 110control: ${PACKAGE_DIR}/control 111 112.PHONY: build 113build: ${PACKAGE_DIR}/build 114 115.PHONY: clean 116clean: ${PACKAGE_DIR}/clean 117 rm -f debian-binary 118 119.PHONY: deb 120deb: ${PACKAGE_DIR}/${PACKAGE}_${VERSION}_${ARCH}.deb 121 122 123clobber:: 124 rm -rf ${PACKAGE_DIR}/debian_binary ${PACKAGE_DIR}/control \ 125 ${PACKAGE_DIR}/data ${PACKAGE_DIR}/build 126 127push: 128 scp *.deb radare.org:/srv/http/radareorg/cydia/debs 129