Verified Commit 77be90ee authored by Sven-Hendrik Haase's avatar Sven-Hendrik Haase
Browse files

Remove old unnecessary scripts

parent 7ef7f204
Pipeline #1015 failed with stages
in 3 minutes and 2 seconds
#!/usr/bin/env python
# -*- encoding; utf-8 -*-
#
# Author: Christian Rebischke <chris.rebischke@archlinux.org>
# This file is licensed under GPLv3
import urllib.request
import json
import datetime
import sys
import subprocess
import os.path
API_URL = 'https://app.vagrantup.com/api/v1/box/archlinux/archlinux'
NOW = datetime.date.today()
LEN_RELEASES = 2
CWD = '/srv/arch-boxes/arch-boxes'
ISO_PATH = '/srv/ftp/iso/latest/archlinux-' + NOW.strftime(
"%Y.%m") + '.01-x86_64.iso'
ISO_CHECKSUM_PATH = '/srv/ftp/iso/latest/sha1sums.txt'
PACKER_CMD_TEMPLATE = [
"/usr/bin/packer", "build", "-parallel=false", "-var", "'headless=true'",
"-var", "'write_zeroes=yes'", "-except=vmware-iso", "vagrant.json"
]
def main():
exit_if_resources_present()
with urllib.request.urlopen(API_URL) as response:
data = json.load(response)
release_version = data['current_version']['version']
release_providers = data['current_version']['providers']
if not is_latest(release_version):
subprocess.call(PACKER_CMD_TEMPLATE, cwd=CWD)
else:
if not all_released(release_providers):
determine_missing_release(release_providers)
def exit_if_resources_present():
if os.path.exists(ISO_PATH) and os.path.exists(ISO_CHECKSUM_PATH):
pass
else:
sys.exit(0)
def build_packer_call(provider):
provider_map = {"virtualbox": "virtualbox", "libvirt": "qemu"}
packer = PACKER_CMD_TEMPLATE.copy()
packer[7] += ","
packer[7] += provider_map[provider]
return packer
def determine_missing_release(release_providers):
subprocess.call(build_packer_call(release_providers[0]['name']), cwd=CWD)
def is_latest(release_version):
# we need to use .date() here, otherwise the compare is going to fail
release = datetime.datetime.strptime(release_version, "%Y.%m.%d").date()
# set the day to 1, because we only want to check for month and year
release = release.replace(day=1)
current_release = NOW.replace(day=1)
return current_release <= release
def all_released(release_providers):
return LEN_RELEASES <= len(release_providers)
if __name__ == '__main__':
main()
#!/bin/bash
set -x
case $1 in
install-packer)
PACKER_CURRENT_VERSION="$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r -M '.current_version')"
PACKER_URL="https://releases.hashicorp.com/packer/$PACKER_CURRENT_VERSION/packer_${PACKER_CURRENT_VERSION}_linux_amd64.zip"
PACKER_SHA256="https://releases.hashicorp.com/packer/$PACKER_CURRENT_VERSION/packer_${PACKER_CURRENT_VERSION}_SHA256SUMS"
PACKER_SHA256_SIG="https://releases.hashicorp.com/packer/$PACKER_CURRENT_VERSION/packer_${PACKER_CURRENT_VERSION}_SHA256SUMS.sig"
HASHICORP_FINGERPRINT=91a6e7f85d05c65630bef18951852d87348ffc4c
HASHICORP_KEY="https://keybase.io/hashicorp/pgp_keys.asc?fingerprint=${HASHICORP_FINGERPRINT}"
curl -LO "${PACKER_URL}"
curl -LO "${PACKER_SHA256}"
curl -LO "${PACKER_SHA256_SIG}"
wget -Lo hashicorp.key "${HASHICORP_KEY}"
gpg --with-fingerprint --with-colons hashicorp.key | grep ${HASHICORP_FINGERPRINT^^}
gpg --import hashicorp.key
gpg --verify "packer_${PACKER_CURRENT_VERSION}_SHA256SUMS.sig" "packer_${PACKER_CURRENT_VERSION}_SHA256SUMS"
grep linux_amd64 "packer_${PACKER_CURRENT_VERSION}_SHA256SUMS" >packer_SHA256SUM_linux_amd64
sha256sum --check --status packer_SHA256SUM_linux_amd64
unzip "packer_${PACKER_CURRENT_VERSION}_linux_amd64.zip"
./packer --version
;;
install-shfmt)
SHFMT_VERSION="$(curl -s https://api.github.com/repos/mvdan/sh/releases/latest | jq -r -M '.tag_name')"
curl -Lo shfmt https://github.com/mvdan/sh/releases/download/"${SHFMT_VERSION}"/shfmt_"${SHFMT_VERSION}"_linux_amd64
chmod +x ./shfmt
./shfmt --version
;;
install-yapf)
pip3 install yapf --user
;;
install-flake8)
pip3 install flake8 --user
;;
verify-official)
./packer validate -var "iso_checksum_url=https://mirror.pkgbuild.com/iso/latest/sha1sums.txt" -except=vagrant-cloud vagrant.json
;;
verify-local)
./packer validate local.json
;;
verify-cloud)
./packer validate cloud.json
;;
# We use + instead of \; here because find doesn't pass
# the exit code through when used with \;
shellcheck)
find . -iname "*.sh" -exec shellcheck {} +
;;
shfmt)
find . -iname "*.sh" -exec ./shfmt -i 2 -ci -d {} +
;;
yapf)
find . -iname "*.py" -exec python3 -m yapf -d {} +
;;
flake8)
find . -iname "*.py" -exec python3 -m flake8 {} +
;;
*)
exit 1
;;
esac
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment