can this be turned into a script?

Discussion in 'Mac Programming' started by luke9511, Mar 2, 2016.

  1. luke9511 macrumors member

    Joined:
    Mar 23, 2015
    #1
    hey everyone, so in my last post i was asking about dependencies for apps, well i got it figured out now but need some help, i have a bunch of commands that i have to copy and paste into the cmd line before i am finished, my question is the commands are below, how can i make it so that these commands will work on any app without me having to go in and manually adding the app name to each line and can this be turned into a script so all i have to do is copy it into the folder with the app and run it?

    Code:
    sudo mkdir IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/libexec/qt4/Library/Frameworks/QtCore.framework IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/libexec/qt4/Library/Frameworks/QtGui.framework IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/lib/libminiupnpc.10.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/lib/libssl.1.0.0.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/lib/libz.1.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/lib/libz.1.2.8.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/lib/libcrypto.1.0.0.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/lib/db48/libdb_cxx-4.8.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/lib/libboost_system-mt.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/lib/libboost_filesystem-mt.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/lib/libboost_program_options-mt.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/lib/libboost_thread-mt.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo cp -R /opt/local/lib/libpng16.16.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks
    sudo install_name_tool -id @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore ./IndependentMoneySystem-Qt.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore
    sudo install_name_tool -id @executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui ./IndependentMoneySystem-Qt.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui
    sudo install_name_tool -id @executable_path/../Frameworks/libminiupnpc.10.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libminiupnpc.10.dylib
    sudo install_name_tool -id @executable_path/../Frameworks/libssl.1.0.0.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libssl.1.0.0.dylib
    sudo install_name_tool -id @executable_path/../Frameworks/libz.1.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libz.1.dylib
    sudo install_name_tool -id @executable_path/../Frameworks/libcrypto.1.0.0.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libcrypto.1.0.0.dylib
    sudo install_name_tool -id @executable_path/../Frameworks/libdb_cxx-4.8.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libdb_cxx-4.8.dylib
    sudo install_name_tool -id @executable_path/../Frameworks/libboost_system-mt.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libboost_system-mt.dylib
    sudo install_name_tool -id @executable_path/../Frameworks/libboost_filesystem-mt.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libboost_filesystem-mt.dylib
    sudo install_name_tool -id @executable_path/../Frameworks/libboost_program_options-mt.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libboost_program_options-mt.dylib
    sudo install_name_tool -id @executable_path/../Frameworks/libboost_thread-mt.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libboost_thread-mt.dylib
    sudo install_name_tool -id @executable_path/../Frameworks/libpng16.16.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libpng16.16.dylib
    sudo install_name_tool -change /opt/local/libexec/qt4/Library/Frameworks/QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore IndependentMoneySystem-Qt.app/Contents/MacOs/IndependentMoneySystem-Qt
    sudo install_name_tool -change /opt/local/libexec/qt4/Library/Frameworks/QtGui.framework/Versions/4/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui IndependentMoneySystem-Qt.app/Contents/MacOs/IndependentMoneySystem-Qt
    sudo install_name_tool -change /opt/local/libexec/qt4/Library/Frameworks/QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore IndependentMoneySystem-Qt.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui
    sudo install_name_tool -change /opt/local/lib/libminiupnpc.10.dylib @executable_path/../Frameworks/libminiupnpc.10.dylib IndependentMoneySystem-Qt.app/Contents/MacOs/IndependentMoneySystem-Qt
    sudo install_name_tool -change /opt/local/lib/libssl.1.0.0.dylib @executable_path/../Frameworks/libssl.1.0.0.dylib IndependentMoneySystem-Qt.app/Contents/MacOs/IndependentMoneySystem-Qt
    sudo install_name_tool -change /opt/local/lib/libz.1.dylib @executable_path/../Frameworks/libz.1.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libcrypto.1.0.0.dylib
    sudo install_name_tool -change /opt/local/lib/libz.1.dylib @executable_path/../Frameworks/libz.1.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libssl.1.0.0.dylib
    sudo install_name_tool -change /opt/local/lib/libcrypto.1.0.0.dylib @executable_path/../Frameworks/libcrypto.1.0.0.dylib IndependentMoneySystem-Qt.app/Contents/MacOs/IndependentMoneySystem-Qt
    sudo install_name_tool -change /opt/local/lib/libcrypto.1.0.0.dylib @executable_path/../Frameworks/libcrypto.1.0.0.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libssl.1.0.0.dylib
    sudo install_name_tool -change /opt/local/lib/db48/libdb_cxx-4.8.dylib @executable_path/../Frameworks/libdb_cxx-4.8.dylib IndependentMoneySystem-Qt.app/Contents/MacOs/IndependentMoneySystem-Qt
    sudo install_name_tool -change /opt/local/lib/libboost_system-mt.dylib @executable_path/../Frameworks/libboost_system-mt.dylib IndependentMoneySystem-Qt.app/Contents/MacOs/IndependentMoneySystem-Qt
    sudo install_name_tool -change /opt/local/lib/libboost_system-mt.dylib @executable_path/../Frameworks/libboost_system-mt.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libboost_filesystem-mt.dylib
    sudo install_name_tool -change /opt/local/lib/libboost_system-mt.dylib @executable_path/../Frameworks/libboost_system-mt.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libboost_thread-mt.dylib
    sudo install_name_tool -change /opt/local/lib/libboost_filesystem-mt.dylib @executable_path/../Frameworks/libboost_filesystem-mt.dylib IndependentMoneySystem-Qt.app/Contents/MacOs/IndependentMoneySystem-Qt
    sudo install_name_tool -change /opt/local/lib/libboost_program_options-mt.dylib @executable_path/../Frameworks/libboost_program_options-mt.dylib IndependentMoneySystem-Qt.app/Contents/MacOs/IndependentMoneySystem-Qt
    sudo install_name_tool -change /opt/local/lib/libboost_thread-mt.dylib @executable_path/../Frameworks/libboost_thread-mt.dylib IndependentMoneySystem-Qt.app/Contents/MacOs/IndependentMoneySystem-Qt
    sudo install_name_tool -change /opt/local/lib/libpng16.16.dylib @executable_path/../Frameworks/libpng16.16.dylib IndependentMoneySystem-Qt.app/Contents/Frameworks/libpng16.16.dylib
    sudo install_name_tool -change /opt/local/lib/libpng16.16.dylib @executable_path/../Frameworks/libpng16.16.dylib IndependentMoneySystem-Qt.app/Contents/MacOs/IndependentMoneySystem-Qt
     
  2. cqexbesd macrumors regular

    Joined:
    Jun 4, 2009
    #2
    I don't know exactly what you are trying to achieve but some points:

    You can paste these commands into a text file and it becomes a script. You can run it by:
    • typing
      Code:
      sh path/to/script
    • or by making the first line read
      Code:
      #!/bin/sh
      , make the file executable (
      Code:
      chmod a+x path/to/script
      ) and then just typing
      Code:
      path/to/script
    • or by making the first line read
      Code:
      #!/bin/sh
      , make the file executable (
      Code:
      chmod a+x path/to/script
      ) and then putting the script in your path (or changing your path to include the location of the script)
    To save changing the filename on each line each time you should use a variable.
    Code:
    APP_NAME=Foo.app
    sudo mkdir "${APP_NAME}/Contents/Frameworks"
    sudo cp -R /opt/local/libexec/qt4/Library/Frameworks/QtCore.framework "${APP_NAME}/Contents/Frameworks"
    
    etc. You can set the variable either once at the beginning of your script, as shown above, or take it as a command line argument - e.g. you run the script as
    Code:
    path/to/script Foo.app
    and the script contains
    Code:
    APP_NAME=$1
    or you can try to make the script determine the value using some heuristic.

    If you only run the script from within the app's directory you could try something like
    Code:
    APP_NAME=`basename $PWD`
    Hopefully that is enough to get you going.
     
  3. luke9511 thread starter macrumors member

    Joined:
    Mar 23, 2015
    #3
    i tried following what you posted but it cant find the app when i use the variable
     
  4. cqexbesd macrumors regular

    Joined:
    Jun 4, 2009
    #4
    You will need to be much more specific if anyone is to help you.

    What exactly does your script contain?
    What did you type?
    In which directory where you when you typed it?
    What was the error?
     

Share This Page