2308.patch

Botanic, 07/19/2012 02:06 am

Download (5.7 kB)

b/code/ryzom/client/src/CMakeLists.txt Wed Jul 18 17:04:17 2012 -0700
1 1
# These are Windows/MFC apps
2
IF(WIN32)
3
#  ADD_SUBDIRECTORY(bug_report)
4 2
  SET(SEVENZIP_LIBRARY "ryzom_sevenzip")
5
ENDIF(WIN32)
6 3

7 4
ADD_SUBDIRECTORY(client_sheets)
8 5
ADD_SUBDIRECTORY(seven_zip)
b/code/ryzom/client/src/client_cfg.cpp Wed Jul 18 17:04:17 2012 -0700
418 418
	SelectionFXSize = 0.8f;
419 419

420 420
	// only force patching under Windows by default
421
#ifdef NL_OS_WINDOWS
422 421
	PatchWanted = true;
423
#else
424
	PatchWanted = false;
425
#endif
426 422
	PatchUrl = "";
427 423
	PatchletUrl = "";
428 424
	PatchVersion = "";
b/code/ryzom/client/src/login_patch.cpp Wed Jul 18 17:04:17 2012 -0700
18 18
// Includes
19 19
//
20 20

21
#include <sys/stat.h>
22
#include <unistd.h>
23

21 24
#include "stdpch.h"
22 25

23 26
#include <memory>
......
38 41
#include "nel/misc/big_file.h"
39 42
#include "nel/misc/i18n.h"
40 43

41
#ifdef NL_OS_WINOWS
42
	#define NL_USE_SEVENZIP 1
43
#endif
44
#define NL_USE_SEVENZIP 1
44 45

45 46
// 7 zip includes
46 47
#ifdef NL_USE_SEVENZIP
......
740 741
// ****************************************************************************
741 742
void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool wantRyzomRestart, bool useBatchFile)
742 743
{
744

743 745
	uint nblab = 0;
744 746

745 747
	FILE *fp = NULL;
......
753 755
			string err = toString("Can't open file '%s' for writing: code=%d %s (error code 29)", UpdateBatchFilename.c_str(), errno, strerror(errno));
754 756
			throw Exception (err);
755 757
		}
758
		//use bat if windows if not use sh
759
		#ifdef NL_OS_WINDOWS
756 760
		fprintf(fp, "@echo off\n");
761
		#else
762
		fprintf(fp, "#!/bin/sh\n");
763
		#endif
757 764
	}
758 765

759 766
	// Unpack files with category ExtractPath non empty
......
808 815

809 816
					if (useBatchFile)
810 817
					{
818
						#ifdef NL_OS_WINDOWS
811 819
						SrcPath = CPath::standardizeDosPath(SrcPath);
812 820
						DstPath = CPath::standardizeDosPath(DstPath);
821
						#else
822
						SrcPath = CPath::standardizePath(SrcPath);
823
						DstPath = CPath::standardizePath(DstPath);
824
						#endif
813 825
					}
814 826

815 827
					std::string SrcName = SrcPath + vFilenames[fff];
......
817 829

818 830
					if (useBatchFile)
819 831
					{
832
						//write windows .bat format else write sh format
833
						#ifdef NL_OS_WINDOWS
820 834
						fprintf(fp, ":loop%u\n", nblab);
821 835
						fprintf(fp, "attrib -r -a -s -h %s\n", DstName.c_str());
822 836
						fprintf(fp, "del %s\n", DstName.c_str());
823 837
						fprintf(fp, "if exist %s goto loop%u\n", DstName.c_str(), nblab);
824 838
						fprintf(fp, "move %s %s\n", SrcName.c_str(), DstPath.c_str());
839
						#else
840
						fprintf(fp, "chmod 777 %s\n", DstName.c_str());
841
						fprintf(fp, "rm -rf %s\n", DstName.c_str());
842
						fprintf(fp, "mv %s %s\n", SrcName.c_str(), DstPath.c_str());
843
						#endif
844
						
825 845
					}
826 846
					else
827 847
					{
......
838 858
	// Finalize batch file
839 859
	if (NLMISC::CFile::isExists("patch") && NLMISC::CFile::isDirectory("patch"))
840 860
	{
861
		#ifdef NL_OS_WINDOWS
841 862
		if (useBatchFile)
842 863
		{
843 864
			fprintf(fp, ":looppatch\n");
844 865
		}
845

866
		#endif
867
		
846 868
		vector<string> vFileList;
847 869
		CPath::getPathContent ("patch", false, false, true, vFileList, NULL, false);
848 870
		for(uint32 i = 0; i < vFileList.size(); ++i)
849 871
		{
850 872
			if (useBatchFile)
851 873
			{
874
				#ifdef NL_OS_WINDOWS
852 875
				fprintf(fp, "del %s\n", CPath::standardizeDosPath(vFileList[i]).c_str());
876
				#else
877
				fprintf(fp, "rm -f %s\n", CPath::standardizePath(vFileList[i]).c_str());
878
				#endif
853 879
			}
854 880
			else
855 881
			{
......
859 885

860 886
		if (useBatchFile)
861 887
		{
888
			#ifdef NL_OS_WINDOWS
862 889
			fprintf(fp, "rd /Q /S patch\n");
863 890
			fprintf(fp, "if exist patch goto looppatch\n");
891
			#else
892
			fprintf(fp, "rm -rf patch\n");
893
			#endif
864 894
		}
865 895
		else
866 896
		{
......
872 902
	{
873 903
		if (wantRyzomRestart)
874 904
		{
905
			#ifdef NL_OS_WINDOWS
875 906
			fprintf(fp, "start %s %%1 %%2 %%3\n", RyzomFilename.c_str());
907
			#else
908
			fprintf(fp, "./%s $1 $2 $3\n", RyzomFilename.c_str());
909
			#endif
876 910
		}
877 911

878 912
		bool writeError = ferror(fp) != 0;
......
887 921
			throw NLMISC::EWriteError(UpdateBatchFilename.c_str());
888 922
		}
889 923
	}
924

890 925
}
891 926

892 927
// ****************************************************************************
......
944 979
//	CloseHandle( pi.hThread );
945 980

946 981
#else
947
	// TODO for Linux and Mac OS
982
	// Start the child process.
983
	bool r2Mode = false;
984
	#ifndef RY_BG_DOWNLOADER
985
		r2Mode = ClientCfg.R2Mode;
986
	#endif
987
	string strCmdLine;
988

989
	strCmdLine = "./" + UpdateBatchFilename;
990

991
	chmod(strCmdLine.c_str(), S_IRWXU);
992
	if (r2Mode)
993
	{
994
		if (execl(strCmdLine.c_str(), LoginLogin.c_str(), LoginPassword.c_str()) == -1)
995
		{
996
			int errsv = errno;
997
			nlerror("Execl Error: %d %s", errsv, strCmdLine.c_str(), (char *) NULL);
998
		} else {
999
			nlinfo("Ran batch file r2Mode Success");
1000
		}
1001
	}
1002
	else
1003
	{
1004
		if (execl(strCmdLine.c_str(), LoginLogin.c_str(), LoginPassword.c_str(), LoginShardId, (char *) NULL) == -1)
1005
		{
1006
			int errsv = errno;
1007
			nlerror("Execl r2mode Error: %d %s", errsv, strCmdLine.c_str());
1008
		} else {
1009
			nlinfo("Ran batch file Success");
1010
		}
1011
	}
948 1012
#endif
949 1013

950 1014
//	exit(0);