-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-6184] Improve Fabric vendoring (scripts)
This patch adds pinning capability for Hyperledger Fabric dependencies. The packages are split between internal and external paths. Change-Id: Ia56ff0977ea567c16a068eec712ac1248fcbf101 Signed-off-by: Troy Ronda <troy@troyronda.com>
- Loading branch information
Showing
11 changed files
with
700 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
scripts/third_party_pins/fabric-ca/apply_fabric_ca_client_utils.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# This script pins the BCCSP package family from Hyperledger Fabric into the SDK | ||
# These files are checked into internal paths. | ||
# Note: This script must be adjusted as upstream makes adjustments | ||
|
||
IMPORT_SUBSTS=($IMPORT_SUBSTS) | ||
|
||
declare -a PKGS=( | ||
"api" | ||
"lib" | ||
"lib/tls" | ||
"lib/tcert" | ||
"lib/spi" | ||
"util" | ||
) | ||
|
||
declare -a FILES=( | ||
"api/client.go" | ||
"api/net.go" | ||
|
||
"lib/client.go" | ||
"lib/identity.go" | ||
"lib/signer.go" | ||
"lib/clientconfig.go" | ||
"lib/util.go" | ||
"lib/serverstruct.go" | ||
|
||
"lib/tls/tls.go" | ||
|
||
"lib/tcert/api.go" | ||
"lib/tcert/util.go" | ||
"lib/tcert/tcert.go" | ||
"lib/tcert/keytree.go" | ||
|
||
"lib/spi/affiliation.go" | ||
"lib/spi/userregistry.go" | ||
|
||
"util/util.go" | ||
"util/args.go" | ||
"util/csp.go" | ||
"util/struct.go" | ||
"util/flag.go" | ||
) | ||
|
||
echo 'Removing current upstream project from working directory ...' | ||
rm -Rf "${INTERNAL_PATH}" | ||
mkdir -p "${INTERNAL_PATH}" | ||
|
||
# Create directory structure for packages | ||
for i in "${PKGS[@]}" | ||
do | ||
mkdir -p $INTERNAL_PATH/${i} | ||
done | ||
|
||
# Apply global import patching | ||
echo "Patching import paths on upstream project ..." | ||
for i in "${FILES[@]}" | ||
do | ||
for subst in "${IMPORT_SUBSTS[@]}" | ||
do | ||
sed -i '' -e $subst $TMP_PROJECT_PATH/${i} | ||
done | ||
goimports -w $TMP_PROJECT_PATH/${i} | ||
done | ||
|
||
# Copy patched project into internal paths | ||
echo "Copying patched upstream project into working directory ..." | ||
for i in "${FILES[@]}" | ||
do | ||
TARGET_PATH=`dirname $INTERNAL_PATH/${i}` | ||
cp $TMP_PROJECT_PATH/${i} $TARGET_PATH | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# This script fetches code used in the SDK originating from other Hyperledger Fabric projects | ||
# These files are checked into internal paths. | ||
# Note: This script must be adjusted as upstream makes adjustments | ||
|
||
UPSTREAM_PROJECT="github.com/hyperledger/fabric-ca" | ||
UPSTREAM_BRANCH="release" | ||
SCRIPTS_PATH="scripts/third_party_pins/fabric-ca" | ||
PATCHES_PATH="scripts/third_party_pins/fabric-ca/patches" | ||
|
||
THIRDPARTY_INTERNAL_FABRIC_CA_PATH='internal/github.com/hyperledger/fabric-ca' | ||
|
||
#### | ||
# Clone and patch packages into repo | ||
|
||
# Clone original project into temporary directory | ||
echo "Fetching upstream project ($UPSTREAM_PROJECT:$UPSTREAM_COMMIT) ..." | ||
CWD=`pwd` | ||
TMP=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'` | ||
|
||
TMP_PROJECT_PATH=$TMP/src/$UPSTREAM_PROJECT | ||
mkdir -p $TMP_PROJECT_PATH | ||
cd ${TMP_PROJECT_PATH}/.. | ||
|
||
git clone https://${UPSTREAM_PROJECT}.git | ||
cd $TMP_PROJECT_PATH | ||
git checkout $UPSTREAM_BRANCH | ||
git reset --hard $UPSTREAM_COMMIT | ||
|
||
echo "Patching upstream project ..." | ||
git am ${CWD}/${PATCHES_PATH}/* | ||
|
||
cd $CWD | ||
|
||
# fabric-ca client utils | ||
echo "Pinning and patching fabric-ca client utils..." | ||
declare -a CLIENT_UTILS_IMPORT_SUBSTS=( | ||
's/\"github.com\/hyperledger\/fabric-ca/\"github.com\/hyperledger\/fabric-sdk-go\/internal\/github.com\/hyperledger\/fabric-ca/g' | ||
's/\"github.com\/hyperledger\/fabric\/bccsp/\"github.com\/hyperledger\/fabric-sdk-go\/pkg\/third_party\/bccsp/g' | ||
) | ||
eval "INTERNAL_PATH=$THIRDPARTY_INTERNAL_FABRIC_CA_PATH TMP_PROJECT_PATH=$TMP_PROJECT_PATH IMPORT_SUBSTS=\"${CLIENT_UTILS_IMPORT_SUBSTS[*]}\" $SCRIPTS_PATH/apply_fabric_ca_client_utils.sh" | ||
|
||
# Cleanup temporary files from patch application | ||
echo "Removing temporary files ..." | ||
rm -Rf $TMP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# This script pins the BCCSP package family from Hyperledger Fabric into the SDK | ||
# These files are checked into internal paths. | ||
# Note: This script must be adjusted as upstream makes adjustments | ||
|
||
IMPORT_SUBSTS=($IMPORT_SUBSTS) | ||
|
||
declare -a PKGS=( | ||
"bccsp" | ||
"bccsp/factory" | ||
"bccsp/pkcs11" | ||
"bccsp/signer" | ||
"bccsp/sw" | ||
"bccsp/utils" | ||
) | ||
|
||
declare -a FILES=( | ||
"bccsp/aesopts.go" | ||
"bccsp/bccsp.go" | ||
"bccsp/ecdsaopts.go" | ||
"bccsp/hashopts.go" | ||
"bccsp/keystore.go" | ||
"bccsp/opts.go" | ||
"bccsp/rsaopts.go" | ||
"bccsp/rsaopts.go" | ||
"bccsp/rsaopts.go" | ||
|
||
"bccsp/factory/factory.go" | ||
"bccsp/factory/nopkcs11.go" | ||
"bccsp/factory/opts.go" | ||
"bccsp/factory/pkcs11.go" | ||
"bccsp/factory/pkcs11factory.go" | ||
"bccsp/factory/swfactory.go" | ||
|
||
"bccsp/pkcs11/conf.go" | ||
"bccsp/pkcs11/ecdsa.go" | ||
"bccsp/pkcs11/ecdsakey.go" | ||
"bccsp/pkcs11/impl.go" | ||
"bccsp/pkcs11/pkcs11.go" | ||
|
||
"bccsp/signer/signer.go" | ||
|
||
"bccsp/sw/aes.go" | ||
"bccsp/sw/aeskey.go" | ||
"bccsp/sw/conf.go" | ||
"bccsp/sw/dummyks.go" | ||
"bccsp/sw/ecdsa.go" | ||
"bccsp/sw/ecdsakey.go" | ||
"bccsp/sw/fileks.go" | ||
"bccsp/sw/hash.go" | ||
"bccsp/sw/impl.go" | ||
"bccsp/sw/internals.go" | ||
"bccsp/sw/keyderiv.go" | ||
"bccsp/sw/keygen.go" | ||
"bccsp/sw/keyimport.go" | ||
"bccsp/sw/rsa.go" | ||
"bccsp/sw/rsakey.go" | ||
|
||
"bccsp/utils/errs.go" | ||
"bccsp/utils/io.go" | ||
"bccsp/utils/keys.go" | ||
"bccsp/utils/slice.go" | ||
"bccsp/utils/x509.go" | ||
) | ||
|
||
echo 'Removing current upstream project from working directory ...' | ||
rm -Rf "${INTERNAL_PATH}/bccsp" | ||
mkdir -p "${INTERNAL_PATH}/bccsp" | ||
|
||
# Create directory structure for packages | ||
for i in "${PKGS[@]}" | ||
do | ||
mkdir -p $INTERNAL_PATH/${i} | ||
done | ||
|
||
# Apply global import patching | ||
echo "Patching import paths on upstream project ..." | ||
for i in "${FILES[@]}" | ||
do | ||
for subst in "${IMPORT_SUBSTS[@]}" | ||
do | ||
sed -i '' -e $subst $TMP_PROJECT_PATH/${i} | ||
done | ||
goimports -w $TMP_PROJECT_PATH/${i} | ||
done | ||
|
||
# Copy patched project into internal paths | ||
echo "Copying patched upstream project into working directory ..." | ||
for i in "${FILES[@]}" | ||
do | ||
TARGET_PATH=`dirname $INTERNAL_PATH/${i}` | ||
cp $TMP_PROJECT_PATH/${i} $TARGET_PATH | ||
done |
Oops, something went wrong.