mirror of
https://github.com/bitnami/minideb.git
synced 2026-06-04 10:13:55 +08:00
apply pr feedback
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
language: bash
|
||||
sudo: required
|
||||
script: bash shellcheck && bash snapshot && sudo bash buildall
|
||||
script: bash shellcheck && sudo bash buildall
|
||||
dist: xenial
|
||||
services:
|
||||
- docker
|
||||
|
||||
@@ -6,13 +6,50 @@ set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
DISTS="jessie
|
||||
stretch
|
||||
buster
|
||||
buster-snapshot
|
||||
unstable
|
||||
"
|
||||
DISTS="buster-snapshot"
|
||||
|
||||
# is_snapshot() {
|
||||
# local -r dist_snapshot_regex="^(jessie|stretch|buster|unstable)-snapshot"
|
||||
# [[ $1 =~ $dist_snapshot_regex ]]
|
||||
# }
|
||||
|
||||
get_latest_month_query(){
|
||||
local -r snapshot_tmp_dir=$(mktemp -d)
|
||||
local -r snapshot_archive_tmp_file="${snapshot_tmp_dir}/archive.html"
|
||||
mkdir -p "${snapshot_tmp_dir}"
|
||||
|
||||
! curl -sSfL "https://snapshot.debian.org/archive/debian/" > "$snapshot_archive_tmp_file" && echo "Error when accessing https://snapshot.debian.org/archive/debian/" && return 1
|
||||
|
||||
local month_query=$(grep -Po "(\?year=\d\d\d\d&month=\d+)" "${snapshot_archive_tmp_file}" | tail -1)
|
||||
|
||||
[[ -z "$month_query" ]] && echo "Not found snapshots using the following regex: (?year=\d\d\d\d&month=\d+)" && return 1
|
||||
|
||||
echo "$month_query"
|
||||
}
|
||||
|
||||
get_latest_debian_snapshot_id() {
|
||||
local -r snapshot_tmp_dir=$(mktemp -d)
|
||||
local -r snapshot_list_tmp_file="${snapshot_tmp_dir}/month-snapshots.html"
|
||||
mkdir -p "${snapshot_tmp_dir}"
|
||||
|
||||
! month_query=$(get_latest_month_query) && return 1
|
||||
|
||||
! curl -sSfL "https://snapshot.debian.org/archive/debian/$month_query" > "$snapshot_list_tmp_file" && echo "Not found snapshots for these parameters: query=${month_query}" && return 1
|
||||
|
||||
local snapshot_id=$(grep -Po "(\d+T.*Z)" "${snapshot_list_tmp_file}" | tail -1)
|
||||
|
||||
[[ -z "$snapshot_id" ]] && echo "Not found snapshot id using the following regex: (\d+T.*Z)" && return 1
|
||||
|
||||
echo "$snapshot_id"
|
||||
}
|
||||
|
||||
! snapshot_id=$(get_latest_debian_snapshot_id) && exit 1
|
||||
|
||||
for DIST in $DISTS; do
|
||||
./buildone "$DIST"
|
||||
DIST=${DIST%-*}
|
||||
|
||||
./buildone "$DIST" "$snapshot_id"
|
||||
done
|
||||
|
||||
mkdir -p build
|
||||
echo "$snapshot_id" > build/snapshot_id
|
||||
|
||||
@@ -41,16 +41,12 @@ log() {
|
||||
echo "$@" >&2
|
||||
}
|
||||
|
||||
is_snapshot() {
|
||||
local -r dist_snapshot_regex="^(jessie|stretch|buster|unstable)-snapshot"
|
||||
[[ $1 =~ $dist_snapshot_regex ]]
|
||||
}
|
||||
|
||||
build() {
|
||||
DIST=$1
|
||||
if is_snapshot "$DIST"; then
|
||||
! debian_snapshot_id=$(cat build/snapshot_id) && return
|
||||
TAG="${DIST}-${debian_snapshot_id}"
|
||||
|
||||
debian_snapshot_id=${2:-}
|
||||
if [ -n "$debian_snapshot_id" ]; then
|
||||
TAG="${DIST}-snapshot-${debian_snapshot_id}"
|
||||
else
|
||||
TAG=$DIST
|
||||
fi
|
||||
@@ -108,4 +104,4 @@ if [ -z "$1" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
build "$1"
|
||||
build "$1" "$2"
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
jessie
|
||||
@@ -6,7 +6,7 @@ set -o pipefail
|
||||
ROOT=$(cd "$(dirname "$0")" && pwd)
|
||||
|
||||
TARGET=${1:?Specify the target filename}
|
||||
DIST=${2%-*}
|
||||
DIST=${2:-stable}
|
||||
SNAPSHOT_ID=${3:-}
|
||||
|
||||
LOGFILE=${TARGET}.log
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
snapshot_list_tmp_dir=$(mktemp -d)
|
||||
mkdir -p "${snapshot_list_tmp_dir}"
|
||||
|
||||
get_latest_month_query(){
|
||||
snapshot_archive_tmp_file="${snapshot_list_tmp_dir}/archive.html"
|
||||
|
||||
! curl -sSfL "https://snapshot.debian.org/archive/debian/" > "$snapshot_archive_tmp_file" && echo "Error when accessing https://snapshot.debian.org/archive/debian/" && return 1
|
||||
|
||||
month_query=$(grep -Po "(\?year=\d\d\d\d&month=\d+)" "${snapshot_archive_tmp_file}" | tail -1)
|
||||
|
||||
[[ -z "$month_query" ]] && echo "Not found snapshots using the following regex: (?year=\d\d\d\d&month=\d+)" && return 1
|
||||
|
||||
echo "$month_query" && return 0
|
||||
}
|
||||
|
||||
get_latest_debian_snapshot_id() {
|
||||
! month_query=$(get_latest_month_query) && return 1
|
||||
|
||||
snapshot_list_tmp_file="${snapshot_list_tmp_dir}/month-snapshots.html"
|
||||
|
||||
! curl -sSfL "https://snapshot.debian.org/archive/debian/$month_query" > "$snapshot_list_tmp_file" && echo "Not found snapshots for these parameters: query=${month_query}" && return 1
|
||||
|
||||
snapshot_id=$(grep -Po "(\d+T.*Z)" "${snapshot_list_tmp_file}" | tail -1)
|
||||
|
||||
[[ -z "$snapshot_id" ]] && echo "Not found snapshot id using the following regex: (\d+T.*Z)" && return 1
|
||||
|
||||
mkdir -p build
|
||||
echo "$snapshot_id" > build/snapshot_id && return 0
|
||||
}
|
||||
|
||||
get_latest_debian_snapshot_id
|
||||
Reference in New Issue
Block a user