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

Script to create zip and tar of Polycube with submodules #314

Merged
merged 3 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions scripts/create_pcn_sourcepack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/bin/bash

# This script is used to create an archive with all the polycube sources, including submodules.
# Currently github can create automatically the source pack, but it fails to include
# all the files belonging to submodules, hence making this function unsuitable for this project:
# https://github.saobby.my.eu.orgmunity/t/create-release-that-contains-submodule/1329
# This script allows to download either a specific branch or a tagged version of Polycube,
# and create both a ZIP and a TAR containing all the sources.
# Put this script where you want to clone Polycube.


DIR=`pwd`

echo "Example of compressed archive name format: polycube-0.9.0-rc"

git clone https://github.com/polycube-network/polycube.git
cd polycube
git submodule update --init --recursive

# give the possibility to create an archive of a certain branch or tag
echo "----------------------------------------------------------------"
echo "Select if you want to archive a branch or a tagged version."
echo -n "Type 'b' for branch or 't' for tag: "
read choice

if [ $choice == 'b' ]
then
echo "----------------------------------------------------------------"
echo "Current branches:"
git branch -a

echo -n "Type the branch name or press enter for master: "
read branch

if [ -z "$branch" ] || [ $branch == 'master' ]
then
echo -n "Type the version: "
read version
echo "Compressing Polycube master with version equal to $version ..."
else
if [ `git branch -a | egrep "^[[:space:]]+${branch}$"` ]
then
echo -n "Type the version: "
read version
git checkout $branch
echo "Compressing Polycube $branch with version equal to $version ..."
else
echo "Branch $branch does not exist"
exit 0
fi
fi
elif [ $choice == 't' ]
then
echo "----------------------------------------------------------------"
echo "Current tags:"
git tag

echo -n "Type the tag: "
read tag
if [ `git tag | egrep "${tag}$"` ]
then
git checkout $tag
echo "Compressing Polycube with version equal to $tag ..."
tag=${tag/v}
tag=${tag/-rc}
version=$tag
else
echo "tag $tag does not exist"
exit 0
fi
else
echo "error"
exit 0
fi

cd $DIR

# rename folder
mv polycube polycube-"$version"-rc

# create zip
ZIP=polycube-"$version"-rc.zip

zip -rq $ZIP polycube-"$version"-rc -x '*.git*'

if test -f "$ZIP"
then
echo "$ZIP created successfully"
else
echo "Error: $ZIP not created"
fi

# create tar
TAR=polycube-"$version"-rc.tar.gz

tar --exclude .git -czf $TAR polycube-"$version"-rc

if test -f "$TAR"
then
echo "$TAR created successfully"
else
echo "Error: $TAR not created"
fi
5 changes: 4 additions & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ if [ "$MODE" == "update" ] ; then
# from the current branch (default: master)
git pull
git submodule update --init --recursive

# Print the last commit in the current branch, just to make sure
# we're compiling exactly what we expect
git log -1
fi

mkdir -p build && cd build
git log -1

# depending on the mode different services are enabled
if [ "$MODE" == "pcn-iptables" ]; then
Expand Down