diff --git a/Dockerfile b/Dockerfile index 06ef0a5..9abd6dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM lsiobase/ubuntu:bionic +FROM lsiobase/alpine:3.9 # set version label ARG BUILD_DATE @@ -7,21 +7,36 @@ LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DA LABEL maintainer="thelamer" ARG NPM_CONFIG_UNSAFE_PERM=true +# add local files +COPY /root / + RUN \ echo "**** install build packages ****" && \ - apt-get update && \ - apt-get install -y \ + apk add --no-cache \ g++ \ gcc \ git \ + libgcc \ + libxml2-dev \ make \ - python && \ + nodejs \ + openssl-dev \ + python \ + tmux +RUN \ echo "**** Compile Cloud9 from source ****" && \ git clone --depth 1 \ https://github.com/c9/core.git c9sdk && \ cd c9sdk && \ + sed -i \ + 's/node-pty-prebuilt/node-pty/g' \ + plugins/node_modules/vfs-local/localfs.js && \ mkdir -p /c9bins && \ - HOME=/c9bins scripts/install-sdk.sh && \ + sed -i \ + '/$URL/c\bash /install.sh' \ + scripts/install-sdk.sh && \ + HOME=/c9bins scripts/install-sdk.sh +RUN \ echo "**** Restructure files for copy ****" && \ mkdir -p \ /buildout && \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 488cca8..2ddefb7 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,4 +1,4 @@ -FROM lsiobase/ubuntu:arm64v8-bionic +FROM lsiobase/alpine:arm64v8-3.9 # set version label ARG BUILD_DATE @@ -7,21 +7,36 @@ LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DA LABEL maintainer="thelamer" ARG NPM_CONFIG_UNSAFE_PERM=true +# add local files +COPY /root / + RUN \ echo "**** install build packages ****" && \ - apt-get update && \ - apt-get install -y \ + apk add --no-cache \ g++ \ gcc \ git \ + libgcc \ + libxml2-dev \ make \ - python && \ + nodejs \ + openssl-dev \ + python \ + tmux +RUN \ echo "**** Compile Cloud9 from source ****" && \ git clone --depth 1 \ https://github.com/c9/core.git c9sdk && \ cd c9sdk && \ + sed -i \ + 's/node-pty-prebuilt/node-pty/g' \ + plugins/node_modules/vfs-local/localfs.js && \ mkdir -p /c9bins && \ - HOME=/c9bins scripts/install-sdk.sh && \ + sed -i \ + '/$URL/c\bash /install.sh' \ + scripts/install-sdk.sh && \ + HOME=/c9bins scripts/install-sdk.sh +RUN \ echo "**** Restructure files for copy ****" && \ mkdir -p \ /buildout && \ diff --git a/Dockerfile.armhf b/Dockerfile.armhf index 00fff6c..f4978c3 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -1,4 +1,4 @@ -FROM lsiobase/ubuntu:arm32v7-bionic +FROM lsiobase/alpine:arm32v7-3.9 # set version label ARG BUILD_DATE @@ -7,21 +7,36 @@ LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DA LABEL maintainer="thelamer" ARG NPM_CONFIG_UNSAFE_PERM=true +# add local files +COPY /root / + RUN \ echo "**** install build packages ****" && \ - apt-get update && \ - apt-get install -y \ + apk add --no-cache \ g++ \ gcc \ git \ + libgcc \ + libxml2-dev \ make \ - python && \ + nodejs \ + openssl-dev \ + python \ + tmux +RUN \ echo "**** Compile Cloud9 from source ****" && \ git clone --depth 1 \ https://github.com/c9/core.git c9sdk && \ cd c9sdk && \ + sed -i \ + 's/node-pty-prebuilt/node-pty/g' \ + plugins/node_modules/vfs-local/localfs.js && \ mkdir -p /c9bins && \ - HOME=/c9bins scripts/install-sdk.sh && \ + sed -i \ + '/$URL/c\bash /install.sh' \ + scripts/install-sdk.sh && \ + HOME=/c9bins scripts/install-sdk.sh +RUN \ echo "**** Restructure files for copy ****" && \ mkdir -p \ /buildout && \ diff --git a/Jenkinsfile b/Jenkinsfile index e38a77f..e41c850 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,9 +10,6 @@ pipeline { environment { BUILDS_DISCORD=credentials('build_webhook_url') GITHUB_TOKEN=credentials('498b4638-2d02-4ce5-832d-8a57d01d97ab') - EXT_GIT_BRANCH = 'master' - EXT_USER = 'c9' - EXT_REPO = 'core' BUILD_VERSION_ARG = 'CLOUD9_VERSION' LS_USER = 'linuxserver' LS_REPO = 'docker-baseimage-cloud9' @@ -20,16 +17,9 @@ pipeline { DOCKERHUB_IMAGE = 'lsiobase/cloud9' DEV_DOCKERHUB_IMAGE = 'lsiodev/cloud9-base' PR_DOCKERHUB_IMAGE = 'lspipepr/cloud9-base' - DIST_IMAGE = 'ubuntu' + DIST_IMAGE = 'alpine' MULTIARCH='true' - CI='true' - CI_WEB='false' - CI_PORT='8000' - CI_SSL='false' - CI_DELAY='120' - CI_DOCKERENV='TZ=US/Pacific' - CI_AUTH='user:password' - CI_WEBPATH='' + CI='false' } stages { // Setup all the basic environment variables needed for the build @@ -38,7 +28,7 @@ pipeline { script{ env.EXIT_STATUS = '' env.LS_RELEASE = sh( - script: '''docker run --rm alexeiled/skopeo sh -c 'skopeo inspect docker://docker.io/'${DOCKERHUB_IMAGE}':files 2>/dev/null' | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''', + script: '''docker run --rm alexeiled/skopeo sh -c 'skopeo inspect docker://docker.io/'${DOCKERHUB_IMAGE}':files-alpine 2>/dev/null' | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''', returnStdout: true).trim() env.LS_RELEASE_NOTES = sh( script: '''cat readme-vars.yml | awk -F \\" '/date: "[0-9][0-9].[0-9][0-9].[0-9][0-9]:/ {print $4;exit;}' | sed -E ':a;N;$!ba;s/\\r{0,1}\\n/\\\\n/g' ''', @@ -102,23 +92,16 @@ pipeline { /* ######################## External Release Tagging ######################## */ - // If this is a github commit trigger determine the current commit at head - stage("Set ENV github_commit"){ - steps{ - script{ - env.EXT_RELEASE = sh( - script: '''curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/commits/${EXT_GIT_BRANCH} | jq -r '. | .sha' | cut -c1-8 ''', - returnStdout: true).trim() - } - } - } - // If this is a github commit trigger Set the external release link - stage("Set ENV commit_link"){ - steps{ - script{ - env.RELEASE_LINK = 'https://github.com/' + env.EXT_USER + '/' + env.EXT_REPO + '/commit/' + env.EXT_RELEASE - } - } + // If this is a custom command to determine version use that command + stage("Set tag custom bash"){ + steps{ + script{ + env.EXT_RELEASE = sh( + script: ''' echo c4d1c59d-alpine ''', + returnStdout: true).trim() + env.RELEASE_LINK = 'custom_command' + } + } } // Sanitize the release tag and strip illegal docker or github characters stage("Sanitize tag"){ @@ -130,10 +113,10 @@ pipeline { } } } - // If this is a files build use live docker endpoints + // If this is a files-alpine build use live docker endpoints stage("Set ENV live build"){ when { - branch "files" + branch "files-alpine" environment name: 'CHANGE_ID', value: '' } steps { @@ -151,7 +134,7 @@ pipeline { // If this is a dev build use dev docker endpoints stage("Set ENV dev build"){ when { - not {branch "files"} + not {branch "files-alpine"} environment name: 'CHANGE_ID', value: '' } steps { @@ -218,7 +201,7 @@ pipeline { // Use helper containers to render templated files stage('Update-Templates') { when { - branch "files" + branch "files-alpine" environment name: 'CHANGE_ID', value: '' expression { env.CONTAINER_NAME != null @@ -229,15 +212,15 @@ pipeline { set -e TEMPDIR=$(mktemp -d) docker pull linuxserver/jenkins-builder:latest - docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=files -v ${TEMPDIR}:/ansible/jenkins linuxserver/jenkins-builder:latest + docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=files-alpine -v ${TEMPDIR}:/ansible/jenkins linuxserver/jenkins-builder:latest docker pull linuxserver/doc-builder:latest - docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=files -v ${TEMPDIR}:/ansible/readme linuxserver/doc-builder:latest + docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=files-alpine -v ${TEMPDIR}:/ansible/readme linuxserver/doc-builder:latest if [ "$(md5sum ${TEMPDIR}/${LS_REPO}/Jenkinsfile | awk '{ print $1 }')" != "$(md5sum Jenkinsfile | awk '{ print $1 }')" ] || \ [ "$(md5sum ${TEMPDIR}/${CONTAINER_NAME}/README.md | awk '{ print $1 }')" != "$(md5sum README.md | awk '{ print $1 }')" ] || \ [ "$(cat ${TEMPDIR}/${LS_REPO}/LICENSE | md5sum | cut -c1-8)" != "${LICENSE_TAG}" ]; then mkdir -p ${TEMPDIR}/repo git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO} - git --git-dir ${TEMPDIR}/repo/${LS_REPO}/.git checkout -f files + git --git-dir ${TEMPDIR}/repo/${LS_REPO}/.git checkout -f files-alpine cp ${TEMPDIR}/${CONTAINER_NAME}/README.md ${TEMPDIR}/repo/${LS_REPO}/ cp ${TEMPDIR}/docker-${CONTAINER_NAME}/Jenkinsfile ${TEMPDIR}/repo/${LS_REPO}/ cp ${TEMPDIR}/docker-${CONTAINER_NAME}/LICENSE ${TEMPDIR}/repo/${LS_REPO}/ @@ -269,7 +252,7 @@ pipeline { // Exit the build if the Templated files were just updated stage('Template-exit') { when { - branch "files" + branch "files-alpine" environment name: 'CHANGE_ID', value: '' environment name: 'FILES_UPDATED', value: 'true' expression { @@ -311,7 +294,7 @@ pipeline { } stage('Build ARMHF') { agent { - label 'ARMHF' + label 'X86-64-MULTI' } steps { withCredentials([ @@ -338,7 +321,7 @@ pipeline { } stage('Build ARM64') { agent { - label 'ARM64' + label 'X86-64-MULTI' } steps { withCredentials([ @@ -365,89 +348,6 @@ pipeline { } } } - // Take the image we just built and dump package versions for comparison - stage('Update-packages') { - when { - branch "files" - environment name: 'CHANGE_ID', value: '' - environment name: 'EXIT_STATUS', value: '' - } - steps { - sh '''#! /bin/bash - set -e - TEMPDIR=$(mktemp -d) - if [ "${MULTIARCH}" == "true" ]; then - LOCAL_CONTAINER=${IMAGE}:amd64-${META_TAG} - else - LOCAL_CONTAINER=${IMAGE}:${META_TAG} - fi - if [ "${DIST_IMAGE}" == "alpine" ]; then - docker run --rm --entrypoint '/bin/sh' -v ${TEMPDIR}:/tmp ${LOCAL_CONTAINER} -c '\ - apk info -v > /tmp/package_versions.txt && \ - sort -o /tmp/package_versions.txt /tmp/package_versions.txt && \ - chmod 777 /tmp/package_versions.txt' - elif [ "${DIST_IMAGE}" == "ubuntu" ]; then - docker run --rm --entrypoint '/bin/sh' -v ${TEMPDIR}:/tmp ${LOCAL_CONTAINER} -c '\ - apt list -qq --installed | sed "s#/.*now ##g" | cut -d" " -f1 > /tmp/package_versions.txt && \ - sort -o /tmp/package_versions.txt /tmp/package_versions.txt && \ - chmod 777 /tmp/package_versions.txt' - fi - NEW_PACKAGE_TAG=$(md5sum ${TEMPDIR}/package_versions.txt | cut -c1-8 ) - echo "Package tag sha from current packages in buit container is ${NEW_PACKAGE_TAG} comparing to old ${PACKAGE_TAG} from github" - if [ "${NEW_PACKAGE_TAG}" != "${PACKAGE_TAG}" ]; then - git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/${LS_REPO} - git --git-dir ${TEMPDIR}/${LS_REPO}/.git checkout -f files - cp ${TEMPDIR}/package_versions.txt ${TEMPDIR}/${LS_REPO}/ - cd ${TEMPDIR}/${LS_REPO}/ - wait - git add package_versions.txt - git commit -m 'Bot Updating Package Versions' - git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all - echo "true" > /tmp/packages-${COMMIT_SHA}-${BUILD_NUMBER} - echo "Package tag updated, stopping build process" - else - echo "false" > /tmp/packages-${COMMIT_SHA}-${BUILD_NUMBER} - echo "Package tag is same as previous continue with build process" - fi - rm -Rf ${TEMPDIR}''' - script{ - env.PACKAGE_UPDATED = sh( - script: '''cat /tmp/packages-${COMMIT_SHA}-${BUILD_NUMBER}''', - returnStdout: true).trim() - } - } - } - // Exit the build if the package file was just updated - stage('PACKAGE-exit') { - when { - branch "files" - environment name: 'CHANGE_ID', value: '' - environment name: 'PACKAGE_UPDATED', value: 'true' - environment name: 'EXIT_STATUS', value: '' - } - steps { - script{ - env.EXIT_STATUS = 'ABORTED' - } - } - } - // Exit the build if this is just a package check and there are no changes to push - stage('PACKAGECHECK-exit') { - when { - branch "files" - environment name: 'CHANGE_ID', value: '' - environment name: 'PACKAGE_UPDATED', value: 'false' - environment name: 'EXIT_STATUS', value: '' - expression { - params.PACKAGE_CHECK == 'true' - } - } - steps { - script{ - env.EXIT_STATUS = 'ABORTED' - } - } - } /* ####### Testing ####### */ @@ -475,6 +375,7 @@ pipeline { docker tag lsiodev/buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} ${IMAGE}:arm64v8-${META_TAG} fi docker run --rm \ + --shm-size=1gb \ -v /var/run/docker.sock:/var/run/docker.sock \ -e IMAGE=\"${IMAGE}\" \ -e DELAY_START=\"${CI_DELAY}\" \ @@ -518,12 +419,12 @@ pipeline { sh '''#! /bin/bash echo $DOCKERPASS | docker login -u $DOCKERUSER --password-stdin ''' - sh "docker tag ${IMAGE}:${META_TAG} ${IMAGE}:files" - sh "docker push ${IMAGE}:files" + sh "docker tag ${IMAGE}:${META_TAG} ${IMAGE}:files-alpine" + sh "docker push ${IMAGE}:files-alpine" sh "docker push ${IMAGE}:${META_TAG}" sh '''docker rmi \ ${IMAGE}:${META_TAG} \ - ${IMAGE}:files || :''' + ${IMAGE}:files-alpine || :''' } } @@ -553,24 +454,24 @@ pipeline { docker tag lsiodev/buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} ${IMAGE}:arm32v7-${META_TAG} docker tag lsiodev/buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} ${IMAGE}:arm64v8-${META_TAG} fi''' - sh "docker tag ${IMAGE}:amd64-${META_TAG} ${IMAGE}:amd64-files" - sh "docker tag ${IMAGE}:arm32v7-${META_TAG} ${IMAGE}:arm32v7-files" - sh "docker tag ${IMAGE}:arm64v8-${META_TAG} ${IMAGE}:arm64v8-files" + sh "docker tag ${IMAGE}:amd64-${META_TAG} ${IMAGE}:amd64-files-alpine" + sh "docker tag ${IMAGE}:arm32v7-${META_TAG} ${IMAGE}:arm32v7-files-alpine" + sh "docker tag ${IMAGE}:arm64v8-${META_TAG} ${IMAGE}:arm64v8-files-alpine" sh "docker push ${IMAGE}:amd64-${META_TAG}" sh "docker push ${IMAGE}:arm32v7-${META_TAG}" sh "docker push ${IMAGE}:arm64v8-${META_TAG}" - sh "docker push ${IMAGE}:amd64-files" - sh "docker push ${IMAGE}:arm32v7-files" - sh "docker push ${IMAGE}:arm64v8-files" - sh "docker manifest push --purge ${IMAGE}:files || :" - sh "docker manifest create ${IMAGE}:files ${IMAGE}:amd64-files ${IMAGE}:arm32v7-files ${IMAGE}:arm64v8-files" - sh "docker manifest annotate ${IMAGE}:files ${IMAGE}:arm32v7-files --os linux --arch arm" - sh "docker manifest annotate ${IMAGE}:files ${IMAGE}:arm64v8-files --os linux --arch arm64 --variant v8" + sh "docker push ${IMAGE}:amd64-files-alpine" + sh "docker push ${IMAGE}:arm32v7-files-alpine" + sh "docker push ${IMAGE}:arm64v8-files-alpine" + sh "docker manifest push --purge ${IMAGE}:files-alpine || :" + sh "docker manifest create ${IMAGE}:files-alpine ${IMAGE}:amd64-files-alpine ${IMAGE}:arm32v7-files-alpine ${IMAGE}:arm64v8-files-alpine" + sh "docker manifest annotate ${IMAGE}:files-alpine ${IMAGE}:arm32v7-files-alpine --os linux --arch arm" + sh "docker manifest annotate ${IMAGE}:files-alpine ${IMAGE}:arm64v8-files-alpine --os linux --arch arm64 --variant v8" sh "docker manifest push --purge ${IMAGE}:${META_TAG} || :" sh "docker manifest create ${IMAGE}:${META_TAG} ${IMAGE}:amd64-${META_TAG} ${IMAGE}:arm32v7-${META_TAG} ${IMAGE}:arm64v8-${META_TAG}" sh "docker manifest annotate ${IMAGE}:${META_TAG} ${IMAGE}:arm32v7-${META_TAG} --os linux --arch arm" sh "docker manifest annotate ${IMAGE}:${META_TAG} ${IMAGE}:arm64v8-${META_TAG} --os linux --arch arm64 --variant v8" - sh "docker manifest push --purge ${IMAGE}:files" + sh "docker manifest push --purge ${IMAGE}:files-alpine" sh "docker manifest push --purge ${IMAGE}:${META_TAG}" } } @@ -578,7 +479,7 @@ pipeline { // If this is a public release tag it in the LS Github stage('Github-Tag-Push-Release') { when { - branch "files" + branch "files-alpine" expression { env.LS_RELEASE != env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER } @@ -590,16 +491,16 @@ pipeline { sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/git/tags \ -d '{"tag":"'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\ "object": "'${COMMIT_SHA}'",\ - "message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to files",\ + "message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to files-alpine",\ "type": "commit",\ "tagger": {"name": "LinuxServer Jenkins","email": "jenkins@linuxserver.io","date": "'${GITHUB_DATE}'"}}' ''' echo "Pushing New release for Tag" sh '''#! /bin/bash - curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/commits/${EXT_GIT_BRANCH} | jq '. | .commit.message' | sed 's:^.\\(.*\\).$:\\1:' > releasebody.json + echo "Updating to ${EXT_RELEASE_CLEAN}" > releasebody.json echo '{"tag_name":"'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\ - "target_commitish": "files",\ + "target_commitish": "files-alpine",\ "name": "'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\ - "body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**'${EXT_REPO}' Changes:**\\n\\n' > start + "body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**Remote Changes:**\\n\\n' > start printf '","draft": false,"prerelease": true}' >> releasebody.json paste -d'\\0' start releasebody.json > releasebody.json.done curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done''' diff --git a/jenkins-vars.yml b/jenkins-vars.yml index d312318..57136f7 100644 --- a/jenkins-vars.yml +++ b/jenkins-vars.yml @@ -2,14 +2,14 @@ # jenkins variables project_name: docker-baseimage-cloud9 -external_type: github_commit +external_type: na +custom_version_command: "echo c4d1c59d-alpine" release_type: prerelease -release_tag: files -ls_branch: files +release_tag: files-alpine +ls_branch: files-alpine +skip_package_check: true +use_qemu: true repo_vars: - - EXT_GIT_BRANCH = 'master' - - EXT_USER = 'c9' - - EXT_REPO = 'core' - BUILD_VERSION_ARG = 'CLOUD9_VERSION' - LS_USER = 'linuxserver' - LS_REPO = 'docker-baseimage-cloud9' @@ -17,13 +17,6 @@ repo_vars: - DOCKERHUB_IMAGE = 'lsiobase/cloud9' - DEV_DOCKERHUB_IMAGE = 'lsiodev/cloud9-base' - PR_DOCKERHUB_IMAGE = 'lspipepr/cloud9-base' - - DIST_IMAGE = 'ubuntu' + - DIST_IMAGE = 'alpine' - MULTIARCH='true' - - CI='true' - - CI_WEB='false' - - CI_PORT='8000' - - CI_SSL='false' - - CI_DELAY='120' - - CI_DOCKERENV='TZ=US/Pacific' - - CI_AUTH='user:password' - - CI_WEBPATH='' + - CI='false' diff --git a/package_versions.txt b/package_versions.txt deleted file mode 100755 index a15e5fe..0000000 --- a/package_versions.txt +++ /dev/null @@ -1,196 +0,0 @@ -adduser3.116ubuntu1 -apt1.6.10 -apt-utils1.6.10 -base-files10.1ubuntu2.4 -base-passwd3.5.44 -bash4.4.18-2ubuntu1.1 -binutils2.30-21ubuntu1~18.04.1 -binutils-common2.30-21ubuntu1~18.04.1 -binutils-x86-64-linux-gnu2.30-21ubuntu1~18.04.1 -bsdutils1:2.31.1-0.4ubuntu3.3 -bzip21.0.6-8.1 -ca-certificates20180409 -coreutils8.28-1ubuntu1 -cpp4:7.4.0-1ubuntu2.2 -cpp-77.4.0-1ubuntu1~18.04 -curl7.58.0-2ubuntu3.7 -dash0.5.8-2.10 -debconf1.5.66ubuntu1 -debianutils4.8.4 -diffutils1:3.6-1 -dpkg1.19.0.5ubuntu2.1 -e2fsprogs1.44.1-1ubuntu1.1 -fdisk2.31.1-0.4ubuntu3.3 -file1:5.32-2ubuntu0.2 -findutils4.6.0+git+20170828-2 -g++4:7.4.0-1ubuntu2.2 -g++-77.4.0-1ubuntu1~18.04 -gcc4:7.4.0-1ubuntu2.2 -gcc-77.4.0-1ubuntu1~18.04 -gcc-7-base7.4.0-1ubuntu1~18.04 -gcc-8-base8.3.0-6ubuntu1~18.04 -git1:2.17.1-1ubuntu0.4 -git-man1:2.17.1-1ubuntu0.4 -gpgv2.2.4-1ubuntu1.2 -grep3.1-2 -gzip1.6-5ubuntu1 -hostname3.20 -init-system-helpers1.51 -krb5-locales1.16-2ubuntu0.1 -less487-0.1 -libacl12.2.52-3build1 -libapt-inst2.01.6.10 -libapt-pkg5.01.6.10 -libasan47.4.0-1ubuntu1~18.04 -libasn1-8-heimdal7.5.0+dfsg-1 -libatomic18.3.0-6ubuntu1~18.04 -libattr11:2.4.47-2build1 -libaudit11:2.8.2-1ubuntu1 -libaudit-common1:2.8.2-1ubuntu1 -libbinutils2.30-21ubuntu1~18.04.1 -libblkid12.31.1-0.4ubuntu3.3 -libbsd00.8.7-1 -libbz2-1.01.0.6-8.1 -libc62.27-3ubuntu1 -libc6-dev2.27-3ubuntu1 -libcap-ng00.7.7-3.1 -libc-bin2.27-3ubuntu1 -libcc1-08.3.0-6ubuntu1~18.04 -libc-dev-bin2.27-3ubuntu1 -libcilkrts57.4.0-1ubuntu1~18.04 -libcom-err21.44.1-1ubuntu1.1 -libcurl3-gnutls7.58.0-2ubuntu3.7 -libcurl47.58.0-2ubuntu3.7 -libdb5.35.3.28-13.1ubuntu1 -libdebconfclient00.213ubuntu1 -libedit23.1-20170329-1 -liberror-perl0.17025-1 -libexpat12.2.5-3 -libext2fs21.44.1-1ubuntu1.1 -libfdisk12.31.1-0.4ubuntu3.3 -libffi63.2.1-8 -libgcc11:8.3.0-6ubuntu1~18.04 -libgcc-7-dev7.4.0-1ubuntu1~18.04 -libgcrypt201.8.1-4ubuntu1.1 -libgdbm51.14.1-6 -libgdbm-compat41.14.1-6 -libgmp102:6.1.2+dfsg-2 -libgnutls303.5.18-1ubuntu1 -libgomp18.3.0-6ubuntu1~18.04 -libgpg-error01.27-6 -libgssapi3-heimdal7.5.0+dfsg-1 -libgssapi-krb5-21.16-2ubuntu0.1 -libhcrypto4-heimdal7.5.0+dfsg-1 -libheimbase1-heimdal7.5.0+dfsg-1 -libheimntlm0-heimdal7.5.0+dfsg-1 -libhogweed43.4-1 -libhx509-5-heimdal7.5.0+dfsg-1 -libidn2-02.0.4-1.1build2 -libisl190.19-1 -libitm18.3.0-6ubuntu1~18.04 -libk5crypto31.16-2ubuntu0.1 -libkeyutils11.5.9-9.2ubuntu2 -libkrb5-26-heimdal7.5.0+dfsg-1 -libkrb5-31.16-2ubuntu0.1 -libkrb5support01.16-2ubuntu0.1 -libldap-2.4-22.4.45+dfsg-1ubuntu1.2 -libldap-common2.4.45+dfsg-1ubuntu1.2 -liblsan08.3.0-6ubuntu1~18.04 -liblz4-10.0~r131-2ubuntu3 -liblzma55.2.2-1.3 -libmagic11:5.32-2ubuntu0.2 -libmagic-mgc1:5.32-2ubuntu0.2 -libmount12.31.1-0.4ubuntu3.3 -libmpc31.1.0-1 -libmpfr64.0.1-1 -libmpx28.3.0-6ubuntu1~18.04 -libncurses56.1-1ubuntu1.18.04 -libncursesw56.1-1ubuntu1.18.04 -libnettle63.4-1 -libnghttp2-141.30.0-1ubuntu1 -libp11-kit00.23.9-2 -libpam0g1.1.8-3.6ubuntu2.18.04.1 -libpam-modules1.1.8-3.6ubuntu2.18.04.1 -libpam-modules-bin1.1.8-3.6ubuntu2.18.04.1 -libpam-runtime1.1.8-3.6ubuntu2.18.04.1 -libpcre32:8.39-9 -libperl5.265.26.1-6ubuntu0.3 -libprocps62:3.3.12-3ubuntu1.1 -libpsl50.19.1-5build1 -libpython2.7-minimal2.7.15~rc1-1ubuntu0.1 -libpython2.7-stdlib2.7.15~rc1-1ubuntu0.1 -libpython-stdlib2.7.15~rc1-1 -libquadmath08.3.0-6ubuntu1~18.04 -libreadline77.0-3 -libroken18-heimdal7.5.0+dfsg-1 -librtmp12.4+20151223.gitfa8646d.1-1 -libsasl2-22.1.27~101-g0780600+dfsg-3ubuntu2 -libsasl2-modules2.1.27~101-g0780600+dfsg-3ubuntu2 -libsasl2-modules-db2.1.27~101-g0780600+dfsg-3ubuntu2 -libseccomp22.3.1-2.1ubuntu4.1 -libselinux12.7-2build2 -libsemanage12.7-2build2 -libsemanage-common2.7-2build2 -libsepol12.7-1 -libsmartcols12.31.1-0.4ubuntu3.3 -libsqlite3-03.22.0-1 -libss21.44.1-1ubuntu1.1 -libssl1.0.01.0.2n-1ubuntu5.3 -libssl1.11.1.0g-2ubuntu4.3 -libstdc++68.3.0-6ubuntu1~18.04 -libstdc++-7-dev7.4.0-1ubuntu1~18.04 -libsystemd0237-3ubuntu10.21 -libtasn1-64.13-2 -libtinfo56.1-1ubuntu1.18.04 -libtsan08.3.0-6ubuntu1~18.04 -libubsan07.4.0-1ubuntu1~18.04 -libudev1237-3ubuntu10.21 -libunistring20.9.9-0ubuntu2 -libuuid12.31.1-0.4ubuntu3.3 -libwind0-heimdal7.5.0+dfsg-1 -libx11-62:1.6.4-3ubuntu0.2 -libx11-data2:1.6.4-3ubuntu0.2 -libxau61:1.0.8-1 -libxcb11.13-2~ubuntu18.04 -libxdmcp61:1.1.2-3 -libxext62:1.3.3-1 -libxmuu12:1.1.2-2 -libzstd11.3.3+dfsg-2ubuntu1 -linux-libc-dev4.15.0-50.54 -locales2.27-3ubuntu1 -login1:4.5-1ubuntu2 -lsb-base9.20170808ubuntu1 -make4.1-9.1ubuntu1 -manpages4.15-1 -manpages-dev4.15-1 -mawk1.3.3-17ubuntu3 -mime-support3.60ubuntu1 -mount2.31.1-0.4ubuntu3.3 -multiarch-support2.27-3ubuntu1 -ncurses-base6.1-1ubuntu1.18.04 -ncurses-bin6.1-1ubuntu1.18.04 -netbase5.4 -openssh-client1:7.6p1-4ubuntu0.3 -openssl1.1.0g-2ubuntu4.3 -passwd1:4.5-1ubuntu2 -patch2.7.6-2ubuntu1 -perl5.26.1-6ubuntu0.3 -perl-base5.26.1-6ubuntu0.3 -perl-modules-5.265.26.1-6ubuntu0.3 -procps2:3.3.12-3ubuntu1.1 -publicsuffix20180223.1310-1 -python2.7.15~rc1-1 -python2.72.7.15~rc1-1ubuntu0.1 -python2.7-minimal2.7.15~rc1-1ubuntu0.1 -python-minimal2.7.15~rc1-1 -readline-common7.0-3 -sed4.4-2 -sensible-utils0.0.12 -sysvinit-utils2.88dsf-59.10ubuntu1 -tar1.29b-2ubuntu0.1 -tzdata2019a-0ubuntu0.18.04 -ubuntu-keyring2018.09.18.1~18.04.0 -util-linux2.31.1-0.4ubuntu3.3 -xauth1:1.0.10-1 -xz-utils5.2.2-1.3 -zlib1g1:1.2.11.dfsg-0ubuntu2 diff --git a/root/install.sh b/root/install.sh new file mode 100644 index 0000000..185737e --- /dev/null +++ b/root/install.sh @@ -0,0 +1,367 @@ +#!/bin/bash -e +set -e +has() { + type "$1" > /dev/null 2>&1 +} + +# Redirect stdout ( > ) into a named pipe ( >() ) running "tee" +# exec > >(tee /tmp/installlog.txt) + +# Without this, only stdout would be captured - i.e. your +# log file would not contain any error messages. +exec 2>&1 + +if has "wget"; then + DOWNLOAD() { + wget --no-check-certificate -nc -O "$2" "$1" + } +elif has "curl"; then + DOWNLOAD() { + curl -sSL -o "$2" "$1" + } +else + echo "Error: you need curl or wget to proceed" >&2; + exit 1 +fi + +C9_DIR=$HOME/.c9 +if [[ ${1-} == -d ]]; then + C9_DIR=$2 + shift 2 +fi + +# Check if C9_DIR exists +if [ ! -d "$C9_DIR" ]; then + mkdir -p $C9_DIR +fi + +VERSION=1 +NODE_VERSION=v6.3.1 +NODE_VERSION_ARM_PI=v0.10.28 +NPM=$C9_DIR/node/bin/npm +NODE=$C9_DIR/node/bin/node + +export TMP=$C9_DIR/tmp +export TMPDIR=$TMP + +PYTHON=python + +# node-gyp uses sytem node or fails with command not found if +# we don't bump this node up in the path +PATH="$C9_DIR/node/bin/:$C9_DIR/node_modules/.bin:$PATH" + +start() { + if [ $# -lt 1 ]; then + start base + return + fi + + check_deps + + # Try to figure out the os and arch for binary fetching + local uname="$(uname -s)" + local os= + local arch="$(uname -m)" + case "$uname" in + Linux*) os=linux ;; + Darwin*) os=darwin ;; + SunOS*) os=sunos ;; + FreeBSD*) os=freebsd ;; + CYGWIN*) os=windows ;; + MINGW*) os=windows ;; + esac + case "$arch" in + *arm64*) arch=arm64 ;; + *aarch64*) arch=arm64 ;; + *armv6l*) arch=armv6l ;; + *armv7l*) arch=armv7l ;; + *x86_64*) arch=x64 ;; + *i*86*) arch=x86 ;; + *) + echo "Unsupported Architecture: $os $arch" 1>&2 + exit 1 + ;; + esac + + if [ "$arch" == "x64" ] && [[ $HOSTTYPE == i*86 ]]; then + arch=x86 # check if 32 bit bash is installed on 64 bit kernel + fi + + if [ "$os" != "linux" ] && [ "$os" != "darwin" ]; then + echo "Unsupported Platform: $os $arch" 1>&2 + exit 1 + fi + + case $1 in + "help" ) + echo + echo "Cloud9 Installer" + echo + echo "Usage:" + echo " install help Show this message" + echo " install install [name [name ...]] Download and install a set of packages" + echo " install ls List available packages" + echo + ;; + + "ls" ) + echo "!node - Node.js" + echo "!tmux - TMUX" + echo "!nak - NAK" + echo "!ptyjs - pty.js" + echo "!collab - collab" + echo "coffee - Coffee Script" + echo "less - Less" + echo "sass - Sass" + echo "typescript - TypeScript" + echo "stylus - Stylus" + # echo "go - Go" + # echo "heroku - Heroku" + # echo "rhc - RedHat OpenShift" + # echo "gae - Google AppEngine" + ;; + + "install" ) + shift + + # make sure dirs are around + mkdir -p "$C9_DIR"/bin + mkdir -p "$C9_DIR"/tmp + mkdir -p "$C9_DIR"/node_modules + + # install packages + while [ $# -ne 0 ] + do + if [ "$1" == "tmux" ]; then + cd "$C9_DIR" + time tmux_install $os $arch + shift + continue + fi + cd "$C9_DIR" + time eval ${1} $os $arch + shift + done + + # finalize + pushd "$C9_DIR"/node_modules/.bin + for FILE in "$C9_DIR"/node_modules/.bin/*; do + FILE=$(readlink "$FILE") + # can't use the -i flag since it is not compatible between bsd and gnu versions + sed -e's/#!\/usr\/bin\/env node/#!'"${NODE//\//\\/}/" "$FILE" > "$FILE.tmp-sed" + mv "$FILE.tmp-sed" "$FILE" + done + popd + + echo $VERSION > "$C9_DIR"/installed + + cd "$C9_DIR" + DOWNLOAD https://raw.githubusercontent.com/c9/install/master/packages/license-notice.md "Third-Party Licensing Notices.md" + + echo :Done. + ;; + + "base" ) + echo "Installing base packages. Use --help for more options" + start install node tmux_install nak ptyjs collab + ;; + + * ) + start base + ;; + esac +} + +check_deps() { + local ERR + local OS + + if [[ `cat /etc/os-release 2>/dev/null` =~ CentOS ]]; then + OS="CentOS" + elif [[ `cat /proc/version 2>/dev/null` =~ Ubuntu|Debian ]]; then + OS="DEBIAN" + fi + + for DEP in make gcc; do + if ! has $DEP; then + echo "Error: please install $DEP to proceed" >&2 + if [ "$OS" == "CentOS" ]; then + echo "To do so, log into your machine and type 'yum groupinstall -y development'" >&2 + elif [ "$OS" == "DEBIAN" ]; then + echo "To do so, log into your machine and type 'sudo apt-get install build-essential'" >&2 + fi + ERR=1 + fi + done + + # CentOS + if [ "$OS" == "CentOS" ]; then + if ! yum list installed glibc-static >/dev/null 2>&1; then + echo "Error: please install glibc-static to proceed" >&2 + echo "To do so, log into your machine and type 'yum install glibc-static'" >&2 + ERR=1 + fi + fi + + check_python + + if [ "$ERR" ]; then exit 1; fi +} + +check_python() { + if type -P python2.7 &> /dev/null; then + PYTHONVERSION="2.7" + PYTHON="python2.7" + elif type -P python &> /dev/null; then + PYTHONVERSION=`python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))'` + PYTHON="python" + fi + + if [[ $PYTHONVERSION != "2.7" ]]; then + echo "Python version 2.7 is required to install pty.js. Please install python 2.7 and try again. You can find more information on how to install Python in the docs: https://docs.c9.io/ssh_workspaces.html" + exit 100 + fi +} + +# NodeJS + +download_virtualenv() { + VIRTUALENV_VERSION="virtualenv-12.0.7" + DOWNLOAD "https://pypi.python.org/packages/source/v/virtualenv/$VIRTUALENV_VERSION.tar.gz" $VIRTUALENV_VERSION.tar.gz + tar xzf $VIRTUALENV_VERSION.tar.gz + rm $VIRTUALENV_VERSION.tar.gz + mv $VIRTUALENV_VERSION virtualenv +} + +ensure_local_gyp() { + # when gyp is installed globally npm install pty.js won't work + # to test this use `sudo apt-get install gyp` + if [ `"$PYTHON" -c 'import gyp; print gyp.__file__' 2> /dev/null` ]; then + echo "You have a global gyp installed. Setting up VirtualEnv without global pakages" + rm -rf virtualenv + rm -rf python + if has virtualenv; then + virtualenv -p python2 "$C9_DIR/python" + else + download_virtualenv + "$PYTHON" virtualenv/virtualenv.py "$C9_DIR/python" + fi + if [[ -f "$C9_DIR/python/bin/python2" ]]; then + PYTHON="$C9_DIR/python/bin/python2" + else + echo "Unable to setup virtualenv" + exit 1 + fi + fi + "$NPM" config -g set python "$PYTHON" + "$NPM" config -g set unsafe-perm true + + local GYP_PATH=$C9_DIR/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js + if [ -f "$GYP_PATH" ]; then + ln -s "$GYP_PATH" "$C9_DIR"/node/bin/node-gyp &> /dev/null || : + fi +} + +node(){ + echo :Installing Node $NODE_VERSION + + + DOWNLOAD https://nodejs.org/dist/"$NODE_VERSION/node-$NODE_VERSION-$1-$2.tar.gz" node.tar.gz + tar xzf node.tar.gz + mv "node-$NODE_VERSION-$1-$2" node + rm -f node.tar.gz + + cp /usr/bin/node /c9bins/.c9/node/bin/ + + # use local npm cache + "$NPM" config -g set cache "$C9_DIR/tmp/.npm" + ensure_local_gyp + +} + +tmux_install(){ + mkdir -p /c9bins/.c9/bin/ + cp /usr/bin/tmux /c9bins/.c9/bin/tmux +} + +collab(){ + echo :Installing Collab Dependencies + "$NPM" cache clean + "$NPM" install sqlite3 + "$NPM" install sequelize@2.0.0-beta.0 + mkdir -p "$C9_DIR"/lib + cd "$C9_DIR"/lib + DOWNLOAD https://raw.githubusercontent.com/c9/install/master/packages/sqlite3/linux/sqlite3.tar.gz sqlite3.tar.gz + tar xzf sqlite3.tar.gz + rm sqlite3.tar.gz + ln -sf "$C9_DIR"/lib/sqlite3/sqlite3 "$C9_DIR"/bin/sqlite3 +} + +nak(){ + echo :Installing Nak + "$NPM" install https://github.com/c9/nak/tarball/c9 +} + +ptyjs(){ + echo :Installing pty.js + "$NPM" install node-pty + + if ! hasPty; then + echo "Unknown exception installing pty.js" + "$C9_DIR/node/bin/node" -e "console.log(require('node-pty'))" + exit 100 + fi +} + +hasPty() { + local HASPTY=$("$C9_DIR/node/bin/node" -p "typeof require('node-pty').createTerminal=='function'" 2> /dev/null) + if [ "$HASPTY" != true ]; then + return 1 + fi +} + +coffee(){ + echo :Installing Coffee Script + "$NPM" install coffee +} + +less(){ + echo :Installing Less + "$NPM" install less +} + +sass(){ + echo :Installing Sass + "$NPM" install sass +} + +typescript(){ + echo :Installing TypeScript + "$NPM" install typescript +} + +stylus(){ + echo :Installing Stylus + "$NPM" install stylus +} + +# go(){ + +# } + +# heroku(){ + +# } + +# rhc(){ + +# } + +# gae(){ + +# } + +start "$@" + +# cleanup tmp files +rm -rf "$C9_DIR/tmp"