From 8f23de8376ce42f34112e84fb9de4a649971b225 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Tue, 4 Feb 2020 08:34:24 +1000 Subject: [PATCH] Initial commit --- .gitignore | 11 ++++ Jenkinsfile.debian10 | 50 +++++++++++++++ Jenkinsfile.debian9 | 50 +++++++++++++++ Jenkinsfile.mint19 | 50 +++++++++++++++ Jenkinsfile.ubuntu-bionic | 50 +++++++++++++++ Jenkinsfile.ubuntu-eoan | 50 +++++++++++++++ README.md | 3 + build | 128 ++++++++++++++++++++++++++++++++++++++ debian/README | 6 ++ debian/changelog | 3 + debian/changelog.upstream | 4 ++ debian/compat | 1 + debian/control | 21 +++++++ debian/install | 1 + debian/rules | 28 +++++++++ debian/source/format | 1 + debian/versions.upstream | 1 + dpkg.json | 10 +++ 18 files changed, 468 insertions(+) create mode 100644 .gitignore create mode 100644 Jenkinsfile.debian10 create mode 100644 Jenkinsfile.debian9 create mode 100644 Jenkinsfile.mint19 create mode 100644 Jenkinsfile.ubuntu-bionic create mode 100644 Jenkinsfile.ubuntu-eoan create mode 100644 README.md create mode 100755 build create mode 100644 debian/README create mode 100644 debian/changelog create mode 100644 debian/changelog.upstream create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/install create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 debian/versions.upstream create mode 100644 dpkg.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39c651f --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +.idea +._* +.DS_Store +RPMS +SRPMS +DEPS +BUILD +BUILDROOT +*.swp +sign +starship* diff --git a/Jenkinsfile.debian10 b/Jenkinsfile.debian10 new file mode 100644 index 0000000..3bfc02c --- /dev/null +++ b/Jenkinsfile.debian10 @@ -0,0 +1,50 @@ +pipeline { + options { + buildDiscarder(logRotator(numToKeepStr: '10')) + disableConcurrentBuilds() + } + agent { + label 'dpkg' + } + stages { + stage('Prepare') { + steps { + ansiColor('xterm') { + sh 'rm -rf sign' + sh 'mkdir -p sign' + + dir(path: 'sign') { + git(url: "${RPM_SIGN_GIT_REPO}", credentialsId: "${RPM_SIGN_CREDENTIALS_ID}") + sh 'chmod 600 .gnupg/*' + } + } + } + } + stage('Build') { + steps { + ansiColor('xterm') { + sh './build debian 10-rust' + } + } + } + stage('Publish') { + steps { + script { + def Dpkg = readJSON file: 'dpkg.json' + archiveArtifacts(artifacts: "${Dpkg.PACKAGE}*.*", caseSensitive: true, onlyIfSuccessful: true) + dpkgGithubRelease('debian10') + } + } + } + } + post { + success { + juxtapose event: 'success' + sh 'figlet "SUCCESS"' + } + failure { + juxtapose event: 'failure' + sh 'figlet "FAILURE"' + } + } +} diff --git a/Jenkinsfile.debian9 b/Jenkinsfile.debian9 new file mode 100644 index 0000000..099d7f4 --- /dev/null +++ b/Jenkinsfile.debian9 @@ -0,0 +1,50 @@ +pipeline { + options { + buildDiscarder(logRotator(numToKeepStr: '10')) + disableConcurrentBuilds() + } + agent { + label 'dpkg' + } + stages { + stage('Prepare') { + steps { + ansiColor('xterm') { + sh 'rm -rf sign' + sh 'mkdir -p sign' + + dir(path: 'sign') { + git(url: "${RPM_SIGN_GIT_REPO}", credentialsId: "${RPM_SIGN_CREDENTIALS_ID}") + sh 'chmod 600 .gnupg/*' + } + } + } + } + stage('Build') { + steps { + ansiColor('xterm') { + sh './build debian 9-rust' + } + } + } + stage('Publish') { + steps { + script { + def Dpkg = readJSON file: 'dpkg.json' + archiveArtifacts(artifacts: "${Dpkg.PACKAGE}*.*", caseSensitive: true, onlyIfSuccessful: true) + dpkgGithubRelease('debian9') + } + } + } + } + post { + success { + juxtapose event: 'success' + sh 'figlet "SUCCESS"' + } + failure { + juxtapose event: 'failure' + sh 'figlet "FAILURE"' + } + } +} diff --git a/Jenkinsfile.mint19 b/Jenkinsfile.mint19 new file mode 100644 index 0000000..46c5636 --- /dev/null +++ b/Jenkinsfile.mint19 @@ -0,0 +1,50 @@ +pipeline { + options { + buildDiscarder(logRotator(numToKeepStr: '10')) + disableConcurrentBuilds() + } + agent { + label 'dpkg' + } + stages { + stage('Prepare') { + steps { + ansiColor('xterm') { + sh 'rm -rf sign' + sh 'mkdir -p sign' + + dir(path: 'sign') { + git(url: "${RPM_SIGN_GIT_REPO}", credentialsId: "${RPM_SIGN_CREDENTIALS_ID}") + sh 'chmod 600 .gnupg/*' + } + } + } + } + stage('Build') { + steps { + ansiColor('xterm') { + sh './build mint 19-rust' + } + } + } + stage('Publish') { + steps { + script { + def Dpkg = readJSON file: 'dpkg.json' + archiveArtifacts(artifacts: "${Dpkg.PACKAGE}*.*", caseSensitive: true, onlyIfSuccessful: true) + dpkgGithubRelease('mint19') + } + } + } + } + post { + success { + juxtapose event: 'success' + sh 'figlet "SUCCESS"' + } + failure { + juxtapose event: 'failure' + sh 'figlet "FAILURE"' + } + } +} diff --git a/Jenkinsfile.ubuntu-bionic b/Jenkinsfile.ubuntu-bionic new file mode 100644 index 0000000..436d744 --- /dev/null +++ b/Jenkinsfile.ubuntu-bionic @@ -0,0 +1,50 @@ +pipeline { + options { + buildDiscarder(logRotator(numToKeepStr: '10')) + disableConcurrentBuilds() + } + agent { + label 'dpkg' + } + stages { + stage('Prepare') { + steps { + ansiColor('xterm') { + sh 'rm -rf sign' + sh 'mkdir -p sign' + + dir(path: 'sign') { + git(url: "${RPM_SIGN_GIT_REPO}", credentialsId: "${RPM_SIGN_CREDENTIALS_ID}") + sh 'chmod 600 .gnupg/*' + } + } + } + } + stage('Build') { + steps { + ansiColor('xterm') { + sh './build ubuntu bionic-rust' + } + } + } + stage('Publish') { + steps { + script { + def Dpkg = readJSON file: 'dpkg.json' + archiveArtifacts(artifacts: "${Dpkg.PACKAGE}*.*", caseSensitive: true, onlyIfSuccessful: true) + dpkgGithubRelease('ubuntu-bionic') + } + } + } + } + post { + success { + juxtapose event: 'success' + sh 'figlet "SUCCESS"' + } + failure { + juxtapose event: 'failure' + sh 'figlet "FAILURE"' + } + } +} diff --git a/Jenkinsfile.ubuntu-eoan b/Jenkinsfile.ubuntu-eoan new file mode 100644 index 0000000..f889adf --- /dev/null +++ b/Jenkinsfile.ubuntu-eoan @@ -0,0 +1,50 @@ +pipeline { + options { + buildDiscarder(logRotator(numToKeepStr: '10')) + disableConcurrentBuilds() + } + agent { + label 'dpkg' + } + stages { + stage('Prepare') { + steps { + ansiColor('xterm') { + sh 'rm -rf sign' + sh 'mkdir -p sign' + + dir(path: 'sign') { + git(url: "${RPM_SIGN_GIT_REPO}", credentialsId: "${RPM_SIGN_CREDENTIALS_ID}") + sh 'chmod 600 .gnupg/*' + } + } + } + } + stage('Build') { + steps { + ansiColor('xterm') { + sh './build ubuntu eoan-rust' + } + } + } + stage('Publish') { + steps { + script { + def Dpkg = readJSON file: 'dpkg.json' + archiveArtifacts(artifacts: "${Dpkg.PACKAGE}*.*", caseSensitive: true, onlyIfSuccessful: true) + dpkgGithubRelease('ubuntu-eoan') + } + } + } + } + post { + success { + juxtapose event: 'success' + sh 'figlet "SUCCESS"' + } + failure { + juxtapose event: 'failure' + sh 'figlet "FAILURE"' + } + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..8ebd497 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# [dust](https://github.com/bootandy/dust) + +Builds for Debian based distros hosted on [dpkg.jc21.com](https://dpkg.jc21.com) diff --git a/build b/build new file mode 100755 index 0000000..6bcb623 --- /dev/null +++ b/build @@ -0,0 +1,128 @@ +#!/bin/bash -e + +################################################## +# +# ./build DISTRO [DOCKER_TAG] +# +# If no docker tag, `latest` is used +# +# ie: +# ./build debian 9 +# +################################################## + +CWD=$(pwd) +CYAN='\E[1;36m' +RED='\E[1;31m' +YELLOW='\E[1;33m' +GREEN='\E[1;32m' +BLUE='\E[1;34m' +RESET='\E[0m' + +DISTRO=$1 +if [ "$DISTRO" == "" ]; then + echo -en "${RED}ERROR: ${RESET}" + echo -e "You must specify a Distro to build for: debian, mint" + echo "ie: ./build debian" + exit 1 +fi + +DOCKER_TAG=$2 +if [ "$DOCKER_TAG" == "" ]; then + DOCKER_TAG=latest +fi + +# Make sure jq exists +if ! hash jq 2>/dev/null; then + echo -en "${RED}ERROR: ${RESET}" + echo -e "jq command is required" + exit 1 +fi + +# Make sure docker exists +if ! hash docker 2>/dev/null; then + echo -en "${RED}ERROR: ${RESET}" + echo -e "docker command is required" + exit 1 +fi + +# Variables +DOCKER_IMAGE=jc21/dpkg-${DISTRO} +PACKAGE=$(cat dpkg.json | jq -r .PACKAGE) +VERSION=$(cat dpkg.json | jq -r .VERSION) +GH_USER=$(cat dpkg.json | jq -r .GH_USER) +GH_VERSION=$(cat dpkg.json | jq -r .GH_VERSION) +SIGN_KEY=$(cat dpkg.json | jq -r .SIGN_KEY) +URL= + +export PACKAGE VERSION GH_USER GH_VERSION +eval "URL=$(cat dpkg.json | jq -r .URL)" + +if [ -z "$URL" ]; then + echo -en "${RED}ERROR: ${RESET}" + echo -e "URL could not be determined from dpkg.json file" + exit 1 +fi + +echo -e "${BLUE}❯ ${GREEN}Building ${CYAN}${PACKAGE} v${VERSION} ${GREEN}for ${DISTRO}:${DOCKER_TAG}${RESET}" + +# Clean +rm -rf "${PACKAGE}-${VERSION}" + +# Download +echo -e "${BLUE}❯ ${YELLOW}Downloading${RESET}" +if [ -e "${PACKAGE}_${VERSION}.orig.tar.gz" ]; then + echo "${PACKAGE}_${VERSION}.orig.tar.gz exists, skipping..." +else + wget -nv "${URL}" -O "${PACKAGE}_${VERSION}.orig.tar.gz" +fi + +# Extract +echo -e "${BLUE}❯ ${YELLOW}Extracting${RESET}" +tar xzf "${PACKAGE}_${VERSION}.orig.tar.gz" + +# Copy over debian package info +echo -e "${BLUE}❯ ${YELLOW}Setting up ./debian folder${RESET}" +cp -pr debian "${PACKAGE}-${VERSION}"/ + +# Pull latest builder image +echo -e "${BLUE}❯ ${YELLOW}Pulling docker image: ${DOCKER_IMAGE}:${DOCKER_TAG}${RESET}" +docker pull "${DOCKER_IMAGE}:${DOCKER_TAG}" + +# Use the build to change the ownership of folders +echo -e "${BLUE}❯ ${YELLOW}Temporarily changing ownership${RESET}" +docker run --rm \ + -v "${CWD}:/home/builder/package" \ + -v "${CWD}/sign/.gnupg:/home/builder/.gnupg" \ + "${DOCKER_IMAGE}:${DOCKER_TAG}" \ + sudo chown -R builder:builder /home/builder/package /home/builder/.gnupg + +# Build +echo -e "${BLUE}❯ ${YELLOW}Building${RESET}" +set +e + +# Docker Run Part 1 +docker run --rm \ + --name "dpkgbuild-${BUILD_TAG:-dpkg-${DISTRO}-${PACKAGE}}" \ + -v "${CWD}:/home/builder/package" \ + -v "${CWD}/sign/.gnupg:/home/builder/.gnupg" \ + -e "GOPROXY=${GOPROXY}" \ + -w "/home/builder/package/${PACKAGE}-${VERSION}" \ + "${DOCKER_IMAGE}:${DOCKER_TAG}" \ + bash -c "sudo mk-build-deps --install --tool='apt-get --no-install-recommends -y' debian/control && dpkg-buildpackage --sign-key="${SIGN_KEY}" --force-sign" + +BUILD_SUCCESS=$? + +# Change ownership back +echo -e "${BLUE}❯ ${YELLOW}Reverting ownership${RESET}" +docker run --rm \ + -v "${CWD}:/home/builder/package" \ + -v "${CWD}/sign/.gnupg:/home/builder/.gnupg" \ + "${DOCKER_IMAGE}:${DOCKER_TAG}" \ + sudo chown -R "$(id -u):$(id -g)" /home/builder/package /home/builder/.gnupg + +# do we need to exit the loop? +if [ $BUILD_SUCCESS -ne 0 ]; then + echo -e "${BLUE}❯ ${RED}Exiting due to error${RESET}" + exit ${BUILD_SUCCESS} +fi diff --git a/debian/README b/debian/README new file mode 100644 index 0000000..99dd9eb --- /dev/null +++ b/debian/README @@ -0,0 +1,6 @@ +The Debian Package dust +---------------------------- + +Comments regarding the Package + + -- Jamie Curnow Sub, 15 Sep 2019 9:00:00 +1000 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..a4d418a --- /dev/null +++ b/debian/changelog @@ -0,0 +1,3 @@ +dust (0.4.41) unstable; urgency=medium + + * See: https://github.com/bootandy/dust/releases/tag/v0.4.41 diff --git a/debian/changelog.upstream b/debian/changelog.upstream new file mode 100644 index 0000000..a9ae94e --- /dev/null +++ b/debian/changelog.upstream @@ -0,0 +1,4 @@ +Version v0.4.41: +--------------------------------------- + +See: https://github.com/bootandy/dust/releases/tag/v0.4.41 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..e866ae6 --- /dev/null +++ b/debian/control @@ -0,0 +1,21 @@ +Source: dust +Section: util +Priority: optional +Maintainer: Jamie Curnow +Build-Depends: debhelper (>= 8.0.0), libgit2-dev, libssl-dev, pkg-config, cmake +Standards-Version: 4.3.0.1 +Homepage: https://github.com/bootandy/dust +Vcs-Git: https://github.com/bootandy/dust.git +Vcs-Browser: https://github.com/bootandy/dust + +Package: dust +Architecture: any +Multi-Arch: foreign +Depends: ${misc:Depends} +Pre-Depends: ${misc:Pre-Depends} +Description: Dust is meant to give you an instant overview of which directories are + using disk space without requiring sort or head. Dust will print a + maximum of 1 'Did not have permissions message'. Dust will list the 20 biggest + sub directories or files and will smartly recurse down the tree to find the + larger ones. There is no need for a '-d' flag or a '-h' flag. The largest sub + directory will have its size shown in red diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..5206b97 --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +target/release/dust /usr/bin \ No newline at end of file diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..1022e9b --- /dev/null +++ b/debian/rules @@ -0,0 +1,28 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#export DH_VERBOSE = 1 + + +# see FEATURE AREAS in dpkg-buildflags(1) +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + + +%: + dh $@ + +# dh_make generated override targets +# This is example for Cmake (See https://bugs.debian.org/641051 ) +#override_dh_auto_configure: +# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) + +# Set go modules to on and use GoCenter for immutable modules + +build: + cargo build --release diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/debian/versions.upstream b/debian/versions.upstream new file mode 100644 index 0000000..d034e8f --- /dev/null +++ b/debian/versions.upstream @@ -0,0 +1 @@ +v0.4.41 diff --git a/dpkg.json b/dpkg.json new file mode 100644 index 0000000..6fd847f --- /dev/null +++ b/dpkg.json @@ -0,0 +1,10 @@ +{ + "PACKAGE": "dust", + "VERSION": "0.4.41", + "GH_USER": "bootandy", + "URL": "https://github.com/${GH_USER}/${PACKAGE}/archive/v${VERSION}.tar.gz", + "SIGN_KEY": "EFD591B218E19AE3376D80D14F9E050D1DFFBB86", + "publish": { + "GH_USER": "jc21-dpkg" + } +}