forked from mirrored-repos/manjaro-tools
Compare commits
62 commits
master
...
master-Jun
Author | SHA1 | Date | |
---|---|---|---|
|
5704e623e0 | ||
|
1c357b69ce | ||
|
b5b6000852 | ||
|
470773a9ce | ||
|
620fe0655a | ||
|
22a3c4221b | ||
|
e1b82cec3a | ||
|
913b9d874c | ||
|
1702ed7aea | ||
|
5f06a4dd5d | ||
|
bb34a7f6d0 | ||
|
8046b1f4b1 | ||
|
984d5adde4 | ||
|
3278c1df91 | ||
|
ab5d0deb47 | ||
|
d734e5457c | ||
|
1648288c9f | ||
|
94fcd520c5 | ||
|
aef651518a | ||
|
15cfc351e8 | ||
|
59294cf2a7 | ||
|
95f296acde | ||
|
aa84e639a3 | ||
|
1b50455b51 | ||
|
254bcfd10f | ||
|
0b5482f7f0 | ||
|
6f00ee26bb | ||
|
21d5a1a0d6 | ||
|
1d3003ecd9 | ||
|
a8c3d88d8c | ||
|
333d307a44 | ||
|
ad7715c3b6 | ||
|
7fdcb0fcb3 | ||
|
7aa3c071eb | ||
|
711397a74c | ||
|
952f516389 | ||
|
28c6d649aa | ||
|
d84f30aa08 | ||
|
69445b01f5 | ||
|
3828892808 | ||
|
17b8b418ab | ||
|
ecf8a998dc | ||
|
470e64b563 | ||
|
ad13419fbe | ||
|
c225d41f87 | ||
|
ed8de0f88d | ||
|
bf2ddc1e1d | ||
|
d455564eb6 | ||
|
a4fc8325df | ||
|
b121fe7490 | ||
|
518992d723 | ||
|
a1492e8d1e | ||
|
25ddeb1593 | ||
|
37b9feb061 | ||
|
93626731c7 | ||
|
9533b8ce93 | ||
|
ed95e249a2 | ||
|
8a5fc4e0b0 | ||
|
734ea24b57 | ||
|
d477c42ecb | ||
|
92aaea7694 | ||
|
187aac2a35 |
32 changed files with 1439 additions and 1423 deletions
3
Makefile
3
Makefile
|
@ -1,4 +1,4 @@
|
|||
Version=0.15.0
|
||||
Version=0.16.0
|
||||
|
||||
PREFIX = /usr/local
|
||||
SYSCONFDIR = /etc
|
||||
|
@ -18,6 +18,7 @@ LIBS_BASE = \
|
|||
lib/util.sh \
|
||||
lib/util-mount.sh \
|
||||
lib/util-msg.sh \
|
||||
lib/util-chroot.sh \
|
||||
lib/util-fstab.sh
|
||||
|
||||
SHARED_BASE = \
|
||||
|
|
16
README.md
16
README.md
|
@ -1,8 +1,6 @@
|
|||
manjaro-tools
|
||||
=============
|
||||
|
||||
Manjaro-tools-0.14
|
||||
|
||||
User manual
|
||||
|
||||
### 1. manjaro-tools.conf
|
||||
|
@ -65,9 +63,6 @@ overriding
|
|||
# build dir where buildpkg or buildiso chroots are created
|
||||
# chroots_dir=/var/lib/manjaro-tools
|
||||
|
||||
# log dir where log files are created
|
||||
# log_dir='/var/log/manjaro-tools'
|
||||
|
||||
# custom build mirror server
|
||||
# build_mirror=http://mirror.netzspielplatz.de/manjaro/packages
|
||||
|
||||
|
@ -136,17 +131,20 @@ It it run in a abs/pkgbuilds directory which contains directories with PKGBUILD.
|
|||
~~~
|
||||
$ buildpkg -h
|
||||
Usage: buildpkg [options]
|
||||
-p <pkg> Buildset or pkg [default: default]
|
||||
-p <pkg> Build list or pkg [default: default]
|
||||
-a <arch> Arch [default: auto]
|
||||
-b <branch> Branch [default: stable]
|
||||
-r <dir> Chroots directory
|
||||
[default: /var/lib/manjaro-tools/buildpkg]
|
||||
-i <pkg> Install a package into the working copy of the chroot
|
||||
-c Recreate chroot
|
||||
-i <pkgs> Install packages into the working copy of the chroot
|
||||
-o Create chroot
|
||||
-d Delete chroot
|
||||
-c Clean chroot copy
|
||||
-u Update chroot copy
|
||||
-w Clean up cache and sources
|
||||
-n Install and run namcap check
|
||||
-s Sign packages
|
||||
-u udev base-devel group (no systemd)
|
||||
-x Udev base-devel group (no systemd)
|
||||
-q Query settings and pretend build
|
||||
-h This help
|
||||
~~~
|
||||
|
|
|
@ -19,6 +19,7 @@ LIBDIR='@libdir@'
|
|||
|
||||
import ${LIBDIR}/util.sh
|
||||
import ${LIBDIR}/util-mount.sh
|
||||
import ${LIBDIR}/util-chroot.sh
|
||||
|
||||
newroot=/mnt
|
||||
|
||||
|
@ -47,9 +48,8 @@ usage() {
|
|||
# usage
|
||||
# exit $(( $# ? 0 : 1 ))
|
||||
# fi
|
||||
#
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts=':C:cdGiM'
|
||||
|
||||
|
@ -67,7 +67,7 @@ while getopts ${opts} arg; do
|
|||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
check_root
|
||||
|
||||
(( $# )) || die "No root directory specified"
|
||||
newroot=$1; shift
|
||||
|
@ -97,7 +97,7 @@ if ! pacman -r "$newroot" -Sy "${pacman_args[@]}"; then
|
|||
fi
|
||||
|
||||
# kill chroot process if needed (TODO: check if needed at all)
|
||||
kill_chroot_process "$newroot"
|
||||
# kill_chroot_process "$newroot"
|
||||
|
||||
if ${copykeyring};then
|
||||
copy_keyring "$newroot"
|
||||
|
|
|
@ -18,9 +18,42 @@ SYSCONFDIR='@sysconfdir@'
|
|||
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
|
||||
|
||||
import ${LIBDIR}/util.sh
|
||||
import ${LIBDIR}/util-iso.sh
|
||||
import ${LIBDIR}/util-iso-mount.sh
|
||||
|
||||
prepare_build(){
|
||||
timer_start=$(get_timer)
|
||||
profile=$1
|
||||
edition=$(get_edition "${profile}")
|
||||
profile_dir=${run_dir}/${edition}/${profile}
|
||||
|
||||
check_profile "${profile_dir}"
|
||||
load_profile_config "${profile_dir}/profile.conf"
|
||||
|
||||
local pacman_conf=$(get_pacman_conf)
|
||||
|
||||
local mirrors_conf=$(get_pac_mirrors_conf "${target_branch}")
|
||||
|
||||
iso_file=$(gen_iso_fn).iso
|
||||
|
||||
local mirror="${build_mirror}/${target_branch}"
|
||||
|
||||
mkchroot_args+=(-C ${pacman_conf} -S ${mirrors_conf} -B "${mirror}" -K)
|
||||
work_dir=${chroots_iso}/${profile}/${target_arch}
|
||||
|
||||
iso_dir="${cache_dir_iso}/${edition}/${profile}/${dist_release}"
|
||||
|
||||
iso_root=${chroots_iso}/${profile}/iso
|
||||
mnt_dir=${chroots_iso}/${profile}/mnt
|
||||
prepare_dir "${mnt_dir}"
|
||||
|
||||
prepare_dir "${iso_dir}"
|
||||
user_own "${iso_dir}"
|
||||
}
|
||||
|
||||
show_profile(){
|
||||
prepare_profile "$1"
|
||||
local prof="$1"
|
||||
prepare_build "$prof"
|
||||
msg2 "iso_file: %s" "${iso_file}"
|
||||
if ${verbose};then
|
||||
msg2 "autologin: %s" "${autologin}"
|
||||
|
@ -61,9 +94,9 @@ display_settings(){
|
|||
show_version
|
||||
show_config
|
||||
|
||||
msg "PROFILE:"
|
||||
msg2 "build_lists: %s" "$(show_build_lists ${list_dir_iso})"
|
||||
msg2 "build_list_iso: %s" "${build_list_iso}"
|
||||
# msg "PROFILE:"
|
||||
# msg2 "build_lists: %s" "$(show_build_lists ${list_dir_iso})"
|
||||
# msg2 "build_list_iso: %s" "${build_list_iso}"
|
||||
msg2 "is_build_list: %s" "${is_build_list}"
|
||||
|
||||
msg "OPTIONS:"
|
||||
|
@ -93,10 +126,7 @@ display_settings(){
|
|||
|
||||
load_user_info
|
||||
|
||||
load_config "${USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
||||
|
||||
# to force old way to have buildiso run in iso-profiles dir
|
||||
# run_dir=$(pwd)
|
||||
load_config "${MT_USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
||||
|
||||
load_run_dir "${profile_repo}"
|
||||
|
||||
|
@ -107,6 +137,8 @@ iso_only=false
|
|||
verbose=false
|
||||
persist=false
|
||||
|
||||
mkchroot_args=(-L)
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options]"
|
||||
echo " -p <profile> Buildset or profile [default: ${build_list_iso}]"
|
||||
|
@ -135,7 +167,7 @@ usage() {
|
|||
exit $1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='p:a:b:r:t:k:i:g:czxmvqh'
|
||||
|
||||
|
@ -162,27 +194,10 @@ done
|
|||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
timer_start=$(get_timer)
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
|
||||
prepare_dir "${log_dir}"
|
||||
|
||||
prepare_dir "${tmp_dir}"
|
||||
|
||||
eval_build_list "${list_dir_iso}" "${build_list_iso}"
|
||||
|
||||
import ${LIBDIR}/util-iso.sh
|
||||
import ${LIBDIR}/util-iso-mount.sh
|
||||
check_root
|
||||
|
||||
check_requirements
|
||||
|
||||
for sig in TERM HUP QUIT; do
|
||||
trap "trap_exit $sig \"$(gettext "%s signal caught. Exiting...")\" \"$sig\"" "$sig"
|
||||
done
|
||||
trap 'trap_exit INT "$(gettext "Aborted by user! Exiting...")"' INT
|
||||
trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' ERR
|
||||
|
||||
${pretend} && display_settings && exit 1
|
||||
|
||||
run build "${build_list_iso}"
|
||||
|
|
117
bin/buildpkg.in
117
bin/buildpkg.in
|
@ -20,6 +20,7 @@ SYSCONFDIR='@sysconfdir@'
|
|||
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
|
||||
|
||||
import ${LIBDIR}/util.sh
|
||||
import ${LIBDIR}/util-chroot.sh
|
||||
import ${LIBDIR}/util-pkg.sh
|
||||
import ${LIBDIR}/util-pkg-chroot.sh
|
||||
|
||||
|
@ -37,9 +38,9 @@ display_settings(){
|
|||
show_version
|
||||
show_config
|
||||
|
||||
msg "PROFILE:"
|
||||
msg2 "build_lists: %s" "$(show_build_lists ${list_dir_pkg})"
|
||||
msg2 "build_list_pkg: %s" "${build_list_pkg}"
|
||||
# msg "PROFILE:"
|
||||
# msg2 "build_lists: %s" "$(show_build_lists ${list_dir_pkg})"
|
||||
# msg2 "build_list_pkg: %s" "${build_list_pkg}"
|
||||
msg2 "is_build_list: %s" "${is_build_list}"
|
||||
|
||||
msg "OPTIONS:"
|
||||
|
@ -49,8 +50,11 @@ display_settings(){
|
|||
|
||||
|
||||
msg "ARGS:"
|
||||
msg2 "create_first: %s" "${create_first}"
|
||||
msg2 "delete_first: %s" "${delete_first}"
|
||||
msg2 "clean_first: %s" "${clean_first}"
|
||||
msg2 "wipe_clean: %s" "${wipe_clean}"
|
||||
msg2 "update_first: %s" "${update_first}"
|
||||
msg2 "purge: %s" "${purge}"
|
||||
msg2 "namcap: %s" "${namcap}"
|
||||
msg2 "sign: %s" "${sign}"
|
||||
msg2 "udev_root: %s" "${udev_root}"
|
||||
|
@ -58,9 +62,9 @@ display_settings(){
|
|||
msg "PATHS:"
|
||||
msg2 "pkg_dir: %s" "${pkg_dir}"
|
||||
|
||||
if ${clean_first};then
|
||||
if ${create_first};then
|
||||
msg "PKG:"
|
||||
msg2 "base_packages: %s" "${base_packages[*]}"
|
||||
msg2 "packages: %s" "${packages[*]}"
|
||||
fi
|
||||
|
||||
msg "BUILD QUEUE:"
|
||||
|
@ -69,13 +73,15 @@ display_settings(){
|
|||
|
||||
load_user_info
|
||||
|
||||
load_config "${USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
||||
load_vars "$USER_HOME/.makepkg.conf" || load_vars /etc/makepkg.conf
|
||||
|
||||
install_pkgs=()
|
||||
load_config "${MT_USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
||||
load_vars "${PAC_USERCONFDIR}/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf"
|
||||
load_vars /etc/makepkg.conf
|
||||
|
||||
create_first=false
|
||||
delete_first=false
|
||||
clean_first=false
|
||||
wipe_clean=false
|
||||
update_first=false
|
||||
purge=false
|
||||
namcap=false
|
||||
pretend=false
|
||||
is_build_list=false
|
||||
|
@ -83,6 +89,43 @@ sign=false
|
|||
udev_root=false
|
||||
is_multilib=false
|
||||
|
||||
mkchroot_args=(-L)
|
||||
mkchrootpkg_args=()
|
||||
|
||||
install_pkgs=()
|
||||
|
||||
prepare_build(){
|
||||
local pac_arch='default'
|
||||
|
||||
if [[ "${target_arch}" == 'multilib' ]];then
|
||||
pac_arch='multilib'
|
||||
is_multilib=true
|
||||
fi
|
||||
|
||||
local pacman_conf="${DATADIR}/pacman-$pac_arch.conf"
|
||||
|
||||
work_dir="${chroots_pkg}/${target_branch}/${target_arch}"
|
||||
pkg_dir="${cache_dir_pkg}/${target_branch}/${target_arch}"
|
||||
|
||||
local makepkg_conf=$(get_makepkg_conf "${target_arch}")
|
||||
|
||||
[[ "$pac_arch" == 'multilib' ]] && target_arch='x86_64'
|
||||
|
||||
local mirror="${build_mirror}/${target_branch}"
|
||||
|
||||
local mirrors_conf=$(get_pac_mirrors_conf "${target_branch}")
|
||||
|
||||
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${mirrors_conf} -B ${mirror})
|
||||
|
||||
mkchrootpkg_args+=(-r ${work_dir})
|
||||
|
||||
eval_build_list "${list_dir_pkg}" "${build_list_pkg}"
|
||||
|
||||
init_base_devel
|
||||
|
||||
timer_start=$(get_timer)
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options]"
|
||||
echo " -p <pkg> Build list or pkg [default: ${build_list_pkg}]"
|
||||
|
@ -91,11 +134,14 @@ usage() {
|
|||
echo ' -r <dir> Chroots directory'
|
||||
echo " [default: ${chroots_pkg}]"
|
||||
echo ' -i <pkgs> Install packages into the working copy of the chroot'
|
||||
echo ' -c Recreate chroot'
|
||||
echo ' -o Create chroot'
|
||||
echo ' -d Delete chroot'
|
||||
echo ' -c Clean chroot copy'
|
||||
echo ' -u Update chroot copy'
|
||||
echo ' -w Clean up cache and sources'
|
||||
echo ' -n Install and run namcap check'
|
||||
echo ' -s Sign packages'
|
||||
echo ' -u Udev base-devel group (no systemd)'
|
||||
echo ' -x Udev base-devel group (no systemd)'
|
||||
echo ' -q Query settings and pretend build'
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
|
@ -103,9 +149,9 @@ usage() {
|
|||
exit $1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='p:a:b:r:i:cwnsuqh'
|
||||
opts='p:a:b:r:i:odcuwnsxqh'
|
||||
|
||||
while getopts "${opts}" arg; do
|
||||
case "${arg}" in
|
||||
|
@ -113,48 +159,31 @@ while getopts "${opts}" arg; do
|
|||
a) target_arch="$OPTARG" ;;
|
||||
b) target_branch="$OPTARG" ;;
|
||||
r) chroots_pkg="$OPTARG" ;;
|
||||
i) install_pkgs+=("$OPTARG"); mkchrootpkg_args+=(-I ${install_pkgs[*]}) ;;
|
||||
c) clean_first=true ;;
|
||||
w) wipe_clean=true ;;
|
||||
i) install_pkgs+=("$OPTARG"); mkchrootpkg_args+=(-I "${install_pkgs[*]}") ;;
|
||||
o) create_first=true ;;
|
||||
d) delete_first=true ;;
|
||||
c) clean_first=true ; mkchrootpkg_args+=(-c) ;;
|
||||
u) update_first=true ; mkchrootpkg_args+=(-u) ;;
|
||||
w) purge=true ;;
|
||||
n) namcap=true; mkchrootpkg_args+=(-n) ;;
|
||||
s) sign=true ;;
|
||||
u) udev_root=true ;;
|
||||
x) udev_root=true ;;
|
||||
q) pretend=true ;;
|
||||
h|?) usage 0 ;;
|
||||
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
||||
*) echo "invalid argument '%s'" "${arg}"; usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
check_root
|
||||
|
||||
prepare_dir "${log_dir}"
|
||||
|
||||
prepare_dir "${tmp_dir}"
|
||||
|
||||
prepare_conf "${target_arch}"
|
||||
|
||||
mirrors_conf=$(get_pac_mirrors_conf "${target_branch}")
|
||||
|
||||
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${mirrors_conf} -B "${build_mirror}/${target_branch}")
|
||||
|
||||
mkchrootpkg_args+=(-r ${work_dir})
|
||||
|
||||
timer_start=$(get_timer)
|
||||
|
||||
eval_build_list "${list_dir_pkg}" "${build_list_pkg}"
|
||||
|
||||
prepare_dir "${pkg_dir}"
|
||||
|
||||
user_own "${pkg_dir}"
|
||||
|
||||
init_base_devel
|
||||
prepare_build
|
||||
|
||||
${pretend} && display_settings && exit
|
||||
|
||||
${wipe_clean} && clean_up
|
||||
${delete_first} && delete_chroot "${work_dir}/root" "${work_dir}"
|
||||
|
||||
chroot_init
|
||||
${create_first} && create_chroot "${mkchroot_args[@]}" "${work_dir}/root" "${packages[@]}"
|
||||
|
||||
run make_pkg "${build_list_pkg}"
|
||||
|
|
|
@ -16,7 +16,7 @@ SYSCONFDIR='@sysconfdir@'
|
|||
|
||||
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
|
||||
import ${LIBDIR}/util.sh
|
||||
import ${LIBDIR}/util-pkgtree.sh
|
||||
import ${LIBDIR}/util-pkg-tree.sh
|
||||
|
||||
display_settings(){
|
||||
show_version
|
||||
|
@ -36,7 +36,7 @@ display_settings(){
|
|||
|
||||
load_user_info
|
||||
|
||||
load_config "${USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
||||
load_config "${MT_USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
||||
|
||||
sync=false
|
||||
pretend=false
|
||||
|
@ -55,7 +55,7 @@ usage() {
|
|||
exit $1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='sacqh'
|
||||
|
||||
|
@ -72,7 +72,7 @@ done
|
|||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
check_root
|
||||
|
||||
prepare_dir "${tree_dir_abs}"
|
||||
|
||||
|
|
|
@ -62,9 +62,9 @@ display_settings(){
|
|||
show_version
|
||||
show_config
|
||||
|
||||
msg "PROFILE:"
|
||||
msg2 "build_lists: %s" "$(show_build_lists ${list_dir_iso})"
|
||||
msg2 "build_list_iso: %s" "${build_list_iso}"
|
||||
# msg "PROFILE:"
|
||||
# msg2 "build_lists: %s" "$(show_build_lists ${list_dir_iso})"
|
||||
# msg2 "build_list_iso: %s" "${build_list_iso}"
|
||||
msg2 "is_build_list: %s" "${is_build_list}"
|
||||
|
||||
msg "OPTIONS:"
|
||||
|
@ -83,7 +83,7 @@ display_settings(){
|
|||
|
||||
load_user_info
|
||||
|
||||
load_config "${USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
||||
load_config "${MT_USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
||||
|
||||
# to force old way to have buildiso run in iso-profiles dir
|
||||
# run_dir=$(pwd)
|
||||
|
@ -112,7 +112,7 @@ usage() {
|
|||
exit $1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='p:a:i:k:gcvqh'
|
||||
|
||||
|
@ -133,9 +133,7 @@ done
|
|||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
|
||||
prepare_dir "${tmp_dir}"
|
||||
check_root
|
||||
|
||||
eval_build_list "${list_dir_iso}" "${build_list_iso}"
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@ import ${LIBDIR}/util-pkg.sh
|
|||
|
||||
shopt -s extglob
|
||||
|
||||
load_vars "$HOME/.makepkg.conf"
|
||||
load_user_info
|
||||
|
||||
load_vars "${PAC_USERCONFDIR}/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf"
|
||||
load_vars /etc/makepkg.conf
|
||||
|
||||
if [[ ! -f PKGBUILD ]]; then
|
||||
|
|
|
@ -19,7 +19,9 @@ import ${LIBDIR}/util.sh
|
|||
import ${LIBDIR}/util-mount.sh
|
||||
|
||||
working_dir=''
|
||||
files=()
|
||||
keep_mirrors=false
|
||||
nosetarch=false
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] working-dir [run arguments]"
|
||||
|
@ -30,18 +32,20 @@ usage() {
|
|||
echo ' -M <file> Location of a makepkg config file'
|
||||
echo ' -S <file> Location of a pacman-mirrors config file'
|
||||
echo ' -c <dir> Set pacman cache'
|
||||
echo ' -f <file> Copy file from the host to the chroot'
|
||||
echo ' -s Do not run setarch'
|
||||
echo ' -r <list> Bind mountargs ro'
|
||||
echo ' -w <list> Bind mountargs rw'
|
||||
echo ' List format [src1:target1,...,srcN:targetN]'
|
||||
echo ' List format [src1:target1 ... srcN:targetN]'
|
||||
echo ' -B Use custom build mirror'
|
||||
echo ' -K Keep mirrorlist (-B)'
|
||||
echo ' -h This message'
|
||||
exit 1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='hKC:M:S:c:r:w:B:'
|
||||
opts='hKC:M:S:c:r:w:B:f:s'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "${arg}" in
|
||||
|
@ -49,8 +53,10 @@ while getopts ${opts} arg; do
|
|||
M) makepkg_conf="$OPTARG" ;;
|
||||
S) mirrors_conf="$OPTARG" ;;
|
||||
c) cache_dir="$OPTARG" ;;
|
||||
r) mountargs_ro="$OPTARG" ;;
|
||||
w) mountargs_rw="$OPTARG" ;;
|
||||
f) files+=("$OPTARG") ;;
|
||||
s) nosetarch=true ;;
|
||||
r) bindmounts_ro=("$OPTARG") ;;
|
||||
w) bindmounts_rw=("$OPTARG") ;;
|
||||
B) build_mirror="$OPTARG" ;;
|
||||
K) keep_mirrors=true ;;
|
||||
h|?) usage ;;
|
||||
|
@ -60,7 +66,8 @@ done
|
|||
shift $(($OPTIND - 1))
|
||||
|
||||
(( $# < 1 )) && die 'You must specify a directory.'
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
|
||||
check_root
|
||||
|
||||
working_dir=$(readlink -f "$1")
|
||||
shift 1
|
||||
|
@ -81,6 +88,12 @@ copy_hostconf () {
|
|||
[[ -n $makepkg_conf ]] && cp $makepkg_conf "$1/etc/makepkg.conf"
|
||||
[[ -n $mirrors_conf ]] && cp ${mirrors_conf} "$1/etc/pacman-mirrors.conf"
|
||||
|
||||
local file
|
||||
for file in "${files[@]}"; do
|
||||
mkdir -p "$(dirname "$working_dir$file")"
|
||||
cp -T "$file" "$working_dir$file"
|
||||
done
|
||||
|
||||
if [[ -n ${build_mirror} ]];then
|
||||
build_mirror=${build_mirror}'/$repo/$arch'
|
||||
if ${keep_mirrors}; then
|
||||
|
@ -95,7 +108,7 @@ copy_hostconf () {
|
|||
sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i "$1/etc/pacman.conf"
|
||||
}
|
||||
|
||||
chroot_extra_umount() {
|
||||
chroot_extra_mount() {
|
||||
chroot_mount "/etc/resolv.conf" "$1/etc/resolv.conf" -B
|
||||
chroot_mount "${cache_dirs[0]}" "$1${cache_dirs[0]}" -B
|
||||
|
||||
|
@ -103,21 +116,13 @@ chroot_extra_umount() {
|
|||
chroot_mount "$cache_dir" "$1${cache_dir}" -Br
|
||||
done
|
||||
|
||||
if [[ -n ${mountargs_ro[@]} ]];then
|
||||
local IFS=','
|
||||
for m in ${mountargs_ro[@]}; do
|
||||
for m in ${bindmounts_ro[@]}; do
|
||||
chroot_mount "${m%%:*}" "$1${m##*:}" -Br
|
||||
done
|
||||
unset IFS
|
||||
fi
|
||||
|
||||
if [[ -n ${mountargs_rw[@]} ]];then
|
||||
local IFS=','
|
||||
for m in ${mountargs_rw[@]}; do
|
||||
for m in ${bindmounts_rw[@]}; do
|
||||
chroot_mount "${m%%:*}" "$1${m##*:}" -B
|
||||
done
|
||||
unset IFS
|
||||
fi
|
||||
}
|
||||
|
||||
umask 0022
|
||||
|
@ -131,12 +136,14 @@ fi
|
|||
|
||||
chroot_api_mount "${working_dir}" || die "failed to setup API filesystems in chroot %s" "${working_dir}"
|
||||
|
||||
chroot_extra_umount "${working_dir}"
|
||||
chroot_extra_mount "${working_dir}"
|
||||
|
||||
copy_hostconf "${working_dir}"
|
||||
|
||||
eval $(grep '^CARCH=' "$working_dir/etc/makepkg.conf")
|
||||
|
||||
${nosetarch} && unset CARCH
|
||||
|
||||
${CARCH:+setarch "$CARCH"} chroot "${working_dir}" "$@"
|
||||
|
||||
kill_chroot_process "${working_dir}"
|
||||
# kill_chroot_process "${working_dir}"
|
||||
|
|
|
@ -30,9 +30,9 @@ display_settings(){
|
|||
show_version
|
||||
show_config
|
||||
|
||||
msg "PROFILE:"
|
||||
msg2 "build_lists: %s" "$(show_build_lists ${list_dir_iso})"
|
||||
msg2 "build_list_iso: %s" "${build_list_iso}"
|
||||
# msg "PROFILE:"
|
||||
# msg2 "build_lists: %s" "$(show_build_lists ${list_dir_iso})"
|
||||
# msg2 "build_list_iso: %s" "${build_list_iso}"
|
||||
msg2 "is_build_list: %s" "${is_build_list}"
|
||||
|
||||
msg "OPTIONS:"
|
||||
|
@ -62,7 +62,7 @@ display_settings(){
|
|||
|
||||
load_user_info
|
||||
|
||||
load_config "${USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
||||
load_config "${MT_USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
||||
|
||||
run_dir=${cache_dir_iso}
|
||||
|
||||
|
|
|
@ -108,33 +108,19 @@ fi
|
|||
|
||||
while getopts ':LPpt:U' flag; do
|
||||
case $flag in
|
||||
L)
|
||||
bytag=LABEL
|
||||
;;
|
||||
U)
|
||||
bytag=UUID
|
||||
;;
|
||||
P)
|
||||
pseudofs=1
|
||||
;;
|
||||
p)
|
||||
pseudofs=0
|
||||
;;
|
||||
t)
|
||||
bytag=${OPTARG^^}
|
||||
;;
|
||||
:)
|
||||
die '%s: option requires an argument -- '\''%s'\' "${0##*/}" "$OPTARG"
|
||||
;;
|
||||
?)
|
||||
die '%s: invalid option -- '\''%s'\' "${0##*/}" "$OPTARG"
|
||||
;;
|
||||
L) bytag=LABEL ;;
|
||||
U) bytag=UUID ;;
|
||||
P) pseudofs=1 ;;
|
||||
p) pseudofs=0 ;;
|
||||
t) bytag=${OPTARG^^} ;;
|
||||
:) die '%s: option requires an argument -- '\''%s'\' "${0##*/}" "$OPTARG" ;;
|
||||
?) die '%s: invalid option -- '\''%s'\' "${0##*/}" "$OPTARG" ;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
(( $# )) || die "No root directory specified"
|
||||
root=$1; shift
|
||||
root=$(realpath -mL "$1"); shift
|
||||
|
||||
if ! mountpoint -q "$root"; then
|
||||
die "$root is not a mountpoint"
|
||||
|
|
|
@ -35,7 +35,7 @@ display_settings(){
|
|||
|
||||
load_user_info
|
||||
|
||||
load_config "${USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
||||
load_config "${MT_USERCONFDIR}/manjaro-tools.conf" || load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
||||
|
||||
automount=false
|
||||
pretend=false
|
||||
|
@ -55,7 +55,7 @@ usage() {
|
|||
exit $1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts=':haq'
|
||||
|
||||
|
@ -69,7 +69,7 @@ while getopts ${opts} arg; do
|
|||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
check_root
|
||||
|
||||
if ${automount};then
|
||||
chrootdir=/mnt
|
||||
|
|
|
@ -16,11 +16,15 @@ LIBDIR='@libdir@'
|
|||
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
|
||||
|
||||
import ${LIBDIR}/util.sh
|
||||
import ${LIBDIR}/util-chroot.sh
|
||||
|
||||
working_dir=''
|
||||
files=()
|
||||
|
||||
build_locales=false
|
||||
keep_mirrors=false
|
||||
keep_flag=''
|
||||
nosetarch=false
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] working-dir package-list..."
|
||||
|
@ -29,6 +33,8 @@ usage() {
|
|||
echo ' -M <file> Location of a makepkg config file'
|
||||
echo ' -S <file> Location of a pacman-mirrors config file'
|
||||
echo ' -c <dir> Set pacman cache'
|
||||
echo ' -f <file> Copy file from the host to the chroot'
|
||||
echo ' -s Do not run setarch'
|
||||
echo ' -L Use build locale.gen en/de'
|
||||
echo ' -B Use custom build mirror'
|
||||
echo ' -K Keep mirrorlist (-B)'
|
||||
|
@ -37,9 +43,9 @@ usage() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
opts='hLKC:M:S:c:B:'
|
||||
opts='hLKC:M:S:c:B:f:s'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "${arg}" in
|
||||
|
@ -47,18 +53,20 @@ while getopts ${opts} arg; do
|
|||
M) makepkg_conf="$OPTARG" ;;
|
||||
S) mirrors_conf="$OPTARG" ;;
|
||||
c) cache_dir="$OPTARG" ;;
|
||||
f) files+=("$OPTARG") ;;
|
||||
s) nosetarch=true ;;
|
||||
L) build_locales=true ;;
|
||||
B) build_mirror="$OPTARG" ;;
|
||||
K) keep_mirrors=true; keep_flag='-K' ;;
|
||||
h|?) usage ;;
|
||||
*) error "invalid argument '$arg'"; usage ;;
|
||||
*) error "invalid argument '%s'" "$arg"; usage ;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
(( $# < 2 )) && die 'You must specify a directory and one or more packages.'
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
check_root
|
||||
|
||||
working_dir="$(readlink -f $1)"
|
||||
shift 1
|
||||
|
@ -89,6 +97,11 @@ if is_btrfs "$working_dir"; then
|
|||
chmod 0755 "$working_dir"
|
||||
fi
|
||||
|
||||
for file in "${files[@]}"; do
|
||||
mkdir -p "$(dirname "$working_dir$file")"
|
||||
cp "$file" "$working_dir$file"
|
||||
done
|
||||
|
||||
# Workaround when creating a chroot in a branch different of the host
|
||||
if [[ -n $pac_conf ]] && [[ -n $mirrors_conf ]] && [[ -n ${build_mirror} ]]; then
|
||||
url=${build_mirror}'/$repo/$arch'
|
||||
|
@ -96,11 +109,21 @@ if [[ -n $pac_conf ]] && [[ -n $mirrors_conf ]] && [[ -n ${build_mirror} ]]; the
|
|||
pac_base="$working_dir/pacman-basestrap.conf"
|
||||
sed "s#Include = /etc/pacman.d/mirrorlist#Server = ${url}#g" $pac_conf > $pac_base
|
||||
|
||||
_env=()
|
||||
while read -r varname; do
|
||||
_env+=("$varname=${!varname}")
|
||||
done < <(declare -x | sed -r 's/^declare -x ([^=]*)=.*/\1/' | grep -i '_proxy$')
|
||||
env -i "${_env[@]}" \
|
||||
basestrap -GMcd ${pac_base:+-C "$pac_base"} "$working_dir" \
|
||||
"${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'
|
||||
|
||||
[[ -f "$pac_base" ]] && rm "$pac_base"
|
||||
else
|
||||
_env=()
|
||||
while read -r varname; do
|
||||
_env+=("$varname=${!varname}")
|
||||
done < <(declare -x | sed -r 's/^declare -x ([^=]*)=.*/\1/' | grep -i '_proxy$')
|
||||
env -i "${_env[@]}" \
|
||||
basestrap -GMcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \
|
||||
"${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'
|
||||
fi
|
||||
|
@ -117,6 +140,7 @@ if ${build_locales};then
|
|||
fi
|
||||
|
||||
chroot_args=(${pac_conf:+-C "$pac_conf"} ${makepkg_conf:+-M "$makepkg_conf"} ${mirrors_conf:+-S "$mirrors_conf"} ${build_mirror:+-B "$build_mirror"} ${cache_dir:+-c "$cache_dir"} ${keep_flag})
|
||||
${nosetarch} && chroot_args+=(${nosetarch:+-s})
|
||||
|
||||
exec chroot-run \
|
||||
${chroot_args[*]} \
|
||||
|
|
|
@ -16,25 +16,32 @@ LIBDIR='@libdir@'
|
|||
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
|
||||
|
||||
import ${LIBDIR}/util.sh
|
||||
import ${LIBDIR}/util-chroot.sh
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
makepkg_args=(-s --noconfirm -L)
|
||||
init_variables() {
|
||||
default_makepkg_args=(-s --noconfirm -L --holdver)
|
||||
makepkg_args=("${default_makepkg_args[@]}")
|
||||
repack=false
|
||||
update_first=false
|
||||
clean_first=false
|
||||
install_pkg=
|
||||
run_namcap=false
|
||||
temp_chroot=false
|
||||
chrootdir=
|
||||
passeddir=
|
||||
declare -a install_pkgs
|
||||
declare -i ret=0
|
||||
makepkg_user=
|
||||
declare -ga install_pkgs
|
||||
declare -gi ret=0
|
||||
|
||||
bindmounts_ro=()
|
||||
bindmounts_rw=()
|
||||
|
||||
copy=$USER
|
||||
[[ -n $SUDO_USER ]] && copy=$SUDO_USER
|
||||
[[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER
|
||||
[[ -z "$copy" || $copy = root ]] && copy=copy
|
||||
src_owner=${SUDO_USER:-$USER}
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]"
|
||||
|
@ -50,11 +57,17 @@ usage() {
|
|||
echo 'command:'
|
||||
echo ' mkchroot <chrootdir>/root base-devel'
|
||||
echo ''
|
||||
echo " Default makepkg args: ${makepkg_args[*]}"
|
||||
echo 'This script reads {SRC,SRCPKG,PKG,LOG}DEST, MAKEFLAGS and PACKAGER'
|
||||
echo 'from makepkg.conf(5), if those variables are not part of the'
|
||||
echo 'environment.'
|
||||
echo ''
|
||||
echo "Default makepkg args: ${default_makepkg_args[*]}"
|
||||
echo ''
|
||||
echo 'Flags:'
|
||||
echo '-h This help'
|
||||
echo '-c Clean the chroot before building'
|
||||
echo '-d <dir> Bind directory into build chroot as read-write'
|
||||
echo '-D <dir> Bind directory into build chroot as read-only'
|
||||
echo '-u Update the working copy of the chroot before building'
|
||||
echo ' This is useful for rebuilds without dirtying the pristine'
|
||||
echo ' chroot'
|
||||
|
@ -65,69 +78,31 @@ usage() {
|
|||
echo " Default: $copy"
|
||||
echo '-n Run namcap on the package'
|
||||
echo '-T Build in a temporary directory'
|
||||
echo '-U Run makepkg as a specified user'
|
||||
exit 1
|
||||
}
|
||||
|
||||
orig_argv=("$@")
|
||||
|
||||
while getopts 'hcur:I:l:nT' arg; do
|
||||
case "$arg" in
|
||||
c) clean_first=true ;;
|
||||
u) update_first=true ;;
|
||||
r) passeddir="$OPTARG" ;;
|
||||
I) install_pkgs+=("$OPTARG") ;;
|
||||
l) copy="$OPTARG" ;;
|
||||
n) run_namcap=true; makepkg_args+=(-i) ;;
|
||||
T) temp_chroot=true; copy+="-$$" ;;
|
||||
h|*) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
|
||||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
|
||||
# Canonicalize chrootdir, getting rid of trailing /
|
||||
chrootdir=$(readlink -e "$passeddir")
|
||||
[[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir"
|
||||
[[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkchroot %s/root base-devel" "$chrootdir"
|
||||
|
||||
# Detect chrootdir filesystem type
|
||||
chroottype=$(stat -f -c %T "$chrootdir")
|
||||
|
||||
sync_chroot() {
|
||||
local chrootdir=$1
|
||||
local copy=$2
|
||||
local copydir=''
|
||||
if [[ ${copy:0:1} = / ]]; then
|
||||
copydir=$copy
|
||||
else
|
||||
copydir="$chrootdir/$copy"
|
||||
fi
|
||||
|
||||
# Pass all arguments after -- right to makepkg
|
||||
makepkg_args+=("${@:$OPTIND}")
|
||||
if [[ "$chrootdir/root" -ef "$copydir" ]]; then
|
||||
error 'Cannot sync copy with itself: %s' "$copydir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# See if -R was passed to makepkg
|
||||
for arg in "${@:OPTIND}"; do
|
||||
case ${arg%%=*} in
|
||||
-*R*|--repackage)
|
||||
repack=true
|
||||
break 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
load_user_info
|
||||
|
||||
# {{{ functions
|
||||
|
||||
create_chroot() {
|
||||
# Lock the chroot we want to use. We'll keep this lock until we exit.
|
||||
lock 9 "$copydir.lock" "Locking chroot copy [$copy]"
|
||||
|
||||
if [[ ! -d $copydir ]] || $clean_first; then
|
||||
# Get a read lock on the root chroot to make
|
||||
# sure we don't clone a half-updated chroot
|
||||
slock 8 "$chrootdir/root.lock" "Locking clean chroot"
|
||||
slock 8 "$chrootdir/root.lock" \
|
||||
"Locking clean chroot [%s]" "$chrootdir/root"
|
||||
|
||||
stat_busy "Creating clean working copy [$copy]"
|
||||
stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$chrootdir/root" "$copydir"
|
||||
if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then
|
||||
subvolume_delete_recursive "$copydir" ||
|
||||
die "Unable to delete subvolume %s" "$copydir"
|
||||
|
@ -140,47 +115,61 @@ create_chroot() {
|
|||
stat_done
|
||||
|
||||
# Drop the read lock again
|
||||
exec 8>&-
|
||||
fi
|
||||
lock_close 8
|
||||
|
||||
# Update mtime
|
||||
touch "$copydir"
|
||||
}
|
||||
|
||||
clean_temporary() {
|
||||
stat_busy "Removing temporary copy [$copy]"
|
||||
if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then
|
||||
btrfs subvolume delete "$copydir" >/dev/null ||
|
||||
die "Unable to delete subvolume %s" "$copydir"
|
||||
else
|
||||
# avoid change of filesystem in case of an umount failure
|
||||
rm --recursive --force --one-file-system "$copydir" ||
|
||||
die "Unable to delete %s" "$copydir"
|
||||
fi
|
||||
|
||||
# remove lock file
|
||||
rm -f "$copydir.lock"
|
||||
stat_done
|
||||
}
|
||||
# Usage: delete_chroot $copydir [$copy]
|
||||
# delete_chroot() {
|
||||
# local copydir=$1
|
||||
# local copy=${1:-$2}
|
||||
#
|
||||
# stat_busy "Removing chroot copy [%s]" "$copy"
|
||||
# if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then
|
||||
# subvolume_delete_recursive "$copydir" ||
|
||||
# die "Unable to delete subvolume %s" "$copydir"
|
||||
# else
|
||||
# # avoid change of filesystem in case of an umount failure
|
||||
# rm --recursive --force --one-file-system "$copydir" ||
|
||||
# die "Unable to delete %s" "$copydir"
|
||||
# fi
|
||||
#
|
||||
# # remove lock file
|
||||
# rm -f "$copydir.lock"
|
||||
# stat_done
|
||||
# }
|
||||
|
||||
# Usage: install_packages $copydir $pkgs...
|
||||
install_packages() {
|
||||
local copydir=$1
|
||||
local install_pkgs=("${@:2}")
|
||||
|
||||
local -a pkgnames
|
||||
local ret
|
||||
|
||||
pkgnames=("${install_pkgs[@]##*/}")
|
||||
|
||||
cp -- "${install_pkgs[@]}" "$copydir/root/"
|
||||
|
||||
chroot-run "$copydir" \
|
||||
chroot-run -r "${bindmounts_ro[*]}" -w "${bindmounts_rw[*]}" "$copydir" \
|
||||
pacman -U --noconfirm -- "${pkgnames[@]/#//root/}"
|
||||
ret=$?
|
||||
rm -- "${pkgnames[@]/#/$copydir/root/}"
|
||||
|
||||
# If there is no PKGBUILD we are done
|
||||
[[ -f PKGBUILD ]] || exit $ret
|
||||
return $ret
|
||||
}
|
||||
|
||||
# Usage: prepare_chroot $copydir $HOME $repack $run_namcap
|
||||
# Globals:
|
||||
# - MAKEFLAGS
|
||||
# - PACKAGER
|
||||
prepare_chroot() {
|
||||
local copydir=$1
|
||||
local USER_HOME=$2
|
||||
local repack=$3
|
||||
local run_namcap=$4
|
||||
|
||||
$repack || rm -rf "$copydir/build"
|
||||
|
||||
local builduser_uid="${SUDO_UID:-$UID}"
|
||||
|
@ -204,7 +193,7 @@ prepare_chroot() {
|
|||
|
||||
sed -e '/^MAKEFLAGS=/d' -e '/^PACKAGER=/d' -i "$copydir/etc/makepkg.conf"
|
||||
for x in BUILDDIR=/build PKGDEST=/pkgdest SRCPKGDEST=/srcpkgdest SRCDEST=/srcdest LOGDEST=/logdest \
|
||||
"MAKEFLAGS='$MAKEFLAGS'" "PACKAGER='$PACKAGER'"
|
||||
"MAKEFLAGS='${MAKEFLAGS:-}'" "PACKAGER='${PACKAGER:-}'"
|
||||
do
|
||||
grep -q "^$x" "$copydir/etc/makepkg.conf" && continue
|
||||
echo "$x" >>"$copydir/etc/makepkg.conf"
|
||||
|
@ -220,9 +209,7 @@ EOF
|
|||
{
|
||||
printf '#!/bin/bash\n'
|
||||
declare -f _chrootbuild
|
||||
printf '_chrootbuild'
|
||||
printf ' %q' "${makepkg_args[@]}"
|
||||
printf ' || exit\n'
|
||||
printf '_chrootbuild "$@" || exit\n'
|
||||
|
||||
if $run_namcap; then
|
||||
declare -f _chrootnamcap
|
||||
|
@ -236,9 +223,6 @@ EOF
|
|||
# so no global variables
|
||||
_chrootbuild() {
|
||||
. /etc/profile
|
||||
# export HOME=/build
|
||||
# cd /startdir
|
||||
# sudo -u builduser makepkg "$@"
|
||||
sudo -iu builduser bash -c 'cd /startdir; makepkg "$@"' -bash "$@"
|
||||
}
|
||||
|
||||
|
@ -250,37 +234,52 @@ _chrootnamcap() {
|
|||
done
|
||||
}
|
||||
|
||||
# Usage: download_sources $copydir $src_owner
|
||||
# Globals:
|
||||
# - SRCDEST
|
||||
# - USER
|
||||
download_sources() {
|
||||
local copydir=$1
|
||||
local src_owner=$2
|
||||
|
||||
local builddir="$(mktemp -d)"
|
||||
chmod 1777 "$builddir"
|
||||
|
||||
# Ensure sources are downloaded
|
||||
if [[ -n $SUDO_USER ]]; then
|
||||
sudo -u $SUDO_USER env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \
|
||||
makepkg_user=${makepkg_user:-$SUDO_USER}
|
||||
if [[ -n $makepkg_user ]]; then
|
||||
sudo -u "$makepkg_user" env SRCDEST="$SRCDEST" BUILDDIR="$builddir" \
|
||||
makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o
|
||||
else
|
||||
( export SRCDEST BUILDDIR="$builddir"
|
||||
makepkg --asroot --config="$copydir/etc/makepkg.conf" --verifysource -o
|
||||
)
|
||||
error "Running makepkg as root is not allowed."
|
||||
exit 1
|
||||
fi
|
||||
(( $? != 0 )) && die "Could not download sources."
|
||||
|
||||
# Clean up garbage from verifysource
|
||||
rm -rf $builddir
|
||||
rm -rf "$builddir"
|
||||
}
|
||||
|
||||
# Usage: move_products $copydir $owner
|
||||
# Globals:
|
||||
# - PKGDEST
|
||||
# - LOGDEST
|
||||
move_products() {
|
||||
local copydir=$1
|
||||
local src_owner=$2
|
||||
|
||||
local pkgfile
|
||||
for pkgfile in "$copydir"/pkgdest/*; do
|
||||
chown "$src_owner" "$pkgfile"
|
||||
mv "$pkgfile" "$PKGDEST"
|
||||
|
||||
# Fix broken symlink because of temporary chroot PKGDEST /pkgdest
|
||||
if [[ "$PWD" != "$PKGDEST" && -L "$PWD/${pkgfile##*/}" ]]; then
|
||||
rm "$PWD/${pkgfile##*/}"
|
||||
ln -sf "$PKGDEST/${pkgfile##*/}"
|
||||
fi
|
||||
done
|
||||
|
||||
local l
|
||||
for l in "$copydir"/logdest/*; do
|
||||
[[ $l == */logpipe.* ]] && continue
|
||||
chown "$src_owner" "$l"
|
||||
|
@ -294,9 +293,64 @@ move_products() {
|
|||
}
|
||||
# }}}
|
||||
|
||||
orig_argv=("$0" "$@")
|
||||
|
||||
main() {
|
||||
init_variables
|
||||
|
||||
local opts='hcur:I:l:nTD:d:U:'
|
||||
|
||||
while getopts ${opts} arg; do
|
||||
case "$arg" in
|
||||
c) clean_first=true ;;
|
||||
D) bindmounts_ro+=("$OPTARG") ;;
|
||||
d) bindmounts_rw+=("$OPTARG") ;;
|
||||
u) update_first=true ;;
|
||||
r) passeddir="$OPTARG" ;;
|
||||
I) install_pkgs+=("$OPTARG") ;;
|
||||
l) copy="$OPTARG" ;;
|
||||
n) run_namcap=true; makepkg_args+=(-i) ;;
|
||||
T) temp_chroot=true; copy+="-$$" ;;
|
||||
U) makepkg_user="$OPTARG" ;;
|
||||
h|*) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
|
||||
[[ -n $makepkg_user && -z $(id -u "$makepkg_user") ]] && die 'Invalid makepkg user.'
|
||||
|
||||
check_root
|
||||
|
||||
# Canonicalize chrootdir, getting rid of trailing /
|
||||
chrootdir=$(readlink -e "$passeddir")
|
||||
[[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir"
|
||||
[[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkchroot %s/root base-devel" "$chrootdir"
|
||||
|
||||
if [[ ${copy:0:1} = / ]]; then
|
||||
copydir=$copy
|
||||
else
|
||||
copydir="$chrootdir/$copy"
|
||||
fi
|
||||
|
||||
# Pass all arguments after -- right to makepkg
|
||||
makepkg_args+=("${@:$OPTIND}")
|
||||
|
||||
# See if -R was passed to makepkg
|
||||
for arg in "${@:OPTIND}"; do
|
||||
case ${arg%%=*} in
|
||||
-*R*|--repackage)
|
||||
repack=true
|
||||
break 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
load_user_info
|
||||
|
||||
umask 0022
|
||||
|
||||
load_vars "$USER_HOME/.makepkg.conf" || load_vars /etc/makepkg.conf
|
||||
load_vars "${PAC_USERCONFDIR}/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf"
|
||||
load_vars /etc/makepkg.conf
|
||||
|
||||
# Use PKGBUILD directory if these don't exist
|
||||
[[ -d $PKGDEST ]] || PKGDEST=$PWD
|
||||
|
@ -304,32 +358,37 @@ load_vars "$USER_HOME/.makepkg.conf" || load_vars /etc/makepkg.conf
|
|||
[[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD
|
||||
[[ -d $LOGDEST ]] || LOGDEST=$PWD
|
||||
|
||||
create_chroot
|
||||
# Lock the chroot we want to use. We'll keep this lock until we exit.
|
||||
lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy"
|
||||
|
||||
$update_first && chroot-run \
|
||||
-r "${mountargs_ro}" \
|
||||
-w "${mountargs_rw}" \
|
||||
"$copydir" \
|
||||
if [[ ! -d $copydir ]] || $clean_first; then
|
||||
sync_chroot "$chrootdir" "$copy"
|
||||
fi
|
||||
|
||||
$update_first && chroot-run -r "${bindmounts_ro[*]}" -w "${bindmounts_rw[*]}" "$copydir" \
|
||||
pacman -Syu --noconfirm
|
||||
|
||||
[[ -n ${install_pkgs[*]} ]] && install_packages
|
||||
if [[ -n ${install_pkgs[*]:-} ]]; then
|
||||
install_packages "$copydir" "${install_pkgs[@]}"
|
||||
ret=$?
|
||||
# If there is no PKGBUILD we have done
|
||||
[[ -f PKGBUILD ]] || return $ret
|
||||
fi
|
||||
|
||||
download_sources
|
||||
download_sources "$copydir" "$src_owner"
|
||||
|
||||
prepare_chroot
|
||||
prepare_chroot "$copydir" "$USER_HOME" "$repack" "$run_namcap"
|
||||
|
||||
mountargs_rw="${PWD}:/startdir,${SRCDEST}:/srcdest"
|
||||
bindmounts_rw+=("${PWD}:/startdir" "${SRCDEST}:/srcdest")
|
||||
|
||||
if chroot-run -r "${mountargs_ro}" \
|
||||
-w "${mountargs_rw}" \
|
||||
"$copydir" \
|
||||
/chrootbuild; then
|
||||
move_products
|
||||
if chroot-run -r "${bindmounts_ro[*]}" -w "${bindmounts_rw[*]}" "$copydir" \
|
||||
/chrootbuild "${makepkg_args[@]}"; then
|
||||
move_products "$copydir" "$src_owner"
|
||||
else
|
||||
(( ret += 1 ))
|
||||
fi
|
||||
|
||||
$temp_chroot && clean_temporary
|
||||
$temp_chroot && delete_chroot "$copydir" "$copy"
|
||||
|
||||
if (( ret != 0 )); then
|
||||
if $temp_chroot; then
|
||||
|
@ -340,3 +399,6 @@ if (( ret != 0 )); then
|
|||
else
|
||||
true
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
|
@ -17,7 +17,9 @@ LIBDIR='@libdir@'
|
|||
|
||||
import ${LIBDIR}/util.sh
|
||||
|
||||
load_vars "$HOME/.makepkg.conf"
|
||||
load_user_info
|
||||
|
||||
load_vars "${PAC_USERCONFDIR}/makepkg.conf" || load_vars "$USER_HOME/.makepkg.conf"
|
||||
load_vars /etc/makepkg.conf
|
||||
|
||||
if [ ! -e "$1" ]; then
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
# build dir where buildpkg or buildiso chroots are created
|
||||
# chroots_dir=/var/lib/manjaro-tools
|
||||
|
||||
# log dir where log files are created
|
||||
# log_dir='/var/log/manjaro-tools'
|
||||
|
||||
# custom build mirror server
|
||||
# build_mirror=http://mirror.netzspielplatz.de/manjaro/packages
|
||||
|
||||
|
|
|
@ -96,13 +96,31 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|||
<varlistentry>
|
||||
<term><option>-i PKG</option></term>
|
||||
|
||||
<listitem><para>Install a package into the working copy of the chroot.</para></listitem>
|
||||
<listitem><para>Install packages into the working copy of the chroot.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-o</option></term>
|
||||
|
||||
<listitem><para>Create chroot.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-d</option></term>
|
||||
|
||||
<listitem><para>Delete chroot.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-c</option></term>
|
||||
|
||||
<listitem><para>Recreate chroot.</para></listitem>
|
||||
<listitem><para>Clean chroot copy.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-u</option></term>
|
||||
|
||||
<listitem><para>Update chroot copy.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
@ -123,6 +141,12 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|||
<listitem><para>Sign package.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-x</option></term>
|
||||
|
||||
<listitem><para>Udev base-devel group (no systemd).</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-q</option></term>
|
||||
|
||||
|
|
|
@ -76,12 +76,6 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|||
you will upload.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-c</option></term>
|
||||
|
||||
<listitem><para>Create new remote release.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-l</option></term>
|
||||
|
||||
|
|
|
@ -237,6 +237,8 @@ miso_mount_handler() {
|
|||
|
||||
if [[ "${copytoram}" == "y" ]]; then
|
||||
umount -d /run/miso/bootmnt
|
||||
mkdir -p /run/miso/bootmnt/${misobasedir}/${arch}
|
||||
mount -o bind /run/miso/copytoram /run/miso/bootmnt/${misobasedir}/${arch}
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ miso_pxe_http_mount_handler () {
|
|||
local _src=${miso_http_srv}${misobasedir}/${arch}
|
||||
|
||||
for sfs in livefs mhwdfs desktopfs rootfs;do
|
||||
if [[ -f "${_src}/${sfs}.sfs" ]]; then
|
||||
if [[ ! -z "$( curl -s --head "${_src}/${sfs}.sfs" | grep "OK" )" ]]; then
|
||||
_curl_get "${_src}/${sfs}.sfs" "/${arch}"
|
||||
|
||||
if [[ "${checksum}" == "y" ]]; then
|
||||
|
|
94
lib/util-chroot.sh
Normal file
94
lib/util-chroot.sh
Normal file
|
@ -0,0 +1,94 @@
|
|||
#!/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.
|
||||
|
||||
copy_mirrorlist(){
|
||||
cp -a /etc/pacman.d/mirrorlist "$1/etc/pacman.d/"
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
create_min_fs(){
|
||||
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}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
create_chroot(){
|
||||
local timer=$(get_timer)
|
||||
setarch "${target_arch}" \
|
||||
mkchroot "$@"
|
||||
show_elapsed_time "${FUNCNAME}" "${timer}"
|
||||
}
|
||||
|
||||
delete_chroot() {
|
||||
local copydir=$1
|
||||
local copy=${1:-$2}
|
||||
|
||||
stat_busy "Removing chroot copy [%s]" "$copy"
|
||||
if is_btrfs "$chrootdir" && ! mountpoint -q "$copydir"; then
|
||||
subvolume_delete_recursive "$copydir" ||
|
||||
die "Unable to delete subvolume %s" "$copydir"
|
||||
else
|
||||
# avoid change of filesystem in case of an umount failure
|
||||
rm --recursive --force --one-file-system "$copydir" ||
|
||||
die "Unable to delete %s" "$copydir"
|
||||
fi
|
||||
|
||||
# remove lock file
|
||||
rm -f "$copydir.lock"
|
||||
stat_done
|
||||
}
|
||||
|
||||
# $1: chroot
|
||||
# kill_chroot_process(){
|
||||
# # 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
|
||||
# }
|
|
@ -1,97 +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.
|
||||
|
||||
prepare_initcpio(){
|
||||
msg2 "Copying initcpio ..."
|
||||
cp /etc/initcpio/hooks/miso* $1/etc/initcpio/hooks
|
||||
cp /etc/initcpio/install/miso* $1/etc/initcpio/install
|
||||
cp /etc/initcpio/miso_shutdown $1/etc/initcpio
|
||||
}
|
||||
|
||||
prepare_initramfs(){
|
||||
cp ${DATADIR}/mkinitcpio.conf $1/etc/mkinitcpio-${iso_name}.conf
|
||||
local _kernver=$(cat $1/usr/lib/modules/*/version)
|
||||
if [[ -n ${gpgkey} ]]; then
|
||||
su ${OWNER} -c "gpg --export ${gpgkey} >${USERCONFDIR}/gpgkey"
|
||||
exec 17<>${USERCONFDIR}/gpgkey
|
||||
fi
|
||||
MISO_GNUPG_FD=${gpgkey:+17} chroot-run $1 \
|
||||
/usr/bin/mkinitcpio -k ${_kernver} \
|
||||
-c /etc/mkinitcpio-${iso_name}.conf \
|
||||
-g /boot/initramfs.img
|
||||
|
||||
if [[ -n ${gpgkey} ]]; then
|
||||
exec 17<&-
|
||||
fi
|
||||
if [[ -f ${USERCONFDIR}/gpgkey ]]; then
|
||||
rm ${USERCONFDIR}/gpgkey
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_boot_extras(){
|
||||
cp $1/boot/intel-ucode.img $2/intel_ucode.img
|
||||
cp $1/usr/share/licenses/intel-ucode/LICENSE $2/intel_ucode.LICENSE
|
||||
cp $1/boot/memtest86+/memtest.bin $2/memtest
|
||||
cp $1/usr/share/licenses/common/GPL2/license.txt $2/memtest.COPYING
|
||||
}
|
||||
|
||||
prepare_grub(){
|
||||
local platform=i386-pc img='core.img' grub=$2/boot/grub efi=$2/efi/boot \
|
||||
data=$1/usr/share/grub lib=$1/usr/lib/grub prefix=/boot/grub
|
||||
|
||||
prepare_dir ${grub}/${platform}
|
||||
|
||||
cp ${data}/cfg/*.cfg ${grub}
|
||||
|
||||
cp ${lib}/${platform}/* ${grub}/${platform}
|
||||
|
||||
msg2 "Building %s ..." "${img}"
|
||||
|
||||
grub-mkimage -d ${grub}/${platform} -o ${grub}/${platform}/${img} -O ${platform} -p ${prefix} biosdisk iso9660
|
||||
|
||||
cat ${grub}/${platform}/cdboot.img ${grub}/${platform}/${img} > ${grub}/${platform}/eltorito.img
|
||||
|
||||
case ${target_arch} in
|
||||
'i686')
|
||||
platform=i386-efi
|
||||
img=bootia32.efi
|
||||
;;
|
||||
'x86_64')
|
||||
platform=x86_64-efi
|
||||
img=bootx64.efi
|
||||
;;
|
||||
esac
|
||||
|
||||
prepare_dir ${efi}
|
||||
prepare_dir ${grub}/${platform}
|
||||
|
||||
cp ${lib}/${platform}/* ${grub}/${platform}
|
||||
|
||||
msg2 "Building %s ..." "${img}"
|
||||
|
||||
grub-mkimage -d ${grub}/${platform} -o ${efi}/${img} -O ${platform} -p ${prefix} iso9660
|
||||
|
||||
prepare_dir ${grub}/themes
|
||||
cp -r ${data}/themes/${iso_name}-live ${grub}/themes/
|
||||
cp ${data}/unicode.pf2 ${grub}
|
||||
cp -r ${data}/{locales,tz,video} ${grub}
|
||||
|
||||
local size=8M mnt="${mnt_dir}/efiboot" efi_img="$2/efi.img"
|
||||
msg2 "Creating fat image of %s ..." "${size}"
|
||||
truncate -s ${size} "${efi_img}"
|
||||
mkfs.fat -n MISO_EFI "${efi_img}" &>/dev/null
|
||||
prepare_dir "${mnt}"
|
||||
mount_img "${efi_img}" "${mnt}"
|
||||
prepare_dir ${mnt}/efi/boot
|
||||
msg2 "Building %s ..." "${img}"
|
||||
grub-mkimage -d ${grub}/${platform} -o ${mnt}/efi/boot/${img} -O ${platform} -p ${prefix} iso9660
|
||||
umount_img "${mnt}"
|
||||
}
|
366
lib/util-iso-chroot.sh
Normal file
366
lib/util-iso-chroot.sh
Normal file
|
@ -0,0 +1,366 @@
|
|||
#!/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.
|
||||
|
||||
copy_overlay(){
|
||||
local src="$1" dest="$2"
|
||||
if [[ -e $src ]];then
|
||||
msg2 "Copying [%s] ..." "${src##*/}"
|
||||
if [[ -L $src ]];then
|
||||
cp -a --no-preserve=ownership $src/* $dest
|
||||
else
|
||||
cp -LR $src/* $dest
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
add_svc_rc(){
|
||||
local mnt="$1" name="$2"
|
||||
if [[ -f $mnt/etc/init.d/$name ]];then
|
||||
msg2 "Setting %s ..." "$name"
|
||||
chroot $mnt rc-update add $name default &>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
add_svc_sd(){
|
||||
local mnt="$1" name="$2"
|
||||
if [[ -f $mnt/etc/systemd/system/$name.service ]] || \
|
||||
[[ -f $mnt/usr/lib/systemd/system/$name.service ]];then
|
||||
msg2 "Setting %s ..." "$name"
|
||||
chroot $mnt systemctl enable $name &>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
set_xdm(){
|
||||
if [[ -f $1/etc/conf.d/xdm ]];then
|
||||
local conf='DISPLAYMANAGER="'${displaymanager}'"'
|
||||
sed -i -e "s|^.*DISPLAYMANAGER=.*|${conf}|" $1/etc/conf.d/xdm
|
||||
fi
|
||||
}
|
||||
|
||||
configure_mhwd_drivers(){
|
||||
local path=$1${mhwd_repo}/ \
|
||||
drv_path=$1/var/lib/mhwd/db/pci/graphic_drivers
|
||||
info "Configuring mwwd db ..."
|
||||
if [ -z "$(ls $path | grep catalyst-utils 2> /dev/null)" ]; then
|
||||
msg2 "Disabling Catalyst driver"
|
||||
mkdir -p $drv_path/catalyst/
|
||||
touch $drv_path/catalyst/MHWDCONFIG
|
||||
fi
|
||||
if [ -z "$(ls $path | grep nvidia-utils 2> /dev/null)" ]; then
|
||||
msg2 "Disabling Nvidia driver"
|
||||
mkdir -p $drv_path/nvidia/
|
||||
touch $drv_path/nvidia/MHWDCONFIG
|
||||
msg2 "Disabling Nvidia Bumblebee driver"
|
||||
mkdir -p $drv_path/hybrid-intel-nvidia-bumblebee/
|
||||
touch $drv_path/hybrid-intel-nvidia-bumblebee/MHWDCONFIG
|
||||
fi
|
||||
if [ -z "$(ls $path | grep nvidia-304xx-utils 2> /dev/null)" ]; then
|
||||
msg2 "Disabling Nvidia 304xx driver"
|
||||
mkdir -p $drv_path/nvidia-304xx/
|
||||
touch $drv_path/nvidia-304xx/MHWDCONFIG
|
||||
fi
|
||||
if [ -z "$(ls $path | grep nvidia-340xx-utils 2> /dev/null)" ]; then
|
||||
msg2 "Disabling Nvidia 340xx driver"
|
||||
mkdir -p $drv_path/nvidia-340xx/
|
||||
touch $drv_path/nvidia-340xx/MHWDCONFIG
|
||||
fi
|
||||
if [ -z "$(ls $path | grep xf86-video-amdgpu 2> /dev/null)" ]; then
|
||||
msg2 "Disabling AMD gpu driver"
|
||||
mkdir -p $drv_path/xf86-video-amdgpu/
|
||||
touch $drv_path/xf86-video-amdgpu/MHWDCONFIG
|
||||
fi
|
||||
}
|
||||
|
||||
configure_hosts(){
|
||||
sed -e "s|localhost.localdomain|localhost.localdomain ${hostname}|" -i $1/etc/hosts
|
||||
}
|
||||
|
||||
configure_lsb(){
|
||||
local conf=$1/etc/lsb-release
|
||||
if [[ -e $conf ]] ; then
|
||||
msg2 "Configuring lsb-release"
|
||||
sed -i -e "s/^.*DISTRIB_RELEASE.*/DISTRIB_RELEASE=${dist_release}/" $conf
|
||||
sed -i -e "s/^.*DISTRIB_CODENAME.*/DISTRIB_CODENAME=${dist_codename}/" $conf
|
||||
fi
|
||||
}
|
||||
|
||||
configure_logind(){
|
||||
msg2 "Configuring logind ..."
|
||||
local conf=$1/etc/$2/logind.conf
|
||||
if [[ -e $conf ]];then
|
||||
sed -i 's/#\(HandleSuspendKey=\)suspend/\1ignore/' "$conf"
|
||||
sed -i 's/#\(HandleLidSwitch=\)suspend/\1ignore/' "$conf"
|
||||
sed -i 's/#\(HandleHibernateKey=\)hibernate/\1ignore/' "$conf"
|
||||
fi
|
||||
}
|
||||
|
||||
configure_journald(){
|
||||
msg2 "Configuring journald ..."
|
||||
local conf=$1/etc/systemd/journald.conf
|
||||
sed -i 's/#\(Storage=\)auto/\1volatile/' "$conf"
|
||||
}
|
||||
|
||||
configure_services(){
|
||||
local mnt="$1"
|
||||
info "Configuring [%s]" "${initsys}"
|
||||
case ${initsys} in
|
||||
'openrc')
|
||||
for svc in ${enable_openrc[@]}; do
|
||||
[[ $svc == "xdm" ]] && set_xdm "$mnt"
|
||||
add_svc_rc "$mnt" "$svc"
|
||||
done
|
||||
for svc in ${enable_openrc_live[@]}; do
|
||||
add_svc_rc "$mnt" "$svc"
|
||||
done
|
||||
;;
|
||||
'systemd')
|
||||
for svc in ${enable_systemd[@]}; do
|
||||
add_svc_sd "$mnt" "$svc"
|
||||
done
|
||||
for svc in ${enable_systemd_live[@]}; do
|
||||
add_svc_sd "$mnt" "$svc"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
info "Done configuring [%s]" "${initsys}"
|
||||
}
|
||||
|
||||
write_live_session_conf(){
|
||||
local path=$1${SYSCONFDIR}
|
||||
[[ ! -d $path ]] && mkdir -p $path
|
||||
local conf=$path/live.conf
|
||||
msg2 "Writing %s" "${conf##*/}"
|
||||
echo '# live session configuration' > ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# autologin' >> ${conf}
|
||||
echo "autologin=${autologin}" >> ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# login shell' >> ${conf}
|
||||
echo "login_shell=${login_shell}" >> ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# live username' >> ${conf}
|
||||
echo "username=${username}" >> ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# live password' >> ${conf}
|
||||
echo "password=${password}" >> ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# live group membership' >> ${conf}
|
||||
echo "addgroups='${addgroups}'" >> ${conf}
|
||||
if [[ -n ${smb_workgroup} ]];then
|
||||
echo '' >> ${conf}
|
||||
echo '# samba workgroup' >> ${conf}
|
||||
echo "smb_workgroup=${smb_workgroup}" >> ${conf}
|
||||
fi
|
||||
}
|
||||
|
||||
configure_system(){
|
||||
local mnt="$1"
|
||||
case ${initsys} in
|
||||
'systemd')
|
||||
configure_logind "$mnt" "systemd"
|
||||
configure_journald "$mnt"
|
||||
|
||||
# Prevent some services to be started in the livecd
|
||||
echo 'File created by manjaro-tools. See systemd-update-done.service(8).' \
|
||||
| tee "${path}/etc/.updated" >"${path}/var/.updated"
|
||||
|
||||
msg2 "Disable systemd-gpt-auto-generator"
|
||||
ln -sf /dev/null "${path}/usr/lib/systemd/system-generators/systemd-gpt-auto-generator"
|
||||
;;
|
||||
'openrc')
|
||||
configure_logind "$mnt" "elogind"
|
||||
;;
|
||||
esac
|
||||
echo ${hostname} > $mnt/etc/hostname
|
||||
}
|
||||
|
||||
make_repo(){
|
||||
local dest="$1"
|
||||
cp ${DATADIR}/pacman-mhwd.conf $dest/opt
|
||||
repo-add $dest${mhwd_repo}/mhwd.db.tar.gz $dest${mhwd_repo}/*pkg*z
|
||||
}
|
||||
|
||||
clean_iso_root(){
|
||||
local dest="$1"
|
||||
msg2 "Deleting isoroot [%s] ..." "${dest##*/}"
|
||||
rm -rf --one-file-system "$dest"
|
||||
}
|
||||
|
||||
clean_up_image(){
|
||||
|
||||
local path mnt="$1"
|
||||
msg2 "Cleaning [%s]" "${mnt##*/}"
|
||||
if [[ ${1##*/} == 'mhwdfs' ]];then
|
||||
path=$mnt/var
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -mindepth 0 -delete &> /dev/null
|
||||
fi
|
||||
path=$mnt/etc
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -mindepth 0 -delete &> /dev/null
|
||||
fi
|
||||
else
|
||||
[[ -f "$mnt/etc/locale.gen.bak" ]] && mv "$mnt/etc/locale.gen.bak" "$mnt/etc/locale.gen"
|
||||
[[ -f "$mnt/etc/locale.conf.bak" ]] && mv "$mnt/etc/locale.conf.bak" "$mnt/etc/locale.conf"
|
||||
path=$mnt/boot
|
||||
if [[ -d "$path" ]]; then
|
||||
find "$path" -name 'initramfs*.img' -delete &> /dev/null
|
||||
fi
|
||||
path=$mnt/var/lib/pacman/sync
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -type f -delete &> /dev/null
|
||||
fi
|
||||
path=$mnt/var/cache/pacman/pkg
|
||||
if [[ -d $path ]]; then
|
||||
find "$path" -type f -delete &> /dev/null
|
||||
fi
|
||||
path=$mnt/var/log
|
||||
if [[ -d $path ]]; then
|
||||
find "$path" -type f -delete &> /dev/null
|
||||
fi
|
||||
path=$mnt/var/tmp
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -mindepth 1 -delete &> /dev/null
|
||||
fi
|
||||
path=$mnt/tmp
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -mindepth 1 -delete &> /dev/null
|
||||
fi
|
||||
|
||||
if [[ ${mnt##*/} == 'livefs' ]];then
|
||||
rm -rf "$mnt/etc/pacman.d/gnupg"
|
||||
fi
|
||||
fi
|
||||
|
||||
find "$mnt" -name *.pacnew -name *.pacsave -name *.pacorig -delete
|
||||
file=$mnt/boot/grub/grub.cfg
|
||||
if [[ -f "$file" ]]; then
|
||||
rm $file
|
||||
fi
|
||||
}
|
||||
|
||||
copy_from_cache(){
|
||||
local list="${tmp_dir}"/mhwd-cache.list mirror="${build_mirror}/${target_branch}"
|
||||
local mnt="$1"; shift
|
||||
chroot-run -B "$mirror" "$mnt" \
|
||||
pacman -v -Syw --noconfirm "$@" || return 1
|
||||
chroot-run -B "$mirror" "$mnt" \
|
||||
pacman -v -Sp --noconfirm "$@" > "$list"
|
||||
sed -ni '/.pkg.tar.xz/p' "$list"
|
||||
sed -i "s/.*\///" "$list"
|
||||
|
||||
msg2 "Copying mhwd package cache ..."
|
||||
rsync -v --files-from="$list" /var/cache/pacman/pkg "$mnt${mhwd_repo}"
|
||||
}
|
||||
|
||||
chroot_clean(){
|
||||
local dest="$1"
|
||||
for root in "$dest"/*; do
|
||||
[[ -d ${root} ]] || continue
|
||||
local name=${root##*/}
|
||||
if [[ $name != "mhwdfs" ]];then
|
||||
# lock 9 "$name.lock" "Locking chroot copy [%s]" "$name"
|
||||
delete_chroot "${root}" "$dest"
|
||||
fi
|
||||
done
|
||||
|
||||
rm -rf --one-file-system "$dest"
|
||||
}
|
||||
|
||||
prepare_initcpio(){
|
||||
msg2 "Copying initcpio ..."
|
||||
local dest="$1"
|
||||
cp /etc/initcpio/hooks/miso* $dest/etc/initcpio/hooks
|
||||
cp /etc/initcpio/install/miso* $dest/etc/initcpio/install
|
||||
cp /etc/initcpio/miso_shutdown $dest/etc/initcpio
|
||||
}
|
||||
|
||||
prepare_initramfs(){
|
||||
local mnt="$1"
|
||||
cp ${DATADIR}/mkinitcpio.conf $mnt/etc/mkinitcpio-${iso_name}.conf
|
||||
local _kernver=$(cat $mnt/usr/lib/modules/*/version)
|
||||
if [[ -n ${gpgkey} ]]; then
|
||||
su ${OWNER} -c "gpg --export ${gpgkey} >${MT_USERCONFDIR}/gpgkey"
|
||||
exec 17<>${MT_USERCONFDIR}/gpgkey
|
||||
fi
|
||||
MISO_GNUPG_FD=${gpgkey:+17} chroot-run $mnt \
|
||||
/usr/bin/mkinitcpio -k ${_kernver} \
|
||||
-c /etc/mkinitcpio-${iso_name}.conf \
|
||||
-g /boot/initramfs.img
|
||||
|
||||
if [[ -n ${gpgkey} ]]; then
|
||||
exec 17<&-
|
||||
fi
|
||||
if [[ -f ${MT_USERCONFDIR}/gpgkey ]]; then
|
||||
rm ${MT_USERCONFDIR}/gpgkey
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_boot_extras(){
|
||||
local src="$1" dest="$2"
|
||||
cp $src/boot/intel-ucode.img $dest/intel_ucode.img
|
||||
cp $src/usr/share/licenses/intel-ucode/LICENSE $dest/intel_ucode.LICENSE
|
||||
cp $src/boot/memtest86+/memtest.bin $dest/memtest
|
||||
cp $src/usr/share/licenses/common/GPL2/license.txt $dest/memtest.COPYING
|
||||
}
|
||||
|
||||
prepare_grub(){
|
||||
local platform=i386-pc img='core.img' grub=$3/boot/grub efi=$3/efi/boot \
|
||||
lib=$1/usr/lib/grub prefix=/boot/grub theme=$2/usr/share/grub data=$1/usr/share/grub
|
||||
|
||||
prepare_dir ${grub}/${platform}
|
||||
|
||||
cp ${theme}/cfg/*.cfg ${grub}
|
||||
|
||||
cp ${lib}/${platform}/* ${grub}/${platform}
|
||||
|
||||
msg2 "Building %s ..." "${img}"
|
||||
|
||||
grub-mkimage -d ${grub}/${platform} -o ${grub}/${platform}/${img} -O ${platform} -p ${prefix} biosdisk iso9660
|
||||
|
||||
cat ${grub}/${platform}/cdboot.img ${grub}/${platform}/${img} > ${grub}/${platform}/eltorito.img
|
||||
|
||||
case ${target_arch} in
|
||||
'i686')
|
||||
platform=i386-efi
|
||||
img=bootia32.efi
|
||||
;;
|
||||
'x86_64')
|
||||
platform=x86_64-efi
|
||||
img=bootx64.efi
|
||||
;;
|
||||
esac
|
||||
|
||||
prepare_dir ${efi}
|
||||
prepare_dir ${grub}/${platform}
|
||||
|
||||
cp ${lib}/${platform}/* ${grub}/${platform}
|
||||
|
||||
msg2 "Building %s ..." "${img}"
|
||||
|
||||
grub-mkimage -d ${grub}/${platform} -o ${efi}/${img} -O ${platform} -p ${prefix} iso9660
|
||||
|
||||
prepare_dir ${grub}/themes
|
||||
cp -r ${theme}/themes/${iso_name}-live ${grub}/themes/
|
||||
cp ${data}/unicode.pf2 ${grub}
|
||||
cp -r ${theme}/{locales,tz} ${grub}
|
||||
|
||||
local size=4M mnt="${mnt_dir}/efiboot" efi_img="$3/efi.img"
|
||||
msg2 "Creating fat image of %s ..." "${size}"
|
||||
truncate -s ${size} "${efi_img}"
|
||||
mkfs.fat -n MISO_EFI "${efi_img}" &>/dev/null
|
||||
prepare_dir "${mnt}"
|
||||
mount_img "${efi_img}" "${mnt}"
|
||||
prepare_dir ${mnt}/efi/boot
|
||||
msg2 "Building %s ..." "${img}"
|
||||
grub-mkimage -d ${grub}/${platform} -o ${mnt}/efi/boot/${img} -O ${platform} -p ${prefix} iso9660
|
||||
umount_img "${mnt}"
|
||||
}
|
|
@ -1,313 +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.
|
||||
|
||||
copy_overlay(){
|
||||
if [[ -e $1 ]];then
|
||||
msg2 "Copying [%s] ..." "${1##*/}"
|
||||
if [[ -L $1 ]];then
|
||||
cp -a --no-preserve=ownership $1/* $2
|
||||
else
|
||||
cp -LR $1/* $2
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
add_svc_rc(){
|
||||
if [[ -f $1/etc/init.d/$2 ]];then
|
||||
msg2 "Setting %s ..." "$2"
|
||||
chroot $1 rc-update add $2 default &>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
add_svc_sd(){
|
||||
if [[ -f $1/etc/systemd/system/$2.service ]] || \
|
||||
[[ -f $1/usr/lib/systemd/system/$2.service ]];then
|
||||
msg2 "Setting %s ..." "$2"
|
||||
chroot $1 systemctl enable $2 &>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
set_xdm(){
|
||||
if [[ -f $1/etc/conf.d/xdm ]];then
|
||||
local conf='DISPLAYMANAGER="'${displaymanager}'"'
|
||||
sed -i -e "s|^.*DISPLAYMANAGER=.*|${conf}|" $1/etc/conf.d/xdm
|
||||
fi
|
||||
}
|
||||
|
||||
configure_mhwd_drivers(){
|
||||
local path=$1${mhwd_repo}/ \
|
||||
drv_path=$1/var/lib/mhwd/db/pci/graphic_drivers
|
||||
info "Configuring mwwd db ..."
|
||||
if [ -z "$(ls $path | grep catalyst-utils 2> /dev/null)" ]; then
|
||||
msg2 "Disabling Catalyst driver"
|
||||
mkdir -p $drv_path/catalyst/
|
||||
touch $drv_path/catalyst/MHWDCONFIG
|
||||
fi
|
||||
if [ -z "$(ls $path | grep nvidia-utils 2> /dev/null)" ]; then
|
||||
msg2 "Disabling Nvidia driver"
|
||||
mkdir -p $drv_path/nvidia/
|
||||
touch $drv_path/nvidia/MHWDCONFIG
|
||||
msg2 "Disabling Nvidia Bumblebee driver"
|
||||
mkdir -p $drv_path/hybrid-intel-nvidia-bumblebee/
|
||||
touch $drv_path/hybrid-intel-nvidia-bumblebee/MHWDCONFIG
|
||||
fi
|
||||
if [ -z "$(ls $path | grep nvidia-304xx-utils 2> /dev/null)" ]; then
|
||||
msg2 "Disabling Nvidia 304xx driver"
|
||||
mkdir -p $drv_path/nvidia-304xx/
|
||||
touch $drv_path/nvidia-304xx/MHWDCONFIG
|
||||
fi
|
||||
if [ -z "$(ls $path | grep nvidia-340xx-utils 2> /dev/null)" ]; then
|
||||
msg2 "Disabling Nvidia 340xx driver"
|
||||
mkdir -p $drv_path/nvidia-340xx/
|
||||
touch $drv_path/nvidia-340xx/MHWDCONFIG
|
||||
fi
|
||||
if [ -z "$(ls $path | grep xf86-video-amdgpu 2> /dev/null)" ]; then
|
||||
msg2 "Disabling AMD gpu driver"
|
||||
mkdir -p $drv_path/xf86-video-amdgpu/
|
||||
touch $drv_path/xf86-video-amdgpu/MHWDCONFIG
|
||||
fi
|
||||
}
|
||||
|
||||
configure_lsb(){
|
||||
if [ -e $1/etc/lsb-release ] ; then
|
||||
msg2 "Configuring lsb-release"
|
||||
sed -i -e "s/^.*DISTRIB_RELEASE.*/DISTRIB_RELEASE=${dist_release}/" $1/etc/lsb-release
|
||||
sed -i -e "s/^.*DISTRIB_CODENAME.*/DISTRIB_CODENAME=${dist_codename}/" $1/etc/lsb-release
|
||||
fi
|
||||
}
|
||||
|
||||
configure_logind(){
|
||||
msg2 "Configuring logind ..."
|
||||
local conf=$1/etc/$2/logind.conf
|
||||
sed -i 's/#\(HandleSuspendKey=\)suspend/\1ignore/' "$conf"
|
||||
sed -i 's/#\(HandleLidSwitch=\)suspend/\1ignore/' "$conf"
|
||||
sed -i 's/#\(HandleHibernateKey=\)hibernate/\1ignore/' "$conf"
|
||||
}
|
||||
|
||||
configure_journald(){
|
||||
msg2 "Configuring journald ..."
|
||||
local conf=$1/etc/systemd/journald.conf
|
||||
sed -i 's/#\(Storage=\)auto/\1volatile/' "$conf"
|
||||
}
|
||||
|
||||
configure_services(){
|
||||
info "Configuring [%s]" "${initsys}"
|
||||
case ${initsys} in
|
||||
'openrc')
|
||||
for svc in ${enable_openrc[@]}; do
|
||||
[[ $svc == "xdm" ]] && set_xdm "$1"
|
||||
add_svc_rc "$1" "$svc"
|
||||
done
|
||||
for svc in ${enable_openrc_live[@]}; do
|
||||
add_svc_rc "$1" "$svc"
|
||||
done
|
||||
;;
|
||||
'systemd')
|
||||
for svc in ${enable_systemd[@]}; do
|
||||
add_svc_sd "$1" "$svc"
|
||||
done
|
||||
for svc in ${enable_systemd_live[@]}; do
|
||||
add_svc_sd "$1" "$svc"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
info "Done configuring [%s]" "${initsys}"
|
||||
}
|
||||
|
||||
write_live_session_conf(){
|
||||
local path=$1${SYSCONFDIR}
|
||||
[[ ! -d $path ]] && mkdir -p $path
|
||||
local conf=$path/live.conf
|
||||
msg2 "Writing %s" "${conf##*/}"
|
||||
echo '# live session configuration' > ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# autologin' >> ${conf}
|
||||
echo "autologin=${autologin}" >> ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# login shell' >> ${conf}
|
||||
echo "login_shell=${login_shell}" >> ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# live username' >> ${conf}
|
||||
echo "username=${username}" >> ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# live password' >> ${conf}
|
||||
echo "password=${password}" >> ${conf}
|
||||
echo '' >> ${conf}
|
||||
echo '# live group membership' >> ${conf}
|
||||
echo "addgroups='${addgroups}'" >> ${conf}
|
||||
if [[ -n ${smb_workgroup} ]];then
|
||||
echo '' >> ${conf}
|
||||
echo '# samba workgroup' >> ${conf}
|
||||
echo "smb_workgroup=${smb_workgroup}" >> ${conf}
|
||||
fi
|
||||
}
|
||||
|
||||
configure_hosts(){
|
||||
sed -e "s|localhost.localdomain|localhost.localdomain ${hostname}|" -i $1/etc/hosts
|
||||
}
|
||||
|
||||
configure_system(){
|
||||
case ${initsys} in
|
||||
'systemd')
|
||||
configure_logind "$1" "systemd"
|
||||
configure_journald "$1"
|
||||
|
||||
# Prevent some services to be started in the livecd
|
||||
echo 'File created by manjaro-tools. See systemd-update-done.service(8).' \
|
||||
| tee "${path}/etc/.updated" >"${path}/var/.updated"
|
||||
|
||||
msg2 "Disable systemd-gpt-auto-generator"
|
||||
ln -sf /dev/null "${path}/usr/lib/systemd/system-generators/systemd-gpt-auto-generator"
|
||||
;;
|
||||
'openrc')
|
||||
configure_logind "$1" "elogind"
|
||||
# local hn='hostname="'${hostname}'"'
|
||||
# sed -i -e "s|^.*hostname=.*|${hn}|" $1/etc/conf.d/hostname
|
||||
;;
|
||||
esac
|
||||
echo ${hostname} > $1/etc/hostname
|
||||
}
|
||||
|
||||
configure_thus(){
|
||||
msg2 "Configuring Thus ..."
|
||||
source "$1/etc/mkinitcpio.d/${kernel}.preset"
|
||||
local conf="$1/etc/thus.conf"
|
||||
echo "[distribution]" > "$conf"
|
||||
echo "DISTRIBUTION_NAME = \"${dist_name} Linux\"" >> "$conf"
|
||||
echo "DISTRIBUTION_VERSION = \"${dist_release}\"" >> "$conf"
|
||||
echo "SHORT_NAME = \"${dist_name}\"" >> "$conf"
|
||||
echo "[install]" >> "$conf"
|
||||
echo "LIVE_MEDIA_SOURCE = \"/run/miso/bootmnt/${iso_name}/${target_arch}/rootfs.sfs\"" >> "$conf"
|
||||
echo "LIVE_MEDIA_DESKTOP = \"/run/miso/bootmnt/${iso_name}/${target_arch}/desktopfs.sfs\"" >> "$conf"
|
||||
echo "LIVE_MEDIA_TYPE = \"squashfs\"" >> "$conf"
|
||||
echo "LIVE_USER_NAME = \"${username}\"" >> "$conf"
|
||||
echo "KERNEL = \"${kernel}\"" >> "$conf"
|
||||
echo "VMLINUZ = \"$(echo ${ALL_kver} | sed s'|/boot/||')\"" >> "$conf"
|
||||
echo "INITRAMFS = \"$(echo ${default_image} | sed s'|/boot/||')\"" >> "$conf"
|
||||
echo "FALLBACK = \"$(echo ${fallback_image} | sed s'|/boot/||')\"" >> "$conf"
|
||||
|
||||
if [[ -f $1/usr/share/applications/thus.desktop && -f $1/usr/bin/kdesu ]];then
|
||||
sed -i -e 's|sudo|kdesu|g' $1/usr/share/applications/thus.desktop
|
||||
fi
|
||||
}
|
||||
|
||||
configure_live_image(){
|
||||
msg "Configuring [livefs]"
|
||||
configure_hosts "$1"
|
||||
configure_system "$1"
|
||||
configure_services "$1"
|
||||
configure_calamares "$1"
|
||||
[[ ${edition} == "sonar" ]] && configure_thus "$1"
|
||||
write_live_session_conf "$1"
|
||||
msg "Done configuring [livefs]"
|
||||
}
|
||||
|
||||
make_repo(){
|
||||
repo-add $1${mhwd_repo}/mhwd.db.tar.gz $1${mhwd_repo}/*pkg*z
|
||||
}
|
||||
|
||||
copy_from_cache(){
|
||||
local list="${tmp_dir}"/mhwd-cache.list
|
||||
chroot-run \
|
||||
-r "${mountargs_ro}" \
|
||||
-w "${mountargs_rw}" \
|
||||
-B "${build_mirror}/${target_branch}" \
|
||||
"$1" \
|
||||
pacman -v -Syw $2 --noconfirm || return 1
|
||||
chroot-run \
|
||||
-r "${mountargs_ro}" \
|
||||
-w "${mountargs_rw}" \
|
||||
-B "${build_mirror}/${target_branch}" \
|
||||
"$1" \
|
||||
pacman -v -Sp $2 --noconfirm > "$list"
|
||||
sed -ni '/.pkg.tar.xz/p' "$list"
|
||||
sed -i "s/.*\///" "$list"
|
||||
|
||||
msg2 "Copying mhwd package cache ..."
|
||||
rsync -v --files-from="$list" /var/cache/pacman/pkg "$1${mhwd_repo}"
|
||||
}
|
||||
|
||||
chroot_create(){
|
||||
[[ "${1##*/}" == "rootfs" ]] && local flag="-L"
|
||||
setarch "${target_arch}" \
|
||||
mkchroot ${mkchroot_args[*]} ${flag} $@
|
||||
}
|
||||
|
||||
clean_iso_root(){
|
||||
msg2 "Deleting isoroot [%s] ..." "${1##*/}"
|
||||
rm -rf --one-file-system "$1"
|
||||
}
|
||||
|
||||
chroot_clean(){
|
||||
msg "Cleaning up ..."
|
||||
for image in "$1"/*fs; do
|
||||
[[ -d ${image} ]] || continue
|
||||
local name=${image##*/}
|
||||
if [[ $name != "mhwdfs" ]];then
|
||||
msg2 "Deleting chroot [%s] (%s) ..." "$name" "${1##*/}"
|
||||
lock 9 "${image}.lock" "Locking chroot '${image}'"
|
||||
if [[ "$(stat -f -c %T "${image}")" == btrfs ]]; then
|
||||
{ type -P btrfs && btrfs subvolume delete "${image}"; } #&> /dev/null
|
||||
fi
|
||||
rm -rf --one-file-system "${image}"
|
||||
fi
|
||||
done
|
||||
exec 9>&-
|
||||
rm -rf --one-file-system "$1"
|
||||
}
|
||||
|
||||
clean_up_image(){
|
||||
msg2 "Cleaning [%s]" "${1##*/}"
|
||||
|
||||
local path
|
||||
if [[ ${1##*/} == 'mhwdfs' ]];then
|
||||
path=$1/var
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -mindepth 0 -delete &> /dev/null
|
||||
fi
|
||||
path=$1/etc
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -mindepth 0 -delete &> /dev/null
|
||||
fi
|
||||
else
|
||||
[[ -f "$1/etc/locale.gen.bak" ]] && mv "$1/etc/locale.gen.bak" "$1/etc/locale.gen"
|
||||
[[ -f "$1/etc/locale.conf.bak" ]] && mv "$1/etc/locale.conf.bak" "$1/etc/locale.conf"
|
||||
path=$1/boot
|
||||
if [[ -d "$path" ]]; then
|
||||
find "$path" -name 'initramfs*.img' -delete &> /dev/null
|
||||
fi
|
||||
path=$1/var/lib/pacman/sync
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -type f -delete &> /dev/null
|
||||
fi
|
||||
path=$1/var/cache/pacman/pkg
|
||||
if [[ -d $path ]]; then
|
||||
find "$path" -type f -delete &> /dev/null
|
||||
fi
|
||||
path=$1/var/log
|
||||
if [[ -d $path ]]; then
|
||||
find "$path" -type f -delete &> /dev/null
|
||||
fi
|
||||
path=$1/var/tmp
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -mindepth 1 -delete &> /dev/null
|
||||
fi
|
||||
path=$1/tmp
|
||||
if [[ -d $path ]];then
|
||||
find "$path" -mindepth 1 -delete &> /dev/null
|
||||
fi
|
||||
fi
|
||||
find "$1" -name *.pacnew -name *.pacsave -name *.pacorig -delete
|
||||
file=$1/boot/grub/grub.cfg
|
||||
if [[ -f "$file" ]]; then
|
||||
rm $file
|
||||
fi
|
||||
}
|
|
@ -34,29 +34,25 @@ track_fs() {
|
|||
mount "$@" && FS_ACTIVE_MOUNTS=("$5" "${FS_ACTIVE_MOUNTS[@]}")
|
||||
}
|
||||
|
||||
# $1: new branch
|
||||
mount_fs_root(){
|
||||
mount_fs(){
|
||||
FS_ACTIVE_MOUNTS=()
|
||||
local lower= upper="$1" work="$2" pkglist="$3"
|
||||
local fs=${upper##*/}
|
||||
local rootfs="$work/rootfs" desktopfs="$work/desktopfs" livefs="$work/livefs"
|
||||
mkdir -p "${mnt_dir}/work"
|
||||
track_fs -t overlay overlay -olowerdir="${work_dir}/rootfs",upperdir="$1",workdir="${mnt_dir}/work" "$1"
|
||||
}
|
||||
|
||||
mount_fs_desktop(){
|
||||
FS_ACTIVE_MOUNTS=()
|
||||
mkdir -p "${mnt_dir}/work"
|
||||
track_fs -t overlay overlay -olowerdir="${work_dir}/desktopfs":"${work_dir}/rootfs",upperdir="$1",workdir="${mnt_dir}/work" "$1"
|
||||
}
|
||||
|
||||
mount_fs_live(){
|
||||
FS_ACTIVE_MOUNTS=()
|
||||
mkdir -p "${mnt_dir}/work"
|
||||
track_fs -t overlay overlay -olowerdir="${work_dir}/livefs":"${work_dir}/desktopfs":"${work_dir}/rootfs",upperdir="$1",workdir="${mnt_dir}/work" "$1"
|
||||
}
|
||||
|
||||
mount_fs_net(){
|
||||
FS_ACTIVE_MOUNTS=()
|
||||
mkdir -p "${mnt_dir}/work"
|
||||
track_fs -t overlay overlay -olowerdir="${work_dir}/livefs":"${work_dir}/rootfs",upperdir="$1",workdir="${mnt_dir}/work" "$1"
|
||||
mkdir -p "$upper"
|
||||
case $fs in
|
||||
desktopfs) lower="$rootfs" ;;
|
||||
livefs|mhwdfs)
|
||||
lower="$rootfs"
|
||||
[[ -f $pkglist ]] && lower="$desktopfs":"$rootfs"
|
||||
;;
|
||||
bootfs)
|
||||
lower="$livefs":"$rootfs"
|
||||
[[ -f $pkglist ]] && lower="$livefs":"$desktopfs":"$rootfs"
|
||||
;;
|
||||
esac
|
||||
track_fs -t overlay overlay -olowerdir="$lower",upperdir="$upper",workdir="${mnt_dir}/work" "$upper"
|
||||
}
|
||||
|
||||
umount_fs(){
|
||||
|
|
335
lib/util-iso.sh
335
lib/util-iso.sh
|
@ -9,17 +9,18 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
import ${LIBDIR}/util-iso-image.sh
|
||||
import ${LIBDIR}/util-iso-boot.sh
|
||||
import ${LIBDIR}/util-chroot.sh
|
||||
import ${LIBDIR}/util-iso-chroot.sh
|
||||
import ${LIBDIR}/util-yaml.sh
|
||||
|
||||
error_function() {
|
||||
if [[ -p $logpipe ]]; then
|
||||
rm "$logpipe"
|
||||
fi
|
||||
local func="$1"
|
||||
# first exit all subshells, then print the error
|
||||
if (( ! BASH_SUBSHELL )); then
|
||||
error "A failure occurred in %s()." "$1"
|
||||
error "A failure occurred in %s()." "$func"
|
||||
plain "Aborting..."
|
||||
fi
|
||||
umount_fs
|
||||
|
@ -68,20 +69,57 @@ trap_exit() {
|
|||
kill "-$sig" "$$"
|
||||
}
|
||||
|
||||
configure_thus(){
|
||||
local fs="$1"
|
||||
msg2 "Configuring Thus ..."
|
||||
source "$fs/etc/mkinitcpio.d/${kernel}.preset"
|
||||
local conf="$fs/etc/thus.conf"
|
||||
echo "[distribution]" > "$conf"
|
||||
echo "DISTRIBUTION_NAME = \"${dist_name} Linux\"" >> "$conf"
|
||||
echo "DISTRIBUTION_VERSION = \"${dist_release}\"" >> "$conf"
|
||||
echo "SHORT_NAME = \"${dist_name}\"" >> "$conf"
|
||||
echo "[install]" >> "$conf"
|
||||
echo "LIVE_MEDIA_SOURCE = \"/run/miso/bootmnt/${iso_name}/${target_arch}/rootfs.sfs\"" >> "$conf"
|
||||
echo "LIVE_MEDIA_DESKTOP = \"/run/miso/bootmnt/${iso_name}/${target_arch}/desktopfs.sfs\"" >> "$conf"
|
||||
echo "LIVE_MEDIA_TYPE = \"squashfs\"" >> "$conf"
|
||||
echo "LIVE_USER_NAME = \"${username}\"" >> "$conf"
|
||||
echo "KERNEL = \"${kernel}\"" >> "$conf"
|
||||
echo "VMLINUZ = \"$(echo ${ALL_kver} | sed s'|/boot/||')\"" >> "$conf"
|
||||
echo "INITRAMFS = \"$(echo ${default_image} | sed s'|/boot/||')\"" >> "$conf"
|
||||
echo "FALLBACK = \"$(echo ${fallback_image} | sed s'|/boot/||')\"" >> "$conf"
|
||||
|
||||
if [[ -f $fs/usr/share/applications/thus.desktop && -f $fs/usr/bin/kdesu ]];then
|
||||
sed -i -e 's|sudo|kdesu|g' $fs/usr/share/applications/thus.desktop
|
||||
fi
|
||||
}
|
||||
|
||||
configure_live_image(){
|
||||
local fs="$1"
|
||||
msg "Configuring [livefs]"
|
||||
configure_hosts "$fs"
|
||||
configure_system "$fs"
|
||||
configure_services "$fs"
|
||||
configure_calamares "$fs"
|
||||
[[ ${edition} == "sonar" ]] && configure_thus "$fs"
|
||||
write_live_session_conf "$fs"
|
||||
msg "Done configuring [livefs]"
|
||||
}
|
||||
|
||||
make_sig () {
|
||||
local idir="$1" file="$2"
|
||||
msg2 "Creating signature file..."
|
||||
cd "$1"
|
||||
user_own "$1"
|
||||
su ${OWNER} -c "gpg --detach-sign --default-key ${gpgkey} $2.sfs"
|
||||
chown -R root "$1"
|
||||
cd "$idir"
|
||||
user_own "$idir"
|
||||
su ${OWNER} -c "gpg --detach-sign --default-key ${gpgkey} $file.sfs"
|
||||
chown -R root "$idir"
|
||||
cd ${OLDPWD}
|
||||
}
|
||||
|
||||
# $1: file
|
||||
make_checksum(){
|
||||
local idir="$1" file="$2"
|
||||
msg2 "Creating md5sum ..."
|
||||
cd $1
|
||||
md5sum $2.sfs > $2.md5
|
||||
cd $idir
|
||||
md5sum $file.sfs > $file.md5
|
||||
cd ${OLDPWD}
|
||||
}
|
||||
|
||||
|
@ -161,55 +199,35 @@ make_sfs() {
|
|||
|
||||
assemble_iso(){
|
||||
msg "Creating ISO image..."
|
||||
local iso_publisher iso_app_id
|
||||
|
||||
iso_publisher="$(get_osname) <$(get_disturl)>"
|
||||
|
||||
iso_app_id="$(get_osname) Live/Rescue CD"
|
||||
|
||||
# xorriso -as mkisofs \
|
||||
# --protective-msdos-label \
|
||||
# -volid "${iso_label}" \
|
||||
# -appid "${iso_app_id}" \
|
||||
# -publisher "${iso_publisher}" \
|
||||
# -preparer "Prepared by manjaro-tools/${0##*/}" \
|
||||
# -e /efi.img \
|
||||
# -b boot/grub/i386-pc/eltorito.img \
|
||||
# -c boot.catalog \
|
||||
# -no-emul-boot \
|
||||
# -boot-load-size 4 \
|
||||
# -boot-info-table \
|
||||
# -graft-points \
|
||||
# --grub2-boot-info \
|
||||
# --grub2-mbr ${iso_root}/boot/grub/i386-pc/boot_hybrid.img \
|
||||
# --sort-weight 0 / --sort-weight 1 /boot \
|
||||
# -isohybrid-gpt-basdat \
|
||||
# -eltorito-alt-boot \
|
||||
# -output "${iso_dir}/${iso_file}" \
|
||||
# "${iso_root}/"
|
||||
local iso_publisher="$(get_osname) <$(get_disturl)>" \
|
||||
iso_app_id="$(get_osname) Live/Rescue CD" \
|
||||
mod_date=$(date -u +%Y-%m-%d-%H-%M-%S-00 | sed -e s/-//g)
|
||||
|
||||
xorriso -as mkisofs \
|
||||
--modification-date=${mod_date} \
|
||||
--protective-msdos-label \
|
||||
-volid "${iso_label}" \
|
||||
-appid "${iso_app_id}" \
|
||||
-publisher "${iso_publisher}" \
|
||||
-preparer "Prepared by manjaro-tools/${0##*/}" \
|
||||
-r -graft-points -no-pad \
|
||||
--sort-weight 0 / \
|
||||
--sort-weight 1 /boot \
|
||||
--grub2-mbr ${iso_root}/boot/grub/i386-pc/boot_hybrid.img \
|
||||
-partition_offset 16 \
|
||||
-b boot/grub/i386-pc/eltorito.img \
|
||||
-c boot.catalog \
|
||||
-no-emul-boot \
|
||||
-boot-load-size 4 \
|
||||
-boot-info-table \
|
||||
-graft-points \
|
||||
--grub2-boot-info \
|
||||
--grub2-mbr ${iso_root}/boot/grub/i386-pc/boot_hybrid.img \
|
||||
--sort-weight 0 / --sort-weight 1 /boot \
|
||||
-no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info \
|
||||
-eltorito-alt-boot \
|
||||
-efi-boot-part --efi-boot-image \
|
||||
-e efi.img \
|
||||
-append_partition 2 0xef ${iso_root}/efi.img \
|
||||
-e --interval:appended_partition_2:all:: \
|
||||
-no-emul-boot \
|
||||
-isohybrid-gpt-basdat \
|
||||
-output "${iso_dir}/${iso_file}" \
|
||||
"${iso_root}/"
|
||||
-iso-level 3 \
|
||||
-o ${iso_dir}/${iso_file} \
|
||||
${iso_root}/
|
||||
|
||||
# arg to add with xorriso-1.4.7
|
||||
# -iso_mbr_part_type 0x00
|
||||
}
|
||||
|
||||
# Build ISO
|
||||
|
@ -250,154 +268,144 @@ gen_iso_fn(){
|
|||
}
|
||||
|
||||
reset_pac_conf(){
|
||||
info "Restoring [%s/etc/pacman.conf] ..." "$1"
|
||||
local fs="$1"
|
||||
info "Restoring [%s/etc/pacman.conf] ..." "$fs"
|
||||
sed -e 's|^.*HoldPkg.*|HoldPkg = pacman glibc manjaro-system|' \
|
||||
-e "s|^.*#CheckSpace|CheckSpace|" \
|
||||
-i "$1/etc/pacman.conf"
|
||||
-i "$fs/etc/pacman.conf"
|
||||
}
|
||||
|
||||
# Base installation (rootfs)
|
||||
make_image_root() {
|
||||
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
|
||||
if [[ ! -e ${work_dir}/rootfs.lock ]]; then
|
||||
msg "Prepare [Base installation] (rootfs)"
|
||||
local path="${work_dir}/rootfs"
|
||||
mkdir -p ${path}
|
||||
local rootfs="${work_dir}/rootfs"
|
||||
|
||||
chroot_create "${path}" "${packages}" || die
|
||||
prepare_dir "${rootfs}"
|
||||
|
||||
pacman -Qr "${path}" > "${path}/rootfs-pkgs.txt"
|
||||
copy_overlay "${profile_dir}/root-overlay" "${path}"
|
||||
create_chroot "${mkchroot_args[@]}" "${rootfs}" "${packages[@]}"
|
||||
|
||||
reset_pac_conf "${path}"
|
||||
pacman -Qr "${rootfs}" > "${rootfs}/rootfs-pkgs.txt"
|
||||
copy_overlay "${profile_dir}/root-overlay" "${rootfs}"
|
||||
|
||||
configure_lsb "${path}"
|
||||
reset_pac_conf "${rootfs}"
|
||||
|
||||
configure_lsb "${rootfs}"
|
||||
|
||||
clean_up_image "${rootfs}"
|
||||
|
||||
clean_up_image "${path}"
|
||||
: > ${work_dir}/build.${FUNCNAME}
|
||||
msg "Done [Base installation] (rootfs)"
|
||||
fi
|
||||
}
|
||||
|
||||
make_image_desktop() {
|
||||
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
|
||||
if [[ ! -e ${work_dir}/desktopfs.lock ]]; then
|
||||
msg "Prepare [Desktop installation] (desktopfs)"
|
||||
local path="${work_dir}/desktopfs"
|
||||
mkdir -p ${path}
|
||||
local desktopfs="${work_dir}/desktopfs"
|
||||
|
||||
mount_fs_root "${path}"
|
||||
prepare_dir "${desktopfs}"
|
||||
|
||||
chroot_create "${path}" "${packages}"
|
||||
mount_fs "${desktopfs}" "${work_dir}"
|
||||
|
||||
pacman -Qr "${path}" > "${path}/desktopfs-pkgs.txt"
|
||||
cp "${path}/desktopfs-pkgs.txt" ${iso_dir}/$(gen_iso_fn)-pkgs.txt
|
||||
[[ -e ${profile_dir}/desktop-overlay ]] && copy_overlay "${profile_dir}/desktop-overlay" "${path}"
|
||||
create_chroot "${mkchroot_args[@]}" "${desktopfs}" "${packages[@]}"
|
||||
|
||||
reset_pac_conf "${path}"
|
||||
pacman -Qr "${desktopfs}" > "${desktopfs}/desktopfs-pkgs.txt"
|
||||
cp "${desktopfs}/desktopfs-pkgs.txt" ${iso_dir}/$(gen_iso_fn)-pkgs.txt
|
||||
[[ -e ${profile_dir}/desktop-overlay ]] && copy_overlay "${profile_dir}/desktop-overlay" "${desktopfs}"
|
||||
|
||||
reset_pac_conf "${desktopfs}"
|
||||
|
||||
umount_fs
|
||||
clean_up_image "${path}"
|
||||
: > ${work_dir}/build.${FUNCNAME}
|
||||
clean_up_image "${desktopfs}"
|
||||
|
||||
msg "Done [Desktop installation] (desktopfs)"
|
||||
fi
|
||||
}
|
||||
|
||||
mount_fs_select(){
|
||||
if [[ -f "${packages_desktop}" ]]; then
|
||||
mount_fs_desktop "$1"
|
||||
else
|
||||
mount_fs_root "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
make_image_live() {
|
||||
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
|
||||
if [[ ! -e ${work_dir}/livefs.lock ]]; then
|
||||
msg "Prepare [Live installation] (livefs)"
|
||||
local path="${work_dir}/livefs"
|
||||
mkdir -p ${path}
|
||||
local livefs="${work_dir}/livefs"
|
||||
|
||||
mount_fs_select "${path}"
|
||||
prepare_dir "${livefs}"
|
||||
|
||||
chroot_create "${path}" "${packages}"
|
||||
mount_fs "${livefs}" "${work_dir}" "${desktop_list}"
|
||||
|
||||
pacman -Qr "${path}" > "${path}/livefs-pkgs.txt"
|
||||
copy_overlay "${profile_dir}/live-overlay" "${path}"
|
||||
configure_live_image "${path}"
|
||||
create_chroot "${mkchroot_args[@]}" "${livefs}" "${packages[@]}"
|
||||
|
||||
reset_pac_conf "${path}"
|
||||
pacman -Qr "${livefs}" > "${livefs}/livefs-pkgs.txt"
|
||||
copy_overlay "${profile_dir}/live-overlay" "${livefs}"
|
||||
configure_live_image "${livefs}"
|
||||
|
||||
reset_pac_conf "${livefs}"
|
||||
|
||||
umount_fs
|
||||
|
||||
# Clean up GnuPG keys
|
||||
rm -rf "${path}/etc/pacman.d/gnupg"
|
||||
clean_up_image "${path}"
|
||||
: > ${work_dir}/build.${FUNCNAME}
|
||||
clean_up_image "${livefs}"
|
||||
|
||||
msg "Done [Live installation] (livefs)"
|
||||
fi
|
||||
}
|
||||
|
||||
make_image_mhwd() {
|
||||
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
|
||||
if [[ ! -e ${work_dir}/mhwdfs.lock ]]; then
|
||||
msg "Prepare [drivers repository] (mhwdfs)"
|
||||
local path="${work_dir}/mhwdfs"
|
||||
mkdir -p ${path}${mhwd_repo}
|
||||
local mhwdfs="${work_dir}/mhwdfs"
|
||||
|
||||
mount_fs_select "${path}"
|
||||
prepare_dir "${mhwdfs}${mhwd_repo}"
|
||||
|
||||
reset_pac_conf "${path}"
|
||||
mount_fs "${mhwdfs}" "${work_dir}" "${desktop_list}"
|
||||
|
||||
copy_from_cache "${path}" "${packages}"
|
||||
reset_pac_conf "${mhwdfs}"
|
||||
|
||||
if [[ -n "${packages_cleanup}" ]]; then
|
||||
for mhwd_clean in ${packages_cleanup}; do
|
||||
rm ${path}${mhwd_repo}/${mhwd_clean}
|
||||
copy_from_cache "${mhwdfs}" "${packages[@]}"
|
||||
|
||||
if [[ -n "${packages_cleanup[@]}" ]]; then
|
||||
for pkg in ${packages_cleanup[@]}; do
|
||||
rm ${mhwdfs}${mhwd_repo}/${pkg}
|
||||
done
|
||||
fi
|
||||
cp ${DATADIR}/pacman-mhwd.conf ${path}/opt
|
||||
make_repo "${path}"
|
||||
configure_mhwd_drivers "${path}"
|
||||
|
||||
make_repo "${mhwdfs}"
|
||||
configure_mhwd_drivers "${mhwdfs}"
|
||||
|
||||
umount_fs
|
||||
clean_up_image "${path}"
|
||||
: > ${work_dir}/build.${FUNCNAME}
|
||||
clean_up_image "${mhwdfs}"
|
||||
: > ${work_dir}/mhwdfs.lock
|
||||
msg "Done [drivers repository] (mhwdfs)"
|
||||
fi
|
||||
}
|
||||
|
||||
make_image_boot() {
|
||||
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
|
||||
if [[ ! -e ${work_dir}/bootfs.lock ]]; then
|
||||
msg "Prepare [/iso/boot]"
|
||||
local boot="${iso_root}/boot"
|
||||
|
||||
mkdir -p ${boot}
|
||||
prepare_dir "${boot}"
|
||||
|
||||
cp ${work_dir}/rootfs/boot/vmlinuz* ${boot}/vmlinuz-${target_arch}
|
||||
|
||||
local path="${work_dir}/bootfs"
|
||||
mkdir -p ${path}
|
||||
local bootfs="${work_dir}/bootfs"
|
||||
|
||||
if [[ -f "${packages_desktop}" ]]; then
|
||||
mount_fs_live "${path}"
|
||||
else
|
||||
mount_fs_net "${path}"
|
||||
fi
|
||||
mount_fs "${bootfs}" "${work_dir}" "${desktop_list}"
|
||||
|
||||
prepare_initcpio "${path}"
|
||||
prepare_initramfs "${path}"
|
||||
prepare_initcpio "${bootfs}"
|
||||
prepare_initramfs "${bootfs}"
|
||||
|
||||
cp ${path}/boot/initramfs.img ${boot}/initramfs-${target_arch}.img
|
||||
prepare_boot_extras "${path}" "${boot}"
|
||||
cp ${bootfs}/boot/initramfs.img ${boot}/initramfs-${target_arch}.img
|
||||
prepare_boot_extras "${bootfs}" "${boot}"
|
||||
|
||||
umount_fs
|
||||
|
||||
rm -R ${path}
|
||||
: > ${work_dir}/build.${FUNCNAME}
|
||||
rm -R ${bootfs}
|
||||
: > ${work_dir}/bootfs.lock
|
||||
msg "Done [/iso/boot]"
|
||||
fi
|
||||
}
|
||||
|
||||
configure_grub(){
|
||||
local default_args="misobasedir=${iso_name} misolabel=${iso_label}" \
|
||||
boot_args=('quiet')
|
||||
local conf="$1"
|
||||
local default_args="misobasedir=${iso_name} misolabel=${iso_label}" boot_args=('quiet')
|
||||
[[ ${initsys} == 'systemd' ]] && boot_args+=('systemd.show_status=1')
|
||||
|
||||
sed -e "s|@DIST_NAME@|${dist_name}|g" \
|
||||
|
@ -405,42 +413,46 @@ configure_grub(){
|
|||
-e "s|@DEFAULT_ARGS@|${default_args}|g" \
|
||||
-e "s|@BOOT_ARGS@|${boot_args[*]}|g" \
|
||||
-e "s|@PROFILE@|${profile}|g" \
|
||||
-i $1
|
||||
-i $conf
|
||||
}
|
||||
|
||||
configure_grub_theme(){
|
||||
local conf="$1"
|
||||
sed -e "s|@ISO_NAME@|${iso_name}|" -i "$conf"
|
||||
}
|
||||
|
||||
make_grub(){
|
||||
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
|
||||
if [[ ! -e ${work_dir}/grub.lock ]]; then
|
||||
msg "Prepare [/iso/boot/grub]"
|
||||
|
||||
local path="${work_dir}/rootfs"
|
||||
|
||||
prepare_grub "${path}" "${iso_root}"
|
||||
prepare_grub "${work_dir}/rootfs" "${work_dir}/livefs" "${iso_root}"
|
||||
|
||||
configure_grub "${iso_root}/boot/grub/kernels.cfg"
|
||||
configure_grub_theme "${iso_root}/boot/grub/variable.cfg"
|
||||
|
||||
: > ${work_dir}/build.${FUNCNAME}
|
||||
: > ${work_dir}/grub.lock
|
||||
msg "Done [/iso/boot/grub]"
|
||||
fi
|
||||
}
|
||||
|
||||
check_requirements(){
|
||||
[[ -f ${run_dir}/repo_info ]] || die "%s is not a valid iso profiles directory!" "${run_dir}"
|
||||
if ! $(is_valid_arch_iso ${target_arch});then
|
||||
die "%s is not a valid arch!" "${target_arch}"
|
||||
fi
|
||||
if ! $(is_valid_branch ${target_branch});then
|
||||
die "%s is not a valid branch!" "${target_branch}"
|
||||
fi
|
||||
prepare_dir "${log_dir}"
|
||||
|
||||
if ! is_valid_init "${initsys}";then
|
||||
die "%s is not a valid init system!" "${initsys}"
|
||||
fi
|
||||
eval_build_list "${list_dir_iso}" "${build_list_iso}"
|
||||
|
||||
[[ -f ${run_dir}/repo_info ]] || die "%s is not a valid iso profiles directory!" "${run_dir}"
|
||||
|
||||
local iso_kernel=${kernel:5:1} host_kernel=$(uname -r)
|
||||
if [[ ${iso_kernel} < "4" ]] \
|
||||
|| [[ ${host_kernel%%*.} < "4" ]];then
|
||||
die "The host and iso kernels must be version>=4.0!"
|
||||
fi
|
||||
|
||||
for sig in TERM HUP QUIT; do
|
||||
trap "trap_exit $sig \"$(gettext "%s signal caught. Exiting...")\" \"$sig\"" "$sig"
|
||||
done
|
||||
trap 'trap_exit INT "$(gettext "Aborted by user! Exiting...")"' INT
|
||||
trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' ERR
|
||||
}
|
||||
|
||||
compress_images(){
|
||||
|
@ -454,16 +466,16 @@ prepare_images(){
|
|||
local timer=$(get_timer)
|
||||
load_pkgs "${profile_dir}/Packages-Root"
|
||||
run_safe "make_image_root"
|
||||
if [[ -f "${packages_desktop}" ]] ; then
|
||||
load_pkgs "${packages_desktop}"
|
||||
if [[ -f "${desktop_list}" ]] ; then
|
||||
load_pkgs "${desktop_list}"
|
||||
run_safe "make_image_desktop"
|
||||
fi
|
||||
if [[ -f ${profile_dir}/Packages-Live ]]; then
|
||||
load_pkgs "${profile_dir}/Packages-Live"
|
||||
run_safe "make_image_live"
|
||||
fi
|
||||
if [[ -f ${packages_mhwd} ]] ; then
|
||||
load_pkgs "${packages_mhwd}"
|
||||
if [[ -f ${mhwd_list} ]] ; then
|
||||
load_pkgs "${mhwd_list}"
|
||||
run_safe "make_image_mhwd"
|
||||
fi
|
||||
run_safe "make_image_boot"
|
||||
|
@ -532,41 +544,8 @@ get_pacman_conf(){
|
|||
echo "$conf"
|
||||
}
|
||||
|
||||
load_profile(){
|
||||
conf="$1/profile.conf"
|
||||
|
||||
info "Profile: [%s]" "${profile}"
|
||||
|
||||
load_profile_config "$conf"
|
||||
|
||||
pacman_conf=$(get_pacman_conf)
|
||||
|
||||
mirrors_conf=$(get_pac_mirrors_conf "${target_branch}")
|
||||
|
||||
iso_file=$(gen_iso_fn).iso
|
||||
|
||||
mkchroot_args+=(-C ${pacman_conf} -S ${mirrors_conf} -B "${build_mirror}/${target_branch}" -K)
|
||||
work_dir=${chroots_iso}/${profile}/${target_arch}
|
||||
|
||||
iso_dir="${cache_dir_iso}/${edition}/${profile}/${dist_release}"
|
||||
|
||||
iso_root=${chroots_iso}/${profile}/iso
|
||||
mnt_dir=${chroots_iso}/${profile}/mnt
|
||||
prepare_dir "${mnt_dir}"
|
||||
|
||||
prepare_dir "${iso_dir}"
|
||||
user_own "${iso_dir}"
|
||||
}
|
||||
|
||||
prepare_profile(){
|
||||
profile=$1
|
||||
edition=$(get_edition ${profile})
|
||||
profile_dir=${run_dir}/${edition}/${profile}
|
||||
check_profile "${profile_dir}"
|
||||
load_profile "${profile_dir}"
|
||||
}
|
||||
|
||||
build(){
|
||||
prepare_profile "$1"
|
||||
local prof="$1"
|
||||
prepare_build "$prof"
|
||||
make_profile
|
||||
}
|
||||
|
|
|
@ -11,11 +11,9 @@
|
|||
export LC_MESSAGES=C
|
||||
export LANG=C
|
||||
|
||||
disable_colors(){
|
||||
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
|
||||
}
|
||||
declare ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
|
||||
|
||||
enable_colors(){
|
||||
if [[ -t 2 ]]; then
|
||||
# prefer terminal safe colored and bold text when tput is supported
|
||||
if tput setaf 0 &>/dev/null; then
|
||||
ALL_OFF="$(tput sgr0)"
|
||||
|
@ -32,14 +30,8 @@ enable_colors(){
|
|||
YELLOW="${BOLD}\e[33m"
|
||||
BLUE="${BOLD}\e[34m"
|
||||
fi
|
||||
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
|
||||
}
|
||||
|
||||
if [[ -t 2 ]]; then
|
||||
enable_colors
|
||||
else
|
||||
disable_colors
|
||||
fi
|
||||
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
|
||||
|
||||
plain() {
|
||||
local mesg=$1; shift
|
||||
|
@ -73,13 +65,42 @@ error() {
|
|||
|
||||
stat_busy() {
|
||||
local mesg=$1; shift
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" >&2
|
||||
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
|
||||
}
|
||||
|
||||
stat_done() {
|
||||
printf "${BOLD}done${ALL_OFF}\n" >&2
|
||||
}
|
||||
|
||||
lock_close() {
|
||||
local fd=$1
|
||||
exec {fd}>&-
|
||||
}
|
||||
|
||||
lock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -n $1; then
|
||||
stat_busy "$3"
|
||||
flock $1
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
slock() {
|
||||
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
|
||||
mkdir -p -- "$(dirname -- "$2")"
|
||||
eval "exec $1>"'"$2"'
|
||||
fi
|
||||
if ! flock -sn $1; then
|
||||
stat_busy "$3"
|
||||
flock -s $1
|
||||
stat_done
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
exit ${1:-0}
|
||||
}
|
||||
|
|
|
@ -10,23 +10,25 @@
|
|||
# GNU General Public License for more details.
|
||||
|
||||
load_compiler_settings(){
|
||||
local tarch="$1" conf
|
||||
conf=${make_conf_dir}/$tarch.conf
|
||||
local arch="$1" conf
|
||||
conf=${make_conf_dir}/$arch.conf
|
||||
|
||||
[[ -f $conf ]] || return 1
|
||||
|
||||
info "Loading compiler settings: %s" "$tarch"
|
||||
info "Loading compiler settings: %s" "$arch"
|
||||
source $conf
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
get_makepkg_conf(){
|
||||
local conf="${tmp_dir}/makepkg-$1.conf"
|
||||
|
||||
local arch="$1"
|
||||
local conf="${tmp_dir}/makepkg-${arch}.conf"
|
||||
|
||||
cp "${DATADIR}/makepkg.conf" "$conf"
|
||||
|
||||
load_compiler_settings "$1"
|
||||
load_compiler_settings "${arch}"
|
||||
|
||||
sed -i "$conf" \
|
||||
-e "s|@CARCH[@]|$carch|g" \
|
||||
|
@ -36,111 +38,39 @@ get_makepkg_conf(){
|
|||
echo "$conf"
|
||||
}
|
||||
|
||||
# $1: target_arch
|
||||
prepare_conf(){
|
||||
if ! is_valid_arch_pkg "$1";then
|
||||
die "%s is not a valid arch!" "$1"
|
||||
fi
|
||||
|
||||
local pac_arch='default'
|
||||
|
||||
if [[ "$1" == 'multilib' ]];then
|
||||
pac_arch='multilib'
|
||||
is_multilib=true
|
||||
fi
|
||||
|
||||
pacman_conf="${DATADIR}/pacman-$pac_arch.conf"
|
||||
|
||||
work_dir="${chroots_pkg}/${target_branch}/$1"
|
||||
pkg_dir="${cache_dir_pkg}/${target_branch}/$1"
|
||||
|
||||
makepkg_conf=$(get_makepkg_conf "$1")
|
||||
|
||||
[[ "$pac_arch" == 'multilib' ]] && target_arch='x86_64'
|
||||
}
|
||||
|
||||
check_build(){
|
||||
find_pkg $1
|
||||
[[ ! -f $1/PKGBUILD ]] && die "Directory must contain a PKGBUILD!"
|
||||
local bdir="$1"
|
||||
find_pkg "${bdir}"
|
||||
[[ ! -f ${bdir}/PKGBUILD ]] && die "Directory must contain a PKGBUILD!"
|
||||
}
|
||||
|
||||
find_pkg(){
|
||||
local result=$(find . -type d -name "$1")
|
||||
[[ -z $result ]] && die "%s is not a valid package or build list!" "$1"
|
||||
}
|
||||
|
||||
load_group(){
|
||||
local _multi \
|
||||
_space="s| ||g" \
|
||||
_clean=':a;N;$!ba;s/\n/ /g' \
|
||||
_com_rm="s|#.*||g" \
|
||||
devel_group='' \
|
||||
file=${DATADIR}/base-devel-udev
|
||||
|
||||
info "Loading custom group: %s" "$file"
|
||||
|
||||
if ${is_multilib}; then
|
||||
_multi="s|>multilib||g"
|
||||
else
|
||||
_multi="s|>multilib.*||g"
|
||||
fi
|
||||
|
||||
devel_group=$(sed "$_com_rm" "$file" \
|
||||
| sed "$_space" \
|
||||
| sed "$_multi" \
|
||||
| sed "$_clean")
|
||||
|
||||
echo ${devel_group}
|
||||
local bdir="$1"
|
||||
local result=$(find . -type d -name "${bdir}")
|
||||
[[ -z $result ]] && die "%s is not a valid package or build list!" "${bdir}"
|
||||
}
|
||||
|
||||
init_base_devel(){
|
||||
if ${udev_root};then
|
||||
base_packages=( "$(load_group)" )
|
||||
local _multi _space="s| ||g" _clean=':a;N;$!ba;s/\n/ /g' _com_rm="s|#.*||g"
|
||||
local file=${DATADIR}/base-devel-udev
|
||||
|
||||
# info "Loading custom group: %s" "$file"
|
||||
_multi="s|>multilib.*||g"
|
||||
${is_multilib} && _multi="s|>multilib||g"
|
||||
|
||||
packages=($(sed "$_com_rm" "$file" \
|
||||
| sed "$_space" \
|
||||
| sed "$_multi" \
|
||||
| sed "$_clean"))
|
||||
else
|
||||
if ${is_multilib};then
|
||||
base_packages=('base-devel' 'multilib-devel')
|
||||
else
|
||||
base_packages=('base-devel')
|
||||
packages=('base-devel')
|
||||
${is_multilib} && packages+=('multilib-devel')
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
chroot_create(){
|
||||
msg "Creating chroot for [%s] (%s)..." "${target_branch}" "${target_arch}"
|
||||
mkdir -p "${work_dir}"
|
||||
mkchroot_args+=(-L)
|
||||
setarch "${target_arch}" \
|
||||
mkchroot ${mkchroot_args[*]} \
|
||||
"${work_dir}/root" \
|
||||
${base_packages[*]} || abort
|
||||
}
|
||||
|
||||
chroot_clean(){
|
||||
msg "Cleaning chroot for [%s] (%s)..." "${target_branch}" "${target_arch}"
|
||||
for copy in "${work_dir}"/*; do
|
||||
[[ -d ${copy} ]] || continue
|
||||
msg2 "Deleting chroot copy %s ..." "$(basename "${copy}")"
|
||||
|
||||
lock 9 "${copy}.lock" "Locking chroot copy '${copy}'"
|
||||
|
||||
subvolume_delete_recursive "${copy}"
|
||||
rm -rf --one-file-system "${copy}"
|
||||
done
|
||||
exec 9>&-
|
||||
|
||||
rm -rf --one-file-system "${work_dir}"
|
||||
}
|
||||
|
||||
chroot_update(){
|
||||
msg "Updating chroot for [%s] (%s)..." "${target_branch}" "${target_arch}"
|
||||
chroot-run ${mkchroot_args[*]} \
|
||||
"${work_dir}/${OWNER}" \
|
||||
pacman -Syu --noconfirm || abort
|
||||
|
||||
}
|
||||
|
||||
clean_up(){
|
||||
msg "Cleaning up ..."
|
||||
# msg "Cleaning up ..."
|
||||
msg2 "Cleaning [%s]" "${pkg_dir}"
|
||||
find ${pkg_dir} -maxdepth 1 -name "*.*" -delete #&> /dev/null
|
||||
if [[ -z $SRCDEST ]];then
|
||||
|
@ -150,35 +80,38 @@ clean_up(){
|
|||
}
|
||||
|
||||
sign_pkg(){
|
||||
su ${OWNER} -c "signfile ${pkg_dir}/$1"
|
||||
local pkg="$1"
|
||||
su ${OWNER} -c "signfile ${pkg_dir}/${pkg}"
|
||||
}
|
||||
|
||||
move_to_cache(){
|
||||
prepare_dir "${log_dir}"
|
||||
|
||||
local src="$1"
|
||||
[[ -n $PKGDEST ]] && src="$PKGDEST/$1"
|
||||
[[ -n $PKGDEST ]] && src="$PKGDEST/$src"
|
||||
[[ ! -f $src ]] && die
|
||||
msg2 "Moving [%s] -> [%s]" "${src##*/}" "${pkg_dir}"
|
||||
mv $src ${pkg_dir}/
|
||||
${sign} && sign_pkg "${src##*/}"
|
||||
[[ -n $PKGDEST ]] && rm "$1"
|
||||
# [[ -n $PKGDEST ]] && rm "$src"
|
||||
user_own "${pkg_dir}" "-R"
|
||||
}
|
||||
|
||||
archive_logs(){
|
||||
local archive name="$1" ext=log.tar.xz ver src=${tmp_dir}/archives.list target='.'
|
||||
local archive name="$1" ext=log.tar.xz ver src=${tmp_dir}/archives.list dest='.'
|
||||
ver=$(get_full_version "$name")
|
||||
archive="${name}-${ver}-${target_arch}"
|
||||
if [[ -n $LOGDEST ]];then
|
||||
target=$LOGDEST
|
||||
find $target -maxdepth 1 -name "$archive*.log" -printf "%f\n" > $src
|
||||
dest=$LOGDEST
|
||||
find ${dest} -maxdepth 1 -name "$archive*.log" -printf "%f\n" > $src
|
||||
else
|
||||
find $target -maxdepth 1 -name "$archive*.log" > $src
|
||||
find ${dest} -maxdepth 1 -name "$archive*.log" > $src
|
||||
fi
|
||||
msg2 "Archiving log files [%s] ..." "$archive.$ext"
|
||||
tar -cJf ${log_dir}/$archive.$ext -C "$target" -T $src
|
||||
tar -cJf ${log_dir}/$archive.$ext -C "${dest}" -T $src
|
||||
msg2 "Cleaning log files ..."
|
||||
|
||||
find $target -maxdepth 1 -name "$archive*.log" -delete
|
||||
find ${dest} -maxdepth 1 -name "$archive*.log" -delete
|
||||
}
|
||||
|
||||
post_build(){
|
||||
|
@ -197,30 +130,23 @@ post_build(){
|
|||
archive_logs "$name"
|
||||
}
|
||||
|
||||
chroot_init(){
|
||||
local timer=$(get_timer)
|
||||
if ${clean_first} || [[ ! -d "${work_dir}" ]]; then
|
||||
chroot_clean
|
||||
chroot_create
|
||||
else
|
||||
chroot_update
|
||||
fi
|
||||
show_elapsed_time "${FUNCNAME}" "${timer}"
|
||||
}
|
||||
|
||||
build_pkg(){
|
||||
prepare_dir "${pkg_dir}"
|
||||
user_own "${pkg_dir}"
|
||||
${purge} && clean_up
|
||||
setarch "${target_arch}" \
|
||||
mkchrootpkg ${mkchrootpkg_args[*]}
|
||||
mkchrootpkg "${mkchrootpkg_args[@]}"
|
||||
post_build
|
||||
}
|
||||
|
||||
make_pkg(){
|
||||
check_build "$1"
|
||||
msg "Start building [%s]" "$1"
|
||||
cd $1
|
||||
local pkg="$1"
|
||||
check_build "${pkg}"
|
||||
msg "Start building [%s]" "${pkg}"
|
||||
cd ${pkg}
|
||||
build_pkg
|
||||
cd ..
|
||||
msg "Finished building [%s]" "$1"
|
||||
msg "Finished building [%s]" "${pkg}"
|
||||
show_elapsed_time "${FUNCNAME}" "${timer_start}"
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,15 @@
|
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
in_array() {
|
||||
local needle=$1; shift
|
||||
local item
|
||||
for item in "$@"; do
|
||||
[[ $item = $needle ]] && return 0 # Found
|
||||
done
|
||||
return 1 # Not Found
|
||||
}
|
||||
|
||||
# $1: sofile
|
||||
# $2: soarch
|
||||
process_sofile() {
|
||||
|
|
|
@ -135,7 +135,7 @@ write_unpack_conf(){
|
|||
echo " - source: \"/run/miso/bootmnt/${iso_name}/${target_arch}/rootfs.sfs\"" >> "$conf"
|
||||
echo " sourcefs: \"squashfs\"" >> "$conf"
|
||||
echo " destination: \"\"" >> "$conf"
|
||||
if [[ -f "${packages_desktop}" ]] ; then
|
||||
if [[ -f "${desktop_list}" ]] ; then
|
||||
echo " - source: \"/run/miso/bootmnt/${iso_name}/${target_arch}/desktopfs.sfs\"" >> "$conf"
|
||||
echo " sourcefs: \"squashfs\"" >> "$conf"
|
||||
echo " destination: \"\"" >> "$conf"
|
||||
|
@ -238,6 +238,14 @@ write_postcfg_conf(){
|
|||
fi
|
||||
}
|
||||
|
||||
write_umount_conf(){
|
||||
local conf="${modules_dir}/umount.conf"
|
||||
msg2 "Writing %s ..." "${conf##*/}"
|
||||
echo "---" > "$conf"
|
||||
echo 'srcLog: "/root/.cache/Calamares/Calamares/Calamares.log"' >> "$conf"
|
||||
echo 'destLog: "/var/log/Calamares.log"' >> "$conf"
|
||||
}
|
||||
|
||||
get_yaml(){
|
||||
local args=() yaml
|
||||
if ${chrootcfg};then
|
||||
|
@ -325,7 +333,7 @@ write_settings_conf(){
|
|||
echo " - grubcfg" >> "$conf"
|
||||
echo " - bootloader" >> "$conf" && write_bootloader_conf
|
||||
echo " - postcfg" >> "$conf" && write_postcfg_conf
|
||||
echo " - umount" >> "$conf"
|
||||
echo " - umount" >> "$conf" && write_umount_conf
|
||||
echo " - show:" >> "$conf"
|
||||
echo " - finished" >> "$conf" && write_finished_conf
|
||||
echo '' >> "$conf"
|
||||
|
@ -417,8 +425,8 @@ make_profile_yaml(){
|
|||
prepare_check "$1"
|
||||
load_pkgs "${profile_dir}/Packages-Root"
|
||||
write_netgroup_yaml "$1" "$(gen_fn "Packages-Root")"
|
||||
if [[ -f "${packages_desktop}" ]]; then
|
||||
load_pkgs "${packages_desktop}"
|
||||
if [[ -f "${desktop_list}" ]]; then
|
||||
load_pkgs "${desktop_list}"
|
||||
write_netgroup_yaml "$1" "$(gen_fn "Packages-Desktop")"
|
||||
fi
|
||||
${calamares} && write_calamares_yaml "$1"
|
||||
|
|
174
lib/util.sh
174
lib/util.sh
|
@ -110,20 +110,10 @@ eval_build_list(){
|
|||
esac"
|
||||
}
|
||||
|
||||
in_array() {
|
||||
local needle=$1; shift
|
||||
local item
|
||||
for item in "$@"; do
|
||||
[[ $item = $needle ]] && return 0 # Found
|
||||
done
|
||||
return 1 # Not Found
|
||||
}
|
||||
|
||||
get_timer(){
|
||||
echo $(date +%s)
|
||||
}
|
||||
|
||||
|
||||
# $1: start timer
|
||||
elapsed_time(){
|
||||
echo $(echo $1 $(get_timer) | awk '{ printf "%0.2f",($2-$1)/60 }')
|
||||
|
@ -133,43 +123,6 @@ show_elapsed_time(){
|
|||
info "Time %s: %s minutes" "$1" "$(elapsed_time $2)"
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
check_root() {
|
||||
(( EUID == 0 )) && return
|
||||
if type -P sudo >/dev/null; then
|
||||
exec sudo -- "$@"
|
||||
else
|
||||
exec su root -c "$(printf ' %q' "$@")"
|
||||
fi
|
||||
}
|
||||
|
||||
copy_mirrorlist(){
|
||||
cp -a /etc/pacman.d/mirrorlist "$1/etc/pacman.d/"
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
load_vars() {
|
||||
local var
|
||||
|
||||
|
@ -207,11 +160,11 @@ init_common(){
|
|||
|
||||
[[ -z ${chroots_dir} ]] && chroots_dir='/var/lib/manjaro-tools'
|
||||
|
||||
[[ -z ${log_dir} ]] && log_dir='/var/log/manjaro-tools'
|
||||
|
||||
[[ -z ${build_mirror} ]] && build_mirror='http://mirror.netzspielplatz.de/manjaro/packages'
|
||||
|
||||
[[ -z ${tmp_dir} ]] && tmp_dir='/tmp/manjaro-tools'
|
||||
log_dir='/var/log/manjaro-tools'
|
||||
|
||||
tmp_dir='/tmp'
|
||||
}
|
||||
|
||||
init_buildtree(){
|
||||
|
@ -233,7 +186,7 @@ init_buildpkg(){
|
|||
|
||||
make_conf_dir="${SYSCONFDIR}/make.conf.d"
|
||||
|
||||
[[ -d ${USERCONFDIR}/pkg.list.d ]] && list_dir_pkg=${USERCONFDIR}/pkg.list.d
|
||||
[[ -d ${MT_USERCONFDIR}/pkg.list.d ]] && list_dir_pkg=${MT_USERCONFDIR}/pkg.list.d
|
||||
|
||||
[[ -z ${build_list_pkg} ]] && build_list_pkg='default'
|
||||
|
||||
|
@ -270,17 +223,17 @@ get_distid(){
|
|||
}
|
||||
|
||||
get_disturl(){
|
||||
source /etc/os-release
|
||||
source /usr/lib/os-release
|
||||
echo "${HOME_URL}"
|
||||
}
|
||||
|
||||
get_osname(){
|
||||
source /etc/os-release
|
||||
source /usr/lib/os-release
|
||||
echo "${NAME}"
|
||||
}
|
||||
|
||||
get_osid(){
|
||||
source /etc/os-release
|
||||
source /usr/lib/os-release
|
||||
echo "${ID}"
|
||||
}
|
||||
|
||||
|
@ -289,7 +242,7 @@ init_buildiso(){
|
|||
|
||||
list_dir_iso="${SYSCONFDIR}/iso.list.d"
|
||||
|
||||
[[ -d ${USERCONFDIR}/iso.list.d ]] && list_dir_iso=${USERCONFDIR}/iso.list.d
|
||||
[[ -d ${MT_USERCONFDIR}/iso.list.d ]] && list_dir_iso=${MT_USERCONFDIR}/iso.list.d
|
||||
|
||||
[[ -z ${build_list_iso} ]] && build_list_iso='default'
|
||||
|
||||
|
@ -457,8 +410,8 @@ reset_profile(){
|
|||
unset disable_openrc
|
||||
unset enable_systemd_live
|
||||
unset enable_openrc_live
|
||||
unset packages_desktop
|
||||
unset packages_mhwd
|
||||
unset desktop_list
|
||||
unset mhwd_list
|
||||
unset login_shell
|
||||
unset netinstall
|
||||
unset chrootcfg
|
||||
|
@ -494,9 +447,9 @@ check_profile(){
|
|||
die "Profile [%s] sanity check failed!" "$1"
|
||||
fi
|
||||
|
||||
[[ -f "$1/Packages-Desktop" ]] && packages_desktop=$1/Packages-Desktop
|
||||
[[ -f "$1/Packages-Desktop" ]] && desktop_list=$1/Packages-Desktop
|
||||
|
||||
[[ -f "$1/Packages-Mhwd" ]] && packages_mhwd=$1/Packages-Mhwd
|
||||
[[ -f "$1/Packages-Mhwd" ]] && mhwd_list=$1/Packages-Mhwd
|
||||
|
||||
if ! ${netinstall}; then
|
||||
chrootcfg="false"
|
||||
|
@ -600,7 +553,7 @@ load_pkgs(){
|
|||
_purge="s|>cleanup.*||g" \
|
||||
_purge_rm="s|>cleanup||g"
|
||||
|
||||
packages=$(sed "$_com_rm" "$1" \
|
||||
packages=($(sed "$_com_rm" "$1" \
|
||||
| sed "$_space" \
|
||||
| sed "$_blacklist" \
|
||||
| sed "$_purge" \
|
||||
|
@ -620,18 +573,18 @@ load_pkgs(){
|
|||
| sed "$_basic_rm" \
|
||||
| sed "$_extra" \
|
||||
| sed "$_extra_rm" \
|
||||
| sed "$_clean")
|
||||
| sed "$_clean"))
|
||||
|
||||
if [[ $1 == "${packages_mhwd}" ]]; then
|
||||
if [[ $1 == "${mhwd_list}" ]]; then
|
||||
|
||||
[[ ${_used_kernel} < "42" ]] && local _amd="s|xf86-video-amdgpu||g"
|
||||
|
||||
packages_cleanup=$(sed "$_com_rm" "$1" \
|
||||
packages_cleanup=($(sed "$_com_rm" "$1" \
|
||||
| grep cleanup \
|
||||
| sed "$_purge_rm" \
|
||||
| sed "$_kernel" \
|
||||
| sed "$_clean" \
|
||||
| sed "$_amd")
|
||||
| sed "$_amd"))
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -654,7 +607,7 @@ write_repo_conf(){
|
|||
for r in ${repos[@]}; do
|
||||
path=${r%/repo_info}
|
||||
name=${path##*/}
|
||||
echo "run_dir=$path" > ${USERCONFDIR}/$name.conf
|
||||
echo "run_dir=$path" > ${MT_USERCONFDIR}/$name.conf
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -667,13 +620,14 @@ load_user_info(){
|
|||
USER_HOME=$HOME
|
||||
fi
|
||||
|
||||
USERCONFDIR="$USER_HOME/.config/manjaro-tools"
|
||||
prepare_dir "${USERCONFDIR}"
|
||||
MT_USERCONFDIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/manjaro-tools"
|
||||
PAC_USERCONFDIR="${XDG_CONFIG_HOME:-$USER_HOME/.config}/pacman"
|
||||
prepare_dir "${MT_USERCONFDIR}"
|
||||
}
|
||||
|
||||
load_run_dir(){
|
||||
[[ -f ${USERCONFDIR}/$1.conf ]] || write_repo_conf
|
||||
[[ -r ${USERCONFDIR}/$1.conf ]] && source ${USERCONFDIR}/$1.conf
|
||||
[[ -f ${MT_USERCONFDIR}/$1.conf ]] || write_repo_conf
|
||||
[[ -r ${MT_USERCONFDIR}/$1.conf ]] && source ${MT_USERCONFDIR}/$1.conf
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -683,71 +637,13 @@ show_version(){
|
|||
}
|
||||
|
||||
show_config(){
|
||||
if [[ -f ${USERCONFDIR}/manjaro-tools.conf ]]; then
|
||||
if [[ -f ${MT_USERCONFDIR}/manjaro-tools.conf ]]; then
|
||||
msg2 "config: %s" "~/.config/manjaro-tools/manjaro-tools.conf"
|
||||
else
|
||||
msg2 "config: %s" "${manjaro_tools_conf}"
|
||||
fi
|
||||
}
|
||||
|
||||
# $1: chroot
|
||||
kill_chroot_process(){
|
||||
# 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
|
||||
}
|
||||
|
||||
create_min_fs(){
|
||||
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}
|
||||
}
|
||||
|
||||
is_valid_init(){
|
||||
case $1 in
|
||||
'openrc'|'systemd') return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
is_valid_arch_pkg(){
|
||||
eval "case $1 in
|
||||
$(show_build_profiles "${make_conf_dir}")) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac"
|
||||
}
|
||||
|
||||
is_valid_arch_iso(){
|
||||
case $1 in
|
||||
'i686'|'x86_64') return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
is_valid_branch(){
|
||||
case $1 in
|
||||
'stable'|'testing'|'unstable') return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
run(){
|
||||
if ${is_build_list};then
|
||||
for item in ${build_list[@]};do
|
||||
|
@ -758,21 +654,11 @@ run(){
|
|||
fi
|
||||
}
|
||||
|
||||
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
|
||||
check_root() {
|
||||
(( EUID == 0 )) && return
|
||||
if type -P sudo >/dev/null; then
|
||||
exec sudo -- "${orig_argv[@]}"
|
||||
else
|
||||
exec su root -c "$(printf ' %q' "${orig_argv[@]}")"
|
||||
fi
|
||||
done < <(find "$1" -xdev -depth -inum 256 -print0)
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue