forked from ProcursusTeam/Procursus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dpkg.mk
114 lines (102 loc) · 4.75 KB
/
dpkg.mk
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
ifneq ($(PROCURSUS),1)
$(error Use the main Makefile)
endif
STRAPPROJECTS += dpkg
DOWNLOAD += https://deb.debian.org/debian/pool/main/d/dpkg/dpkg_$(DPKG_VERSION).tar.xz
DPKG_VERSION := 1.20.0
DEB_DPKG_V ?= $(DPKG_VERSION)
dpkg-setup: setup
$(call EXTRACT_TAR,dpkg_$(DPKG_VERSION).tar.xz,dpkg-$(DPKG_VERSION),dpkg)
mkdir -p $(BUILD_WORK)/dpkg-$(DPKG_VERSION)-patches
wget -q -O $(BUILD_WORK)/dpkg-$(DPKG_VERSION)-patches/zstd.patch \
'https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=892664;filename=0001-dpkg-Add-Zstandard-compression-and-decompression-sup.patch;msg=20'
$(call DO_PATCH,dpkg-$(DPKG_VERSION),dpkg,-p1)
ifneq ($(wildcard $(BUILD_WORK)/dpkg/.build_complete),)
dpkg:
@echo "Using previously built dpkg."
else
dpkg: dpkg-setup gettext xz zstd
# Ugliness to avoid using a git submodule
$(SED) -i '/PREINSTFILE/a #define EXTRAINSTFILE \"extrainst_\"' $(BUILD_WORK)/dpkg/lib/dpkg/dpkg.h
$(SED) -i '/tar_deferred_extract/a \ if (oldversionstatus == PKG_STAT_NOTINSTALLED || oldversionstatus == PKG_STAT_CONFIGFILES) { \
maintscript_new(pkg, EXTRAINSTFILE, "extra-installation", cidir, cidirrest, \
"install", NULL); \
} else { \
maintscript_new(pkg, EXTRAINSTFILE, "extra-installation", cidir, cidirrest, \
"upgrade", \
versiondescribe(&pkg->installed.version, vdew_nonambig), \
NULL); \
}' $(BUILD_WORK)/dpkg/src/unpack.c
$(SED) -i '/update_dyld_shared_cache/d' $(BUILD_WORK)/dpkg/src/help.c
$(SED) -i '/i18n.h/a #ifdef __APPLE__ \
#include <string.h> \
#include <xlocale.h> \
#endif' $(BUILD_WORK)/dpkg/lib/dpkg/i18n.c
$(SED) -i '/config.h/i #include <sys/errno.h>' $(BUILD_WORK)/dpkg/lib/dpkg/command.c
$(SED) -i 's/ohshite(_("unable to execute %s (%s)"), cmd->name, cmd->filename);/if (errno == EPERM || errno == ENOEXEC) { \
\ const char *shell; \
\ if (access(DEFAULTSHELL, X_OK) == 0) { \
\ shell = DEFAULTSHELL; \
\ } else if (access("\/etc\/alternatives\/sh", X_OK) == 0) { \
\ shell = "\/etc\/alternatives\/sh"; \
\ } else if (access("\/bin\/bash", X_OK) == 0) { \
\ shell = "\/bin\/bash"; \
\ } else { \
\ ohshite(_("unable to execute %s (%s): no shell!"), cmd->name, cmd->filename); \
\ } \
\ struct command newcmd; \
\ command_init(\&newcmd, shell, NULL); \
\ command_add_args(\&newcmd, shell, "-c", "\\"$$0\\" \\"$$@\\"", NULL); \
\ command_add_argl(\&newcmd, cmd->argv); \
\ execvp(shell, (char * const *)newcmd.argv); \
\ & \
\ }/' $(BUILD_WORK)/dpkg/lib/dpkg/command.c
$(SED) -i '/base-bsd-darwin/a base-bsd-darwin-arm64 $(DEB_ARCH) \
base-bsd-darwin-arm $(DEB_ARCH) \
base-bsd-darwin-armk $(DEB_ARCH)' $(BUILD_WORK)/dpkg/data/tupletable
$(SED) -i '/armeb/a armk armk arm.*k 32 little' $(BUILD_WORK)/dpkg/data/cputable
if ! [ -f $(BUILD_WORK)/dpkg/configure ]; then \
cd $(BUILD_WORK)/dpkg && ./autogen; \
fi
cd $(BUILD_WORK)/dpkg && ./configure -C \
--host=$(GNU_HOST_TRIPLE) \
--prefix=/usr \
--localstatedir=/var \
--sysconfdir=/etc \
--with-admindir=/Library/dpkg \
--with-logdir=/var/log/dpkg \
--disable-start-stop-daemon \
--disable-dselect \
LDFLAGS="$(CFLAGS) $(LDFLAGS)" \
PERL_LIBDIR='$$(prefix)/share/perl5' \
TAR=tar \
LZMA_LIBS='$(BUILD_BASE)/usr/local/lib/liblzma.dylib'
+$(MAKE) -C $(BUILD_WORK)/dpkg
+$(MAKE) -C $(BUILD_WORK)/dpkg install \
DESTDIR="$(BUILD_STAGE)/dpkg"
mkdir -p $(BUILD_STAGE)/dpkg/var/lib
ln -s /Library/dpkg $(BUILD_STAGE)/dpkg/var/lib/dpkg
touch $(BUILD_WORK)/dpkg/.build_complete
endif
dpkg-package: dpkg-stage
# dpkg.mk Package Structure
rm -rf $(BUILD_DIST)/dpkg{,-dev}
mkdir -p $(BUILD_DIST)/dpkg{,-dev}/usr/{bin,share/dpkg}
# dpkg.mk Prep DPKG
cp -a $(BUILD_STAGE)/dpkg/{etc,Library,var} $(BUILD_DIST)/dpkg
cp -a $(BUILD_STAGE)/dpkg/usr/bin/{dpkg{,-deb,-divert,-maintscript-helper,-query,-split,-statoverride,-trigger},update-alternatives} $(BUILD_DIST)/dpkg/usr/bin
cp -a $(BUILD_STAGE)/dpkg/usr/share/polkit-1 $(BUILD_DIST)/dpkg/usr/share
cp -a $(BUILD_STAGE)/dpkg/usr/share/dpkg/{abi,cpu,os,tuple}table $(BUILD_DIST)/dpkg/usr/share/dpkg
# dpkg.mk Prep DPKG-Dev
cp -a $(BUILD_STAGE)/dpkg/usr/bin/dpkg-{architecture,buildflags,buildpackage,checkbuilddeps,distaddfile,genbuildinfo,genchanges,gencontrol,gensymbols,mergechangelogs,name,parsechangelog,scanpackages,scansources,shlibdeps,source,vendor} $(BUILD_DIST)/dpkg-dev/usr/bin
cp -a $(BUILD_STAGE)/dpkg/usr/lib $(BUILD_DIST)/dpkg-dev/usr
cp -a $(BUILD_STAGE)/dpkg/usr/share/perl5 $(BUILD_DIST)/dpkg-dev/usr/share
cp -a $(BUILD_STAGE)/dpkg/usr/share/dpkg/*.mk $(BUILD_DIST)/dpkg-dev/usr/share/dpkg
#dpkg.mk Sign
$(call SIGN,dpkg,general.xml)
# dpkg.mk Make .debs
$(call PACK,dpkg,DEB_DPKG_V)
$(call PACK,dpkg-dev,DEB_DPKG_V)
# dpkg.mk Build cleanup
rm -rf $(BUILD_DIST)/dpkg{,-dev}
.PHONY: dpkg dpkg-package