summaryrefslogtreecommitdiff
path: root/core/ports/post_update_patches.patch.new
blob: 6dffe313ec42a9b841a348ee325c2836fbdf641a (plain)
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
--- ports.in	2004-03-07 21:55:24.000000000 +0100
+++ ports.in	2016-04-27 22:41:06.030194539 +0200
@@ -22,6 +22,57 @@
 
 VERSION="#VERSION#"
 PORTS_DIR="/usr/ports"
+PATCHES_DIR="/usr/patches"
+MASTER_KEY="/etc/ports/$(ls -1 "/etc/ports" | grep -m1 '\.sec$')"
+
+post_update_hooks() {
+	(
+		. $file
+		case $(basename $driver) in
+			httpup)
+				CURRENT_DIR=${ROOT_DIR#$PORTS_DIR}
+			;;
+			rsync)
+				CURRENT_DIR=${destination#$PORTS_DIR}
+			;;
+			git)
+				CURRENT_DIR=/$NAME
+			;;
+			*)
+			echo "$COMMAND: unknown driver '$(basename $driver)'"
+			exit 1
+		esac
+		[ -d $PATCHES_DIR$CURRENT_DIR ] || exit 0
+		for PATCH_PORT in $PATCHES_DIR$CURRENT_DIR/*; do
+			[ -d $PATCH_PORT ] || continue
+			[ -d $PORTS_DIR${PATCH_PORT#$PATCHES_DIR} ] || continue
+			cd $PORTS_DIR${PATCH_PORT#$PATCHES_DIR}
+			pkgmk -do -cs || exit $?
+			for DATEI in $(find $PATCH_PORT \( -name ".*" -prune -false \) -o \( -type f -not -name ".*" \) ); do
+				case $DATEI in
+					*.patch)
+						echo "$(pwd): patching '$DATEI' ..."
+						patch -p0 -i $DATEI || exit $?
+						for PF in $(grep '^--- ' $DATEI | awk '{print $2}' | sort -u); do
+							sed -i "/^SHA256 ($PF) = /d" .signature
+							sha256sum --tag $PF >> .signature
+						done
+					;;
+					*.new)
+						echo "$(pwd): copying '$DATEI'"
+						cp $DATEI $(basename $DATEI .new)
+						md5sum $(basename $DATEI .new) >> .md5sum
+						sha256sum --tag $(basename $DATEI .new) >> .signature
+					;;
+					*)
+						echo "$COMMAND: patch file '$DATEI' has unknown extension"
+						exit 1
+				esac
+			done
+			pkgmk -rs -sk $MASTER_KEY
+		done
+	) || exit $?
+}
 
 check_ports_dir() {
 	if [ ! -d "$PORTS_DIR" ]; then
@@ -53,6 +104,7 @@
 						file=/etc/ports/$collection.$suffix
 						if [ -f $file ]; then
 							$driver $file
+							post_update_hooks $driver $file
 						fi
 					fi
 				done
@@ -67,6 +119,7 @@
 				suffix=`basename $driver`
 				for file in /etc/ports/*.$suffix; do
 					$driver $file
+					post_update_hooks $driver $file
 				done
 			fi
 		done