forked from ProcursusTeam/Procursus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diskdev-cmds.mk
102 lines (90 loc) · 4.55 KB
/
diskdev-cmds.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
ifneq ($(PROCURSUS),1)
$(error Use the main Makefile)
endif
STRAPPROJECTS += diskdev-cmds
DISKDEV-CMDS_VERSION := 593.230.1
DEB_DISKDEV-CMDS_V ?= $(DISKDEV-CMDS_VERSION)
diskdev-cmds-setup: setup
wget -q -nc -P $(BUILD_SOURCE) https://opensource.apple.com/tarballs/diskdev_cmds/diskdev_cmds-$(DISKDEV-CMDS_VERSION).tar.gz
$(call EXTRACT_TAR,diskdev_cmds-$(DISKDEV-CMDS_VERSION).tar.gz,diskdev_cmds-$(DISKDEV-CMDS_VERSION),diskdev-cmds)
mkdir -p $(BUILD_STAGE)/diskdev-cmds/{usr/{{s,}bin,libexec},sbin}
# Mess of copying over headers because some build_base headers interfere with the build of Apple cmds.
mkdir -p $(BUILD_WORK)/diskdev-cmds/include/{arm,machine,{System/,}sys,uuid}
cp -a $(MACOSX_SYSROOT)/usr/include/sys/{disk,reboot,vnioctl,vmmeter}.h $(MACOSX_SYSROOT)/System/Library/Frameworks/Kernel.framework/Versions/Current/Headers/sys/disklabel.h $(BUILD_WORK)/diskdev-cmds/include/sys
cp -a $(BUILD_BASE)/usr/include/{unistd,stdlib}.h $(BUILD_WORK)/diskdev-cmds/include
wget -q -nc -P $(BUILD_WORK)/diskdev-cmds/include \
https://opensource.apple.com/source/libutil/libutil-57/mntopts.h \
https://opensource.apple.com/source/xnu/xnu-6153.11.26/EXTERNAL_HEADERS/mach-o/nlist.h
wget -q -nc -P $(BUILD_WORK)/diskdev-cmds/include/arm \
https://opensource.apple.com/source/xnu/xnu-6153.11.26/bsd/arm/disklabel.h
wget -q -nc -P $(BUILD_WORK)/diskdev-cmds/include/machine \
https://opensource.apple.com/source/xnu/xnu-6153.11.26/bsd/machine/disklabel.h
wget -q -nc -P $(BUILD_WORK)/diskdev-cmds/include/sys \
https://opensource.apple.com/source/xnu/xnu-6153.11.26/bsd/sys/vnode.h
wget -q -nc -P $(BUILD_WORK)/diskdev-cmds/include/System/sys \
https://opensource.apple.com/source/xnu/xnu-6153.11.26/bsd/sys/fsctl.h
wget -q -nc -P $(BUILD_WORK)/diskdev-cmds/include/System/uuid \
https://opensource.apple.com/source/Libc/Libc-1353.11.2/uuid/namespace.h
ifneq ($(wildcard $(BUILD_WORK)/diskdev-cmds/.build_complete),)
diskdev-cmds:
@echo "Using previously built diskdev-cmds."
else
diskdev-cmds: .SHELLFLAGS=-O extglob -c
diskdev-cmds: diskdev-cmds-setup
cd $(BUILD_WORK)/diskdev-cmds/disklib; \
rm -f mntopts.h getmntopts.c; \
for arch in $(ARCHES); do \
for c in *.c; do \
$(CC) -arch $${arch} -isysroot $(TARGET_SYSROOT) $(PLATFORM_VERSION_MIN) -isystem ../include -fno-common -o $$(basename $${c} .c)-$${arch}.o -c $${c}; \
done; \
$(AR) -r libdisk-$${arch}.a *-$${arch}.o; \
LIBDISKA=$$(echo disklib/libdisk-$${arch}.a $${LIBDISKA}); \
done; \
cd $(BUILD_WORK)/diskdev-cmds; \
for tproj in !(fstyp|fsck_hfs|fuser|mount_portal|mount_swapfs|mount_umap|newfs_hfs_debug).tproj; do \
tproj=$$(basename $$tproj .tproj); \
echo $$tproj; \
extra=; \
if [[ $$tproj = restore ]]; then \
extra="${extra} -DRRESTORE"; \
fi; \
if [[ $$tproj = mount_cd9660 || $$tproj = mount_hfs ]]; then \
extra="${extra} -framework IOKit"; \
fi; \
if [[ $$tproj = mount_cd9660 || $$tproj = mount_hfs || $$tproj = newfs_hfs ]]; then \
extra="${extra} -framework CoreFoundation"; \
fi; \
$(CC) $(ARCH) -isysroot $(TARGET_SYSROOT) $(PLATFORM_VERSION_MIN) -isystem include -DTARGET_OS_SIMULATOR -Idisklib -o $$tproj $$(find "$$tproj.tproj" -name '*.c') $${LIBDISKA} -lutil $$extra; \
done
cd $(BUILD_WORK)/diskdev-cmds/fstyp.tproj; \
for c in *.c; do \
bin=../$$(basename $$c .c); \
$(CC) $(ARCH) -isysroot $(TARGET_SYSROOT) $(PLATFORM_VERSION_MIN) -isystem ../include -o $$bin $$c; \
done
cd $(BUILD_WORK)/diskdev-cmds; \
cp -a quota $(BUILD_STAGE)/diskdev-cmds/usr/bin; \
cp -a dev_mkdb edquota fdisk quotaon repquota vsdbutil $(BUILD_STAGE)/diskdev-cmds/usr/sbin; \
cp -a vndevice $(BUILD_STAGE)/diskdev-cmds/usr/libexec; \
cp -a quotacheck umount @(fstyp|newfs)?(_*([a-z0-9])) @(mount_*([a-z0-9])) $(BUILD_STAGE)/diskdev-cmds/sbin
ifeq ($(shell [ "$(CFVER_WHOLE)" -ge 1600 ] && echo 1),1)
rm -f $(BUILD_STAGE)/diskdev-cmds/sbin/umount
endif
touch $(BUILD_WORK)/diskdev-cmds/.build_complete
endif
diskdev-cmds-package: diskdev-cmds-stage
# diskdev-cmds.mk Package Structure
rm -rf $(BUILD_DIST)/diskdev-cmds
# diskdev-cmds.mk Prep diskdev-cmds
cp -a $(BUILD_STAGE)/diskdev-cmds $(BUILD_DIST)
# diskdev-cmds.mk Sign
$(call SIGN,diskdev-cmds,general.xml)
# system-cmds.mk Permissions
$(FAKEROOT) chmod u+s $(BUILD_DIST)/diskdev-cmds/usr/bin/quota
ifneq ($(shell [ "$(CFVER_WHOLE)" -ge 1600 ] && echo 1),1)
$(FAKEROOT) chmod u+s $(BUILD_DIST)/diskdev-cmds/sbin/umount
endif
# diskdev-cmds.mk Make .debs
$(call PACK,diskdev-cmds,DEB_DISKDEV-CMDS_V)
# diskdev-cmds.mk Build cleanup
rm -rf $(BUILD_DIST)/diskdev-cmds
.PHONY: diskdev-cmds diskdev-cmds-package