有静态库名#!/bin/bash
date1=$(date +"%s")
byteSize=1073741824
CHUNK_SIZE=1073741824
hashsize=1048576
if [[ -z "${1}" ]]; then
echo "No file provided."
exit 1
fi
ARCHIVE="/mnt/dbfiles/mahipal/splitfiles/${1}"
ARCHIVE_SIZE=`cat "${ARCHIVE}" | wc --bytes`
cd /mnt/dbfiles/mahipal/splitfiles
rm -rf TEMP
rm -rf HASH
mkdir TEMP
mkdir HASH
cd /mnt/dbfiles/mahipal/splitfiles/TEMP
date3=$(date +"%s")
split -d --bytes=${CHUNK_SIZE} "${ARCHIVE}" chunk -a 4
date4=$(date +"%s")
diff2=$(($date4-$date3))
cd /mnt/dbfiles/mahipal/splitfiles/HASH
date5=$(date +"%s")
split -d --bytes=${hashsize} "${ARCHIVE}" chunk -a 5
date6=$(date +"%s")
diff3=$(($date6-$date5))
cd /mnt/dbfiles/mahipal/splitfiles/TEMP
lastpartsize=`expr $(ls -l | tail -1 | awk '{print$5}') + 0`
lastfile=$(ls -l | tail -1 | awk '{print$9}')
cont=$(ls -l | wc -l)
cnt=`expr $cont - 2`
fileCount=$(ls -1 | grep "^chunk" | wc -l)
echo "Total parts to upload: " $fileCount
files=$(ls | grep "^chunk")
init=$(/bin/aws glacier initiate-multipart-upload --account-id - --part-size $byteSize --vault-name final_vault --archive-description "${1}_${ARCHIVE_SIZE}_${byteSize}")
echo "---------------------------------------"
uploadId=$(echo $init | jq '.uploadId' | xargs)
touch commands.txt
i=0
for f in $files
do
byteStart=$((i*byteSize))
byteEnd=$((i*byteSize+byteSize-1))
echo /bin/aws glacier upload-multipart-part --body $f --range "'"'bytes '"$byteStart"'-'"$byteEnd"'/*'"'" --account-id - --vault-name final_vault --upload-id $uploadId >> commands.txt
i=$(($i+1))
if [ "$i" == "$cnt" ]
then
byteEnd=`expr $byteEnd + 1`
byteEnd2=$((i*byteSize+lastpartsize-1))
byteSize=$lastpartsize
echo /bin/aws glacier upload-multipart-part --body $lastfile --range "'"'bytes '"$byteEnd"'-'"$byteEnd2"'/*'"'" --account-id - --vault-name final_vault --upload-id $uploadId >> commands.txt
break
fi
done
parallel --load 100% -a commands.txt --no-notice --bar
cd /mnt/dbfiles/mahipal/splitfiles/HASH
files=$(ls | grep "^chunk")
for f in $files
do
openssl dgst -sha256 -binary ${f} > "hash${f:5}"
done
echo "List Active Multipart Uploads:"
echo "Verify that a connection is open:"
/bin/aws glacier list-multipart-uploads --account-id - --vault-name final_vault >> /mnt/dbfiles/mahipal/splitfiles/TEMP/commands.txt
echo "-------------"
echo "Contents of commands.txt"
cd /mnt/dbfiles/mahipal/splitfiles/TEMP
cat commands.txt
# Calculate tree hash.
cd /mnt/dbfiles/mahipal/splitfiles/HASH
echo "Calculating tree hash..."
while true; do
COUNT=`ls hash* | wc -l`
if [[ ${COUNT} -le 2 ]]; then
TREE_HASH=$(cat hash* | openssl dgst -sha256 | awk '{print $2}')
break
fi
ls hash* | xargs -n 2 | while read PAIR; do
PAIRARRAY=(${PAIR})
if [[ ${#PAIRARRAY[@]} -eq 1 ]]; then
break
fi
cat ${PAIR} | openssl dgst -sha256 -binary > temphash
rm ${PAIR}
mv temphash "${PAIRARRAY[0]}"
done
done
cd /mnt/dbfiles/mahipal/splitfiles/TEMP
echo "Finalizing..."
/bin/aws glacier complete-multipart-upload --account-id=- --vault-name="final_vault" --upload-id="$uploadId" --checksum="${TREE_HASH}" --archive-size=${ARCHIVE_SIZE} >>commands.txt
RETVAL=$?
if [[ ${RETVAL} -ne 0 ]]; then
echo "complete-multipart-upload failed with status code: ${RETVAL}" >>commands.txt
echo "Aborting upload ${uploadId}" >>commands.txt
/bin/aws glacier abort-multipart-upload --account-id=- --vault-name="final_vault" --upload-id="${uploadId}" >>commands.txt
exit 1
fi
echo "--------------"
echo "Deleting temporary commands.txt file"
#rm commands.txt
date2=$(date +"%s")
diff=$(($date2-$date1))
echo "Total Split Duration for Chunk Part Size: $(($diff2/ 3600 )) hours $((($diff2 % 3600) / 60)) minutes $(($diff2 % 60)) seconds" >>commands.txt
echo "Total Split Duration for hash Part Size: $(($diff3/ 3600 )) hours $((($diff3 % 3600) / 60)) minutes $(($diff3 % 60)) seconds" >>commands.txt
echo "Total upload Duration: $(($diff/ 3600 )) hours $((($diff % 3600) / 60)) minutes $(($diff % 60)) seconds" >>commands.txt
echo "Done."
exit 0
,另一个名为libstatic1.a
的名为libstatic2.a
的测试应用的静态库
testapp
有一个方法libstatic1.a
testcmethds
已关联libstatic2.a
,并在方法libstatic1.a
中调用了testcmethds
samecalltest
已关联testapp
和libstatic1.a
libstatic2.a
将成功并正常运行。
为什么没有符号冲突,我使用testapp
检查两个nm -a
lib,它有相同的方法符号。
.a