mirror of
https://github.com/clearlinux/mixer-tools.git
synced 2026-09-06 21:51:30 +00:00
Add helpers file for the scripts to use
This will do a lot of the ugly work that does not need to be taking up space in the main scripts, and should be abstracted out so they are easier to read. Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
This commit is contained in:
+3
-1
@@ -3,11 +3,13 @@ dist_bin_SCRIPTS = \
|
||||
create-update.sh \
|
||||
build-chroots.sh \
|
||||
init-mix.sh \
|
||||
init-versions.sh \
|
||||
update-bundles.sh \
|
||||
pack-maker.sh \
|
||||
superpack-maker.sh
|
||||
|
||||
instdir = $(datadir)/mixer-tools
|
||||
dist_inst_DATA = helpers
|
||||
|
||||
configdir = $(datadir)/defaults/mixer
|
||||
dist_config_DATA = \
|
||||
yum.conf.in \
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Program that builds the actual chroots
|
||||
BUILDERSCRIPT="bundle-chroot-builder.py"
|
||||
|
||||
# Fallback config files for the scripts
|
||||
BUILDERCONF=
|
||||
LOCALCONF=
|
||||
|
||||
SIGNING=1
|
||||
YUM_TEMPLATE="/usr/share/defaults/mixer/yum.conf.in"
|
||||
|
||||
STATE_DIR=
|
||||
YUM_CONF=
|
||||
BUNDLE_DIR=
|
||||
CERT=
|
||||
CLRVER=
|
||||
MIXVER=
|
||||
REPODIR=
|
||||
RPMDIR=
|
||||
|
||||
check_dep() {
|
||||
type $1 &> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$1 program not found... Unable to continue"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_deps() {
|
||||
check_dep "createrepo_c"
|
||||
check_dep "git"
|
||||
check_dep "hardlink"
|
||||
check_dep "m4"
|
||||
check_dep "openssl"
|
||||
check_dep "parallel"
|
||||
check_dep "rpm"
|
||||
check_dep "yum"
|
||||
}
|
||||
|
||||
update_repo() {
|
||||
local repo="$1"
|
||||
(
|
||||
if [ ! -d "$repo" ]; then
|
||||
git clone https://github.com/clearlinux/"$repo.git"
|
||||
cd "$repo"
|
||||
else
|
||||
cd "$repo"
|
||||
# to force the update of clr-bundles "latest" tag
|
||||
git fetch --tags
|
||||
git checkout master
|
||||
git pull origin master
|
||||
fi
|
||||
set +e
|
||||
# checkout the tag relating to the clear version used to build against
|
||||
git checkout tags/"$CLRVER"
|
||||
local branch="${CLRVER}_mix"
|
||||
git rev-parse --verify "$branch"
|
||||
if [ $? -eq 0 ]; then
|
||||
git checkout "$branch"
|
||||
git pull
|
||||
else
|
||||
git checkout -b "$branch"
|
||||
fi
|
||||
set -e
|
||||
cd ..
|
||||
)
|
||||
}
|
||||
|
||||
install_cert() {
|
||||
if [ ! -z $CERT ]; then
|
||||
if [ ! -f $CERT ]; then
|
||||
# This generates the private key and self signed certificate
|
||||
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 \
|
||||
-keyout private.pem -out $CERT \
|
||||
-subj "/C=US/ST=Oregon/L=Portland/O=Company Name/OU=Org/CN=www.example.com/DN=MixerCert" \
|
||||
-config /usr/share/defaults/mixer/certattributes.cnf
|
||||
fi
|
||||
echo -e "Installing certificate\n"
|
||||
sudo cp $CERT "$STATE_DIR/image/$MIXVER/os-core-update/usr/share/clear/update-ca/"
|
||||
fi
|
||||
}
|
||||
|
||||
sign_manifest_mom() {
|
||||
if [ -f "$CERT" ]; then
|
||||
sudo openssl smime -sign -binary -in update/www/$MIXVER/Manifest.MoM \
|
||||
-signer $CERT -inkey private.pem \
|
||||
-outform DER -out update/www/$MIXVER/Manifest.MoM.sig
|
||||
fi
|
||||
}
|
||||
|
||||
load_builder_conf() {
|
||||
if [ -f "$PWD/builder.conf" ]; then
|
||||
LOCALCONF="$PWD/builder.conf"
|
||||
elif [ -z $BUILDERCONF ]; then
|
||||
echo -e "ERROR: Cannot find any builder.conf to use!\n"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
read_builder_conf() {
|
||||
STATE_DIR=$(awk -F '=[ ]*' '/^SERVER_STATE_DIR *=/ {print $2; exit}' $1)
|
||||
YUM_CONF=$(awk -F '=[ ]*' '/^YUM_CONF *=/ {print $2; exit}' $1)
|
||||
BUNDLE_DIR=$(awk -F '=[ ]*' '/^BUNDLE_DIR *=/ {print $2; exit}' $1)
|
||||
CERT=$(awk -F '=[ ]*' '/^CERT *=/ {print $2; exit}' $1)
|
||||
CLRVER=$(awk -F '=[ ]*' '/^CLEAR_VERSION *=/ {print $2; exit}' $1)
|
||||
MIXVER=$(awk -F '=[ ]*' '/^MIX_VERSION *=/ {print $2; exit}' $1)
|
||||
REPODIR=$(awk -F '=[ ]*' '/^REPODIR *=/ {print $2; exit}' $1)
|
||||
RPMDIR=$(awk -F '=[ ]*' '/^RPMDIR *=/ {print $2; exit}' $1)
|
||||
FORMAT=$(awk -F '=[ ]*' '/^FORMAT *=/ {print $2; exit}' $1)
|
||||
}
|
||||
|
||||
clean_chroots() {
|
||||
for BUNDLE in $(ls "$BUNDLE_DIR" | grep -v "^full"); do
|
||||
sudo rm -rf "$STATE_DIR/image/$MIXVER/$BUNDLE"
|
||||
done
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
CLRVER=
|
||||
MIXVER=
|
||||
|
||||
if [ -e /usr/lib/os-release ]; then
|
||||
CLRVER=$(awk -F= '/^VERSION_ID/ { print $2 }' /usr/lib/os-release)
|
||||
fi
|
||||
|
||||
# For a vanilla system, default to "10" for the mix version, since "0" has
|
||||
# special meaning for SWUPD (zero packs, etc.). Otherwise, add 10 to the latest
|
||||
# mix version.
|
||||
if [ -d /var/lib/update/image ]; then
|
||||
versions=$(ls /var/lib/update/image/ | grep -E '^[0-9]+' | sort -n)
|
||||
if [ -n "$versions" ]; then
|
||||
latest=$(echo "$versions" | tail -1)
|
||||
MIXVER=$(expr $latest + 10)
|
||||
else
|
||||
MIXVER=10
|
||||
fi
|
||||
else
|
||||
MIXVER=10
|
||||
fi
|
||||
|
||||
usage() {
|
||||
echo -n "Usage: $0"
|
||||
echo -n " [-h | --help]"
|
||||
echo -n " [-c <ver> | --clear-version <ver>]"
|
||||
echo -n " [-m <ver> | --mix-version <ver>]"
|
||||
echo
|
||||
}
|
||||
|
||||
while [ "$1" != "" ]; do
|
||||
case "$1" in
|
||||
-c | --clear-version )
|
||||
shift; CLRVER="$1"
|
||||
;;
|
||||
-m | --mix-version )
|
||||
shift; MIXVER="$1"
|
||||
;;
|
||||
-h | --help )
|
||||
usage; exit 1
|
||||
;;
|
||||
* )
|
||||
usage; exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$CLRVER" ]; then
|
||||
echo "Please specify a Clear version with -c"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$MIXVER" ]; then
|
||||
echo "Please specify a mix version with -m"
|
||||
echo "The version must be >= 10, and a multiple of 10"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# CLRVER and MIXVER must only be positive integers that are multiples of 10
|
||||
regexp='^[0-9]+0$'
|
||||
if ! [[ "$CLRVER" =~ $regexp ]]; then
|
||||
echo "CLRVER must be a positive integer and a multiple of 10"
|
||||
exit 1
|
||||
fi
|
||||
if ! [[ "$MIXVER" =~ $regexp ]]; then
|
||||
echo "MIXVER must be a positive integer and a multiple of 10"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# used in other mixer scripts
|
||||
echo "$CLRVER" > "$PWD/.clear-version"
|
||||
echo "$MIXVER" > "$PWD/.mix-version"
|
||||
|
||||
echo "Initialized Clear version to $CLRVER"
|
||||
echo "Initialized mix version to $MIXVER"
|
||||
|
||||
exit 0
|
||||
|
||||
# vi: ts=8 sw=2 sts=2 et tw=80
|
||||
Reference in New Issue
Block a user