Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Commit

Permalink
Merge pull request #170 from ludeeus/gitlab
Browse files Browse the repository at this point in the history
Initial preperations for hosting the package on GitLab
  • Loading branch information
Landrash committed Jul 4, 2018
2 parents 47e03a2 + 2d336cb commit 45df3db
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 54 deletions.
30 changes: 30 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
stages:
- build
- test
- deploy
build-package:
stage: build
image: debian
script:
- apt update
- apt -y upgrade
- apt install -y curl
- curl -sL https://gitlab.com/hassbian/CI/raw/master/hassbian-scripts/build_and_test.sh | bash -s ${CI_COMMIT_REF_NAME}
test-package:
stage: test
image: debian
script:
- apt update
- apt -y upgrade
- apt install -y curl
- curl -sL https://gitlab.com/hassbian/CI/raw/master/hassbian-scripts/build_and_test.sh | bash -s ${CI_COMMIT_REF_NAME}
- apt -y install ${CI_PROJECT_DIR}/package.deb

deploy-to-repo:
stage: deploy
image: debian
script:
- apt update
- apt -y upgrade
- apt install -y curl git
- curl -sL https://gitlab.com/hassbian/CI/raw/master/hassbian-scripts/distribute.sh | bash -s ${CI_COMMIT_REF_NAME}
5 changes: 0 additions & 5 deletions docs/hassbian_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ $ sudo apt install -y ./hassbian*
$ sudo hassbian-config upgrade hassbian-script
```

## Upgrade to prerelease
```
$ sudo hassbian-config upgrade hassbian-script --beta
```

## Upgrade to dev branch
```
$ sudo hassbian-config upgrade hassbian-script --dev
Expand Down
68 changes: 19 additions & 49 deletions package/opt/hassbian/suites/hassbian-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,38 @@ function hassbian-script-show-copyright-info {
}

function hassbian-script-upgrade-package {

if [ "$DEV" == "true" ]; then
echo "This script downloads new scripts directly from the dev branch on Github."
echo "you can use this to be on the 'bleeding edge of the development of Hassbian.'"
echo "This is not recommended for daily use."
echo -n "Are you really sure you want to continue? [N/y] : "
read -r RESPONSE
if [ "$RESPONSE" == "y" ] || [ "$RESPONSE" == "Y" ]; then
RESPONSE="Y"
devbranch="-dev"
else
echo "Exiting..."
return 0
fi
echo "Creating and changing in to a temporary folder."
cd || exit
sudo mkdir /tmp/hassbian_config_update
cd /tmp/hassbian_config_update || exit

echo "Downloading new scripts from github."
curl -L https://api.github.com/repos/home-assistant/hassbian-scripts/tarball| sudo tar xz --strip=1

echo "Moving scripts to the install folder."
yes | sudo cp -rf /tmp/hassbian_config_update/package/usr/local/bin/hassbian-config /usr/local/bin/hassbian-config
yes | sudo cp -rf /tmp/hassbian_config_update/package/opt/hassbian/suites/* /opt/hassbian/suites/

echo "Removing the temporary folder."
cd || exit
sudo rm -r /tmp/hassbian_config_update
fi
echo "Updating apt information..."
echo "deb [trusted=yes] https://gitlab.com/hassbian/repository$devbranch/raw/master stretch main" | sudo tee /etc/apt/sources.list.d/hassbian.list
apt update

echo "Checking installed version..."
current_version=$(apt list hassbian-scripts | tail -1 | awk -F'[' '{print $NF}' | awk -F']' '{print $1}')
if [ "$current_version" != "installed" ]; then
echo "Removing old version of hassbian-scripts..."
apt purge -y hassbian-scripts
apt clean

echo "Installing newest version of hassbian-scripts..."
echo "deb [trusted=yes] https://gitlab.com/hassbian/repository$devbranch/raw/master stretch main" | sudo tee /etc/apt/sources.list.d/hassbian.list
apt update
apt install -y hassbian-scripts
else
echo "Changing to a temporary folder"
cd /tmp || exit

echo "Downloading latest release"
if [ "$BETA" == "true" ]; then
echo "Checking if there is an prerelease available..."
prerelease=$(curl https://api.github.com/repos/home-assistant/hassbian-scripts/releases | grep '"prerelease": true')
if [ ! -z "${prerelease}" ]; then
echo "Prerelease found..."
curl https://api.github.com/repos/home-assistant/hassbian-scripts/releases | grep "browser_download_url.*deb" | head -1 | cut -d : -f 2,3 | tr -d \" | wget -qi -
else
echo "Prerelease not found..."
echo "Downloading latest stable version..."
curl https://api.github.com/repos/home-assistant/hassbian-scripts/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -qi -
fi
else
curl https://api.github.com/repos/home-assistant/hassbian-scripts/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -qi -
fi

HASSBIAN_PACKAGE=$(echo hassbian*.deb)

echo "Installing latest release"
downloadedversion=$(echo "$HASSBIAN_PACKAGE" | awk -F'_' '{print $2}' | cut -d . -f 1,2,3)
currentversion=$(hassbian-config -V)
if [[ "$currentversion" > "$downloadedversion" ]]; then
apt install -y /tmp/"$HASSBIAN_PACKAGE" --allow-downgrades
else
apt install -y /tmp/"$HASSBIAN_PACKAGE" --reinstall
fi
echo "Cleanup"
rm "$HASSBIAN_PACKAGE"
echo "Installed version is up to date, exiting..."
return 0
fi

systemctl daemon-reload

echo
Expand Down

0 comments on commit 45df3db

Please sign in to comment.