Permalink
Browse files

Use buildpack-packager submodule

* No more shunit test for package
* version in root

[#73384384]
  • Loading branch information...
1 parent 99b9a95 commit 69e3adc1f5941c706c52566da692c233d0c89283 Kyle McConnaughay and Tim Johnson committed Jun 26, 2014
Showing with 11 additions and 191 deletions.
  1. +3 −0 .gitmodules
  2. +3 −1 CF_README.md
  3. +0 −98 bin/cf_packager
  4. +3 −1 bin/package
  5. +1 −0 buildpack-packager
  6. +1 −1 cf.Gemfile.lock
  7. +0 −90 cf_shunit/test_package
  8. 0 {bin → }/version
View
@@ -0,0 +1,3 @@
+[submodule "buildpack-packager"]
+ path = buildpack-packager
+ url = https://github.com/cf-buildpacks/buildpack-packager.git
View
@@ -12,4 +12,6 @@ Notes to developers
* In offline mode, this buildpack will fail with non-Git vcs dependencies in requirements.txt
* When deploying an app with vendor dependencies, the buildpack does not attempt to download dependencies. Vendor all
-your dependencies in /vendor. See [The PIP documentation for fast local installs.](http://pip.readthedocs.org/en/latest/user_guide.html#fast-local-installs)
+your dependencies in /vendor. See [The PIP documentation for fast local installs.](http://pip.readthedocs.org/en/latest/user_guide.html#fast-local-installs)
+
+* Run `git submodule init` to fetch the buildpack-packager dependency
View
@@ -1,98 +0,0 @@
-BIN_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-BASE_PATH=${BIN_PATH}/..
-WORK_DIRECTORY=/tmp/_make_buildpack
-
-function __check_usage {
- if [ ${number_of_arguments} -ne 1 ] || ([ ${mode} != "online" ] && [ ${mode} != "offline" ]); then
- echo "Usage:"
- echo " ./package [online|offline]"
- exit 1
- fi
-}
-
-function __parse_arguments {
- number_of_arguments=$#
- mode=$1
-}
-
-function __create_work_directory {
- old_dir=$(pwd)
- mkdir ${WORK_DIRECTORY}
-}
-
-function __setup {
- __parse_arguments $@
- __check_usage
- __create_work_directory
-}
-
-function __copy_buildpack_to_work_directory {
- cp -r ${BASE_PATH}/* ${WORK_DIRECTORY}
-}
-
-function __translate_url_to_filename {
- dependency_url=$1
- sed 's/[:\/]/_/g' <<< ${dependency_url}
-}
-
-function __package_dependencies {
- mkdir dependencies
-
- for dependency in ${dependencies[@]}
- do
- filename=$(__translate_url_to_filename ${dependency})
- curl ${dependency} -o ./dependencies/${filename} -L
- done
-}
-
-function __build_zip_exclusion_string {
- zip_exclude_string=''
- for excluded_file in ${excluded_files[@]}
- do
- zip_exclude_string="$zip_exclude_string --exclude=*${excluded_file}*"
- done
-
- echo ${zip_exclude_string}
-}
-
-function __generate_filename {
- source ${BIN_PATH}/version
-
- filename=${language}'_buildpack'
-
- if [[ ${mode} == 'offline' ]]; then
- filename=${filename}'-offline'
- fi
-
- filename=${filename}'-v'${VERSION}
- filename=${filename}'.zip'
-
- echo ${filename}
-}
-
-function __zip_buildpack {
- zip -r ${BIN_PATH}/../$(__generate_filename) ./ $(__build_zip_exclusion_string)
-}
-
-
-function __cleanup {
- cd ${old_dir}
- rm -rf ${WORK_DIRECTORY}
-}
-
-function package_buildpack {
- __setup $@
-
- __copy_buildpack_to_work_directory
-
- cd ${WORK_DIRECTORY}
-
- if [[ ${mode} == 'offline' ]]; then
- __package_dependencies
- fi
-
- __zip_buildpack
-
- __cleanup
-}
-
View
@@ -26,5 +26,7 @@ excluded_files=(
'test/'
)
-source $BIN/cf_packager
+BIN="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+source $BIN/../buildpack-packager/lib/packager
+
package_buildpack $@
Submodule buildpack-packager added at 6ca369
View
@@ -1,6 +1,6 @@
GIT
remote: git://github.com/cf-buildpacks/machete.git
- revision: 44b615dfb6757a442ab9cbcb7fca21611105c733
+ revision: a37c2748ab2d8f14602b4768653917970c02ef04
branch: master
specs:
machete (0.0.1)
View
@@ -1,90 +0,0 @@
-#!/bin/bash
-
-# To run, from ~/workspace/buildpacks/cf-buildpack-python
-#
-# bin/test_package
-
-# ==================================== Mocks ====================================
-# The mocks are not subshell safe. They work by defining a global bash function that takes precedence over the UNIX
-# tools like curl and zip
-function curl() {
- args="$@";
- ARGUMENTS_CALLED_WITH_FOR_CURL=("${ARGUMENTS_CALLED_WITH_FOR_CURL[@]}" "$args");
- return 0;
-}
-
-function zip() {
- args="$@";
- ARGUMENTS_CALLED_WITH_FOR_ZIP=("${ARGUMENTS_CALLED_WITH_FOR_ZIP[@]}" "$args");
- return 0;
-}
-
-# Reset mocks
-setUp() {
- ARGUMENTS_CALLED_WITH_FOR_CURL=()
- ARGUMENTS_CALLED_WITH_FOR_ZIP=()
-}
-
-# ==================================== Tests ====================================
-testDependenciesAreDownloadedInOfflineMode() {
- source $BIN/package offline
-
- assertEquals 'curl should download files with the url in the saved filename' \
- 'http://lang-python.s3.amazonaws.com/runtimes/python-2.7.0.tar.gz -o ./dependencies/http___lang-python.s3.amazonaws.com_runtimes_python-2.7.0.tar.gz -L' \
- "${ARGUMENTS_CALLED_WITH_FOR_CURL[0]}"
-
- assertEquals 'curl downloads 13 dependencies' "13" "${#ARGUMENTS_CALLED_WITH_FOR_CURL[@]}"
-}
-
-testDependenciesAreNotDownloadedInOnlineMode() {
- source $BIN/package online
-
- assertEquals 'curl downloads 0 dependencies' "0" "${#ARGUMENTS_CALLED_WITH_FOR_CURL[@]}"
-}
-
-testZipForBuildpackIsCreated() {
- source $BIN/package online
-
- assertEquals 'Buildpack is zipped' "1" "${#ARGUMENTS_CALLED_WITH_FOR_ZIP[@]}"
-}
-
-testOnlineZipIsCreatedWithCorrectName() {
- source $BIN/package online
- first_call=${ARGUMENTS_CALLED_WITH_FOR_ZIP[0]}
- assertTrue "online zip has version number and no mode" $(contains "$first_call" "python_buildpack-v1.0.0.zip")
-}
-
-testOfflineZipIsCreatedWithCorrectName() {
- source $BIN/package offline
- first_call=${ARGUMENTS_CALLED_WITH_FOR_ZIP[0]}
- assertTrue "offline zip has version number and mode" $(contains "$first_call" "python_buildpack-offline-v1.0.0.zip")
-}
-
-testExcludeFilesFromTheBuildpack() {
- source $BIN/package online
-
- arguments=$ARGUMENTS_CALLED_WITH_FOR_ZIP[@]
-
- assertTrue "zip excludes .git" $(contains "$arguments" " --exclude=*.git/*")
- assertTrue "zip excludes .gitignore" $(contains "$arguments" " --exclude=*.gitignore*")
- assertTrue "zip excludes cf_spec" $(contains "$arguments" " --exclude=*cf_spec/*")
- assertTrue "zip excludes log" $(contains "$arguments" " --exclude=*log/*")
- assertTrue "zip excludes test" $(contains "$arguments" " --exclude=*test/*")
-}
-
-# ==================================== Utilities ====================================
-function contains() {
- string=$1
- substring=$2
-
- if [[ $string == *"${substring}"* ]]
- then
- echo '0'
- else
- echo '1'
- fi
-}
-
-BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-BIN=$BASE/../bin
-source $BASE/../vendor/shunit2
View
File renamed without changes.

0 comments on commit 69e3adc

Please sign in to comment.