2014-10-08 00:11:53 +02:00
|
|
|
#!/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.
|
|
|
|
|
2016-02-27 00:39:58 +01:00
|
|
|
# $1: section
|
2016-05-23 03:03:00 +02:00
|
|
|
parse_section() {
|
2016-09-15 23:58:18 +02:00
|
|
|
local is_section=0
|
|
|
|
while read line; do
|
|
|
|
[[ $line =~ ^\ {0,}# ]] && continue
|
|
|
|
[[ -z "$line" ]] && continue
|
|
|
|
if [ $is_section == 0 ]; then
|
|
|
|
if [[ $line =~ ^\[.*?\] ]]; then
|
|
|
|
line=${line:1:$((${#line}-2))}
|
|
|
|
section=${line// /}
|
|
|
|
if [[ $section == $1 ]]; then
|
|
|
|
is_section=1
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
elif [[ $line =~ ^\[.*?\] && $is_section == 1 ]]; then
|
|
|
|
break
|
|
|
|
else
|
|
|
|
pc_key=${line%%=*}
|
|
|
|
pc_key=${pc_key// /}
|
|
|
|
pc_value=${line##*=}
|
|
|
|
pc_value=${pc_value## }
|
|
|
|
eval "$pc_key='$pc_value'"
|
|
|
|
fi
|
|
|
|
done < "$2"
|
2016-05-23 03:03:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
get_repos() {
|
2016-09-15 23:58:18 +02:00
|
|
|
local section repos=() filter='^\ {0,}#'
|
|
|
|
while read line; do
|
|
|
|
[[ $line =~ "${filter}" ]] && continue
|
|
|
|
[[ -z "$line" ]] && continue
|
|
|
|
if [[ $line =~ ^\[.*?\] ]]; then
|
|
|
|
line=${line:1:$((${#line}-2))}
|
|
|
|
section=${line// /}
|
|
|
|
case ${section} in
|
|
|
|
"options") continue ;;
|
|
|
|
*) repos+=("${section}") ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
done < "$1"
|
|
|
|
echo ${repos[@]}
|
2016-05-23 03:03:00 +02:00
|
|
|
}
|
2016-02-27 00:39:58 +01:00
|
|
|
|
2016-05-23 03:03:00 +02:00
|
|
|
check_user_repos_conf(){
|
2016-09-15 23:58:18 +02:00
|
|
|
local repositories=$(get_repos "$1") uri='file://'
|
|
|
|
for repo in ${repositories[@]}; do
|
|
|
|
msg2 "parsing repo [%s] ..." "${repo}"
|
|
|
|
parse_section "${repo}" "$1"
|
|
|
|
[[ ${pc_value} == $uri* ]] && die "Using local repositories is not supported!"
|
|
|
|
done
|
2016-05-23 03:03:00 +02:00
|
|
|
}
|
2016-05-20 19:42:16 +02:00
|
|
|
|
2016-06-09 08:12:24 +02:00
|
|
|
get_pac_mirrors_conf(){
|
2016-09-15 23:58:18 +02:00
|
|
|
local conf="$tmp_dir/pacman-mirrors-$1.conf"
|
|
|
|
cp "${DATADIR}/pacman-mirrors.conf" "$conf"
|
|
|
|
sed -i "$conf" \
|
|
|
|
-e "s|Branch = stable|Branch = $1|"
|
2016-06-09 08:12:24 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
echo "$conf"
|
2016-06-09 08:12:24 +02:00
|
|
|
}
|
|
|
|
|
2016-06-09 18:03:38 +02:00
|
|
|
read_build_list(){
|
2016-09-15 23:58:18 +02:00
|
|
|
local _space="s| ||g" \
|
|
|
|
_clean=':a;N;$!ba;s/\n/ /g' \
|
|
|
|
_com_rm="s|#.*||g"
|
2015-11-23 22:57:17 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
build_list=$(sed "$_com_rm" "$1.list" \
|
|
|
|
| sed "$_space" \
|
|
|
|
| sed "$_clean")
|
2015-11-23 22:57:17 +01:00
|
|
|
}
|
|
|
|
|
2016-06-09 18:03:38 +02:00
|
|
|
# $1: list_dir
|
|
|
|
show_build_lists(){
|
2016-09-15 23:58:18 +02:00
|
|
|
local list temp
|
|
|
|
for item in $(ls $1/*.list); do
|
|
|
|
temp=${item##*/}
|
|
|
|
list=${list:-}${list:+|}${temp%.list}
|
|
|
|
done
|
|
|
|
echo $list
|
2015-06-06 09:48:56 +02:00
|
|
|
}
|
|
|
|
|
2016-06-09 13:27:45 +02:00
|
|
|
# $1: make_conf_dir
|
2016-06-09 21:58:18 +02:00
|
|
|
show_build_profiles(){
|
2016-10-13 19:10:04 +02:00
|
|
|
local cpuarch temp
|
2016-09-15 23:58:18 +02:00
|
|
|
for item in $(ls $1/*.conf); do
|
|
|
|
temp=${item##*/}
|
2016-10-13 19:10:04 +02:00
|
|
|
cpuarch=${cpuarch:-}${cpuarch:+|}${temp%.conf}
|
2016-09-15 23:58:18 +02:00
|
|
|
done
|
2016-10-13 19:10:04 +02:00
|
|
|
echo $cpuarch
|
2016-06-09 10:01:42 +02:00
|
|
|
}
|
|
|
|
|
2016-06-09 18:03:38 +02:00
|
|
|
# $1: list_dir
|
|
|
|
# $2: build list
|
|
|
|
eval_build_list(){
|
2016-09-15 23:58:18 +02:00
|
|
|
eval "case $2 in
|
|
|
|
$(show_build_lists $1)) is_build_list=true; read_build_list $1/$2 ;;
|
|
|
|
*) is_build_list=false ;;
|
|
|
|
esac"
|
2015-06-06 09:48:56 +02:00
|
|
|
}
|
|
|
|
|
2016-02-27 18:01:45 +01:00
|
|
|
in_array() {
|
2016-09-15 23:58:18 +02:00
|
|
|
local needle=$1; shift
|
|
|
|
local item
|
|
|
|
for item in "$@"; do
|
|
|
|
[[ $item = $needle ]] && return 0 # Found
|
|
|
|
done
|
|
|
|
return 1 # Not Found
|
2016-02-27 18:01:45 +01:00
|
|
|
}
|
|
|
|
|
2015-02-18 04:28:11 +01:00
|
|
|
get_timer(){
|
2016-09-15 23:58:18 +02:00
|
|
|
echo $(date +%s)
|
2015-02-18 04:28:11 +01:00
|
|
|
}
|
|
|
|
|
2015-09-20 12:40:49 +02:00
|
|
|
|
2015-02-18 04:28:11 +01:00
|
|
|
# $1: start timer
|
|
|
|
elapsed_time(){
|
2016-09-15 23:58:18 +02:00
|
|
|
echo $(echo $1 $(get_timer) | awk '{ printf "%0.2f",($2-$1)/60 }')
|
2015-02-18 04:28:11 +01:00
|
|
|
}
|
|
|
|
|
2016-02-15 16:47:52 +01:00
|
|
|
show_elapsed_time(){
|
2016-09-15 23:58:18 +02:00
|
|
|
info "Time %s: %s minutes" "$1" "$(elapsed_time $2)"
|
2016-02-15 16:47:52 +01:00
|
|
|
}
|
|
|
|
|
2016-02-26 19:25:07 +01:00
|
|
|
lock() {
|
2016-09-15 23:58:18 +02:00
|
|
|
eval "exec $1>"'"$2"'
|
|
|
|
if ! flock -n $1; then
|
|
|
|
stat_busy "$3"
|
|
|
|
flock $1
|
|
|
|
stat_done
|
|
|
|
fi
|
2016-02-26 19:25:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
slock() {
|
2016-09-15 23:58:18 +02:00
|
|
|
eval "exec $1>"'"$2"'
|
|
|
|
if ! flock -sn $1; then
|
|
|
|
stat_busy "$3"
|
|
|
|
flock -s $1
|
|
|
|
stat_done
|
|
|
|
fi
|
2016-02-26 19:25:07 +01:00
|
|
|
}
|
|
|
|
|
2014-11-12 02:19:58 +01:00
|
|
|
check_root() {
|
2016-09-15 23:58:18 +02:00
|
|
|
(( EUID == 0 )) && return
|
|
|
|
if type -P sudo >/dev/null; then
|
|
|
|
exec sudo -- "$@"
|
|
|
|
else
|
|
|
|
exec su root -c "$(printf ' %q' "$@")"
|
|
|
|
fi
|
2014-11-12 02:19:58 +01:00
|
|
|
}
|
|
|
|
|
2015-06-03 16:09:26 +02:00
|
|
|
copy_mirrorlist(){
|
2016-09-15 23:58:18 +02:00
|
|
|
cp -a /etc/pacman.d/mirrorlist "$1/etc/pacman.d/"
|
2015-06-03 00:14:49 +02:00
|
|
|
}
|
|
|
|
|
2015-06-03 16:09:26 +02:00
|
|
|
copy_keyring(){
|
2016-09-15 23:58:18 +02:00
|
|
|
if [[ -d /etc/pacman.d/gnupg ]] && [[ ! -d $1/etc/pacman.d/gnupg ]]; then
|
|
|
|
cp -a /etc/pacman.d/gnupg "$1/etc/pacman.d/"
|
|
|
|
fi
|
2015-06-01 21:19:28 +02:00
|
|
|
}
|
|
|
|
|
2014-11-13 00:19:49 +01:00
|
|
|
load_vars() {
|
2016-09-15 23:58:18 +02:00
|
|
|
local var
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -f $1 ]] || return 1
|
2014-11-13 00:19:49 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER CARCH GPGKEY; do
|
|
|
|
[[ -z ${!var} ]] && eval $(grep -a "^${var}=" "$1")
|
|
|
|
done
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
return 0
|
2014-11-13 00:19:49 +01:00
|
|
|
}
|
|
|
|
|
2015-06-12 11:09:29 +02:00
|
|
|
prepare_dir(){
|
2017-08-12 18:25:38 +02:00
|
|
|
if [[ ! -d $1 ]];then
|
|
|
|
mkdir -p $1
|
|
|
|
fi
|
2015-06-12 11:09:29 +02:00
|
|
|
}
|
|
|
|
|
2016-03-02 17:42:49 +01:00
|
|
|
# $1: chroot
|
|
|
|
get_branch(){
|
2016-09-15 23:58:18 +02:00
|
|
|
echo $(cat "$1/etc/pacman-mirrors.conf" | grep '^Branch = ' | sed 's/Branch = \s*//g')
|
2016-03-02 17:42:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# $1: chroot
|
|
|
|
# $2: branch
|
|
|
|
set_branch(){
|
2016-09-15 23:58:18 +02:00
|
|
|
info "Setting mirrorlist branch: %s" "$2"
|
|
|
|
sed -e "s|/stable|/$2|g" -i "$1/etc/pacman.d/mirrorlist"
|
2016-03-02 17:42:49 +01:00
|
|
|
}
|
|
|
|
|
2015-06-06 15:54:37 +02:00
|
|
|
init_common(){
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${target_branch} ]] && target_branch='stable'
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${target_arch} ]] && target_arch=$(uname -m)
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${cache_dir} ]] && cache_dir='/var/cache/manjaro-tools'
|
2015-05-21 22:44:32 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${chroots_dir} ]] && chroots_dir='/var/lib/manjaro-tools'
|
2015-05-21 22:44:32 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${log_dir} ]] && log_dir='/var/log/manjaro-tools'
|
2016-02-26 17:56:17 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${build_mirror} ]] && build_mirror='http://mirror.netzspielplatz.de/manjaro/packages'
|
2016-06-11 20:32:03 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${tmp_dir} ]] && tmp_dir='/tmp/manjaro-tools'
|
2015-06-06 15:54:37 +02:00
|
|
|
}
|
2015-06-06 10:03:52 +02:00
|
|
|
|
2015-06-06 15:54:37 +02:00
|
|
|
init_buildtree(){
|
2016-09-15 23:58:18 +02:00
|
|
|
tree_dir=${cache_dir}/pkgtree
|
2015-06-09 00:02:32 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
tree_dir_abs=${tree_dir}/packages-archlinux
|
2015-06-09 00:02:32 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${repo_tree[@]} ]] && repo_tree=('core' 'extra' 'community' 'multilib' 'openrc')
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${host_tree} ]] && host_tree='https://github.com/manjaro'
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${host_tree_abs} ]] && host_tree_abs='https://projects.archlinux.org/git/svntogit'
|
2015-06-06 15:54:37 +02:00
|
|
|
}
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-06-06 15:54:37 +02:00
|
|
|
init_buildpkg(){
|
2016-09-15 23:58:18 +02:00
|
|
|
chroots_pkg="${chroots_dir}/buildpkg"
|
2015-05-21 23:23:33 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
list_dir_pkg="${SYSCONFDIR}/pkg.list.d"
|
2015-05-21 23:23:33 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
make_conf_dir="${SYSCONFDIR}/make.conf.d"
|
2016-06-09 10:01:42 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -d ${USERCONFDIR}/pkg.list.d ]] && list_dir_pkg=${USERCONFDIR}/pkg.list.d
|
2015-12-03 21:06:43 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${build_list_pkg} ]] && build_list_pkg='default'
|
2015-11-30 21:35:30 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
cache_dir_pkg=${cache_dir}/pkg
|
2015-06-06 15:54:37 +02:00
|
|
|
}
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-02-21 11:47:32 +01:00
|
|
|
get_iso_label(){
|
2016-09-15 23:58:18 +02:00
|
|
|
local label="$1"
|
|
|
|
label="${label//_}" # relace all _
|
|
|
|
label="${label//-}" # relace all -
|
|
|
|
label="${label^^}" # all uppercase
|
|
|
|
label="${label::8}" # limit to 8 characters
|
|
|
|
echo ${label}
|
2016-02-21 11:47:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
get_codename(){
|
2016-09-15 23:58:18 +02:00
|
|
|
source /etc/lsb-release
|
|
|
|
echo "${DISTRIB_CODENAME}"
|
2016-02-21 11:47:32 +01:00
|
|
|
}
|
|
|
|
|
2017-02-16 00:33:52 +01:00
|
|
|
get_release(){
|
|
|
|
source /etc/lsb-release
|
|
|
|
echo "${DISTRIB_RELEASE}"
|
|
|
|
}
|
|
|
|
|
|
|
|
get_distname(){
|
|
|
|
source /etc/lsb-release
|
|
|
|
echo "${DISTRIB_ID%Linux}"
|
|
|
|
}
|
|
|
|
|
2017-02-16 16:46:04 +01:00
|
|
|
get_distid(){
|
|
|
|
source /etc/lsb-release
|
|
|
|
echo "${DISTRIB_ID}"
|
|
|
|
}
|
|
|
|
|
2017-02-16 00:33:52 +01:00
|
|
|
get_disturl(){
|
2017-06-09 09:28:33 +02:00
|
|
|
source /usr/lib/os-release
|
2017-02-16 00:33:52 +01:00
|
|
|
echo "${HOME_URL}"
|
|
|
|
}
|
|
|
|
|
|
|
|
get_osname(){
|
2017-06-09 09:28:33 +02:00
|
|
|
source /usr/lib/os-release
|
2017-02-16 00:33:52 +01:00
|
|
|
echo "${NAME}"
|
|
|
|
}
|
|
|
|
|
|
|
|
get_osid(){
|
2017-06-09 09:28:33 +02:00
|
|
|
source /usr/lib/os-release
|
2017-02-16 00:33:52 +01:00
|
|
|
echo "${ID}"
|
|
|
|
}
|
|
|
|
|
2015-06-06 15:54:37 +02:00
|
|
|
init_buildiso(){
|
2016-09-15 23:58:18 +02:00
|
|
|
chroots_iso="${chroots_dir}/buildiso"
|
2015-05-21 23:23:33 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
list_dir_iso="${SYSCONFDIR}/iso.list.d"
|
2015-05-21 23:23:33 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -d ${USERCONFDIR}/iso.list.d ]] && list_dir_iso=${USERCONFDIR}/iso.list.d
|
2015-12-03 21:06:43 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${build_list_iso} ]] && build_list_iso='default'
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
cache_dir_iso="${cache_dir}/iso"
|
2015-11-30 21:35:30 +01:00
|
|
|
|
2017-02-20 15:39:23 +01:00
|
|
|
profile_repo='iso-profiles'
|
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
##### iso settings #####
|
2015-03-02 23:35:15 +01:00
|
|
|
|
2017-02-16 00:33:52 +01:00
|
|
|
[[ -z ${dist_release} ]] && dist_release=$(get_release)
|
2014-12-03 22:59:30 +01:00
|
|
|
|
2017-10-31 17:28:26 +01:00
|
|
|
[[ -z ${dist_codename} ]] && dist_codename=$(get_codename)
|
2014-12-03 22:59:30 +01:00
|
|
|
|
2017-02-16 00:33:52 +01:00
|
|
|
dist_name=$(get_distname)
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2017-02-16 00:33:52 +01:00
|
|
|
iso_name=$(get_osid)
|
2015-03-03 19:39:53 +01:00
|
|
|
|
2017-02-16 10:24:38 +01:00
|
|
|
[[ -z ${dist_branding} ]] && dist_branding="MJRO"
|
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
iso_label=$(get_iso_label "${dist_branding}${dist_release//.}")
|
2015-03-05 10:54:09 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${initsys} ]] && initsys="systemd"
|
2016-02-17 18:56:37 +01:00
|
|
|
|
2016-12-20 15:41:10 +01:00
|
|
|
[[ -z ${kernel} ]] && kernel="linux49"
|
2016-02-17 18:56:37 +01:00
|
|
|
|
2017-02-15 01:18:20 +01:00
|
|
|
[[ -z ${gpgkey} ]] && gpgkey=''
|
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
mhwd_repo="/opt/pkg"
|
2015-06-06 15:54:37 +02:00
|
|
|
}
|
|
|
|
|
2015-11-12 00:31:51 +01:00
|
|
|
init_deployiso(){
|
|
|
|
|
2017-02-12 21:10:24 +01:00
|
|
|
host="sourceforge.net"
|
|
|
|
|
2017-02-16 16:46:04 +01:00
|
|
|
[[ -z ${project} ]] && project="[SetProject]"
|
2017-02-12 21:10:24 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${account} ]] && account="[SetUser]"
|
2015-11-12 00:31:51 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${limit} ]] && limit=100
|
2017-02-12 19:19:18 +01:00
|
|
|
|
|
|
|
[[ -z ${tracker_url} ]] && tracker_url='udp://mirror.strits.dk:6969'
|
|
|
|
|
|
|
|
[[ -z ${piece_size} ]] && piece_size=21
|
2017-02-13 09:53:21 +01:00
|
|
|
|
|
|
|
[[ -z ${iso_mirrors[@]} ]] && iso_mirrors=('heanet' 'jaist' 'netcologne' 'iweb' 'kent')
|
|
|
|
|
2017-02-16 16:46:04 +01:00
|
|
|
torrent_meta="$(get_distid)"
|
2015-11-12 00:31:51 +01:00
|
|
|
}
|
|
|
|
|
2015-06-06 15:54:37 +02:00
|
|
|
load_config(){
|
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -f $1 ]] || return 1
|
2015-06-06 15:54:37 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
manjaro_tools_conf="$1"
|
2015-06-06 15:54:37 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -r ${manjaro_tools_conf} ]] && source ${manjaro_tools_conf}
|
2015-06-06 15:54:37 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
init_common
|
2015-06-06 15:54:37 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
init_buildtree
|
2015-06-06 15:54:37 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
init_buildpkg
|
2015-06-06 15:54:37 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
init_buildiso
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
init_deployiso
|
2015-11-12 00:31:51 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
return 0
|
2015-03-02 23:35:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
load_profile_config(){
|
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -f $1 ]] || return 1
|
2015-03-02 23:35:15 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
profile_conf="$1"
|
2015-03-02 23:35:15 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -r ${profile_conf} ]] && source ${profile_conf}
|
2015-03-02 23:35:15 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${displaymanager} ]] && displaymanager="none"
|
2015-03-02 23:35:15 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${autologin} ]] && autologin="true"
|
|
|
|
[[ ${displaymanager} == 'none' ]] && autologin="false"
|
2015-06-06 13:43:00 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${multilib} ]] && multilib="true"
|
2015-06-09 17:17:23 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${nonfree_mhwd} ]] && nonfree_mhwd="true"
|
2015-06-09 18:42:55 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${efi_boot_loader} ]] && efi_boot_loader="grub"
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${hostname} ]] && hostname="manjaro"
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${username} ]] && username="manjaro"
|
2015-05-21 22:44:32 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${password} ]] && password="manjaro"
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${login_shell} ]] && login_shell='/bin/bash'
|
2016-05-21 10:17:44 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
if [[ -z ${addgroups} ]];then
|
2017-03-09 12:23:07 +01:00
|
|
|
addgroups="video,power,storage,optical,network,lp,scanner,wheel,sys"
|
2016-09-15 23:58:18 +02:00
|
|
|
fi
|
2014-12-17 02:14:15 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
if [[ -z ${enable_systemd[@]} ]];then
|
|
|
|
enable_systemd=('bluetooth' 'cronie' 'ModemManager' 'NetworkManager' 'org.cups.cupsd' 'tlp' 'tlp-sleep')
|
|
|
|
fi
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${disable_systemd[@]} ]] && disable_systemd=('pacman-init')
|
2015-09-12 13:03:47 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
if [[ -z ${enable_openrc[@]} ]];then
|
2017-03-26 18:54:45 +02:00
|
|
|
enable_openrc=('acpid' 'bluetooth' 'elogind' 'cronie' 'cupsd' 'dbus' 'syslog-ng' 'NetworkManager')
|
2016-09-15 23:58:18 +02:00
|
|
|
fi
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${disable_openrc[@]} ]] && disable_openrc=()
|
2015-09-12 13:03:47 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
if [[ -z ${enable_systemd_live[@]} ]];then
|
|
|
|
enable_systemd_live=('manjaro-live' 'mhwd-live' 'pacman-init' 'mirrors-live')
|
|
|
|
fi
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
if [[ -z ${enable_openrc_live[@]} ]];then
|
|
|
|
enable_openrc_live=('manjaro-live' 'mhwd-live' 'pacman-init' 'mirrors-live')
|
|
|
|
fi
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
if [[ ${displaymanager} != "none" ]]; then
|
|
|
|
enable_openrc+=('xdm')
|
2017-02-27 21:49:19 +01:00
|
|
|
enable_systemd+=("${displaymanager}")
|
2016-09-15 23:58:18 +02:00
|
|
|
fi
|
2016-08-04 21:03:06 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${netinstall} ]] && netinstall='false'
|
2016-07-29 01:12:51 +02:00
|
|
|
|
2017-07-30 13:42:53 +02:00
|
|
|
[[ -z ${mhwd_used} ]] && mhwd_used='true'
|
|
|
|
|
2017-08-12 18:25:38 +02:00
|
|
|
[[ -z ${oem_used} ]] && oem_used='false'
|
|
|
|
|
2016-09-28 14:24:06 +02:00
|
|
|
[[ -z ${chrootcfg} ]] && chrootcfg='false'
|
2016-07-30 16:26:46 +02:00
|
|
|
|
2016-11-01 11:16:22 +01:00
|
|
|
netgroups="https://raw.githubusercontent.com/manjaro/calamares-netgroups/master"
|
2016-07-30 21:31:07 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${geoip} ]] && geoip='true'
|
2016-09-11 23:16:59 +02:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -z ${smb_workgroup} ]] && smb_workgroup=''
|
2016-08-22 12:36:35 +02:00
|
|
|
|
2017-03-09 13:01:20 +01:00
|
|
|
basic='true'
|
2017-02-04 14:24:33 +01:00
|
|
|
[[ -z ${extra} ]] && extra='false'
|
|
|
|
|
|
|
|
${extra} && basic='false'
|
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
return 0
|
2014-12-08 22:16:06 +01:00
|
|
|
}
|
2015-01-11 21:09:01 +01:00
|
|
|
|
2016-09-18 12:21:18 +02:00
|
|
|
get_edition(){
|
|
|
|
local result=$(find ${run_dir} -maxdepth 2 -name "$1") path
|
|
|
|
[[ -z $result ]] && die "%s is not a valid profile or build list!" "$1"
|
|
|
|
path=${result%/*}
|
|
|
|
echo ${path##*/}
|
|
|
|
}
|
|
|
|
|
2016-09-18 12:06:09 +02:00
|
|
|
reset_profile(){
|
|
|
|
unset displaymanager
|
|
|
|
unset autologin
|
|
|
|
unset multilib
|
|
|
|
unset nonfree_mhwd
|
|
|
|
unset efi_boot_loader
|
|
|
|
unset hostname
|
|
|
|
unset username
|
|
|
|
unset password
|
|
|
|
unset addgroups
|
|
|
|
unset enable_systemd
|
|
|
|
unset disable_systemd
|
|
|
|
unset enable_openrc
|
|
|
|
unset disable_openrc
|
|
|
|
unset enable_systemd_live
|
|
|
|
unset enable_openrc_live
|
2016-10-25 11:12:12 +02:00
|
|
|
unset packages_desktop
|
2016-09-18 12:06:09 +02:00
|
|
|
unset packages_mhwd
|
|
|
|
unset login_shell
|
|
|
|
unset netinstall
|
2016-09-28 14:24:06 +02:00
|
|
|
unset chrootcfg
|
2016-09-18 12:06:09 +02:00
|
|
|
unset geoip
|
2017-02-04 10:51:00 +01:00
|
|
|
unset extra
|
2016-09-18 12:06:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
check_profile(){
|
2017-03-09 13:01:20 +01:00
|
|
|
local keyfiles=("$1/Packages-Root"
|
|
|
|
"$1/Packages-Live")
|
2016-09-18 12:06:09 +02:00
|
|
|
|
2017-03-09 13:01:20 +01:00
|
|
|
local keydirs=("$1/root-overlay"
|
|
|
|
"$1/live-overlay")
|
2016-09-18 12:06:09 +02:00
|
|
|
|
|
|
|
local has_keyfiles=false has_keydirs=false
|
|
|
|
for f in ${keyfiles[@]}; do
|
|
|
|
if [[ -f $f ]];then
|
|
|
|
has_keyfiles=true
|
|
|
|
else
|
|
|
|
has_keyfiles=false
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
for d in ${keydirs[@]}; do
|
|
|
|
if [[ -d $d ]];then
|
|
|
|
has_keydirs=true
|
|
|
|
else
|
|
|
|
has_keydirs=false
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if ! ${has_keyfiles} && ! ${has_keydirs};then
|
2017-03-09 13:01:20 +01:00
|
|
|
die "Profile [%s] sanity check failed!" "$1"
|
2016-09-18 12:06:09 +02:00
|
|
|
fi
|
|
|
|
|
2017-03-09 13:01:20 +01:00
|
|
|
[[ -f "$1/Packages-Desktop" ]] && packages_desktop=$1/Packages-Desktop
|
2016-09-18 12:06:09 +02:00
|
|
|
|
2017-03-09 13:01:20 +01:00
|
|
|
[[ -f "$1/Packages-Mhwd" ]] && packages_mhwd=$1/Packages-Mhwd
|
2016-09-18 12:06:09 +02:00
|
|
|
|
2016-09-28 14:24:06 +02:00
|
|
|
if ! ${netinstall}; then
|
|
|
|
chrootcfg="false"
|
2016-09-18 12:06:09 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# $1: file name
|
|
|
|
load_pkgs(){
|
|
|
|
info "Loading Packages: [%s] ..." "${1##*/}"
|
|
|
|
|
2016-10-03 01:16:27 +02:00
|
|
|
local _init _init_rm
|
|
|
|
case "${initsys}" in
|
|
|
|
'openrc')
|
|
|
|
_init="s|>openrc||g"
|
|
|
|
_init_rm="s|>systemd.*||g"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
_init="s|>systemd||g"
|
|
|
|
_init_rm="s|>openrc.*||g"
|
|
|
|
;;
|
|
|
|
esac
|
2016-10-11 21:53:04 +02:00
|
|
|
|
2017-02-04 13:48:07 +01:00
|
|
|
local _multi _nonfree_default _nonfree_multi _arch _arch_rm _nonfree_i686 _nonfree_x86_64 _basic _basic_rm _extra _extra_rm
|
|
|
|
|
|
|
|
if ${basic};then
|
|
|
|
_basic="s|>basic||g"
|
|
|
|
else
|
|
|
|
_basic_rm="s|>basic.*||g"
|
|
|
|
fi
|
2017-02-04 10:51:00 +01:00
|
|
|
|
|
|
|
if ${extra};then
|
|
|
|
_extra="s|>extra||g"
|
|
|
|
else
|
|
|
|
_extra_rm="s|>extra.*||g"
|
|
|
|
fi
|
|
|
|
|
2016-10-03 01:16:27 +02:00
|
|
|
case "${target_arch}" in
|
|
|
|
"i686")
|
|
|
|
_arch="s|>i686||g"
|
|
|
|
_arch_rm="s|>x86_64.*||g"
|
|
|
|
_multi="s|>multilib.*||g"
|
|
|
|
_nonfree_multi="s|>nonfree_multilib.*||g"
|
|
|
|
_nonfree_x86_64="s|>nonfree_x86_64.*||g"
|
2016-09-18 12:06:09 +02:00
|
|
|
if ${nonfree_mhwd};then
|
|
|
|
_nonfree_default="s|>nonfree_default||g"
|
2016-10-03 01:16:27 +02:00
|
|
|
_nonfree_i686="s|>nonfree_i686||g"
|
|
|
|
|
2016-09-18 12:06:09 +02:00
|
|
|
else
|
|
|
|
_nonfree_default="s|>nonfree_default.*||g"
|
2016-10-03 01:16:27 +02:00
|
|
|
_nonfree_i686="s|>nonfree_i686.*||g"
|
2016-09-18 12:06:09 +02:00
|
|
|
fi
|
2016-10-03 01:16:27 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
_arch="s|>x86_64||g"
|
|
|
|
_arch_rm="s|>i686.*||g"
|
|
|
|
_nonfree_i686="s|>nonfree_i686.*||g"
|
|
|
|
if ${multilib};then
|
|
|
|
_multi="s|>multilib||g"
|
|
|
|
if ${nonfree_mhwd};then
|
|
|
|
_nonfree_default="s|>nonfree_default||g"
|
|
|
|
_nonfree_x86_64="s|>nonfree_x86_64||g"
|
|
|
|
_nonfree_multi="s|>nonfree_multilib||g"
|
|
|
|
else
|
|
|
|
_nonfree_default="s|>nonfree_default.*||g"
|
|
|
|
_nonfree_multi="s|>nonfree_multilib.*||g"
|
|
|
|
_nonfree_x86_64="s|>nonfree_x86_64.*||g"
|
|
|
|
fi
|
2016-09-18 12:06:09 +02:00
|
|
|
else
|
2016-10-03 01:16:27 +02:00
|
|
|
_multi="s|>multilib.*||g"
|
|
|
|
if ${nonfree_mhwd};then
|
|
|
|
_nonfree_default="s|>nonfree_default||g"
|
|
|
|
_nonfree_x86_64="s|>nonfree_x86_64||g"
|
|
|
|
_nonfree_multi="s|>nonfree_multilib.*||g"
|
|
|
|
else
|
|
|
|
_nonfree_default="s|>nonfree_default.*||g"
|
|
|
|
_nonfree_x86_64="s|>nonfree_x86_64.*||g"
|
|
|
|
_nonfree_multi="s|>nonfree_multilib.*||g"
|
|
|
|
fi
|
2016-09-18 12:06:09 +02:00
|
|
|
fi
|
2016-10-03 01:16:27 +02:00
|
|
|
;;
|
|
|
|
esac
|
2016-10-11 21:53:04 +02:00
|
|
|
|
2016-10-03 01:16:27 +02:00
|
|
|
local _edition _edition_rm
|
|
|
|
case "${edition}" in
|
2016-10-11 21:53:04 +02:00
|
|
|
'sonar')
|
2016-10-03 01:16:27 +02:00
|
|
|
_edition="s|>sonar||g"
|
|
|
|
_edition_rm="s|>manjaro.*||g"
|
|
|
|
;;
|
2016-10-11 21:53:04 +02:00
|
|
|
*)
|
2016-10-03 01:16:27 +02:00
|
|
|
_edition="s|>manjaro||g"
|
|
|
|
_edition_rm="s|>sonar.*||g"
|
|
|
|
;;
|
|
|
|
esac
|
2016-10-11 21:53:04 +02:00
|
|
|
|
2016-09-18 12:06:09 +02:00
|
|
|
local _blacklist="s|>blacklist.*||g" \
|
|
|
|
_kernel="s|KERNEL|$kernel|g" \
|
|
|
|
_used_kernel=${kernel:5:2} \
|
|
|
|
_space="s| ||g" \
|
|
|
|
_clean=':a;N;$!ba;s/\n/ /g' \
|
|
|
|
_com_rm="s|#.*||g" \
|
|
|
|
_purge="s|>cleanup.*||g" \
|
|
|
|
_purge_rm="s|>cleanup||g"
|
|
|
|
|
2016-10-25 11:12:12 +02:00
|
|
|
packages=$(sed "$_com_rm" "$1" \
|
2016-09-18 12:06:09 +02:00
|
|
|
| sed "$_space" \
|
|
|
|
| sed "$_blacklist" \
|
|
|
|
| sed "$_purge" \
|
|
|
|
| sed "$_init" \
|
|
|
|
| sed "$_init_rm" \
|
|
|
|
| sed "$_arch" \
|
|
|
|
| sed "$_arch_rm" \
|
|
|
|
| sed "$_nonfree_default" \
|
|
|
|
| sed "$_multi" \
|
|
|
|
| sed "$_nonfree_i686" \
|
|
|
|
| sed "$_nonfree_x86_64" \
|
|
|
|
| sed "$_nonfree_multi" \
|
|
|
|
| sed "$_kernel" \
|
2016-10-03 01:16:27 +02:00
|
|
|
| sed "$_edition" \
|
|
|
|
| sed "$_edition_rm" \
|
2017-02-04 13:48:07 +01:00
|
|
|
| sed "$_basic" \
|
|
|
|
| sed "$_basic_rm" \
|
2017-02-04 10:51:00 +01:00
|
|
|
| sed "$_extra" \
|
|
|
|
| sed "$_extra_rm" \
|
2016-09-18 12:06:09 +02:00
|
|
|
| sed "$_clean")
|
|
|
|
|
|
|
|
if [[ $1 == "${packages_mhwd}" ]]; then
|
|
|
|
|
2016-11-01 11:16:22 +01:00
|
|
|
[[ ${_used_kernel} < "42" ]] && local _amd="s|xf86-video-amdgpu||g"
|
2016-09-18 12:06:09 +02:00
|
|
|
|
|
|
|
packages_cleanup=$(sed "$_com_rm" "$1" \
|
|
|
|
| grep cleanup \
|
|
|
|
| sed "$_purge_rm" \
|
|
|
|
| sed "$_kernel" \
|
|
|
|
| sed "$_clean" \
|
|
|
|
| sed "$_amd")
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-08-21 15:20:29 +02:00
|
|
|
user_own(){
|
2016-09-15 23:58:18 +02:00
|
|
|
local flag=$2
|
|
|
|
chown ${flag} "${OWNER}:$(id --group ${OWNER})" "$1"
|
2016-08-21 15:20:29 +02:00
|
|
|
}
|
|
|
|
|
2015-02-16 20:32:47 +01:00
|
|
|
clean_dir(){
|
2016-09-15 23:58:18 +02:00
|
|
|
if [[ -d $1 ]]; then
|
|
|
|
msg "Cleaning [%s] ..." "$1"
|
|
|
|
rm -r $1/*
|
|
|
|
fi
|
2015-02-16 20:32:47 +01:00
|
|
|
}
|
|
|
|
|
2015-12-05 19:37:40 +01:00
|
|
|
write_repo_conf(){
|
2017-02-16 19:39:39 +01:00
|
|
|
local repos=$(find $USER_HOME -type f -name "repo_info")
|
2016-09-15 23:58:18 +02:00
|
|
|
local path name
|
|
|
|
[[ -z ${repos[@]} ]] && run_dir=${DATADIR}/iso-profiles && return 1
|
|
|
|
for r in ${repos[@]}; do
|
2017-02-20 15:21:17 +01:00
|
|
|
path=${r%/repo_info}
|
2016-09-15 23:58:18 +02:00
|
|
|
name=${path##*/}
|
|
|
|
echo "run_dir=$path" > ${USERCONFDIR}/$name.conf
|
|
|
|
done
|
2015-12-05 19:37:40 +01:00
|
|
|
}
|
|
|
|
|
2015-01-13 13:41:28 +01:00
|
|
|
load_user_info(){
|
2016-09-15 23:58:18 +02:00
|
|
|
OWNER=${SUDO_USER:-$USER}
|
2015-01-13 13:41:28 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
if [[ -n $SUDO_USER ]]; then
|
|
|
|
eval "USER_HOME=~$SUDO_USER"
|
|
|
|
else
|
|
|
|
USER_HOME=$HOME
|
|
|
|
fi
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-09-15 23:58:18 +02:00
|
|
|
USERCONFDIR="$USER_HOME/.config/manjaro-tools"
|
|
|
|
prepare_dir "${USERCONFDIR}"
|
2015-01-13 13:41:28 +01:00
|
|
|
}
|
2015-02-14 10:49:16 +01:00
|
|
|
|
2015-12-05 19:37:40 +01:00
|
|
|
load_run_dir(){
|
2016-09-15 23:58:18 +02:00
|
|
|
[[ -f ${USERCONFDIR}/$1.conf ]] || write_repo_conf
|
|
|
|
[[ -r ${USERCONFDIR}/$1.conf ]] && source ${USERCONFDIR}/$1.conf
|
|
|
|
return 0
|
2015-12-05 19:37:40 +01:00
|
|
|
}
|
|
|
|
|
2015-05-22 16:51:45 +02:00
|
|
|
show_version(){
|
2016-09-15 23:58:18 +02:00
|
|
|
msg "manjaro-tools"
|
|
|
|
msg2 "version: %s" "${version}"
|
2015-05-22 16:51:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
show_config(){
|
2016-09-15 23:58:18 +02:00
|
|
|
if [[ -f ${USERCONFDIR}/manjaro-tools.conf ]]; then
|
2017-02-16 16:46:04 +01:00
|
|
|
msg2 "config: %s" "~/.config/manjaro-tools/manjaro-tools.conf"
|
2016-09-15 23:58:18 +02:00
|
|
|
else
|
2017-02-16 16:46:04 +01:00
|
|
|
msg2 "config: %s" "${manjaro_tools_conf}"
|
2016-09-15 23:58:18 +02:00
|
|
|
fi
|
2015-05-22 16:51:45 +02:00
|
|
|
}
|
2015-05-31 23:32:50 +02:00
|
|
|
|
|
|
|
# $1: chroot
|
2015-11-28 20:28:45 +01:00
|
|
|
kill_chroot_process(){
|
2016-09-15 23:58:18 +02:00
|
|
|
# enable to have more debug info
|
|
|
|
#msg "machine-id (etc): $(cat $1/etc/machine-id)"
|
|
|
|
#[[ -e $1/var/lib/dbus/machine-id ]] && msg "machine-id (lib): $(cat $1/var/lib/dbus/machine-id)"
|
|
|
|
#msg "running processes: "
|
|
|
|
#lsof | grep $1
|
|
|
|
|
|
|
|
local prefix="$1" flink pid name
|
|
|
|
for root_dir in /proc/*/root; do
|
|
|
|
flink=$(readlink $root_dir)
|
|
|
|
if [ "x$flink" != "x" ]; then
|
|
|
|
if [ "x${flink:0:${#prefix}}" = "x$prefix" ]; then
|
|
|
|
# this process is in the chroot...
|
|
|
|
pid=$(basename $(dirname "$root_dir"))
|
|
|
|
name=$(ps -p $pid -o comm=)
|
|
|
|
info "Killing chroot process: %s (%s)" "$name" "$pid"
|
|
|
|
kill -9 "$pid"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2015-05-31 23:32:50 +02:00
|
|
|
}
|
2015-06-01 01:09:05 +02:00
|
|
|
|
2015-06-01 23:15:29 +02:00
|
|
|
create_min_fs(){
|
2016-09-15 23:58:18 +02:00
|
|
|
msg "Creating install root at %s" "$1"
|
|
|
|
mkdir -m 0755 -p $1/var/{cache/pacman/pkg,lib/pacman,log} $1/{dev,run,etc}
|
|
|
|
mkdir -m 1777 -p $1/tmp
|
|
|
|
mkdir -m 0555 -p $1/{sys,proc}
|
2015-06-01 15:52:03 +02:00
|
|
|
}
|
2015-06-09 01:14:58 +02:00
|
|
|
|
2015-06-15 10:51:40 +02:00
|
|
|
is_valid_init(){
|
2016-09-15 23:58:18 +02:00
|
|
|
case $1 in
|
|
|
|
'openrc'|'systemd') return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
2015-06-14 22:31:31 +02:00
|
|
|
}
|
2015-11-26 12:26:21 +01:00
|
|
|
|
2015-11-27 12:22:38 +01:00
|
|
|
is_valid_arch_pkg(){
|
2016-09-15 23:58:18 +02:00
|
|
|
eval "case $1 in
|
|
|
|
$(show_build_profiles "${make_conf_dir}")) return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac"
|
2015-11-27 12:22:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
is_valid_arch_iso(){
|
2016-09-15 23:58:18 +02:00
|
|
|
case $1 in
|
|
|
|
'i686'|'x86_64') return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
2015-11-27 12:22:38 +01:00
|
|
|
}
|
2015-11-28 17:37:13 +01:00
|
|
|
|
|
|
|
is_valid_branch(){
|
2016-09-15 23:58:18 +02:00
|
|
|
case $1 in
|
|
|
|
'stable'|'testing'|'unstable') return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
2015-11-28 17:37:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
run(){
|
2016-09-15 23:58:18 +02:00
|
|
|
if ${is_build_list};then
|
|
|
|
for item in ${build_list[@]};do
|
|
|
|
$1 $item
|
|
|
|
done
|
|
|
|
else
|
|
|
|
$1 $2
|
|
|
|
fi
|
2015-11-28 17:37:13 +01:00
|
|
|
}
|
2017-03-26 18:54:45 +02:00
|
|
|
|
|
|
|
is_btrfs() {
|
|
|
|
[[ -e "$1" && "$(stat -f -c %T "$1")" == btrfs ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
subvolume_delete_recursive() {
|
|
|
|
local subvol
|
|
|
|
|
|
|
|
is_btrfs "$1" || return 0
|
|
|
|
|
|
|
|
while IFS= read -d $'\0' -r subvol; do
|
|
|
|
if ! btrfs subvolume delete "$subvol" &>/dev/null; then
|
|
|
|
error "Unable to delete subvolume %s" "$subvol"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done < <(find "$1" -xdev -depth -inum 256 -print0)
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
2017-10-23 23:47:35 +02:00
|
|
|
|
|
|
|
create_chksums() {
|
|
|
|
msg2 "creating checksums for [$1]"
|
|
|
|
sha1sum $1 > $1.sha1
|
|
|
|
sha256sum $1 > $1.sha256
|
|
|
|
}
|