summaryrefslogtreecommitdiff
path: root/app-portage/cfg-update/files/cfg-update-1.8.2-bashrc.patch
blob: 73fe9b83103ae0d2922a43854c5d9bb199404f90 (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
--- cfg-update-1.8.2-r1/cfg-update
+++ cfg-update-1.8.2-r1/cfg-update
@@ -538,9 +538,9 @@
             local $ENV{LC_ALL}="C";
             if (`grep '^.*cfg-update.*--index' $portage_hook` =~ /cfg-update/) {
                 local $ENV{LC_ALL}="C";
-                if (`grep '^#.*cfg-update.*--index' $portage_hook` =~ /cfg-update/) {
+                if (`grep ': cfg-update.*--index' $portage_hook` =~ /cfg-update/) {
                     &root_only("Can't enable the Portage hook if you're not root...");
-                    `perl -p -i -e 's/#if \\[ \\"\\\$EBUILD_PHASE\\" = \\"setup\\" \\] && \\[ -e \\"\\/usr\\/bin\\/cfg-update\\" \\]; then cfg-update --index; fi/if \\[ \\"\\\$EBUILD_PHASE\\" = \\"setup\\" \\] && \\[ -e \\"\\/usr\\/bin\\/cfg-update\\" \\]; then cfg-update --index; fi/;' $portage_hook`;
+                    `perl -p -i -e 's/: (cfg-update.*--index)/\$1/;' $portage_hook`;
                     if ($opt_d >= 1) { print "$tab"."Enabled Portage hook in $portage_hook...\n"; }
                 } else {
                     if ($opt_d >= 1) { print "$tab"."Portage hook is already enabled...\n"; }
@@ -549,16 +549,17 @@
                 &root_only("Can't add the Portage hook if you're not root...");
                 `echo >> $portage_hook`;
                 `echo "# This hook is neccesary for automatic updating of the cfg-update index, please do not modify it!" >> $portage_hook`;
-                `echo "if [ \\"\\\$EBUILD_PHASE\\" = \\"setup\\" ] && [ -e \\"/usr/bin/cfg-update\\" ]; then cfg-update --index; fi" >> $portage_hook`;
-                `echo >> $portage_hook`;
+                `echo "pre_pkg_setup() {" >> $portage_hook`;
+                `echo "	[[ \\\$ROOT = / ]] && cfg-update --index" >> $portage_hook`;
+                `echo "}" >> $portage_hook`;
                 if ($opt_d >= 1) { print "$tab"."Added Portage hook in $portage_hook...\n"; }
             }
         } else {
             &root_only("Can't create the Portage hook if you're not root...");
-            `echo >> $portage_hook`;
             `echo "# This hook is neccesary for automatic updating of the cfg-update index, please do not modify it!" >> $portage_hook`;
-            `echo "if [ \\"\\\$EBUILD_PHASE\\" = \\"setup\\" ] && [ -e \\"/usr/bin/cfg-update\\" ]; then cfg-update --index; fi" >> $portage_hook`;
-            `echo >> $portage_hook`;
+            `echo "pre_pkg_setup() {" >> $portage_hook`;
+            `echo "	[[ \\\$ROOT = / ]] && cfg-update --index" >> $portage_hook`;
+            `echo "}" >> $portage_hook`;
             if ($opt_d >= 1) { print "$tab"."Created Portage hook in $portage_hook...\n"; }
         }
     }
@@ -2209,11 +2210,11 @@
         local $ENV{LC_ALL}="C";
         if (`grep '^.*cfg-update.*--index' $portage_hook` =~ /cfg-update/) {
             local $ENV{LC_ALL}="C";
-            if (`grep '^#.*cfg-update.*--index' $portage_hook` =~ /cfg-update/) {
+            if (`grep ': cfg-update.*--index' $portage_hook` =~ /cfg-update/) {
                 if ($opt_ebuild == 0) { print "$tab"."  Portage hook is already disabled...\n"; }
             } else {
                 &root_only("Can't disable the Portage hook if you're not root...");
-                `perl -p -i -e 's/^if \\[ \\"\\\$EBUILD_PHASE\\" = \\"setup\\" \\] && \\[ -e \\"\\/usr\\/bin\\/cfg-update\\" \\]; then cfg-update --index; fi/#if \\[ \\"\\\$EBUILD_PHASE\\" = \\"setup\\" \\] && \\[ -e \\"\\/usr\\/bin\\/cfg-update\\" \\]; then cfg-update --index; fi/;' $portage_hook`;
+                `perl -p -i -e 's/cfg-update.*--index/: \$&/;' $portage_hook`;
                 if ($opt_ebuild == 0) { print "$tab"."  Disabled Portage hook in $portage_hook...\n"; }
             }
         } else {