Compare commits

..

11 Commits

Author SHA1 Message Date
0918ff749d pkg2yaml: write valid yaml 2019-01-01 21:23:33 +01:00
3d3e4376c5 fix empty line 2019-01-01 12:58:48 +01:00
7499878d00 rename lib 2019-01-01 12:41:22 +01:00
d9e99543f6 unify yaml writer 2019-01-01 12:37:58 +01:00
43983042dd pkg2yaml: write pkgname in pkgbase 2018-12-31 14:32:08 +01:00
1b5f09076f pkg2yaml: write pkgbase name 2018-12-31 12:08:53 +01:00
d770030869 pkg2yaml: fix ident for pkgbase info 2018-12-31 11:24:25 +01:00
ea06ec0b2e util-pkg-subrepo: check master by default 2018-12-30 11:56:05 +01:00
e67990ae04 commitpkg: make check for pull work 2018-12-30 11:50:33 +01:00
b37d5f0236 buildtree & commitpkg: use same pull func 2018-12-30 03:45:17 +01:00
989af04593 pkg2yaml: include deps 2018-12-30 03:44:29 +01:00
9 changed files with 316 additions and 211 deletions

View File

@@ -26,7 +26,8 @@ LIBS_BASE = \
lib/util-msg.sh \
lib/util-mount.sh \
lib/util-chroot.sh \
lib/util-fstab.sh
lib/util-fstab.sh \
lib/util-yaml.sh
SHARED_BASE = \
$(wildcard data/pacman*.conf)

View File

@@ -26,70 +26,33 @@ pull_tree_arch(){
for tree in ${tree_names[@]};do
if [[ -d ${tree} ]];then
cd ${tree}
msg "Checking (%s)" "${tree}"
pull_tree
pull_tree "${tree}"
cd ..
else
msg "Cloning (%s) ..." "$tree"
clone_tree "${HOST_TREE_ARCH}/${tree}"
clone_tree "${HOST_TREE_ARCH}" "${tree}"
fi
done
}
config_tree(){
local tree="$1"
cd $tree
git config --bool pull.rebase true
git config commit.gpgsign true
if [[ -n "${GPGKEY}" ]];then
git config user.signingkey "${GPGKEY}"
else
warning "No GPGKEY configured in makepkg.conf!"
fi
cd ..
}
pull_tree_artix(){
cd ${TREE_DIR_ARTIX}
for tree in ${tree_names[@]};do
if [[ -d ${tree} ]];then
config_tree "${tree}"
cd ${tree}
msg "Checking (%s)" "${tree}"
pull_tree
pull_tree "${tree}"
cd ..
else
msg "Cloning (%s) ..." "$tree"
clone_tree "${HOST_TREE_ARTIX}/${tree}"
clone_tree "${HOST_TREE_ARTIX}" "${tree}"
config_tree "${tree}"
fi
done
}
mkrepo(){
local pkg="$1" team="$2"
local pkg_path=${TREE_DIR_ARTIX}/$team/$pkg
cd ${TREE_DIR_ARTIX}/$team
local org=$(get_pkg_org "$pkg")
create_repo "$pkg" "$org"
add_repo_to_team "$pkg" "$org" "$team"
subrepo_clone "$pkg" "$org"
prepare_dir "$pkg_path/trunk"
commit_jenkins_files "$pkg"
}
sync_pkg(){
local rsync_args=(-aWxvci --progress --delete-before --no-R --no-implied-dirs)
local src="$1" dest="$2" tree="$3"
local src="$1" dest="$2"
info "Sync from archlinux (%s)" "$tree"
rsync "${rsync_args[@]}" $src/ $dest/
}
@@ -126,41 +89,24 @@ from_arch(){
src=$package/repos/$repo
local git_tree_artix=$(find_tree "${TREE_DIR_ARTIX}" "$pkg")
dest=${TREE_DIR_ARTIX}/$git_tree_artix/$pkg/trunk
dest=${TREE_DIR_ARTIX}/$git_tree_arch/$pkg/trunk
show_deps "$src" "$repo"
if [[ -d $dest ]];then
cd ${TREE_DIR_ARTIX}/$git_tree_artix
cd ${TREE_DIR_ARTIX}/$git_tree_arch
source $dest/PKGBUILD 2>/dev/null
local artixver=$(get_full_version $pkg)
msg2 "Artix Version: %s" "$artixver"
sync_pkg "$src" "$dest" "$git_tree_arch"
patch_pkg "$pkg"
else
git_tree_artix=$git_tree_arch
dest=${TREE_DIR_ARTIX}/$git_tree_artix/$pkg/trunk
cd ${TREE_DIR_ARTIX}/$git_tree_artix
local org=$(get_pkg_org "$pkg")
create_repo "$pkg" "$org"
add_repo_to_team "$pkg" "$org" "$git_tree_artix"
subrepo_clone "$pkg" "$org"
commit_jenkins_files "$pkg"
prepare_dir "$dest"
sync_pkg "$src" "$dest" "$git_tree_artix"
subrepo_new "$pkg" "$git_tree_arch"
fi
info "Sync from archlinux (%s)" "$git_tree_arch"
sync_pkg "$src" "$dest"
patch_pkg "$pkg"
}
view_build(){
@@ -209,7 +155,7 @@ usage() {
echo " -s Clone or pull repos"
echo " -z Don't clone or pull arch repos"
echo ' -i Import a package from arch repos'
echo ' -m Make new remote subrepo and clone it'
echo ' -n Make new remote subrepo and clone it'
echo ' -c Configure subrepo url'
echo ' -v View package depends'
echo ' -h This help'
@@ -249,6 +195,6 @@ ${view} && view_build "${PACKAGE}"
${import} && from_arch "${PACKAGE}"
${createnew} && mkrepo "${PACKAGE}" "${TEAM}"
${createnew} && subrepo_new "${PACKAGE}" "${TEAM}"
${conf} && subrepo_config "${PACKAGE}" "${SUBORG}"

View File

@@ -38,6 +38,8 @@ commit_pkg(){
local ver=$(get_full_version "${PACKAGE}")
local commit_msg=""
local head=$(get_local_head)
if ${remove};then
local action='remove'
if [[ "${REPO_SRC}" == 'trunk' ]];then
@@ -61,12 +63,12 @@ commit_pkg(){
cd ${TREE_DIR_ARTIX}/${git_tree}
if ${push};then
mainrepo_pull "${git_tree}"
pull_tree "${git_tree}" "$head"
subrepo_push "${PACKAGE}"
subrepo_clean "${PACKAGE}"
# sleep 1
mainrepo_push "${git_tree}"
push_tree "${git_tree}"
fi
git prune
else
@@ -83,6 +85,8 @@ symlink_commit_pkg(){
[[ $arch == 'any' ]] && CARCH=any
local ver=$(get_full_version "${PACKAGE}")
local head=$(get_local_head)
if [[ ${REPO_SRC} == 'trunk' ]];then
local action='add'
local dest="${REPO_DEST}-$CARCH"
@@ -112,12 +116,12 @@ symlink_commit_pkg(){
cd ${TREE_DIR_ARTIX}/${git_tree}
if ${push};then
mainrepo_pull "${git_tree}"
pull_tree "${git_tree}" "$head"
subrepo_push "${PACKAGE}"
subrepo_clean "${PACKAGE}"
# sleep 1
mainrepo_push "${git_tree}"
push_tree "${git_tree}"
fi
git prune
else

View File

@@ -11,34 +11,138 @@
VERSION=@version@
VERSION=0.10.4.r2.gd0e3c4e
LIBDIR='@libdir@'
if [[ -f "$1"/PKGBUILD ]]; then
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
import ${LIBDIR}/util-yaml.sh
for lib in "$LIBRARY"/*.sh; do
source "$lib"
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
for lib in "$LIBRARY"/*.sh; do
source "$lib"
done
source /etc/makepkg.conf
write_attr(){
local ident1="$1" ident2="$2" ident3="$3"
local attrname=$4 attrvalues=("${@:5}")
# normalize whitespace, strip leading and trailing
attrvalues=("${attrvalues[@]//+([[:space:]])/ }")
attrvalues=("${attrvalues[@]#[[:space:]]}")
attrvalues=("${attrvalues[@]%[[:space:]]}")
case $attrname in
makedepends|checkdepends|depends|provides|arch)
Yaml+=$(write_yaml_map $ident1 "$attrname")
for v in ${attrvalues[@]};do
Yaml+=$(write_yaml_seq $ident2 "$v")
done
;;
*)
for v in ${attrvalues[@]};do
Yaml+=$(write_yaml_map $ident3 "$attrname" "$v")
done
;;
esac
}
extract_info() {
local pkgname=$1 attrname=$2 isarray=$3 outvalue=
if get_pkgbuild_attribute "$pkgname" "$attrname" "$isarray" 'outvalue'; then
[[ -z $pkgname ]] && write_attr 2 4 2 "$attrname" "${outvalue[@]}"
[[ -n $pkgname ]] && write_attr 4 6 2 "$attrname" "${outvalue[@]}"
fi
}
write_details() {
local attr package_arch a
local multivalued_arch_attrs=(provides depends makedepends checkdepends)
local singlevalued=()
local multivalued=(arch provides depends checkdepends)
if [[ -z "$1" ]];then
singlevalued=(pkgver pkgrel epoch)
multivalued=(arch provides depends makedepends checkdepends)
fi
for attr in "${singlevalued[@]}"; do
extract_info "$1" "$attr" 0
done
. /etc/makepkg.conf
. "$1"/PKGBUILD
for attr in "${multivalued[@]}"; do
extract_info "$1" "$attr" 1
done
pkgfile=$(print_all_package_names)
fi
get_pkgbuild_attribute "$1" 'arch' 1 'package_arch'
for a in "${package_arch[@]}"; do
# 'any' is special. there's no support for, e.g. depends_any.
[[ $a = any ]] && continue
NL=$'\n'
for attr in "${multivalued_arch_attrs[@]}"; do
extract_info "$1" "${attr}_$a" 1
done
done
}
Yaml="%YAML 1.2"$NL
Yaml+="---"$NL
write_pkg_yaml(){
local pkgfile=$(print_all_package_names)
Yaml+="pkgfile:"$NL
for f in ${pkgfile[@]};do
Yaml+=" - ${f##*/}"$NL
Yaml=$(write_yaml_header)
Yaml+=$(write_empty_line)
Yaml+=$(write_yaml_map 0 "pkgbase")
Yaml+=$(write_yaml_map 2 "pkgname" "${pkgbase:-$pkgname}")
${details} && write_details ''
Yaml+=$(write_empty_line)
Yaml+=$(write_yaml_map 0 "package")
for pkg in "${pkgname[@]}"; do
Yaml+=$(write_yaml_seq_map 2 "pkgname" "$pkg")
${details} && write_details "$pkg"
done
Yaml+=$(write_empty_line)
Yaml+=$(write_yaml_map 0 "pkgfile")
for f in ${pkgfile[@]};do
Yaml+=$(write_yaml_seq 2 "${f##*/}")
done
Yaml+=$(write_empty_line)
printf '%s' "${Yaml}"
}
usage() {
echo "Usage: ${0##*/} [options]"
echo " -d Don't include details"
echo ' -h This help'
echo ''
exit $1
}
details=true
opts='dh'
while getopts "${opts}" arg; do
case "${arg}" in
d) details=false ;;
h|?) usage 0 ;;
*) echo "invalid argument '${arg}'"; usage 1 ;;
esac
done
Yaml+="pkgname:"$NL
for n in ${pkgname[@]};do
Yaml+=" - ${n##*/}"$NL
done
shift $(( $OPTIND - 1 ))
printf '%s' "${Yaml}"
[[ -f "$1"/PKGBUILD ]] || die "%s/PKGBUILD does not exist!" "$1"
PACKAGE=$1/PKGBUILD; shift
source "$PACKAGE"
write_pkg_yaml

View File

@@ -1,84 +0,0 @@
#!/bin/bash
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
write_users_conf(){
local conf="$1/users.conf"
msg2 "Writing %s ..." "${conf##*/}"
echo "---" > "$conf"
echo "defaultGroups:" >> "$conf"
local IFS=','
for g in ${ADDGROUPS[@]};do
echo " - $g" >> "$conf"
done
unset IFS
echo "autologinGroup: autologin" >> "$conf"
echo "doAutologin: false" >> "$conf"
echo "sudoersGroup: wheel" >> "$conf"
echo "setRootPassword: true" >> "$conf"
echo "availableShells: /bin/bash, /bin/zsh" >> "$conf" # only used in new 'users' module
# echo "passwordRequirements:" >> "$conf"
# echo " minLength: -1" >> "$conf"
# echo " maxLength: -1" >> "$conf"
# echo " libpwquality:" >> "$conf"
# echo " - minlen=8" >> "$conf"
# echo " - minclass=80" >> "$conf"
}
write_servicescfg_conf(){
local init="$2"
local conf="$1"/services-"$init".conf
msg2 "Writing %s ..." "${conf##*/}"
echo '---' > "$conf"
case "$init" in
'runit')
echo 'svDir: /etc/runit/sv' >> "$conf"
echo '' >> "$conf"
echo 'runsvDir: /etc/runit/runsvdir' >> "$conf"
echo '' >> "$conf"
echo 'services:' >> "$conf"
echo " enabled:" >> "$conf"
for svc in ${SERVICES[@]};do
echo " - name: $svc" >> "$conf"
echo ' runlevel: default' >> "$conf"
done
;;
'openrc')
echo 'initdDir: /etc/init.d' >> "$conf"
echo '' >> "$conf"
echo 'runlevelsDir: /etc/runlevels' >> "$conf"
echo '' >> "$conf"
echo 'services:' >> "$conf"
for svc in ${SERVICES[@]};do
echo " - name: $svc" >> "$conf"
echo ' runlevel: default' >> "$conf"
done
;;
esac
}
write_postcfg_conf(){
local conf="$1/postcfg.conf" init="$2"
sed -e "s|openrc|$init|" -i "$conf"
}
configure_calamares(){
local mods="$1/etc/calamares/modules" init="$2"
if [[ -d "$mods" ]];then
info "Configuring [Calamares]"
write_users_conf "$mods"
write_servicescfg_conf "$mods" "$init"
write_postcfg_conf "$mods" "$init"
local name=services-"$init"
sed -e "s|services-openrc|$name|" -i "$1"/etc/calamares/settings.conf
info "Done configuring [Calamares]"
fi
}

View File

@@ -11,8 +11,8 @@
import ${LIBDIR}/util-chroot.sh
import ${LIBDIR}/util-iso-grub.sh
import ${LIBDIR}/util-iso-yaml.sh
import ${LIBDIR}/util-iso-profile.sh
import ${LIBDIR}/util-yaml.sh
track_img() {
info "mount: [%s]" "$2"
@@ -256,13 +256,77 @@ clean_up_image(){
fi
}
write_users_conf(){
local yaml=$(write_yaml_header)
yaml+=$(write_empty_line)
yaml+=$(write_yaml_map 0 'defaultGroups')
local IFS=','
for g in ${ADDGROUPS[@]};do
yaml+=$(write_yaml_seq 2 "$g")
done
unset IFS
yaml+=$(write_yaml_map 0 'autologinGroup' 'autologin')
yaml+=$(write_yaml_map 0 'doAutologin' 'false')
yaml+=$(write_yaml_map 0 'sudoersGroup' 'wheel')
yaml+=$(write_yaml_map 0 'setRootPassword' 'true')
yaml+=$(write_yaml_map 0 'availableShells' '/bin/bash, /bin/zsh')
# yaml+=$(write_yaml_map 0 'passwordRequirements')
# yaml+=$(write_yaml_map 2 'minLength' '-1')
# yaml+=$(write_yaml_map 2 'maxLength' '-1')
# yaml+=$(write_yaml_map 2 'libpwquality')
# yaml+=$(write_yaml_seq 4 "minlen=8")
# yaml+=$(write_yaml_seq 4 "minclass=80")
yaml+=$(write_empty_line)
printf '%s' "${yaml}"
}
write_servicescfg_conf(){
local yaml=$(write_yaml_header)
yaml+=$(write_empty_line)
case "${INITSYS}" in
'runit')
yaml+=$(write_yaml_map 0 'svDir' '/etc/runit/sv')
yaml+=$(write_yaml_map 0 'runsvDir' '/etc/runit/runsvdir')
yaml+=$(write_yaml_map 0 'services')
yaml+=$(write_yaml_map 2 'enabled')
for svc in ${SERVICES[@]};do
yaml+=$(write_yaml_seq_map 4 'name' "$svc")
yaml+=$(write_yaml_map 6 'runlevel' 'default')
done
;;
'openrc')
yaml+=$(write_yaml_map 0 'initdDir' '/etc/init.d')
yaml+=$(write_yaml_map 0 'runlevelsDir' '/etc/runlevels')
yaml+=$(write_yaml_map 0 'services')
for svc in ${SERVICES[@]};do
yaml+=$(write_yaml_seq_map 2 'name' "$svc")
yaml+=$(write_yaml_map 4 'runlevel' 'default')
done
;;
esac
yaml+=$(write_empty_line)
printf '%s' "${yaml}"
}
configure_calamares(){
local mods="$1/etc/calamares/modules"
if [[ -d "$mods" ]];then
info "Configuring [Calamares]"
write_users_conf > "$mods"/users.conf
write_servicescfg_conf > "$mods"/services-"${INITSYS}".conf
sed -e "s|openrc|${INITSYS}|" -i "$mods"/postcfg.conf
sed -e "s|services-openrc|services-${INITSYS}|" -i "$1"/etc/calamares/settings.conf
info "Done configuring [Calamares]"
fi
}
configure_live_image(){
local fs="$1"
msg "Configuring [livefs]"
configure_hosts "$fs"
configure_system "$fs"
configure_services "$fs"
configure_calamares "$fs" "${INITSYS}"
configure_calamares "$fs"
write_live_session_conf "$fs"
msg "Done configuring [livefs]"
}

View File

@@ -9,6 +9,14 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
get_local_head(){
echo $(git log --pretty=%H ...refs/heads/master^ | head -n 1)
}
get_remote_head(){
echo $(git ls-remote origin -h refs/heads/master | cut -f1)
}
subrepo_push(){
local pkg="$1"
msg2 "Update (%s)" "$pkg"
@@ -41,16 +49,40 @@ subrepo_clone(){
git subrepo clone gitea@"${GIT_DOMAIN}":"$org"/"$gitname".git "$pkg"
}
mainrepo_pull(){
local tree="$1"
msg2 "Check (%s)" "${tree}"
git push origin master
clone_tree(){
local timer=$(get_timer) url="$1" tree="$2"
msg "Cloning (%s) ..." "$tree"
git clone $url/$tree.git
show_elapsed_time "${FUNCNAME}" "${timer}"
}
has_changes(){
local head_l="$1" head_r="$2"
if [[ "$head_l" == "$head_r" ]]; then
msg2 "remote changes: no"
return 1
else
msg2 "remote changes: yes"
return 0
fi
}
mainrepo_push(){
pull_tree(){
local tree="$1"
msg2 "Update (%s)" "${tree}"
local local_head=${2:-$(get_local_head)}
local remote_head=$(get_remote_head)
msg "Checking (%s)" "${tree}"
if $(has_changes "${local_head}" "${remote_head}");then
git pull origin master
fi
}
push_tree(){
local tree="$1"
msg "Update (%s)" "${tree}"
git push origin master
}
@@ -88,3 +120,35 @@ commit_jenkins_files(){
git commit -m "add jenkinsfile & .artixlinux/agent.yaml"
}
config_tree(){
local tree="$1"
cd $tree
git config --bool pull.rebase true
git config commit.gpgsign true
if [[ -n "${GPGKEY}" ]];then
git config user.signingkey "${GPGKEY}"
else
warning "No GPGKEY configured in makepkg.conf!"
fi
cd ..
}
subrepo_new(){
local pkg="$1" team="$2"
local dest=${TREE_DIR_ARTIX}/$team/$pkg/trunk
cd ${TREE_DIR_ARTIX}/$team
local org=$(get_pkg_org "$pkg")
create_repo "$pkg" "$org"
add_repo_to_team "$pkg" "$org" "$team"
subrepo_clone "$pkg" "$org"
prepare_dir "$dest"
commit_jenkins_files "$pkg"
}

View File

@@ -9,14 +9,6 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
get_local_head(){
echo $(git log --pretty=%H ...refs/heads/$1^ | head -n 1)
}
get_remote_head(){
echo $(git ls-remote origin -h refs/heads/$1 | cut -f1)
}
patch_pkg(){
local pkg="$1"
case $pkg in
@@ -103,24 +95,6 @@ get_import_path(){
echo $import_path
}
clone_tree(){
local timer=$(get_timer) host_tree="$1"
git clone $host_tree.git
show_elapsed_time "${FUNCNAME}" "${timer}"
}
pull_tree(){
local branch="master"
local local_head=$(get_local_head "$branch")
local remote_head=$(get_remote_head "$branch")
if [[ "${local_head}" == "${remote_head}" ]]; then
msg2 "remote changes: no"
else
msg2 "remote changes: yes"
git pull origin "$branch"
fi
}
pkgver_equal() {
if [[ $1 = *-* && $2 = *-* ]]; then
# if both versions have a pkgrel, then they must be an exact match

32
lib/util-yaml.sh Normal file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
write_yaml_header(){
printf '%s\n%s' "%YAML 1.2" '---'
}
write_empty_line(){
printf '\n%s\n' ' '
}
write_yaml_map(){
local ident="$1" key="$2" val="$3"
printf "\n%${ident}s%s: %s\n" '' "$key" "$val"
}
write_yaml_seq(){
local ident="$1" val="$2"
printf "\n%${ident}s- %s\n" '' "$val"
}
write_yaml_seq_map(){
local ident="$1" key="$2" val="$3"
printf "\n%${ident}s- %s: %s\n" '' "$key" "$val"
}