diff --git a/.build.sh b/.build.sh index a71ec2f7adab22e6353a3f47aeddec60867d4e4f..2fda6613bdc59dcd9c28907da8c38b02b0dd7673 100755 --- a/.build.sh +++ b/.build.sh @@ -6,13 +6,13 @@ apt-get update && apt-get install -y devscripts CHANGELOG="package/debian/changelog" LINE=$(head -n 1 $CHANGELOG) -PACKAGE=$(echo $LINE | cut -d' ' -f1) -VERSION=$(echo $LINE | cut -d' ' -f2 | grep -o -E '[0-9]*\.[0-9]*\.[0-9]*') -tar --exclude=debian -czf ${PACKAGE}_${VERSION}.orig.tar.gz package/* +PACKAGE=$(echo "$LINE" | cut -d' ' -f1) +VERSION=$(echo "$LINE" | cut -d' ' -f2 | grep -o -E '[0-9]*\.[0-9]*\.[0-9]*') +tar --exclude=debian -czf "${PACKAGE}_${VERSION}.orig.tar.gz" package/* -cd package +cd package || exit 1 debuild -us -uc -cd ../ +cd ../ || exit 1 mkdir build/ -mv ${PACKAGE}* build/ +mv "${PACKAGE}"* build/ diff --git a/.deploy.sh b/.deploy.sh index d02eac5c5b4f503eaf15e5d3c814b5eecb161bd2..492c880054991facb60e2c668f6a3be34251e5a8 100755 --- a/.deploy.sh +++ b/.deploy.sh @@ -1,23 +1,33 @@ #!/bin/bash +# shellcheck disable=SC2029 # This script uploads an includes a .deb package in our debian repository. # The distribution is chosen based on the gitlab-ci stage we are on. apt-get update && apt-get install -y dput ssh -eval $(ssh-agent -s) +eval "$(ssh-agent -s)" ssh-add <(echo "$PRIV_KEY") echo "Deploy job name: $CI_JOB_NAME" -if [ "$CI_JOB_NAME" = "deploy_for_testing" ]; then +if [ "$CI_JOB_NAME" = "deploy_for_unstable" ]; then dput -u -f --config=dput.cf repo build/*.changes -elif [ "$CI_JOB_NAME" = "deploy_for_stable" ]; then + +else + if [ "$CI_JOB_NAME" = "deploy_for_testing" ]; then + REPO_SRC="unstable" + REPO_TGT="testing" + elif [ "$CI_JOB_NAME" = "deploy_for_stable" ]; then + REPO_SRC="testing" + REPO_TGT="stable" + fi + CHANGELOG="package/debian/changelog" LINE=$(head -n 1 $CHANGELOG) - PACKAGE=$(echo $LINE | cut -d' ' -f1) - VERSION=$(echo $LINE | cut -d' ' -f2 | grep -o -E '[0-9]*\.[0-9]*\.[0-9]*') + PACKAGE=$(echo "$LINE" | cut -d' ' -f1) + VERSION=$(echo "$LINE" | cut -d' ' -f2 | grep -o -E '[0-9]*\.[0-9]*\.[0-9]*') + REPREPRO_CMD="reprepro -Vb /home/repository/www/le6 copysrc $REPO_TGT $REPO_SRC $PACKAGE $VERSION" - REPREPRO_CMD="reprepro -Vb /home/repository/www/le6 copysrc stable testing $PACKAGE $VERSION" - ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa repository@repo.c3sl.ufpr.br "$REPREPRO_CMD" -fi + ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null repository@repo.c3sl.ufpr.br "$REPREPRO_CMD" +fi diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1ae327e3379874c20d10964ec48310ce0a2e4bef..1f51f5b1291452dffcf8eb5dc9dc4a7b706d8142 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,24 @@ ## Template para empacotamento utilizando o Gitlab-ci. stages: + - lint - build - test - deploy +lint_shell: + stage: lint + tags: + - debian-packaging + script: + - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install wget locales locales-all -y + - locale-gen pt_BR.UTF-8 + - export LANG=pt_BR.UTF-8 + - scversion="stable" # or "v0.4.7", or "latest" + - wget "https://storage.googleapis.com/shellcheck/shellcheck-$scversion.linux.x86_64.tar.xz" + - tar --xz -xvf "shellcheck-$scversion.linux.x86_64.tar.xz" + - shellcheck() { "shellcheck-$scversion/shellcheck" "$@"; } + - ./.linter_shell.sh + build: stage: build artifacts: @@ -31,10 +46,22 @@ test: dependencies: - build +deploy_for_unstable: + stage: deploy + only: + - develop + tags: + - debian-packaging + script: + - ./.deploy.sh + dependencies: + - build + deploy_for_testing: stage: deploy + when: manual only: - - master + - master tags: - debian-packaging script: diff --git a/.linter_shell.sh b/.linter_shell.sh new file mode 100755 index 0000000000000000000000000000000000000000..ba497c762840177e434ab133ad50b0fabc082553 --- /dev/null +++ b/.linter_shell.sh @@ -0,0 +1,22 @@ +#!/bin/bash +YELLOW='\033[0;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +sh_files=$(find -name "*.sh") +exe_files=$(grep -Erl "#\!/bin/(bash|sh)" --exclude=*.* package) +files="$sh_files\n$exe_files" +#find no files +if [[ "$files" == "\n" ]];then + echo -e "${YELLOW}No shell files found!${NC}" + exit 0 +fi + +echo -e "$files"| xargs shellcheck -s bash +if [[ $? -eq 0 ]];then + echo "AWESOME!No problems found." + exit 0 +else + echo -e "Understand errors in: ${BLUE}https://github.com/koalaman/shellcheck/wiki${NC}" + exit 1 +fi diff --git a/package/debian/changelog b/package/debian/changelog index edde66efbc9aa2e5a7090ee6d0e945afa3b86767..71e0c7017a5adaaaef5e9e4a0073f383c101753b 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,3 +1,9 @@ +le-user-apps (0.0.8) unstable; urgency=medium + + * Fix Linter errors + + -- Stephanie Briere Americo <lesuporte@c3sl.ufpr.br> Mon, 09 Jul 2018 11:26:53 -0300 + le-user-apps (0.0.7) testing; urgency=medium * Add le-control-panel diff --git a/package/debian/postrm b/package/debian/postrm index de28b1091b26c4c0da19fbdc10e0a95d768d696e..a03d48f256a8276efa6a11a931921613b2cb094e 100644 --- a/package/debian/postrm +++ b/package/debian/postrm @@ -26,9 +26,8 @@ set -e # Icons paths icon="/usr/share/pixmaps/gconjugue.png" AppPath="/usr/share/applications" -DivertPath="/usr/share/le-user-apps" -if [ remove = "$1" -o abort-install = "$1" -o disappear = "$1" ]; then +if [[ remove = "$1" || abort-install = "$1" || disappear = "$1" ]]; then dpkg-divert --package le-user-apps --rename --remove $icon dpkg-divert --package le-user-apps --rename --remove $AppPath/gconjugue.desktop dpkg-divert --package le-user-apps --rename --remove $AppPath/tuxtype.desktop