Skip to content

Commit

Permalink
Merge pull request #1072 from subutai-io/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
crioto authored Sep 1, 2018
2 parents 23f0822 + d0c0465 commit 1b90f4e
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 41 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [7.1.1] 08/11/2018
1057
* Switched to Google UUID implementation (#1057)

## [7.1.0] 07/24/2018

* Fixed bug with internal ping packet flood
Expand Down
61 changes: 25 additions & 36 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ try {
stash includes: 'bin/p2p', name: 'p2p'
stash includes: 'bin/p2p.exe', name: 'p2p.exe'
stash includes: 'bin/p2p_osx', name: 'p2p_osx'
stash includes: 'upload-ipfs.sh', name: 'upload-ipfs.sh'
}

/*
Expand Down Expand Up @@ -120,18 +121,20 @@ try {

/* upload p2p */
unstash 'p2p'
unstash 'upload-ipfs.sh'
/* get p2p version */
String p2pVersion = sh (script: """
set +x
./bin/p2p -v | cut -d " " -f 3 | tr -d '\n'
""", returnStdout: true)
if (env.BRANCH_NAME == 'master') {
if (env.BRANCH_NAME == 'dev' || env.BRANCH_NAME == 'master') {
String responseP2P = sh (script: """
set +x
curl -s -k ${url}/raw/info?name=p2p
""", returnStdout: true)
sh """
set +x
./upload-ipfs.sh ${env.BRANCH_NAME} Linux
curl -s -k -H "token: ${token}" -Ffile=@bin/p2p -Fversion=${p2pVersion} ${url}/raw/upload
"""
/* delete old p2p */
Expand All @@ -153,6 +156,7 @@ try {
""", returnStdout: true)
sh """
set +x
./upload-ipfs.sh ${env.BRANCH_NAME} MSYS_NT-10.0
curl -s -k -H "token: ${token}" -Ffile=@bin/p2p.exe -Fversion=${p2pVersion} ${url}/raw/upload
"""
/* delete old p2p.exe */
Expand All @@ -166,13 +170,14 @@ try {

/* upload p2p_osx */
unstash 'p2p_osx'
if (env.BRANCH_NAME == 'master') {
if (env.BRANCH_NAME == 'dev' || env.BRANCH_NAME == 'master') {
String responseP2Posx = sh (script: """
set +x
curl -s -k ${url}/raw/info?name=p2p_osx
""", returnStdout: true)
sh """
set +x
./upload-ipfs.sh ${env.BRANCH_NAME} Darwin
curl -s -k -H "token: ${token}" -Ffile=@bin/p2p_osx -Fversion=${p2pVersion} ${url}/raw/upload
"""
/* delete old p2p */
Expand Down Expand Up @@ -242,43 +247,24 @@ try {
sh """
cd ${CWD}
touch uploading_agent
scp uploading_agent subutai*.deb [email protected]:incoming/${env.BRANCH_NAME}/
ssh [email protected] sh /var/reprepro/scripts/scan-incoming.sh ${env.BRANCH_NAME} agent
scp uploading_agent subutai*.deb [email protected]:incoming/${env.BRANCH_NAME}/
ssh [email protected] sh /var/reprepro/scripts/scan-incoming.sh ${env.BRANCH_NAME} agent
"""

sh """
set -x
rm -rf /tmp/p2p-packaging
git clone [email protected]:optdyn/p2p-packaging.git /tmp/p2p-packaging
cd /tmp/p2p-packaging/
${gitcmd}
cp ${CWD}/subutai*.deb .
./upload-ipfs.sh ${env.BRANCH_NAME}
./upload.sh debian ${env.BRANCH_NAME} subutai*.deb
"""

}

if (env.BRANCH_NAME == 'master') {
node("debian") {
notifyBuild('INFO', "Packaging P2P for Debian")
stage("Packaging for Debian")
notifyBuildDetails = "\nFailed on stage - Starting Debian Packaging"

sh """
set -x
rm -rf /tmp/p2p-packaging
git clone [email protected]:optdyn/p2p-packaging.git /tmp/p2p-packaging
cd /tmp/p2p-packaging
${gitcmd}
wget --no-check-certificate https://eu0.${env.BRANCH_NAME}cdn.subutai.io:8338/kurjun/rest/raw/get?name=p2p -O /tmp/p2p-packaging/linux/debian/p2p
chmod +x /tmp/p2p-packaging/linux/debian/p2p
./configure --debian --branch=${env.BRANCH_NAME}
cd linux
debuild -B -d
"""

notifyBuildDetails = "\nFailed on stage - Uploading Debian Package"

String debfile = sh (script: """
set +x
ls /tmp/p2p-packaging | grep .deb | tr -d '\n'
""", returnStdout: true)

sh """
/tmp/p2p-packaging/upload.sh debian ${env.BRANCH_NAME} /tmp/p2p-packaging/${debfile}
"""
}

if (env.BRANCH_NAME == 'dev' || env.BRANCH_NAME == 'master') {

node("mac") {
notifyBuild('INFO', "Packaging P2P for Darwin")
stage("Packaging for Darwin")
Expand All @@ -297,6 +283,7 @@ try {
notifyBuildDetails = "\nFailed on stage - Uploading Darwin Package"

sh """
/tmp/p2p-packaging/./upload-ipfs.sh ${env.BRANCH_NAME}
/tmp/p2p-packaging/upload.sh darwin ${env.BRANCH_NAME} /tmp/p2p-packaging/darwin/p2p.pkg
"""
}
Expand All @@ -313,12 +300,14 @@ try {
echo rm -rf /c/tmp/p2p-packaging > c:\\tmp\\p2p-win.do
echo git clone [email protected]:optdyn/p2p-packaging.git /c/tmp/p2p-packaging >> c:\\tmp\\p2p-win.do
echo cd /c/tmp/p2p-packaging >> c:\\tmp\\p2p-win.do
echo git checkout ${env.BRANCH_NAME} >> c:\\tmp\\p2p-win.do
echo curl -fsSLk https://eu0.${env.BRANCH_NAME}cdn.subutai.io:8338/kurjun/rest/raw/get?name=p2p.exe -o /c/tmp/p2p-packaging/p2p.exe >> c:\\tmp\\p2p-win.do
echo curl -fsSLk https://eu0.cdn.subutai.io:8338/kurjun/rest/raw/get?name=tap-windows-9.21.2.exe -o /c/tmp/p2p-packaging/tap-windows-9.21.2.exe >> c:\\tmp\\p2p-win.do
echo sed -i -e "s/{VERSION_PLACEHOLDER}/${global_version}/g" /c/tmp/p2p-packaging/windows/P2PInstaller/P2PInstaller.vdproj >> c:\\tmp\\p2p-win.do
echo sed -i -e "s/PRODUCT_CODE_PLACEHOLDER/${product_code}/g" /c/tmp/p2p-packaging/windows/P2PInstaller/P2PInstaller.vdproj >> c:\\tmp\\p2p-win.do
echo /c/tmp/p2p-packaging/upload.sh windows ${env.BRANCH_NAME} /c/tmp/p2p-packaging/windows/P2PInstaller/Release/P2PInstaller.msi > c:\\tmp\\p2p-win-upload.do
echo /c/tmp/p2p-packaging/upload-ipfs.sh ${env.BRANCH_NAME} >> c:\\tmp\\p2p-win-upload.do
echo call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\Common7\\Tools\\VsDevCmd.bat" > c:\\tmp\\p2p-pack.bat
echo signtool.exe sign /tr http://timestamp.comodoca.com/authenticode /f "c:\\users\\tray\\od.p12" /p testpassword "c:\\tmp\\p2p-packaging\\p2p.exe" >> c:\\tmp\\p2p-pack.bat
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.1.0
7.1.1
1 change: 1 addition & 0 deletions debian/subutai-p2p.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Type=simple
EnvironmentFile=-/etc/default/subutai-p2p
ExecStart=/usr/bin/p2p daemon -save /var/lib/subutai/data/p2p.save -syslog 127.0.0.1:1514 --mtu=${P2P_MTU}
Restart=always
OnFailure=subutai-cop.service

[Install]
WantedBy=multi-user.target
4 changes: 2 additions & 2 deletions lib/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net"
"time"

"github.com/google/uuid"
"github.com/subutai-io/p2p/protocol"
"github.com/wayn3h0/go-uuid"
)

// OperatingMode - Mode in which DHT client is operating
Expand Down Expand Up @@ -330,7 +330,7 @@ func (dht *DHTClient) WaitID() error {

// RegisterProxy will register current node as a proxy on bootstrap node
func (dht *DHTClient) RegisterProxy(ip net.IP, port int) error {
id, err := uuid.NewTimeBased()
id, err := uuid.NewUUID()
if err != nil {
return fmt.Errorf("Failed to generate ID: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions lib/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"net"

uuid "github.com/wayn3h0/go-uuid"
"github.com/google/uuid"
)

// Different utility functions
Expand Down Expand Up @@ -36,7 +36,7 @@ func GenerateMAC() (string, net.HardwareAddr) {
// we will replace Token with received ID
func GenerateToken() string {
result := ""
id, err := uuid.NewTimeBased()
id, err := uuid.NewUUID()
if err != nil {
Log(Error, "Failed to generate token for peer")
return result
Expand Down
97 changes: 97 additions & 0 deletions upload-ipfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
BRANCH=$1
OS=$2

upload_ipfs (){
filename=$1
user="[email protected]"
fingerprint="877B586E74F170BC4CF6ECABB971E2AC63D23DC9"
cdnHost=$2
extract_id()
{
id_src=$(echo $json | grep "id")
id=${id_src:10:46}
}

json=`curl -k -s -X GET ${cdnHost}/rest/v1/cdn/raw?name=$filename`
echo "Received: $json"
extract_id
echo "Previous file ID is $id"

authId="$(curl -s ${cdnHost}/rest/v1/cdn/token?fingerprint=${fingerprint})"
echo "Auth id obtained and signed $authId"

sign="$(echo ${authId} | gpg --clearsign -u ${user})"
token="$(curl -s --data-urlencode "request=${sign}" ${cdnHost}/rest/v1/cdn/token)"
echo "Token obtained $token"

echo "Uploading file..."
upl_msg="$(curl -sk -H "token: ${token}" -Ffile=@$filename -Ftoken=${token} -X POST "${cdnHost}/rest/v1/cdn/uploadRaw")"
echo "$upl_msg"

echo "Removing previous"
echo $Upload
if [[ -n "$id" ]] && [[ $upl_msg != "An object with id: $id is exist in Bazaar. Increase the file version." ]]
then
curl -k -s -X DELETE "$cdnHost/rest/v1/cdn/raw?token=${token}&id=$id"
fi
echo -e "\\nCompleted"
}

case $OS in
Linux)
BASENAME="p2p"
BIN_EXT=""
;;
MSYS_NT-10.0)
BASENAME="p2p.exe"
BIN_EXT=".exe"
;;
Darwin)
BASENAME="p2p_osx"
BIN_EXT="_osx"
;;
esac

case $BRANCH in
dev)
BINNAME="p2p-dev$BIN_EXT"
cd bin
cp $BASENAME $BINNAME
IPFSURL=https://devbazaar.subutai.io
upload_ipfs $BINNAME $IPFSURL
;;
master)
BINNAME="p2p-master$BIN_EXT"
cd bin
cp $BASENAME $BINNAME
IPFSURL=https://masterbazaar.subutai.io
upload_ipfs $BINNAME $IPFSURL
;;
head)
BINNAME="p2p$BIN_EXT"
if [ $OS = Linux ] || [$OS = MSYS_NT-10.0 ]
then
cd bin
cp $BASENAME $BINNAME
IPFSURL=https://bazaar.subutai.io
upload_ipfs $BINNAME $IPFSURL
fi
;;
HEAD)
BINNAME="subutai-p2p$PKG_EXT"
if [ $OS = Linux ] || [$OS = MSYS_NT-10.0 ]
then
cd bin
cp $BASENAME $BINNAME
IPFSURL=https://bazaar.subutai.io
upload_ipfs $BINNAME $IPFSURL
fi
;;
esac

echo "---------"
echo $BINNAME
echo $OS
echo $BRANCH
echo $VERSION
echo "---------"

0 comments on commit 1b90f4e

Please sign in to comment.