From: SourceForge.net <no...@so...> - 2008-06-18 17:40:24
|
Patches item #1997092, was opened at 2008-06-18 12:35 Message generated for change (Comment added) made by sheiker You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=373087&aid=1997092&group_id=22049 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: NSIS Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Sheiker (sheiker) Assigned to: Amir Szekely (kichik) Summary: PATCH - Commands to allow defining Section Order at Runtime Initial Comment: Add 2 new commands to allow defining Section Order at Runtime. This patch allows us to define, at runtime, the order in which sections will be installed. I have added 2 new commands, called: SectionSetOrder SectionGetOrder I have added a new int variable in the struct section, called "order". By default, "order" for each section is set to 0, indicating no ordering preference. The SectionSetOrder command allows users to set the new order so you can run section installs in a different order. Most of this patch just uses the "SectionSetSize/SectionGetSize" code as its guide. I wrote this patch, specifically because I have a situation where I have 8 or 9 sections, and depending upon which sections are enabled/disabled, I need to change the order of the way I install each section. My topic on the NSIS Forum is here: http://forums.winamp.com/showthread.php?s=&threadid=293244 Below is the copy/paste of the patch. If you accept this patch, and would like a .patch file instead, let me know. Please consider adding this patch, thank you! =================================================================== RCS file: /cvsroot/nsis/NSIS/Docs/src/basic.but,v retrieving revision 1.32 diff -u -r1.32 basic.but --- basic.but 16 Jun 2006 13:18:12 -0000 1.32 +++ basic.but 2 Jun 2008 18:37:36 -0000 @@ -43,7 +43,7 @@ \S2{file} File -\c [/nonfatal] [/a] ([/r] [/x file|wildcard [...]] (file|wildcard) [...] | /oname=file.dat infile.dat) +\c [/nonfatal] [/md5] [/md5verify] [/a] ([/r] [/x file|wildcard [...]] (file|wildcard) [...] | /oname=file.dat infile.dat) Adds file(s) to be extracted to the current output path ($OUTDIR). @@ -57,6 +57,10 @@ \b Use the /x switch to exclude files or directories. +\b If the /md5 switch is used, and NSIS_CONFIG_MD5_SUPPORT was set when compiling NSIS, the md5sum of the file will be calculated and stored in the Installer binary. + +\b If the /md5verify switch is used, and NSIS_CONFIG_MD5_SUPPORT was set when compiling NSIS, the md5sum of the installed file will be calculated and verified against the stored md5sum value for the file. + \b If the /a switch is used, the attributes of the file(s) added will be preserved. \b The File command sets the error flag if overwrite mode is set to 'try' and the file could not be overwritten, or if the overwrite mode is set to 'on' and the file could not be overwritten and the user selects ignore. =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/fileform.cpp,v retrieving revision 1.5 diff -u -r1.5 fileform.cpp --- fileform.cpp 3 Mar 2007 14:18:49 -0000 1.5 +++ fileform.cpp 18 Jun 2008 05:06:06 -0000 @@ -113,6 +113,7 @@ m_sink->write_int(data->code); m_sink->write_int(data->code_size); m_sink->write_int(data->size_kb); + m_sink->write_int(data->order); m_sink->write_string(data->name, NSIS_MAX_STRLEN); } =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/script.cpp,v retrieving revision 1.364 diff -u -r1.364 script.cpp --- script.cpp 5 Oct 2007 09:01:06 -0000 1.364 +++ script.cpp 18 Jun 2008 05:23:04 -0000 @@ -5468,6 +5515,21 @@ if (line.gettoken_str(2)[0] && ent.offsets[1]<0) PRINTHELP() SCRIPT_MSG("SectionGetSize: %s->%s\n",line.gettoken_str(1),line.gettoken_str(2)); return add_entry(&ent); + case TOK_SECTIONSETORDER: + ent.which=EW_SECTIONSET; + ent.offsets[0]=add_string(line.gettoken_str(1)); + ent.offsets[1]=add_string(line.gettoken_str(2)); + ent.offsets[2]=SECTION_FIELD_SET(order); + SCRIPT_MSG("SectionSetOrder: %s->%s\n",line.gettoken_str(1),line.gettoken_str(2)); + return add_entry(&ent); + case TOK_SECTIONGETORDER: + ent.which=EW_SECTIONSET; + ent.offsets[0]=add_string(line.gettoken_str(1)); + ent.offsets[1]=GetUserVarIndex(line, 2); + ent.offsets[2]=SECTION_FIELD_GET(order); + if (line.gettoken_str(2)[0] && ent.offsets[1]<0) PRINTHELP() + SCRIPT_MSG("SectionGetOrder: %s->%s\n",line.gettoken_str(1),line.gettoken_str(2)); + return add_entry(&ent); case TOK_SETCURINSTTYPE: ent.which=EW_INSTTYPESET; ent.offsets[0]=add_string(line.gettoken_str(1)); @@ -5492,6 +5554,8 @@ case TOK_SECTIONGETFLAGS: case TOK_SECTIONSETSIZE: case TOK_SECTIONGETSIZE: + case TOK_SECTIONSETORDER: + case TOK_SECTIONGETORDER: case TOK_SECTIONSETINSTTYPES: case TOK_SECTIONGETINSTTYPES: case TOK_SETCURINSTTYPE: =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/tokens.cpp,v retrieving revision 1.113 diff -u -r1.113 tokens.cpp --- tokens.cpp 8 Sep 2007 17:27:28 -0000 1.113 +++ tokens.cpp 17 Jun 2008 23:52:11 -0000 @@ -170,6 +171,8 @@ {TOK_SECTIONSETTEXT,"SectionSetText",2,0,"section_index text_string",TP_CODE}, {TOK_SECTIONGETSIZE,"SectionGetSize",2,0,"section_index $(user_var: output size)",TP_CODE}, {TOK_SECTIONSETSIZE,"SectionSetSize",2,0,"section_index new_size",TP_CODE}, +{TOK_SECTIONGETORDER,"SectionGetOrder",2,0,"section_index $(user_var: output order)",TP_CODE}, +{TOK_SECTIONSETORDER,"SectionSetOrder",2,0,"section_index new_order",TP_CODE}, {TOK_GETCURINSTTYPE,"GetCurInstType",1,0,"$(user_var: output inst_type_idx)",TP_CODE}, {TOK_SETCURINSTTYPE,"SetCurInstType",1,0,"inst_type_idx",TP_CODE}, {TOK_INSTTYPESETTEXT,"InstTypeSetText",2,0,"insttype_index flags",TP_CODE}, =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/tokens.h,v retrieving revision 1.50 diff -u -r1.50 tokens.h --- tokens.h 14 Apr 2007 12:50:32 -0000 1.50 +++ tokens.h 17 Jun 2008 23:47:52 -0000 @@ -250,6 +250,8 @@ TOK_SECTIONGETINSTTYPES, TOK_SECTIONSETSIZE, TOK_SECTIONGETSIZE, + TOK_SECTIONSETORDER, + TOK_SECTIONGETORDER, TOK_INSTTYPESETTEXT, TOK_INSTTYPEGETTEXT, TOK_GETCURINSTTYPE, =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/exehead/fileform.h,v retrieving revision 1.86 diff -u -r1.86 fileform.h --- fileform.h 8 Sep 2007 17:20:10 -0000 1.86 +++ fileform.h 18 Jun 2008 16:29:24 -0000 @@ -381,6 +384,7 @@ int code; int code_size; int size_kb; + int order; char name[NSIS_MAX_STRLEN]; // '' for invisible sections } section; =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/exehead/Ui.c,v retrieving revision 1.285 diff -u -r1.285 Ui.c --- Ui.c 21 Sep 2007 18:20:12 -0000 1.285 +++ Ui.c 18 Jun 2008 16:23:29 -0000 @@ -1492,6 +1492,9 @@ int m_inst_sec=num_sections; HWND progresswnd = (HWND)p; section *s = g_sections; + int i; + int highest_priority; + #if defined(NSIS_SUPPORT_ACTIVEXREG) || defined(NSIS_SUPPORT_CREATESHORTCUT) { @@ -1513,6 +1516,33 @@ while (m_inst_sec--) { + // Scan section array, looking for the next highest priority section we should run. + // Any non-zero value for "order" is special, and needs to be + // run BEFORE any zero valued "order" section. + // Keep in mind, the "lower" the value, as long as its not 0, is the most + // important/highest priority section we should run. + // Thus 1 is higher priority than 2 or 3, but 1, 2 or 3 are all higher priority than 0. + for (i = num_sections, highest_priority = INT_MAX, s = NULL; i >= 0; i--) + { + section *sec_tmp = g_sections + i; + if (sec_tmp->order > 0 && sec_tmp->order <= highest_priority) + { + highest_priority = sec_tmp->order; + s = sec_tmp; + } + else if (sec_tmp->order >= 0 && highest_priority == INT_MAX) + { + s = sec_tmp; + } + } + + // The while loop above us should ensure that we will never see s as NULL. + if (!s) + { + g_exec_flags.abort++; + break; + } + #ifdef NSIS_CONFIG_COMPONENTPAGE if (s->flags&SF_SELECTED) #endif @@ -1530,7 +1560,9 @@ log_printf2("Skipping section: \"%s\"",s->name); } #endif - s++; + + // Mark section as having been parsed and now done. + s->order = -1; } NotifyCurWnd(WM_NOTIFY_INSTPROC_DONE); ---------------------------------------------------------------------- >Comment By: Sheiker (sheiker) Date: 2008-06-18 12:40 Message: Logged In: YES user_id=1861584 Originator: YES Oops, copied 1 bad entry above, I grabbed the help from the md5sum command, instead of the SectionGet/SetOrder help. Please use the patch below, assuming its accepted. =================================================================== RCS file: /cvsroot/nsis/NSIS/Docs/src/sec.but,v retrieving revision 1.28 diff -u -r1.28 sec.but --- sec.but 28 Oct 2006 15:22:07 -0000 1.28 +++ sec.but 18 Jun 2008 16:50:39 -0000 @@ -139,6 +139,36 @@ \c SectionSetSize ${test_section_id} $0 \c FunctionEnd +\S2{ssectionsetOrder} SectionSetOrder + +\c section_index new_order + +Sets the Installation order of the section specified by section_index. Note that the Index starts with Zero, and negative values are invalid. By default, all sections start with a priority order value of 0. The lower the value of the order, as long as its not zero, is the highest priority section that should be installed first. Thus, 1 is a higher priority than 2 or 3, but 1, 2 and 3 are all higher priority than 0. + +\c Section test test_section_id +\c SectionEnd +\c +\c Function .onInit +\c # set order priority of section 'test' to 1 +\c SectionSetOrder ${test_section_id} 1 +\c FunctionEnd + +\S2{ssectiongetOrder} SectionGetOrder + +\c section_index user_var + +Gets the Order of the section specified by section_index and stores the value in the given User Variable. Note that the Index starts with Zero. + +\c Section test test_section_id +\c SectionEnd +\c +\c Function .onInit +\c # Decrease priority order of section by one. +\c SectionGetOrder ${test_section_id} $0 +\c IntOp $0 $0 + 1 +\c SectionSetOrder ${test_section_id} $0 +\c FunctionEnd + \S2{ssetcurinsttype} SetCurInstType \c inst_type_idx =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/fileform.cpp,v retrieving revision 1.5 diff -u -r1.5 fileform.cpp --- fileform.cpp 3 Mar 2007 14:18:49 -0000 1.5 +++ fileform.cpp 18 Jun 2008 05:06:06 -0000 @@ -113,6 +113,7 @@ m_sink->write_int(data->code); m_sink->write_int(data->code_size); m_sink->write_int(data->size_kb); + m_sink->write_int(data->order); m_sink->write_string(data->name, NSIS_MAX_STRLEN); } =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/script.cpp,v retrieving revision 1.364 diff -u -r1.364 script.cpp --- script.cpp 5 Oct 2007 09:01:06 -0000 1.364 +++ script.cpp 18 Jun 2008 05:23:04 -0000 @@ -5468,6 +5515,21 @@ if (line.gettoken_str(2)[0] && ent.offsets[1]<0) PRINTHELP() SCRIPT_MSG("SectionGetSize: %s->%s\n",line.gettoken_str(1),line.gettoken_str(2)); return add_entry(&ent); + case TOK_SECTIONSETORDER: + ent.which=EW_SECTIONSET; + ent.offsets[0]=add_string(line.gettoken_str(1)); + ent.offsets[1]=add_string(line.gettoken_str(2)); + ent.offsets[2]=SECTION_FIELD_SET(order); + SCRIPT_MSG("SectionSetOrder: %s->%s\n",line.gettoken_str(1),line.gettoken_str(2)); + return add_entry(&ent); + case TOK_SECTIONGETORDER: + ent.which=EW_SECTIONSET; + ent.offsets[0]=add_string(line.gettoken_str(1)); + ent.offsets[1]=GetUserVarIndex(line, 2); + ent.offsets[2]=SECTION_FIELD_GET(order); + if (line.gettoken_str(2)[0] && ent.offsets[1]<0) PRINTHELP() + SCRIPT_MSG("SectionGetOrder: %s->%s\n",line.gettoken_str(1),line.gettoken_str(2)); + return add_entry(&ent); case TOK_SETCURINSTTYPE: ent.which=EW_INSTTYPESET; ent.offsets[0]=add_string(line.gettoken_str(1)); @@ -5492,6 +5554,8 @@ case TOK_SECTIONGETFLAGS: case TOK_SECTIONSETSIZE: case TOK_SECTIONGETSIZE: + case TOK_SECTIONSETORDER: + case TOK_SECTIONGETORDER: case TOK_SECTIONSETINSTTYPES: case TOK_SECTIONGETINSTTYPES: case TOK_SETCURINSTTYPE: =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/tokens.cpp,v retrieving revision 1.113 diff -u -r1.113 tokens.cpp --- tokens.cpp 8 Sep 2007 17:27:28 -0000 1.113 +++ tokens.cpp 17 Jun 2008 23:52:11 -0000 @@ -170,6 +171,8 @@ {TOK_SECTIONSETTEXT,"SectionSetText",2,0,"section_index text_string",TP_CODE}, {TOK_SECTIONGETSIZE,"SectionGetSize",2,0,"section_index $(user_var: output size)",TP_CODE}, {TOK_SECTIONSETSIZE,"SectionSetSize",2,0,"section_index new_size",TP_CODE}, +{TOK_SECTIONGETORDER,"SectionGetOrder",2,0,"section_index $(user_var: output order)",TP_CODE}, +{TOK_SECTIONSETORDER,"SectionSetOrder",2,0,"section_index new_order",TP_CODE}, {TOK_GETCURINSTTYPE,"GetCurInstType",1,0,"$(user_var: output inst_type_idx)",TP_CODE}, {TOK_SETCURINSTTYPE,"SetCurInstType",1,0,"inst_type_idx",TP_CODE}, {TOK_INSTTYPESETTEXT,"InstTypeSetText",2,0,"insttype_index flags",TP_CODE}, =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/tokens.h,v retrieving revision 1.50 diff -u -r1.50 tokens.h --- tokens.h 14 Apr 2007 12:50:32 -0000 1.50 +++ tokens.h 17 Jun 2008 23:47:52 -0000 @@ -250,6 +250,8 @@ TOK_SECTIONGETINSTTYPES, TOK_SECTIONSETSIZE, TOK_SECTIONGETSIZE, + TOK_SECTIONSETORDER, + TOK_SECTIONGETORDER, TOK_INSTTYPESETTEXT, TOK_INSTTYPEGETTEXT, TOK_GETCURINSTTYPE, =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/exehead/fileform.h,v retrieving revision 1.86 diff -u -r1.86 fileform.h --- fileform.h 8 Sep 2007 17:20:10 -0000 1.86 +++ fileform.h 18 Jun 2008 16:29:24 -0000 @@ -381,6 +384,7 @@ int code; int code_size; int size_kb; + int order; char name[NSIS_MAX_STRLEN]; // '' for invisible sections } section; =================================================================== RCS file: /cvsroot/nsis/NSIS/Source/exehead/Ui.c,v retrieving revision 1.285 diff -u -r1.285 Ui.c --- Ui.c 21 Sep 2007 18:20:12 -0000 1.285 +++ Ui.c 18 Jun 2008 16:23:29 -0000 @@ -1492,6 +1492,9 @@ int m_inst_sec=num_sections; HWND progresswnd = (HWND)p; section *s = g_sections; + int i; + int highest_priority; + #if defined(NSIS_SUPPORT_ACTIVEXREG) || defined(NSIS_SUPPORT_CREATESHORTCUT) { @@ -1513,6 +1516,33 @@ while (m_inst_sec--) { + // Scan section array, looking for the next highest priority section we should run. + // Any non-zero value for "order" is special, and needs to be + // run BEFORE any zero valued "order" section. + // Keep in mind, the "lower" the value, as long as its not 0, is the most + // important/highest priority section we should run. + // Thus 1 is higher priority than 2 or 3, but 1, 2 or 3 are all higher priority than 0. + for (i = num_sections, highest_priority = INT_MAX, s = NULL; i >= 0; i--) + { + section *sec_tmp = g_sections + i; + if (sec_tmp->order > 0 && sec_tmp->order <= highest_priority) + { + highest_priority = sec_tmp->order; + s = sec_tmp; + } + else if (sec_tmp->order >= 0 && highest_priority == INT_MAX) + { + s = sec_tmp; + } + } + + // The while loop above us should ensure that we will never see s as NULL. + if (!s) + { + g_exec_flags.abort++; + break; + } + #ifdef NSIS_CONFIG_COMPONENTPAGE if (s->flags&SF_SELECTED) #endif @@ -1530,7 +1560,9 @@ log_printf2("Skipping section: \"%s\"",s->name); } #endif - s++; + + // Mark section as having been parsed and now done. + s->order = -1; } NotifyCurWnd(WM_NOTIFY_INSTPROC_DONE); ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=373087&aid=1997092&group_id=22049 |