buildpackage.sh
来自「MPI stands for the Message Passing Inter」· Shell 代码 · 共 551 行 · 第 1/2 页
SH
551 行
} # Set arch to the first arch in the list. Go through the for loop,# although we'll break out at the end of the first time through. Look# at the other arches that were built by using ls.for arch in $OMPI_ARCH_LIST ; do cd $BUILD_TMP other_archs=`ls -d dist-*` fulldistdir="$BUILD_TMP/dist" echo "--> Creating fat binares and libraries" for other_arch in $other_archs ; do cd "$fulldistdir" # <prefix>/bin - don't copy in 64 bit binaries if echo $other_arch | grep -v 64 > /dev/null ; then files=`find ./${OMPI_PREFIX}/bin -type f -print` for file in $files ; do other_file="$BUILD_TMP/${other_arch}/$file" if test -r $other_file ; then lipo -create $file $other_file -output $file fi done fi # <prefix>/lib - ignore .la files files=`find ./${OMPI_PREFIX}/lib -type f -print | grep -v '\.la$'` for file in $files ; do other_file="$BUILD_TMP/${other_arch}/$file" if test -r $other_file ; then lipo -create $file $other_file -output $file else echo "Not lipoing missing file $other_file" fi done done cd $BUILD_TMP echo "--> Creating multi-architecture mpi.h" # mpi.h # get the top of mpi.h mpih_top=`grep -n '@OMPI_BEGIN_CONFIGURE_SECTION@' $BUILD_TMP/dist/${OMPI_PREFIX}/include/mpi.h | cut -f1 -d:` mpih_top=`echo "$mpih_top - 1" | bc` head -n $mpih_top $BUILD_TMP/dist/${OMPI_PREFIX}/include/mpi.h > mpih_top.txt # now the bottom of mpi.h mpih_bottom_top=`grep -n '@OMPI_END_CONFIGURE_SECTION@' $BUILD_TMP/dist/${OMPI_PREFIX}/include/mpi.h | cut -f1 -d:` mpih_bottom_bottom=`wc -l $BUILD_TMP/dist/${OMPI_PREFIX}/include/mpi.h | cut -f1 -d/` mpih_bottom=`echo "$mpih_bottom_bottom - $mpih_bottom_top" | bc` tail -n $mpih_bottom $BUILD_TMP/dist/${OMPI_PREFIX}/include/mpi.h > mpih_bottom.txt # now get our little section of fun mpih_top=`echo "$mpih_top + 1" | bc` mpih_fun_len=`echo "$mpih_bottom_top - $mpih_top + 1" | bc` head -n $mpih_bottom_top $BUILD_TMP/dist/${OMPI_PREFIX}/include/mpi.h | tail -n $mpih_fun_len > mpih_$arch.txt # start putting it back together rm -f mpi.h cat mpih_top.txt > mpi.h print_arch_if $arch cat mpih_$arch.txt >> mpi.h echo "#endif" >> mpi.h for other_arch_dir in $other_archs ; do other_arch=`echo $other_arch_dir | cut -f2 -d-` mpih_top=`grep -n '@OMPI_BEGIN_CONFIGURE_SECTION@' $BUILD_TMP/$other_arch_dir/${OMPI_PREFIX}/include/mpi.h | cut -f1 -d:` mpih_bottom_top=`grep -n '@OMPI_END_CONFIGURE_SECTION@' $BUILD_TMP/$other_arch_dir/${OMPI_PREFIX}/include/mpi.h | cut -f1 -d:` mpih_fun_len=`echo "$mpih_bottom_top - $mpih_top + 1" | bc` head -n $mpih_bottom_top $BUILD_TMP/$other_arch_dir/${OMPI_PREFIX}/include/mpi.h | tail -n $mpih_fun_len > mpih_$other_arch.txt print_arch_if $other_arch cat mpih_$other_arch.txt >> mpi.h echo "#endif" >> mpi.h done cat mpih_bottom.txt >> mpi.h mv mpi.h $BUILD_TMP/dist/${OMPI_PREFIX}/include/. rm mpih* breakdone# set component load errors to false, as we're almost always going to# fail to load the XGrid components on 64 bit systems, and users don't# need to see that.echo "mca_component_show_load_errors = 0" >> $BUILD_TMP/dist/${OMPI_PREFIX}/etc/openmpi-mca-params.conf########################################################################## Do all the package mojo########################################################################### Prep package info#debug_file="${BUILD_TMP}/disk.out"touch "$debug_file"echo "--> Creating Package Info:"cd $BUILD_TMPpkdir="${BUILD_TMP}/${OMPI_PACKAGE}.pkg"mkdir -p ${pkdir}mkdir ${pkdir}/Contentsmkdir ${pkdir}/Contents/Resourcesmkdir ${pkdir}/Contents/Resources/English.lprojecho 'pmkrpkg1' > ${pkdir}/Contents/PkgInfoinfofile=${pkdir}/Contents/Resources/English.lproj/${OMPI_PACKAGE}.infoecho "Title Open MPI ${version}" > ${infofile}echo "Version ${version}" >> ${infofile}echo "Description Install Open MPI ${version}" >> ${infofile}echo 'DefaultLocation /' >> ${infofile}echo 'DeleteWarning' >> ${infofile}echo 'NeedsAuthorization YES' >> ${infofile}echo 'Required NO' >> ${infofile}echo 'Relocatable NO' >> ${infofile}echo 'RequiresReboot NO' >> ${infofile}echo 'UseUserMask NO' >> ${infofile}echo 'OverwritePermissions NO' >> ${infofile}echo 'InstallFat NO' >> ${infofile}echo "--> Copying OS X-specific ReadMe into package"cp "${OMPI_OSX_README}" "${pkdir}/Contents/Resources/ReadMe.rtf"if [ ! $? = 0 ]; then echo "*** Could not copy in ReadMe.rtf. Aborting!" exit 1fiecho "--> Creating pax file"CWD=`pwd`cd "$fulldistdir"pax -w -f "${pkdir}/Contents/Resources/${OMPI_PACKAGE}.pax" . >> "$debug_file" 2>&1if [ ! $? = 0 ]; then echo "*** Failed building pax file. Aborting!" echo "*** Check $debug_file for information" cd "$CWD" exit 1ficd "$CWD"unset CWDecho "--> Compressing pax file"gzip "${pkdir}/Contents/Resources/${OMPI_PACKAGE}.pax" >> "$debug_file" 2>&1if [ ! $? = 0 ]; then echo "*** Failed compressing pax file. Aborting!" echo "*** Check $debug_file for information" exit 1fiecho "--> Creating bom file"mkbom "$fulldistdir" "${pkdir}/Contents/Resources/${OMPI_PACKAGE}.bom" >> "$debug_file" 2>&1if [ ! $? = 0 ]; then echo "*** Failed building bom file. Aborting!" echo "*** Check $debug_file for information" exit 1fiecho "--> Generating sizes file:"sizesfile="${pkdir}/Contents/Resources/${OMPI_PACKAGE}.sizes"numFiles=`du -a ${fulldistdir} | wc -l`installedSize=`du -s ${fulldistdir} | cut -f1`compressedSize=`du -s ${fulldistdir} | cut -f1`echo "NumFiles ${numFiles}" > ${sizesfile}echo "InstalledSize ${installedSize}" >> ${sizesfile}echo "CompressedSize ${compressedSize}" >> ${sizesfile}cat ${sizesfile}## Make a disk image in read-write mode#echo "--> Creating Disc Image"# Allocated about 2.5MB more than we need, just to be safe. If that# number is less than about 5MB, make 5MB to keep disk utilities# happy.sectorsAlloced=`echo 2*${compressedSize}+50|bc`if [ $sectorsAlloced -lt 10000 ]; then sectorsAlloced=10000fihdiutil create -ov "${BUILD_TMP}/${OMPI_VER_PACKAGE}RW" -sectors ${sectorsAlloced} >> "$debug_file" 2>&1if [ ! $? = 0 ]; then echo "*** Failed hdiutil create. Aborting!" echo "*** Check $debug_file for information" exit 1fimountLoc=`hdid -nomount ${BUILD_TMP}/${OMPI_VER_PACKAGE}RW.dmg | grep HFS | cut -f1`/sbin/newfs_hfs -v ${OMPI_VER_PACKAGE} ${mountLoc} >> "$debug_file" 2>&1if [ ! $? = 0 ]; then echo "*** Failed building HFS+ file system. Aborting!" echo "*** Check $debug_file for information" exit 1fihdiutil eject ${mountLoc} >> "$debug_file" 2>&1if [ ! $? = 0 ]; then echo "*** Could not unmount $mountLoc. Aborting!" echo "*** Check $debug_file for information" exit 1fi## Copy above package into the disk image#echo "--> Copying Package to Disc Image"hdid "${BUILD_TMP}/${OMPI_VER_PACKAGE}RW.dmg" >> "$debug_file" 2>&1if [ ! $? = 0 ]; then echo "*** Could not mount ${BUILD_TMP}/${OMPI_VER_PACKAGE}RW.dmg. Aborting!" echo "*** Check $debug_file for information" exit 1fiif [ ! -d "/Volumes/${OMPI_VER_PACKAGE}" ]; then echo "*** /Volumes/${OMPI_VER_PACKAGE} does not exist. Aborting!" echo "*** Check $debug_file for information" exit 1ficp -R "${pkdir}" "/Volumes/${OMPI_VER_PACKAGE}"if [ ! $? = 0 ]; then echo "*** Error copying ${OMPI_VER_PACKAGE}.pkg. Aborting!" echo "*** Check $debug_file for information" exit 1fi## Converting Disk Image to read-only (and shrink to size needed)#cmd="hdiutil eject ${mountLoc}"echo "--> Ejecting R/W disk: $cmd"eval $cmd >> "$debug_file" 2>&1if [ ! $? = 0 ]; then echo "*** Error ejecting R/W disk. Aborting!" echo "*** Check $debug_file for information" exit 1ficmd="hdiutil resize \"${BUILD_TMP}/${OMPI_VER_PACKAGE}RW.dmg\" -sectors min"echo "--> Resizing: $cmd"eval $cmd >> "$debug_file" 2>&1if [ ! $? = 0 ]; then echo "*** Error resizing disk. Aborting!" echo "*** Check $debug_file for information" exit 1ficmd="hdiutil convert \"${BUILD_TMP}/${OMPI_VER_PACKAGE}RW.dmg\" -format UDRO -o \"/tmp/${OMPI_VER_PACKAGE}.dmg\""echo "--> Converting to R-O: $cmd"eval $cmd >> "$debug_file" 2>&1if [ ! $? = 0 ]; then echo "*** Error converting disk to read-only. Aborting!" echo "*** Check $debug_file for information" exit 1fiecho "--> Compressing disk image"gzip --best "/tmp/${OMPI_VER_PACKAGE}.dmg"echo "--> Cleaning up the staging directory"rm -rf "${BUILD_TMP}"if [ ! $? = 0 ]; then echo "*** Could not clean up ${BUILD_TMP}." echo "You may want to clean it up yourself." exit 1fiecho "--> Done. Package is at: /tmp/${OMPI_VER_PACKAGE}.dmg.gz"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?