1
- # Copyright (c) 2000, 2010 , Oracle and/or its affiliates. All rights reserved.
1
+ # Copyright (c) 2000, 2011 , Oracle and/or its affiliates. All rights reserved.
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
@@ -523,10 +523,27 @@ rm -f $RBR%{_mandir}/man1/make_win_bin_dist.1*
523
523
# #############################################################################
524
524
525
525
%pre -n MySQL-server%{product_suffix}
526
+ # This is the code running at the beginning of a RPM upgrade action,
527
+ # before replacing the old files with the new ones.
526
528
527
529
# ATTENTION: Parts of this are duplicated in the "triggerpostun" !
528
530
529
- mysql_datadir=%{mysqldatadir}
531
+ # There are users who deviate from the default file system layout.
532
+ # Check local settings to support them.
533
+ if [ -x %{_bindir}/my_print_defaults ]
534
+ then
535
+ mysql_datadir=` %{_bindir}/my_print_defaults server mysqld | grep ' ^--datadir=' | sed -n ' s/--datadir=//p' `
536
+ PID_FILE_PATT=` %{_bindir}/my_print_defaults server mysqld | grep ' ^--pid-file=' | sed -n ' s/--pid-file=//p' `
537
+ fi
538
+ if [ -z " $mysql_datadir " ]
539
+ then
540
+ mysql_datadir=%{mysqldatadir}
541
+ fi
542
+ if [ -z " $PID_FILE_PATT " ]
543
+ then
544
+ PID_FILE_PATT=" $mysql_datadir /*.pid"
545
+ fi
546
+
530
547
# Check if we can safely upgrade. An upgrade is only safe if it's from one
531
548
# of our RPMs in the same version family.
532
549
601
618
602
619
# We assume that if there is exactly one ".pid" file,
603
620
# it contains the valid PID of a running MySQL server.
604
- NR_PID_FILES=` ls $mysql_datadir / * .pid 2> /dev/null | wc -l`
621
+ NR_PID_FILES=` ls $PID_FILE_PATT 2> /dev/null | wc -l`
605
622
case $NR_PID_FILES in
606
623
0 ) SERVER_TO_START=' ' ;; # No "*.pid" file == no running server
607
624
1 ) SERVER_TO_START=' true' ;;
@@ -623,8 +640,8 @@ if [ -f $STATUS_FILE ]; then
623
640
echo " before repeating the MySQL upgrade."
624
641
exit 1
625
642
elif [ -n " $SEVERAL_PID_FILES " ] ; then
626
- echo " Your MySQL directory ' $mysql_datadir ' has more than one PID file:"
627
- ls -ld $mysql_datadir / * .pid
643
+ echo " You have more than one PID file:"
644
+ ls -ld $PID_FILE_PATT
628
645
echo " Please check which one (if any) corresponds to a running server"
629
646
echo " and delete all others before repeating the MySQL upgrade."
630
647
exit 1
@@ -649,17 +666,17 @@ if [ -d $mysql_datadir ] ; then
649
666
if [ -n " $SERVER_TO_START " ] ; then
650
667
# There is only one PID file, race possibility ignored
651
668
echo " PID file:" >> $STATUS_FILE
652
- ls -l $mysql_datadir / * .pid >> $STATUS_FILE
653
- cat $mysql_datadir / * .pid >> $STATUS_FILE
669
+ ls -l $PID_FILE_PATT >> $STATUS_FILE
670
+ cat $PID_FILE_PATT >> $STATUS_FILE
654
671
echo >> $STATUS_FILE
655
672
echo " Server process:" >> $STATUS_FILE
656
- ps -fp ` cat $mysql_datadir / * .pid ` >> $STATUS_FILE
673
+ ps -fp ` cat $PID_FILE_PATT ` >> $STATUS_FILE
657
674
echo >> $STATUS_FILE
658
675
echo " SERVER_TO_START=$SERVER_TO_START " >> $STATUS_FILE
659
676
else
660
677
# Take a note we checked it ...
661
678
echo " PID file:" >> $STATUS_FILE
662
- ls -l $mysql_datadir / * .pid >> $STATUS_FILE 2>&1
679
+ ls -l $PID_FILE_PATT >> $STATUS_FILE 2>&1
663
680
fi
664
681
fi
665
682
@@ -674,10 +691,22 @@ if [ -x %{_sysconfdir}/init.d/mysql ] ; then
674
691
fi
675
692
676
693
%post -n MySQL-server%{product_suffix}
694
+ # This is the code running at the end of a RPM install or upgrade action,
695
+ # after the (new) files have been written.
677
696
678
697
# ATTENTION: Parts of this are duplicated in the "triggerpostun" !
679
698
680
- mysql_datadir=%{mysqldatadir}
699
+ # There are users who deviate from the default file system layout.
700
+ # Check local settings to support them.
701
+ if [ -x %{_bindir}/my_print_defaults ]
702
+ then
703
+ mysql_datadir=` %{_bindir}/my_print_defaults server mysqld | grep ' ^--datadir=' | sed -n ' s/--datadir=//p' `
704
+ fi
705
+ if [ -z " $mysql_datadir " ]
706
+ then
707
+ mysql_datadir=%{mysqldatadir}
708
+ fi
709
+
681
710
NEW_VERSION=%{mysql_version}-%{release}
682
711
STATUS_FILE=$mysql_datadir /RPM_UPGRADE_MARKER
683
712
855
884
# http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch10s02.html
856
885
# For all details of this code, see the "pre" and "post" sections.
857
886
858
- mysql_datadir=%{mysqldatadir}
887
+ # There are users who deviate from the default file system layout.
888
+ # Check local settings to support them.
889
+ if [ -x %{_bindir}/my_print_defaults ]
890
+ then
891
+ mysql_datadir=` %{_bindir}/my_print_defaults server mysqld | grep ' ^--datadir=' | sed -n ' s/--datadir=//p' `
892
+ fi
893
+ if [ -z " $mysql_datadir " ]
894
+ then
895
+ mysql_datadir=%{mysqldatadir}
896
+ fi
897
+
859
898
NEW_VERSION=%{mysql_version}-%{release}
860
899
STATUS_FILE=$mysql_datadir /RPM_UPGRADE_MARKER-LAST # Note the difference!
861
900
STATUS_HISTORY=$mysql_datadir /RPM_UPGRADE_HISTORY
@@ -1085,6 +1124,14 @@ echo "=====" >> $STATUS_HISTORY
1085
1124
# merging BK trees)
1086
1125
# #############################################################################
1087
1126
%changelog
1127
+
1128
+ * Thu Feb 09 2011 Joerg Bruehe < joerg.bruehe@oracle.com>
1129
+
1130
+ - Fix bug#56581: If an installation deviates from the default file locations
1131
+ (" datadir" and " pid-file" ), the mechanism to detect a running server (on upgrade)
1132
+ should still work, and use these locations.
1133
+ The problem was that the fix for bug#27072 did not check for local settings.
1134
+
1088
1135
* Tue Nov 23 2010 Jonathan Perkin < jonathan.perkin@oracle.com>
1089
1136
1090
1137
- EXCEPTIONS-CLIENT has been deleted, remove it from here too
0 commit comments