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() {
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
|
|
|
get_repos() {
|
|
|
|
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-02-27 00:39:58 +01:00
|
|
|
|
2016-05-23 03:03:00 +02:00
|
|
|
check_user_repos_conf(){
|
|
|
|
local repositories=$(get_repos "$1") uri='file://'
|
|
|
|
for repo in ${repositories[@]}; do
|
|
|
|
msg2 "parsing repo [%s] ..." "${repo}"
|
|
|
|
parse_section "${repo}" "$1"
|
2016-05-23 03:06:40 +02:00
|
|
|
[[ ${pc_value} == $uri* ]] && die "Using local repositories is not supported!"
|
2016-05-23 03:03:00 +02:00
|
|
|
done
|
|
|
|
}
|
2016-05-20 19:42:16 +02:00
|
|
|
|
2015-11-23 22:57:17 +01:00
|
|
|
read_set(){
|
|
|
|
local _space="s| ||g" \
|
|
|
|
_clean=':a;N;$!ba;s/\n/ /g' \
|
2015-11-28 17:37:13 +01:00
|
|
|
_com_rm="s|#.*||g"
|
2015-11-23 22:57:17 +01:00
|
|
|
|
2015-12-01 12:24:23 +01:00
|
|
|
stack=$(sed "$_com_rm" "$1.set" \
|
2015-11-28 20:28:45 +01:00
|
|
|
| sed "$_space" \
|
|
|
|
| sed "$_clean")
|
2015-11-23 22:57:17 +01:00
|
|
|
}
|
|
|
|
|
2015-11-25 16:53:55 +01:00
|
|
|
# $1: sets_dir
|
2015-12-08 12:33:28 +01:00
|
|
|
list_sets(){
|
2015-11-25 16:53:55 +01:00
|
|
|
local prof temp
|
|
|
|
for item in $(ls $1/*.set); do
|
|
|
|
temp=${item##*/}
|
|
|
|
prof=${prof:-}${prof:+|}${temp%.set}
|
2015-06-09 00:02:32 +02:00
|
|
|
done
|
2015-11-25 16:53:55 +01:00
|
|
|
echo $prof
|
2015-06-06 09:48:56 +02:00
|
|
|
}
|
|
|
|
|
2015-12-01 12:24:23 +01:00
|
|
|
# $1: sets_dir
|
|
|
|
# $2: buildset
|
2015-11-25 16:53:55 +01:00
|
|
|
eval_buildset(){
|
2015-12-01 12:24:23 +01:00
|
|
|
eval "case $2 in
|
2016-02-27 00:39:58 +01:00
|
|
|
$(list_sets $1)) is_buildset=true; read_set $1/$2 ;;
|
2015-11-25 16:53:55 +01:00
|
|
|
*) is_buildset=false ;;
|
|
|
|
esac"
|
2015-06-06 09:48:56 +02:00
|
|
|
}
|
|
|
|
|
2016-02-25 06:40:39 +01:00
|
|
|
get_edition(){
|
2015-12-07 00:58:20 +01:00
|
|
|
local result=$(find ${run_dir} -maxdepth 2 -name "$1") path
|
2016-02-14 23:13:39 +01:00
|
|
|
[[ -z $result ]] && die "%s is not a valid profile or buildset!" "$1"
|
2015-12-07 00:58:20 +01:00
|
|
|
path=${result%/*}
|
2016-02-25 06:40:39 +01:00
|
|
|
echo ${path##*/}
|
2015-11-30 21:35:30 +01:00
|
|
|
}
|
|
|
|
|
2016-02-27 18:01:45 +01:00
|
|
|
in_array() {
|
|
|
|
local needle=$1; shift
|
|
|
|
local item
|
|
|
|
for item in "$@"; do
|
|
|
|
[[ $item = $needle ]] && return 0 # Found
|
|
|
|
done
|
|
|
|
return 1 # Not Found
|
|
|
|
}
|
|
|
|
|
2015-02-18 04:28:11 +01:00
|
|
|
get_timer(){
|
|
|
|
echo $(date +%s)
|
|
|
|
}
|
|
|
|
|
2015-09-20 12:40:49 +02:00
|
|
|
get_timer_ms(){
|
|
|
|
echo $(date +%s%3N)
|
|
|
|
}
|
|
|
|
|
2015-02-18 04:28:11 +01:00
|
|
|
# $1: start timer
|
|
|
|
elapsed_time(){
|
|
|
|
echo $(echo $1 $(get_timer) | awk '{ printf "%0.2f",($2-$1)/60 }')
|
|
|
|
}
|
|
|
|
|
2015-09-20 11:29:29 +02:00
|
|
|
# $1: start timer
|
2015-09-20 12:40:49 +02:00
|
|
|
elapsed_time_ms(){
|
|
|
|
echo $(echo $1 $(get_timer_ms) | awk '{ printf "%0.3f",($2-$1)/1000 }')
|
2015-09-20 11:29:29 +02:00
|
|
|
}
|
|
|
|
|
2016-02-15 16:47:52 +01:00
|
|
|
show_elapsed_time(){
|
2016-02-15 18:53:50 +01: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() {
|
|
|
|
eval "exec $1>"'"$2"'
|
|
|
|
if ! flock -n $1; then
|
|
|
|
stat_busy "$3"
|
|
|
|
flock $1
|
|
|
|
stat_done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
slock() {
|
|
|
|
eval "exec $1>"'"$2"'
|
|
|
|
if ! flock -sn $1; then
|
|
|
|
stat_busy "$3"
|
|
|
|
flock -s $1
|
|
|
|
stat_done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-11-12 02:19:58 +01:00
|
|
|
check_root() {
|
2015-02-13 15:17:00 +01: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(){
|
|
|
|
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(){
|
|
|
|
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() {
|
2015-02-13 15:17:00 +01:00
|
|
|
local var
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
[[ -f $1 ]] || return 1
|
2014-11-13 00:19:49 +01:00
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER CARCH GPGKEY; do
|
2016-04-09 01:53:03 +02:00
|
|
|
[[ -z ${!var} ]] && eval $(grep -a "^${var}=" "$1")
|
2015-02-13 15:17:00 +01:00
|
|
|
done
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
return 0
|
2014-11-13 00:19:49 +01:00
|
|
|
}
|
|
|
|
|
2015-06-12 11:09:29 +02:00
|
|
|
prepare_dir(){
|
|
|
|
[[ ! -d $1 ]] && mkdir -p $1
|
|
|
|
}
|
|
|
|
|
2015-11-13 12:31:41 +01:00
|
|
|
version_gen(){
|
2016-01-07 03:05:04 +01:00
|
|
|
local y=$(date +%Y) m=$(date +%m) ver
|
|
|
|
ver=${y:2}.$m
|
|
|
|
echo $ver
|
2015-11-17 17:03:37 +01:00
|
|
|
}
|
|
|
|
|
2016-03-02 17:42:49 +01:00
|
|
|
# $1: chroot
|
|
|
|
get_branch(){
|
|
|
|
echo $(cat "$1/etc/pacman-mirrors.conf" | grep '^Branch = ' | sed 's/Branch = \s*//g')
|
|
|
|
}
|
|
|
|
|
|
|
|
# $1: chroot
|
|
|
|
# $2: branch
|
|
|
|
set_branch(){
|
2016-03-02 18:20:23 +01:00
|
|
|
info "Setting mirrorlist branch: %s" "$2"
|
2016-03-02 17:42:49 +01:00
|
|
|
sed -e "s|/stable|/$2|g" -i "$1/etc/pacman.d/mirrorlist"
|
|
|
|
}
|
|
|
|
|
2015-06-06 15:54:37 +02:00
|
|
|
init_common(){
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${branch} ]] && branch='stable'
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${arch} ]] && arch=$(uname -m)
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${cache_dir} ]] && cache_dir='/var/cache/manjaro-tools'
|
|
|
|
|
|
|
|
[[ -z ${chroots_dir} ]] && chroots_dir='/var/lib/manjaro-tools'
|
|
|
|
|
2016-02-26 17:56:17 +01:00
|
|
|
[[ -z ${log_dir} ]] && log_dir='/var/log/manjaro-tools'
|
|
|
|
|
2015-06-06 10:03:52 +02:00
|
|
|
[[ -z ${build_mirror} ]] && build_mirror='http://mirror.netzspielplatz.de/manjaro/packages'
|
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(){
|
2015-06-09 00:02:32 +02:00
|
|
|
tree_dir=${cache_dir}/pkgtree
|
|
|
|
|
|
|
|
tree_dir_abs=${tree_dir}/packages-archlinux
|
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${repo_tree[@]} ]] && repo_tree=('core' 'extra' 'community' 'multilib' 'openrc')
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${host_tree} ]] && host_tree='https://github.com/manjaro'
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-05-21 22:44:32 +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(){
|
2015-05-21 23:23:33 +02:00
|
|
|
chroots_pkg="${chroots_dir}/buildpkg"
|
|
|
|
|
2015-12-03 22:54:58 +01:00
|
|
|
sets_dir_pkg="${SYSCONFDIR}/pkg.d"
|
2015-05-21 23:23:33 +02:00
|
|
|
|
2015-12-08 12:33:28 +01:00
|
|
|
[[ -d ${USERCONFDIR}/pkg.d ]] && sets_dir_pkg=${USERCONFDIR}/pkg.d
|
2015-12-03 21:06:43 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${buildset_pkg} ]] && buildset_pkg='default'
|
2015-11-30 21:35:30 +01: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(){
|
|
|
|
local label="$1"
|
|
|
|
label="${label//_}" # relace all _
|
|
|
|
label="${label//-}" # relace all -
|
|
|
|
label="${label^^}" # all uppercase
|
|
|
|
label="${label::8}" # limit to 8 characters
|
|
|
|
echo ${label}
|
|
|
|
}
|
|
|
|
|
|
|
|
get_codename(){
|
|
|
|
source /etc/lsb-release
|
|
|
|
echo "${DISTRIB_CODENAME}"
|
|
|
|
}
|
|
|
|
|
2015-06-06 15:54:37 +02:00
|
|
|
init_buildiso(){
|
2015-05-21 23:23:33 +02:00
|
|
|
chroots_iso="${chroots_dir}/buildiso"
|
|
|
|
|
2015-12-03 22:54:58 +01:00
|
|
|
sets_dir_iso="${SYSCONFDIR}/iso.d"
|
2015-05-21 23:23:33 +02:00
|
|
|
|
2015-12-08 12:33:28 +01:00
|
|
|
[[ -d ${USERCONFDIR}/iso.d ]] && sets_dir_iso=${USERCONFDIR}/iso.d
|
2015-12-03 21:06:43 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${buildset_iso} ]] && buildset_iso='default'
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-11-30 21:35:30 +01:00
|
|
|
cache_dir_iso="${cache_dir}/iso"
|
|
|
|
|
2015-03-02 23:35:15 +01:00
|
|
|
##### iso settings #####
|
|
|
|
|
2016-01-07 03:05:04 +01:00
|
|
|
[[ -z ${dist_release} ]] && dist_release=$(version_gen)
|
2014-12-03 22:59:30 +01:00
|
|
|
|
2016-02-21 11:47:32 +01:00
|
|
|
[[ -z ${dist_codename} ]] && dist_codename=$(get_codename)
|
2014-12-03 22:59:30 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${dist_branding} ]] && dist_branding="MJRO"
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${dist_name} ]] && dist_name="Manjaro"
|
2015-03-03 19:39:53 +01:00
|
|
|
|
2015-12-19 00:20:43 +01:00
|
|
|
iso_name=${dist_name,,}
|
2015-03-03 19:39:53 +01:00
|
|
|
|
2016-02-21 11:47:32 +01:00
|
|
|
iso_label=$(get_iso_label "${dist_branding}${dist_release//.}")
|
2015-03-05 10:54:09 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${iso_publisher} ]] && iso_publisher='Manjaro Linux <http://www.manjaro.org>'
|
2015-05-11 12:47:02 +02:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${iso_app_id} ]] && iso_app_id='Manjaro Linux Live/Rescue CD'
|
2015-05-11 12:47:02 +02:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${iso_compression} ]] && iso_compression='xz'
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${iso_checksum} ]] && iso_checksum='md5'
|
2015-06-11 13:59:34 +02:00
|
|
|
|
2016-02-17 18:56:37 +01:00
|
|
|
[[ -z ${initsys} ]] && initsys="systemd"
|
|
|
|
|
|
|
|
[[ -z ${kernel} ]] && kernel="linux44"
|
|
|
|
|
2015-08-01 16:44:18 +02:00
|
|
|
[[ -z ${use_overlayfs} ]] && use_overlayfs='true'
|
2015-12-06 01:52:40 +01:00
|
|
|
|
2015-12-21 11:00:08 +01:00
|
|
|
[[ -z ${profile_repo} ]] && profile_repo='manjaro-tools-iso-profiles'
|
2015-06-06 15:54:37 +02:00
|
|
|
}
|
|
|
|
|
2015-11-12 00:31:51 +01:00
|
|
|
init_deployiso(){
|
|
|
|
|
2015-11-12 23:10:10 +01:00
|
|
|
[[ -z ${remote_target} ]] && remote_target="/home/frs/project"
|
2015-11-12 00:31:51 +01:00
|
|
|
|
2015-11-12 23:10:10 +01:00
|
|
|
[[ -z ${remote_project} ]] && remote_project="manjaro-testing"
|
2015-11-12 00:31:51 +01:00
|
|
|
|
2015-11-13 12:31:41 +01:00
|
|
|
[[ -z ${remote_user} ]] && remote_user="[SetUser]"
|
2015-11-12 00:31:51 +01:00
|
|
|
|
2015-11-12 12:25:35 +01:00
|
|
|
[[ -z ${remote_url} ]] && remote_url="sourceforge.net"
|
2015-11-24 16:58:40 +01:00
|
|
|
|
|
|
|
[[ -z ${limit} ]] && limit=100
|
2016-02-18 00:02:11 +01:00
|
|
|
|
|
|
|
[[ -z ${tracker_url} ]] && tracker_url=""
|
|
|
|
|
|
|
|
[[ -z ${piece_size} ]] && piece_size=21
|
2015-11-12 00:31:51 +01:00
|
|
|
}
|
|
|
|
|
2015-06-06 15:54:37 +02:00
|
|
|
load_config(){
|
|
|
|
|
|
|
|
[[ -f $1 ]] || return 1
|
|
|
|
|
|
|
|
manjaro_tools_conf="$1"
|
|
|
|
|
|
|
|
[[ -r ${manjaro_tools_conf} ]] && source ${manjaro_tools_conf}
|
|
|
|
|
|
|
|
init_common
|
|
|
|
|
|
|
|
init_buildtree
|
|
|
|
|
|
|
|
init_buildpkg
|
|
|
|
|
|
|
|
init_buildiso
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-11-12 00:31:51 +01:00
|
|
|
init_deployiso
|
|
|
|
|
2015-03-02 23:35:15 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2016-02-26 17:56:17 +01:00
|
|
|
reset_profile(){
|
2015-12-21 11:00:08 +01:00
|
|
|
unset displaymanager
|
|
|
|
unset autologin
|
|
|
|
unset multilib
|
|
|
|
unset pxe_boot
|
|
|
|
unset plymouth_boot
|
|
|
|
unset nonfree_xorg
|
|
|
|
unset efi_boot_loader
|
|
|
|
unset efi_part_size
|
|
|
|
unset hostname
|
|
|
|
unset username
|
|
|
|
unset plymouth_theme
|
|
|
|
unset password
|
|
|
|
unset addgroups
|
|
|
|
unset start_systemd
|
|
|
|
unset disable_systemd
|
|
|
|
unset start_openrc
|
|
|
|
unset disable_openrc
|
|
|
|
unset start_systemd_live
|
|
|
|
unset start_openrc_live
|
2015-12-21 12:03:17 +01:00
|
|
|
unset packages_custom
|
|
|
|
unset packages_mhwd
|
2016-05-22 18:22:24 +02:00
|
|
|
unset login_shell
|
2015-12-21 11:00:08 +01:00
|
|
|
}
|
|
|
|
|
2016-02-25 18:07:13 +01:00
|
|
|
is_valid_bool(){
|
|
|
|
case $1 in
|
|
|
|
'true'|'false') return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
check_profile_vars(){
|
|
|
|
if ! is_valid_bool "${autologin}";then
|
|
|
|
die "autologin only accepts true/false value!"
|
|
|
|
fi
|
|
|
|
if ! is_valid_bool "${multilib}";then
|
|
|
|
die "multilib only accepts true/false value!"
|
|
|
|
fi
|
|
|
|
if ! is_valid_bool "${nonfree_xorg}";then
|
|
|
|
die "nonfree_xorg only accepts true/false value!"
|
|
|
|
fi
|
|
|
|
if ! is_valid_bool "${plymouth_boot}";then
|
|
|
|
die "plymouth_boot only accepts true/false value!"
|
|
|
|
fi
|
|
|
|
if ! is_valid_bool "${pxe_boot}";then
|
|
|
|
die "pxe_boot only accepts true/false value!"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-03-02 23:35:15 +01:00
|
|
|
load_profile_config(){
|
|
|
|
|
|
|
|
[[ -f $1 ]] || return 1
|
|
|
|
|
2015-12-18 04:52:34 +01:00
|
|
|
profile_conf="$1"
|
2015-03-02 23:35:15 +01:00
|
|
|
|
|
|
|
[[ -r ${profile_conf} ]] && source ${profile_conf}
|
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${displaymanager} ]] && displaymanager="none"
|
2015-03-02 23:35:15 +01:00
|
|
|
|
2015-06-06 13:43:00 +02:00
|
|
|
[[ -z ${autologin} ]] && autologin="true"
|
2016-02-25 20:45:40 +01:00
|
|
|
[[ ${displaymanager} == 'none' ]] && autologin="false"
|
2015-06-06 13:43:00 +02:00
|
|
|
|
2015-06-09 17:17:23 +02:00
|
|
|
[[ -z ${multilib} ]] && multilib="true"
|
|
|
|
|
2015-06-20 00:19:51 +02:00
|
|
|
[[ -z ${pxe_boot} ]] && pxe_boot="true"
|
|
|
|
|
2015-06-22 14:47:06 +02:00
|
|
|
[[ -z ${plymouth_boot} ]] && plymouth_boot="true"
|
2016-02-25 20:45:40 +01:00
|
|
|
[[ ${initsys} == 'openrc' ]] && plymouth_boot="false"
|
2015-06-20 00:19:51 +02:00
|
|
|
|
2015-06-09 18:42:55 +02:00
|
|
|
[[ -z ${nonfree_xorg} ]] && nonfree_xorg="true"
|
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${efi_boot_loader} ]] && efi_boot_loader="grub"
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-02-22 17:02:37 +01:00
|
|
|
[[ -z ${efi_part_size} ]] && efi_part_size="31M"
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${hostname} ]] && hostname="manjaro"
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${username} ]] && username="manjaro"
|
|
|
|
|
|
|
|
[[ -z ${plymouth_theme} ]] && plymouth_theme="manjaro-elegant"
|
|
|
|
|
|
|
|
[[ -z ${password} ]] && password="manjaro"
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-05-21 10:17:44 +02:00
|
|
|
[[ -z ${login_shell} ]] && login_shell='/bin/bash'
|
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
if [[ -z ${addgroups} ]];then
|
2016-05-14 12:46:23 +02:00
|
|
|
addgroups="video,power,disk,storage,optical,network,lp,scanner,wheel"
|
2015-02-13 15:17:00 +01:00
|
|
|
fi
|
2014-12-17 02:14:15 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
if [[ -z ${start_systemd[@]} ]];then
|
2015-02-13 15:17:00 +01:00
|
|
|
start_systemd=('bluetooth' 'cronie' 'ModemManager' 'NetworkManager' 'org.cups.cupsd' 'tlp' 'tlp-sleep')
|
|
|
|
fi
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-02-21 11:47:32 +01:00
|
|
|
[[ -z ${disable_systemd[@]} ]] && disable_systemd=('pacman-init')
|
2015-09-12 13:03:47 +02:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
if [[ -z ${start_openrc[@]} ]];then
|
2015-10-11 22:52:22 +02:00
|
|
|
start_openrc=('acpid' 'bluetooth' 'cgmanager' 'consolekit' 'cronie' 'cupsd' 'dbus' 'syslog-ng' 'NetworkManager')
|
2015-02-13 15:17:00 +01:00
|
|
|
fi
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-02-21 11:47:32 +01:00
|
|
|
[[ -z ${disable_openrc[@]} ]] && disable_openrc=('pacman-init')
|
2015-09-12 13:03:47 +02:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
if [[ -z ${start_systemd_live[@]} ]];then
|
2016-02-21 02:56:31 +01:00
|
|
|
start_systemd_live=('manjaro-live' 'mhwd-live' 'pacman-init')
|
2015-02-13 15:17:00 +01:00
|
|
|
fi
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
if [[ -z ${start_openrc_live[@]} ]];then
|
2016-02-21 02:56:31 +01:00
|
|
|
start_openrc_live=('manjaro-live' 'mhwd-live' 'pacman-init')
|
2015-02-13 15:17:00 +01:00
|
|
|
fi
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2016-02-25 18:07:13 +01:00
|
|
|
check_profile_vars
|
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
return 0
|
2014-12-08 22:16:06 +01:00
|
|
|
}
|
2015-01-11 21:09:01 +01:00
|
|
|
|
2015-02-16 20:32:47 +01:00
|
|
|
clean_dir(){
|
|
|
|
if [[ -d $1 ]]; then
|
2016-02-14 23:13:39 +01:00
|
|
|
msg "Cleaning [%s] ..." "$1"
|
2015-02-16 20:32:47 +01:00
|
|
|
rm -r $1/*
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-12-05 19:37:40 +01:00
|
|
|
write_repo_conf(){
|
2015-12-07 16:57:40 +01:00
|
|
|
local repos=$(find $USER_HOME -type f -name ".buildiso")
|
2015-12-05 19:37:40 +01:00
|
|
|
local path name
|
2015-12-21 11:00:08 +01:00
|
|
|
[[ -z ${repos[@]} ]] && run_dir=${DATADIR}/iso-profiles && return 1
|
2015-12-05 19:37:40 +01:00
|
|
|
for r in ${repos[@]}; do
|
|
|
|
path=${r%/.*}
|
|
|
|
name=${path##*/}
|
2015-12-18 01:56:21 +01:00
|
|
|
echo "run_dir=$path" > ${USERCONFDIR}/$name.conf
|
2015-12-05 19:37:40 +01:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2015-01-13 13:41:28 +01:00
|
|
|
load_user_info(){
|
2015-02-13 15:17:00 +01:00
|
|
|
OWNER=${SUDO_USER:-$USER}
|
2015-01-13 13:41:28 +01:00
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
if [[ -n $SUDO_USER ]]; then
|
|
|
|
eval "USER_HOME=~$SUDO_USER"
|
|
|
|
else
|
|
|
|
USER_HOME=$HOME
|
|
|
|
fi
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-12-08 12:33:28 +01: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(){
|
2015-12-08 12:33:28 +01:00
|
|
|
[[ -f ${USERCONFDIR}/$1.conf ]] || write_repo_conf
|
|
|
|
[[ -r ${USERCONFDIR}/$1.conf ]] && source ${USERCONFDIR}/$1.conf
|
2015-12-05 19:37:40 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2015-05-22 16:51:45 +02:00
|
|
|
show_version(){
|
|
|
|
msg "manjaro-tools"
|
2016-02-14 23:13:39 +01:00
|
|
|
msg2 "version: %s" "${version}"
|
2015-05-22 16:51:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
show_config(){
|
2015-12-08 12:33:28 +01:00
|
|
|
if [[ -f ${USERCONFDIR}/manjaro-tools.conf ]]; then
|
2016-02-14 23:13:39 +01:00
|
|
|
msg2 "user_config: %s" "${USERCONFDIR}/manjaro-tools.conf"
|
2015-05-22 16:51:45 +02:00
|
|
|
else
|
2016-02-14 23:13:39 +01:00
|
|
|
msg2 "manjaro_tools_conf: %s" "${manjaro_tools_conf}"
|
2015-05-22 16:51:45 +02:00
|
|
|
fi
|
|
|
|
}
|
2015-05-31 23:32:50 +02:00
|
|
|
|
|
|
|
# $1: chroot
|
2015-11-28 20:28:45 +01:00
|
|
|
kill_chroot_process(){
|
2015-05-31 23:32:50 +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
|
|
|
|
|
2015-11-26 12:26:21 +01:00
|
|
|
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
|
2015-05-31 23:32:50 +02:00
|
|
|
# this process is in the chroot...
|
2015-11-26 12:26:21 +01:00
|
|
|
pid=$(basename $(dirname "$root_dir"))
|
|
|
|
name=$(ps -p $pid -o comm=)
|
2016-02-15 18:53:50 +01:00
|
|
|
info "Killing chroot process: %s (%s)" "$name" "$pid"
|
2015-11-26 12:26:21 +01:00
|
|
|
kill -9 "$pid"
|
2015-05-31 23:32:50 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
2015-06-01 01:09:05 +02:00
|
|
|
|
2015-06-01 23:15:29 +02:00
|
|
|
create_min_fs(){
|
2016-02-14 23:13:39 +01:00
|
|
|
msg "Creating install root at %s" "$1"
|
2015-06-01 23:15:29 +02:00
|
|
|
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(){
|
|
|
|
case $1 in
|
|
|
|
'openrc'|'systemd') return 0 ;;
|
2015-06-14 22:31:31 +02:00
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
|
|
|
}
|
2015-11-26 12:26:21 +01:00
|
|
|
|
2015-11-27 12:22:38 +01:00
|
|
|
is_valid_arch_pkg(){
|
|
|
|
case $1 in
|
|
|
|
'i686'|'x86_64'|'multilib') return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
is_valid_arch_iso(){
|
|
|
|
case $1 in
|
|
|
|
'i686'|'x86_64') return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
|
|
|
}
|
2015-11-28 17:37:13 +01:00
|
|
|
|
|
|
|
is_valid_branch(){
|
|
|
|
case $1 in
|
|
|
|
'stable'|'testing'|'unstable') return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
run(){
|
|
|
|
if ${is_buildset};then
|
2015-11-28 20:28:45 +01:00
|
|
|
for item in ${stack[@]};do
|
|
|
|
$1 $item
|
2015-11-28 17:37:13 +01:00
|
|
|
done
|
|
|
|
else
|
|
|
|
$1 $2
|
|
|
|
fi
|
|
|
|
}
|