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.
|
|
|
|
|
2015-02-09 23:38:12 +01:00
|
|
|
import(){
|
2015-02-13 15:17:00 +01:00
|
|
|
[[ -r $1 ]] && source $1
|
2015-02-09 23:38:12 +01:00
|
|
|
}
|
|
|
|
|
2015-06-06 09:48:56 +02:00
|
|
|
create_set(){
|
|
|
|
msg "[$1/${name}.set]"
|
|
|
|
if [[ -f $1/${name}.set ]];then
|
|
|
|
msg3 "Backing up $1/${name}.set.orig"
|
|
|
|
mv "$1/${name}.set" "$1/${name}.set.orig"
|
|
|
|
fi
|
|
|
|
local list=$(find * -maxdepth 0 -type d | sort)
|
|
|
|
for item in ${list[@]};do
|
|
|
|
if [[ -f $item/$2 ]];then
|
|
|
|
cd $item
|
|
|
|
msg2 "Adding ${item##*/}"
|
|
|
|
echo ${item##*/} >> $1/${name}.set || break
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
calculate_build_order(){
|
2015-06-06 13:14:01 +02:00
|
|
|
local is_split=false path=/tmp/calc
|
|
|
|
mkdir -p $path
|
|
|
|
#[[ -f $path/*.{sort,set,makedeps,split} ]] &&
|
|
|
|
rm $path/*
|
|
|
|
pacman -Qqg base-devel > $path/base-devel.set
|
2015-06-06 09:48:56 +02:00
|
|
|
|
2015-06-06 13:14:01 +02:00
|
|
|
for pkg in $(cat $1/${name}.set);do
|
|
|
|
cd $pkg
|
|
|
|
source PKGBUILD
|
|
|
|
if [[ -n $pkgbase ]];then
|
|
|
|
is_split=true; echo "$pkgbase" >> $path/${name}.split
|
|
|
|
fi
|
|
|
|
for m in ${makedepends[@]};do
|
|
|
|
echo $m >> $path/${name}.makedeps
|
|
|
|
done
|
|
|
|
cd ..
|
|
|
|
done
|
|
|
|
[[ -f $path/${name}.split ]] && sort -u $path/${name}.split > $path/${name}.split.sort
|
|
|
|
sort -u $path/${name}.makedeps > $path/${name}.makedeps.sort
|
|
|
|
|
|
|
|
[[ -f $path/${name}.split ]] && rm $path/${name}.split
|
|
|
|
|
|
|
|
for d in $(cat $path/${name}.makedeps.sort);do
|
|
|
|
for pkg in $(cat $1/${name}.set);do
|
|
|
|
if [[ $pkg == $d ]];then
|
|
|
|
echo $d >> $path/${name}.makedeps
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
sort -u $path/${name}.makedeps > $path/${name}.makedeps.sort
|
|
|
|
rm $path/${name}.makedeps
|
|
|
|
sort -u $path/${name}.makedeps.sort $path/base-devel.set > $path/filter.set
|
2015-06-06 09:48:56 +02:00
|
|
|
|
|
|
|
|
2015-06-06 13:14:01 +02:00
|
|
|
for b in $(cat $path/base-devel.set);do
|
|
|
|
for m in $(cat $path/filter.set);do
|
|
|
|
if [[ $b == $m ]];then
|
|
|
|
sed "/$m/d" -i $path/filter.set
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
2015-06-06 09:48:56 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
remove_set(){
|
|
|
|
if [[ -f $1/${name}.set ]]; then
|
|
|
|
msg "Removing [$1/${name}.set] ..."
|
|
|
|
rm $1/${name}.set
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
show_set(){
|
|
|
|
local list=$(cat $1/${name}.set)
|
|
|
|
msg "Content of [$1/${name}.set] ..."
|
|
|
|
for item in ${list[@]}; do
|
|
|
|
msg2 "$item"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
get_deps(){
|
|
|
|
echo $(pactree -u $1)
|
|
|
|
}
|
|
|
|
|
2015-02-18 04:28:11 +01:00
|
|
|
get_timer(){
|
|
|
|
echo $(date +%s)
|
|
|
|
}
|
|
|
|
|
|
|
|
# $1: start timer
|
|
|
|
elapsed_time(){
|
|
|
|
echo $(echo $1 $(get_timer) | awk '{ printf "%0.2f",($2-$1)/60 }')
|
|
|
|
}
|
|
|
|
|
2014-10-08 00:11:53 +02:00
|
|
|
##
|
|
|
|
# usage : in_array( $needle, $haystack )
|
|
|
|
# return : 0 - found
|
|
|
|
# 1 - not found
|
|
|
|
##
|
|
|
|
in_array() {
|
2015-02-13 15:17:00 +01:00
|
|
|
local needle=$1; shift
|
|
|
|
local item
|
|
|
|
for item in "$@"; do
|
|
|
|
[[ $item = $needle ]] && return 0 # Found
|
|
|
|
done
|
|
|
|
return 1 # Not Found
|
2014-11-11 23:02:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# $1: sofile
|
|
|
|
# $2: soarch
|
|
|
|
process_sofile() {
|
2015-02-13 15:17:00 +01:00
|
|
|
# extract the library name: libfoo.so
|
|
|
|
local soname="${1%.so?(+(.+([0-9])))}".so
|
|
|
|
# extract the major version: 1
|
|
|
|
soversion="${1##*\.so\.}"
|
|
|
|
if [[ "$soversion" = "$1" ]] && (($IGNORE_INTERNAL)); then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if ! in_array "${soname}=${soversion}-$2" ${soobjects[@]}; then
|
2014-11-11 23:02:40 +01:00
|
|
|
# libfoo.so=1-64
|
2015-02-13 15:17:00 +01:00
|
|
|
msg "${soname}=${soversion}-$2"
|
|
|
|
soobjects+=("${soname}=${soversion}-$2")
|
|
|
|
fi
|
2014-10-08 00:11:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
##
|
|
|
|
# usage : get_full_version( [$pkgname] )
|
|
|
|
# return : full version spec, including epoch (if necessary), pkgver, pkgrel
|
|
|
|
##
|
2014-11-11 23:02:40 +01:00
|
|
|
get_full_version() {
|
2015-02-13 15:17:00 +01:00
|
|
|
# set defaults if they weren't specified in buildfile
|
|
|
|
pkgbase=${pkgbase:-${pkgname[0]}}
|
|
|
|
epoch=${epoch:-0}
|
|
|
|
if [[ -z $1 ]]; then
|
|
|
|
if [[ $epoch ]] && (( ! $epoch )); then
|
|
|
|
echo $pkgver-$pkgrel
|
|
|
|
else
|
|
|
|
echo $epoch:$pkgver-$pkgrel
|
|
|
|
fi
|
2014-11-11 23:02:40 +01:00
|
|
|
else
|
2015-02-13 15:17:00 +01:00
|
|
|
for i in pkgver pkgrel epoch; do
|
|
|
|
local indirect="${i}_override"
|
|
|
|
eval $(declare -f package_$1 | sed -n "s/\(^[[:space:]]*$i=\)/${i}_override=/p")
|
|
|
|
[[ -z ${!indirect} ]] && eval ${indirect}=\"${!i}\"
|
|
|
|
done
|
|
|
|
if (( ! $epoch_override )); then
|
|
|
|
echo $pkgver_override-$pkgrel_override
|
|
|
|
else
|
|
|
|
echo $epoch_override:$pkgver_override-$pkgrel_override
|
|
|
|
fi
|
2014-10-08 00:11:53 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-11-11 23:02:40 +01:00
|
|
|
##
|
|
|
|
# usage: find_cached_package( $pkgname, $pkgver, $arch )
|
|
|
|
#
|
|
|
|
# $pkgver can be supplied with or without a pkgrel appended.
|
|
|
|
# If not supplied, any pkgrel will be matched.
|
|
|
|
##
|
|
|
|
find_cached_package() {
|
2015-02-13 15:17:00 +01:00
|
|
|
local searchdirs=("$PWD" "$PKGDEST") results=()
|
|
|
|
local targetname=$1 targetver=$2 targetarch=$3
|
|
|
|
local dir pkg pkgbasename pkgparts name ver rel arch size r results
|
2014-11-11 23:02:40 +01:00
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
for dir in "${searchdirs[@]}"; do
|
|
|
|
[[ -d $dir ]] || continue
|
2014-11-11 23:02:40 +01:00
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
for pkg in "$dir"/*.pkg.tar.xz; do
|
|
|
|
[[ -f $pkg ]] || continue
|
2014-11-11 23:02:40 +01:00
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
# avoid adding duplicates of the same inode
|
|
|
|
for r in "${results[@]}"; do
|
|
|
|
[[ $r -ef $pkg ]] && continue 2
|
|
|
|
done
|
2014-11-11 23:02:40 +01:00
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
# split apart package filename into parts
|
|
|
|
pkgbasename=${pkg##*/}
|
|
|
|
pkgbasename=${pkgbasename%.pkg.tar?(.?z)}
|
2014-11-11 23:02:40 +01:00
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
arch=${pkgbasename##*-}
|
|
|
|
pkgbasename=${pkgbasename%-"$arch"}
|
2014-11-11 23:02:40 +01:00
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
rel=${pkgbasename##*-}
|
|
|
|
pkgbasename=${pkgbasename%-"$rel"}
|
2014-11-11 23:02:40 +01:00
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
ver=${pkgbasename##*-}
|
|
|
|
name=${pkgbasename%-"$ver"}
|
2014-11-11 23:02:40 +01:00
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
if [[ $targetname = "$name" && $targetarch = "$arch" ]] &&
|
|
|
|
pkgver_equal "$targetver" "$ver-$rel"; then
|
|
|
|
results+=("$pkg")
|
|
|
|
fi
|
|
|
|
done
|
2014-11-11 23:02:40 +01:00
|
|
|
done
|
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
case ${#results[*]} in
|
|
|
|
0)
|
2014-11-11 23:02:40 +01:00
|
|
|
return 1
|
2015-02-13 15:17:00 +01:00
|
|
|
;;
|
|
|
|
1)
|
2014-11-11 23:02:40 +01:00
|
|
|
printf '%s\n' "$results"
|
|
|
|
return 0
|
2015-02-13 15:17:00 +01:00
|
|
|
;;
|
|
|
|
*)
|
2014-11-11 23:02:40 +01:00
|
|
|
error 'Multiple packages found:'
|
|
|
|
printf '\t%s\n' "${results[@]}" >&2
|
|
|
|
return 1
|
2015-02-13 15:17:00 +01:00
|
|
|
;;
|
|
|
|
esac
|
2014-11-11 23:02:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
##
|
|
|
|
# usage: pkgver_equal( $pkgver1, $pkgver2 )
|
|
|
|
##
|
|
|
|
pkgver_equal() {
|
|
|
|
local left right
|
|
|
|
|
|
|
|
if [[ $1 = *-* && $2 = *-* ]]; then
|
|
|
|
# if both versions have a pkgrel, then they must be an exact match
|
|
|
|
[[ $1 = "$2" ]]
|
2014-10-08 00:11:53 +02:00
|
|
|
else
|
2014-11-11 23:02:40 +01:00
|
|
|
# otherwise, trim any pkgrel and compare the bare version.
|
|
|
|
[[ ${1%%-*} = "${2%%-*}" ]]
|
2014-10-08 00:11:53 +02:00
|
|
|
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-05-11 12:47:02 +02:00
|
|
|
|
|
|
|
# $1: section
|
|
|
|
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 < "${pacman_conf}"
|
|
|
|
}
|
|
|
|
|
|
|
|
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 < "${pacman_conf}"
|
|
|
|
echo ${repos[@]}
|
|
|
|
}
|
|
|
|
|
|
|
|
clean_pacman_conf(){
|
|
|
|
local repositories=$(get_repos) uri='file://'
|
|
|
|
msg "Cleaning [$1/etc/pacman.conf] ..."
|
|
|
|
for repo in ${repositories[@]}; do
|
|
|
|
case ${repo} in
|
|
|
|
'options'|'core'|'extra'|'community'|'multilib') continue ;;
|
|
|
|
*)
|
|
|
|
msg2 "parsing [${repo}] ..."
|
|
|
|
parse_section ${repo}
|
|
|
|
if [[ ${pc_value} == $uri* ]]; then
|
|
|
|
msg2 "Removing local repo [${repo}] ..."
|
|
|
|
sed -i "/^\[${repo}/,/^Server/d" $1/etc/pacman.conf
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
msg "Done cleaning [$1/etc/pacman.conf]"
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
[[ -z ${!var} ]] && eval $(grep "^${var}=" "$1")
|
|
|
|
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-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'
|
|
|
|
|
|
|
|
[[ -z ${sets_dir} ]] && sets_dir="${SYSCONFDIR}/sets"
|
2015-02-09 23:38:12 +01:00
|
|
|
|
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-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"
|
|
|
|
|
|
|
|
sets_dir_pkg="${sets_dir}/pkg"
|
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${buildset_pkg} ]] && buildset_pkg='default'
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${blacklist_trigger[@]} ]] && blacklist_trigger=('eudev' 'upower-pm-utils' 'eudev-systemdcompat')
|
2015-01-13 13:41:28 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${blacklist[@]} ]] && blacklist=('libsystemd')
|
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_buildiso(){
|
2015-05-21 23:23:33 +02:00
|
|
|
chroots_iso="${chroots_dir}/buildiso"
|
|
|
|
|
|
|
|
sets_dir_iso="${sets_dir}/iso"
|
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${buildset_iso} ]] && buildset_iso='default'
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-03-02 23:35:15 +01:00
|
|
|
##### iso settings #####
|
|
|
|
|
2015-03-05 10:54:09 +01:00
|
|
|
if [[ -z ${dist_release} ]];then
|
2015-02-13 15:17:00 +01:00
|
|
|
source /etc/lsb-release
|
2015-03-05 10:54:09 +01:00
|
|
|
dist_release=${DISTRIB_RELEASE}
|
2015-02-13 15:17:00 +01:00
|
|
|
fi
|
2014-12-03 22:59:30 +01:00
|
|
|
|
2015-03-05 10:54:09 +01:00
|
|
|
if [[ -z ${dist_codename} ]];then
|
2015-03-02 23:35:15 +01:00
|
|
|
source /etc/lsb-release
|
2015-03-05 10:54:09 +01:00
|
|
|
dist_codename="${DISTRIB_CODENAME}"
|
2015-02-13 15:17:00 +01:00
|
|
|
fi
|
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_version} ]] && dist_version=$(date +%Y.%m)
|
2015-03-02 23:35:15 +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-05-21 22:44:32 +02:00
|
|
|
[[ -z ${iso_name} ]] && iso_name="manjaro"
|
2015-03-03 19:39:53 +01:00
|
|
|
|
2015-03-05 10:54:09 +01:00
|
|
|
iso_label="${dist_branding}${dist_release//.}"
|
2015-03-06 19:07:54 +01:00
|
|
|
iso_label="${iso_label//_}" # relace all _
|
|
|
|
iso_label="${iso_label//-}" # relace all -
|
|
|
|
iso_label="${iso_label^^}" # all uppercase
|
|
|
|
iso_label="${iso_label::8}" # limit to 8 characters
|
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-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-03-02 23:35:15 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
load_profile_config(){
|
|
|
|
|
|
|
|
[[ -f $1 ]] || return 1
|
|
|
|
|
|
|
|
profile_conf="$1"
|
|
|
|
|
|
|
|
[[ -r ${profile_conf} ]] && source ${profile_conf}
|
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${initsys} ]] && initsys="systemd"
|
2015-02-09 23:38:12 +01:00
|
|
|
|
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"
|
|
|
|
|
2015-05-31 01:26:28 +02:00
|
|
|
[[ -z ${default_desktop_executable} ]] && default_desktop_executable="none"
|
|
|
|
|
|
|
|
[[ -z ${default_desktop_file} ]] && default_desktop_file="none"
|
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${kernel} ]] && kernel="linux318"
|
2015-05-06 21:05:12 +02:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
[[ -z ${efi_boot_loader} ]] && efi_boot_loader="grub"
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-05-21 22:44:32 +02: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
|
|
|
|
2015-02-13 15:17:00 +01:00
|
|
|
if [[ -z ${addgroups} ]];then
|
2015-02-14 00:27:01 +01:00
|
|
|
addgroups="video,audio,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
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
if [[ -z ${start_openrc[@]} ]];then
|
2015-03-03 19:39:53 +01:00
|
|
|
start_openrc=('acpid' 'bluetooth' 'consolekit' 'cronie' 'cupsd' 'dbus' 'syslog-ng' 'NetworkManager')
|
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_systemd_live[@]} ]];then
|
2015-02-13 15:17:00 +01:00
|
|
|
start_systemd_live=('livecd' 'mhwd-live' 'pacman-init' 'pacman-boot')
|
|
|
|
fi
|
2015-02-09 23:38:12 +01:00
|
|
|
|
2015-05-21 22:44:32 +02:00
|
|
|
if [[ -z ${start_openrc_live[@]} ]];then
|
2015-02-13 15:17:00 +01:00
|
|
|
start_openrc_live=('livecd' 'mhwd-live' 'pacman-init' 'pacman-boot')
|
|
|
|
fi
|
2015-02-09 23:38:12 +01:00
|
|
|
|
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 19:07:19 +01:00
|
|
|
prepare_dir(){
|
|
|
|
[[ ! -d $1 ]] && mkdir -p $1
|
|
|
|
}
|
|
|
|
|
2015-02-16 20:32:47 +01:00
|
|
|
clean_dir(){
|
|
|
|
if [[ -d $1 ]]; then
|
|
|
|
msg "Cleaning [$1] ..."
|
|
|
|
rm -r $1/*
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-01-14 22:29:46 +01:00
|
|
|
# $1: sets_dir
|
2015-01-11 21:09:01 +01:00
|
|
|
load_sets(){
|
2015-02-13 15:17:00 +01:00
|
|
|
local prof temp
|
|
|
|
for item in $(ls $1/*.set); do
|
|
|
|
temp=${item##*/}
|
|
|
|
prof=${prof:-}${prof:+|}${temp%.set}
|
|
|
|
done
|
|
|
|
echo $prof
|
2015-01-11 21:09:01 +01:00
|
|
|
}
|
2015-01-13 13:41:28 +01:00
|
|
|
|
2015-01-29 05:12:17 +01:00
|
|
|
# $1: buildset
|
|
|
|
# $2: sets_dir
|
2015-01-14 22:29:46 +01:00
|
|
|
eval_buildset(){
|
2015-02-13 15:17:00 +01:00
|
|
|
eval "case $1 in
|
|
|
|
$(load_sets $2)) is_buildset=true ;;
|
|
|
|
*) is_buildset=false ;;
|
2015-01-14 22:29:46 +01:00
|
|
|
esac"
|
|
|
|
}
|
|
|
|
|
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-02-13 15:17:00 +01:00
|
|
|
USER_CONFIG="$USER_HOME/.config"
|
2015-01-13 13:41:28 +01:00
|
|
|
}
|
2015-02-14 10:49:16 +01:00
|
|
|
|
2015-05-22 12:42:41 +02:00
|
|
|
# $1: path
|
|
|
|
# $2: exit code
|
2015-05-22 00:13:39 +02:00
|
|
|
check_profile(){
|
|
|
|
local keyfiles=('profile.conf' 'mkinitcpio.conf' 'Packages' 'Packages-Livecd')
|
|
|
|
local keydirs=('overlay' 'overlay-livecd' 'isolinux')
|
|
|
|
local has_keyfiles=false has_keydirs=false
|
2015-05-22 14:53:27 +02:00
|
|
|
#msg "Checking profile [$1]"
|
2015-05-22 00:13:39 +02:00
|
|
|
for f in ${keyfiles[@]}; do
|
|
|
|
if [[ -f $1/$f ]];then
|
|
|
|
has_keyfiles=true
|
|
|
|
else
|
|
|
|
has_keyfiles=false
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
for d in ${keydirs[@]}; do
|
|
|
|
if [[ -d $1/$d ]];then
|
|
|
|
has_keydirs=true
|
|
|
|
else
|
|
|
|
has_keydirs=false
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2015-05-22 14:53:27 +02:00
|
|
|
#msg2 "has_keyfiles: ${has_keyfiles}"
|
|
|
|
#msg2 "has_keydirs: ${has_keydirs}"
|
|
|
|
if ! ${has_keyfiles} && ! ${has_keydirs};then
|
|
|
|
# msg "Profile sanity check passed."
|
|
|
|
# else
|
2015-05-22 00:13:39 +02:00
|
|
|
eval $2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-02-14 10:49:16 +01:00
|
|
|
# $1: file
|
|
|
|
# $2: exit code
|
|
|
|
check_sanity(){
|
|
|
|
if [[ ! -f $1 ]]; then
|
|
|
|
eval "$2"
|
|
|
|
fi
|
|
|
|
}
|
2015-05-22 16:51:45 +02:00
|
|
|
|
|
|
|
show_version(){
|
|
|
|
msg "manjaro-tools"
|
|
|
|
msg2 "version: ${version}"
|
|
|
|
}
|
|
|
|
|
|
|
|
show_config(){
|
|
|
|
if [[ -f ${USER_CONFIG}/manjaro-tools.conf ]]; then
|
|
|
|
msg2 "user_config: ${USER_CONFIG}/manjaro-tools.conf"
|
|
|
|
else
|
|
|
|
msg2 "manjaro_tools_conf: ${manjaro_tools_conf}"
|
|
|
|
fi
|
|
|
|
}
|
2015-05-31 23:32:50 +02:00
|
|
|
|
|
|
|
# $1: chroot
|
|
|
|
fix_dbus(){
|
|
|
|
# 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" LINK PID NAME
|
|
|
|
for ROOT in /proc/*/root; do
|
|
|
|
LINK=$(readlink $ROOT)
|
|
|
|
if [ "x$LINK" != "x" ]; then
|
|
|
|
if [ "x${LINK:0:${#PREFIX}}" = "x$PREFIX" ]; then
|
|
|
|
# this process is in the chroot...
|
|
|
|
PID=$(basename $(dirname "$ROOT"))
|
|
|
|
NAME=$(ps -p $PID -o comm=)
|
|
|
|
msg3 "Killing chroot process: $NAME ($PID)"
|
|
|
|
kill -9 "$PID"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
2015-06-01 01:09:05 +02:00
|
|
|
|
2015-06-01 23:15:29 +02:00
|
|
|
create_min_fs(){
|
|
|
|
msg "Creating install root at $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
|
|
|
}
|