Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #7256: Linux sh installer is broken in 9.1.0 #7313

Merged
merged 14 commits into from
Jun 4, 2019

Conversation

jmarrec
Copy link
Contributor

@jmarrec jmarrec commented May 27, 2019

Pull request overview

Fix #7256: Linux sh installer is broken in 9.1.0

The linux installer was broken in 9.1.0 and until now since the tar.gz (which is also embedded in the .sh script) has one level less, that top level EnergyPlus-X.Y.Z one (cf https://github.com/NREL/EnergyPlus/pull/7148/files#diff-41362486261ba172ec8a6127c1785ccf).

I modified the CPack.SGTZ_Header.sh.in to ask for the full install directory - as opposed to the parent dir and appending EnergyPlus-X.Y.Z - as I think it make a lot more sense anyways. To illustrate:

Before:

  • input_dir is asked to user, defaults to /usr/local
  • Installs into input_dir/EnergyPlus-X.Y.Z (because the embedded tar.gz had that extra level)

Now:

  • input_dir is asked to user, defaults to /usr/local/EnergyPlus-X.Y.Z
  • Installs into input_dir (because the embedded tar.gz does not have that extra level)

I haven't tested mac and Windows but they should be unaffected. I made one extra commit at the end that might need reversing in case it doesn't work (mac is more at risk in that case)

Work Checklist

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • At least one of the following appropriate labels must be added to this PR to be consumed into the changelog:
    • Defect: This pull request repairs a github defect issue. The github issue should be referenced in the PR description
    • Refactoring: This pull request includes code changes that don't change the functionality of the program, just perform refactoring
    • NewFeature: This pull request includes code to add a new feature to EnergyPlus
    • Performance: This pull request includes code changes that are directed at improving the runtime performance of EnergyPlus
    • DoNoPublish: This pull request includes changes that shouldn't be included in the changelog

Review Checklist

This will not be exhaustively relevant to every PR.

  • Functional code review (it has to work!)
  • If defect, results of running current develop vs this branch should exhibit the fix
  • CI status: all green or justified
  • Performance: CI Linux results include performance check
  • Unit Test(s)
  • C++ checks:
    • Argument types
    • If any virtual classes, ensure virtual destructor included, other things
  • IDD changes:
    • Verify naming conventions and styles, memos and notes and defaults
    • Open windows IDF Editor with modified IDD to check for errors
    • If transition, add to input rules file for interfaces
    • If transition, add transition source
    • If transition, update idfs
  • If new idf included, locally check the err file and other outputs
  • Required documentation updates?
  • ExpandObjects changes?
  • If output changes, including tabular output structure, add to output rules file for interfaces

@jmarrec jmarrec requested a review from Myoldmopar May 27, 2019 15:52
@Myoldmopar there might be a good reason I'm not seeing though
@jmarrec jmarrec added the Defect Includes code to repair a defect in EnergyPlus label May 27, 2019
Copy link
Member

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General comments right now. Honestly the actual fix for the Linux installer is fine, it's the extra stuff that worries me.


# Reset
Color_Off='\033[0m' # Text Reset
URed='\033[4;31m' # Red
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these valid for non-bash shells? This script's shebang line is attempting to run sh not bash. I have been searching for non-bash color output codes and literally everything is focusing on bash terminals. This could be because most people think of bash as the only terminal on Linux, so the answers are confusing online, or it's because the color codes really are specific to bash. Anyway, please verify. If we aren't sure, then I'm inclined to turn the color back off to avoid breaking other shells.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works for sh (dash) on ubuntu 16.04 at least as I tested the installer, but see a MCVE below.

URed='\033[4;31m'
Color_Off='\033[0m'
sh -c "echo 'coucou ${URed}COUCOU${Color_Off}'"

image

I don't care if you want me to remove them though, just let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After doing some research, it looks like we are on the up and up. According to Debian policy, any script that includes a shebang line with sh must simply be POSIX-compliant, and the color codes are POSIX-fine. So that's good. If anything were to change, I'd consider making the red code not underlined because it looks like it is a hyperlink. I'd go with bold red (1;31m).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nside dash directly:

image

Copy link
Contributor Author

@jmarrec jmarrec May 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, replaced with

BRed='\033[1;31m'				# Bold Red

Will push after testing on mac.

(FYI I have a handy colors.sh that you can find on OpenStudio-resources here)

exit 1;;
esac

default_install_directory="/usr/local/${package_name}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this is the actual fix, OK.

rm -f "${link_directory}/BasementGHT.idd"
rm -f "${link_directory}/convertESOMTR"
rm -f "${link_directory}/EnergyPlus"
rm -f "${link_directory}/energyplus"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_IFW_TARGET_DIRECTORY "/Applications/${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}-${CPACK_PACKAGE_VERSION_MINOR}-${CPACK_PACKAGE_VERSION_PATCH}")
# CPACK_IFW_TARGET_DIRECTORY defaults to “@ApplicationsDir@/CPACK_PACKAGE_INSTALL_DIRECTORY”
#set(CPACK_IFW_TARGET_DIRECTORY "/Applications/${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}-${CPACK_PACKAGE_VERSION_MINOR}-${CPACK_PACKAGE_VERSION_PATCH}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Windows is working, and we had to add code in here for IFW to work, I was hoping to see Linux-only changes in this PR. It was really annoying to get IFW working with the CMake logic we have in here. I'm curious what this and the CPACK_PACKAGE_INSTALL_DIRECTORY line above are effectively changing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When doing CPack stuff, there are variables that are defined for all Cpack generators, this being one. I think it makes more sense to use these instead of harcoding generator-specific variables, because it would help with consistency, and be more future proof.

That being said in our case it's actually a change that should have no effect as best as I can tell:

If that makes you uneasy I can just revert it, or least harcode the CPACK_IFW_TARGET_DIRECTORY for mac. Let me know

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cf "Variables common to all CPack generators": specifically https://cmake.org/cmake/help/v3.2/module/CPack.html#variable:CPACK_PACKAGE_INSTALL_DIRECTORY

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested building a package on a Mac? If not, I can try from this branch to see what happens. As long as it works, I'm OK with the cleanup, I'm just nervous from trying to get it to work with IFW in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just kicked one on mac a minute ago (after needed to install QtIFW and stuff) to test it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted back to harcoded CPACK_IFW_TARGET_DIRECTORY because it would default to “@ApplicationsDir@/CPACK_PACKAGE_INSTALL_DIRECTORY” which ends up being /Users/julien/Applications/EnergyPlus-9-2-0 and not /Applications/EnergyPlus-9-2-0 like I had expected.

@@ -241,7 +244,6 @@ endif()

if( APPLE )
set(CPACK_PACKAGE_DEFAULT_LOCATION "/Applications")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this variable not picked up by anyone else later in the IFW build? It looks to be unused, but I'm still really nervous about touching this since it works perfectly fine right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already defined on line 10: https://github.com/NREL/EnergyPlus/pull/7313/files/cfbb86e3d7fd51e3c80dcf5102a1ab6937fd8121#diff-41362486261ba172ec8a6127c1785ccfR10

Only difference is that it's defined with the build sha too:

set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CPACK_PACKAGE_VERSION_BUILD}")

I'll revert that too.

# On Mac with Ninja (kitware binary for fortran support) and brew gfortran, I get build errors due to this flag.
if (NOT BUILD_FORTRAN)
AddFlagIfSupported(-fcolor-diagnostics COMPILER_SUPPORTS_fdiagnostics_color)
endif()
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I've never had any issues. Is there any chance we should protect this more specifically for your corner case so that it still works OK for other builds?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never had any issues with it either until today, and I think I had built fortran on mac with ninja before. I don't think it matters that much if no one bumps into this anyways, but there should be a way here to use add_compile_options with generator expressions to limit to everything BUT fortran instead of disabling for everyone.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah add_compile_options($<$<NOT:$<COMPILE_LANGUAGE:Fortran>>:${flag}>) works

rm -f "${link_directory}/SlabGHT.idd"
rm -f "${link_directory}/Transition-V8-2-0-to-V8-3-0"
rm -f "${link_directory}/V8-2-0-Energy+.idd"
rm -f "${link_directory}/V8-3-0-Energy+.idd"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good call.

@Myoldmopar
Copy link
Member

Everything looks to be in great shape now. I think that diff should be unrelated to the work here. I'll build an installer and test it out and this will drop in if everything is good. Thanks @jmarrec

@Myoldmopar
Copy link
Member

Fetched latest develop just now and merged it in and built an installer. Verified that the latest develop build is wonky and that this new one provides a proper install. We should add an install note that the install path now accepts the full path to the E+ install folder, not the parent folder.

I'm building on Mac now and will verify that the install package over there is fine.

@Myoldmopar
Copy link
Member

My IFW package build using this branch on Mac seemed to have trouble. I'm verifying my develop build works OK before any further commentary.

@Myoldmopar
Copy link
Member

OK, my develop build is funny too. @jmarrec can you confirm your package build is OK on Mac? Like the actual artifact is a full package?

If it looks OK to you then I'll probably merge this in and immediately try a CI package build. If CI can also build it OK then I'll just figure out what's up with my personal build sometime later. If CI can't build it either then we'll need to address it right away.

…d/Fix_7256_Installer

* commit '2eb3f96cc3cbfdcd2da70adc3be6f740ae1a297c': (35 commits)
  Encode degree signs properly as UTF-8
  Convert DataStringGlobals.in.cc to UTF-8
  Fix check_non_utf8.py script
  Make E+ fixture use DataStringGlobals::clear_state
  Add a clear_state function to DataStringGlobals.in.cc
  Revert "Merge pull request NREL#7317 from NREL/HotFixFiniteDiffTestDisable"
  Fix IDD unit and validation script
  Make sure file key is in json output for decent CI
  Fix licensetext for Python 3 support
  Fixup change_version script for Python 3
  Remove unused 179D script, clean up validate_idd_units and add to custom_check
  Fix license text python 3 support
  Fix non-utf8 character check for Python 3, remove unused script
  Temporarily disable finite diff tests to clean up unit test issue
  Remove unneeded old python scripts, continuing to test others
  Minor tidying up in fluid properties code - should be no functional change; Move transition support files to PreProcess subdir and add all recent older versions of support files - fixes NREL#7248
  Add protection and clarification for check_pr_labels
  Change to code and unit test
  Update to test files. Zone is now fully controlled by single reference point.
  Remove commented out "using" directive in test
  ...
@jmarrec
Copy link
Contributor Author

jmarrec commented Jun 4, 2019

@Myoldmopar merged develop in, and rebuilt on mac. Definitely a full package, same exact size (59.7MB) as regular develop, installs just fine.

@Myoldmopar
Copy link
Member

Sounds good, thanks @jmarrec. I'll merge this in shortly and trigger a CI package build.

@Myoldmopar Myoldmopar merged commit cbf96ed into NREL:develop Jun 4, 2019
@jmarrec jmarrec deleted the PR_opened/Fix_7256_Installer branch June 4, 2019 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Includes code to repair a defect in EnergyPlus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linux sh installer is broken in 9.1.0
7 participants