Commit 2980fc59 authored by udeved's avatar udeved
Browse files

fix merge conflict and merge devel

parents 22f87e35 f47e96bf
Version=0.9.9
Version=0.9.10
PREFIX = /usr/local
SYSCONFDIR = /etc
......
manjaro-tools
=============
Manjaro-tools-0.9.9
Manjaro-tools-0.9.10
User manual
......@@ -119,117 +119,6 @@ Specifying args will override manjaro-tools.conf settings.
# use_overlayfs="false"
~~~
####Config files in iso profiles
Each iso profile must have these files or symlinks to shared:
######* profile.conf
~~~
##########################################
###### use this file in the profile ######
##########################################
# possible values: openrc,systemd
# initsys="systemd"
# use multilib packages; x86_64 only
# multilib="true"
# displaymanager="lightdm"
# Set to false to disable autologin in the livecd
# autologin="true"
# nonfree xorg drivers
# nonfree_xorg="true"
# use plymouth; initcpio hook
# plymouth_boot="true"
# use pxe boot; initcpio hook
# pxe_boot="true"
################ install ################
# unset defaults to given value
# kernel="linux319"
# unset defaults to given value
# efi_boot_loader="grub"
# set uefi partition size
# efi_part_size=32M
# unset defaults to given value
# plymouth_theme=manjaro-elegant
# unset defaults to given values
# names must match systemd service names
# start_systemd=('bluetooth' 'cronie' 'ModemManager' 'NetworkManager' 'org.cups.cupsd' 'tlp' 'tlp-sleep')
# unset defaults to given values,
# names must match openrc service names
# start_openrc=('acpid' 'bluetooth' 'consolekit' 'cronie' 'cupsd' 'dbus' 'syslog-ng' 'NetworkManager')
################# livecd #################
# unset defaults to given value
# hostname="manjaro"
# unset defaults to given value
# username="manjaro"
# unset defaults to given value
# password="manjaro"
# unset defaults to given values
# addgroups="video,audio,power,disk,storage,optical,network,lp,scanner,wheel"
# unset defaults to given values
# names must match systemd service names
# services in start_systemd array don't need to be listed here
# start_systemd_live=('livecd' 'mhwd-live' 'pacman-init')
# unset defaults to given values,
# names must match openrc service names
# services in start_openrc array don't need to be listed here
# start_openrc_live=('livecd' 'mhwd-live' 'pacman-init')
~~~
######* Packages
* Contains root image packages
* ideally no xorg
######* Packages-Custom/desktop
* Contains the custom image packages
* desktop environment packages go here
* this file is joined at build time with shared/Packages-Custom to pull in shared desktop packages
######* Packages-Xorg
* Contains the Xorg package repo
######* Packages-Livecd
* Contains packages you only want on livecd but not installed on the target system with installer
* default files are in shared folder and can be symlinked or defined in a real file
###### optional custom pacman.conf in profile
* for i686
~~~
pacman-default.conf
~~~
* for x86_64
~~~
pacman-multilib.conf
~~~
If you need a custom livecd-overlay, create overlay-livecd folder in profile, and symlink from shared/overlay-livecd/your_selection to the overlay-livecd folder.
###2. buildpkg
buildpkg is the chroot build script of manjaro-tools.
......@@ -416,3 +305,31 @@ Usage: buildtree [options]
~~~
buildtree -as
~~~
###6. manjaro-chroot
manjaro-chroot is a little tool to quickly chroot into a second system installed on the host.
If the automount option is enabled, manjaro-chroot will detect installed systems with os-prober, and pops up a list with linux systems to select from.
If there is only 1 system installed besides the host system, no list will pop up and it will automatically mount the second system.
~~~
$ manjaro-chroot -h
usage: ${0##*/} chroot-dir [command]
-a Automount detected linux system
-q Query settings and pretend
-h Print this help message
If 'command' is unspecified, manjaro-chroot will launch /bin/sh.
~~~
######* automount
~~~
manjaro-chroot -a
~~~
######* mount manually
~~~
manjaro-chroot /mnt /bin/bash
~~~
......@@ -17,31 +17,79 @@ LIBDIR='@libdir@'
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
import ${LIBDIR}/util.sh
import ${LIBDIR}/util-mount.sh
usage() {
cat <<EOF
usage: ${0##*/} chroot-dir [command]
display_settings(){
show_version
show_config
msg "ARGS:"
msg2 "automount: ${automount}"
msg2 "run_args: ${run_args}"
msg "PATHS:"
msg2 "chrootdir: ${chrootdir}"
}
-h Print this help message
load_user_info
If 'command' is unspecified, ${0##*/} will launch /bin/sh.
load_config "${USER_CONFIG}/manjaro-tools.conf"
load_config "${SYSCONFDIR}/manjaro-tools.conf"
EOF
automount=false
pretend=false
usage() {
echo "usage: ${0##*/} -a [or] ${0##*/} chroot-dir [command]"
echo ' -a Automount detected linux system'
echo ' -q Query settings and pretend'
echo ' -h Print this help message'
echo ''
echo "If 'command' is unspecified, ${0##*/} will launch /bin/sh."
echo ''
echo "If 'automount' is true, ${0##*/} will launch /bin/bash"
echo "and ${chroots_dir}/manjaro-chroot."
echo ''
exit $1
}
if [[ -z $1 || $1 = @(-h|--help) ]]; then
usage
exit $(( $# ? 0 : 1 ))
fi
orig_argv=("$@")
(( EUID == 0 )) || die 'This script must be run with root privileges'
chrootdir=$1
shift
opts=':haq'
[[ -d $chrootdir ]] || die "Can't create chroot on non-directory %s" "$chrootdir"
while getopts ${opts} arg; do
case "${arg}" in
a) automount=true ;;
q) pretend=true ;;
*) echo "invalid argument ${arg}"; usage 1;;
h|?) usage 0 ;;
esac
done
shift $(( OPTIND - 1 ))
chroot_api_mount "$chrootdir" || die "failed to setup API filesystems in chroot %s" "$chrootdir"
chroot_mount /etc/resolv.conf "$chrootdir/etc/resolv.conf" --bind
check_root "$0" "${orig_argv[@]}"
if ${automount};then
chrootdir=${chroots_dir}/manjaro-chroot
prepare_dir ${chrootdir}
run_args=/bin/bash
${pretend} && display_settings && exit 1
os_list=$(detect)
select_os
else
chrootdir=$1
shift
run_args=$@
[[ -d ${chrootdir} ]] || die "Can't create chroot on non-directory %s" "${chrootdir}"
${pretend} && display_settings && exit 1
chroot_api_mount "${chrootdir}" || die "failed to setup API filesystems in chroot %s" "${chrootdir}"
chroot_mount /etc/resolv.conf "${chrootdir}/etc/resolv.conf" --bind
fi
SHELL=/bin/sh chroot "$chrootdir" "$@"
SHELL=/bin/sh unshare --fork --pid chroot "${chrootdir}" "${run_args}"
#!/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.
version=@version@
shopt -s extglob
[[ -r @libdir@/util.sh ]] && source @libdir@/util.sh
[[ -r @libdir@/util-msg.sh ]] && source @libdir@/util-msg.sh
[[ -r @libdir@/util-mount.sh ]] && source @libdir@/util-mount.sh
[[ -r @libdir@/util-fstab.sh ]] && source @libdir@/util-fstab.sh
if [ $EUID -ne 0 ]; then
echo -e "\n${0##*/} must be run with root privileges !\n"
exit 1
fi
mountpoint=/mnt/repchroot
if [ -d $mountpoint ]; then
old_IFS=$IFS
IFS=$'\n'
for i in $(mount | grep "$mountpoint" | tac | awk '{print $3}')
do
umount $mountpoint 2>/dev/null
done
IFS=$old_IFS
else
mkdir -p $mountpoint 2>/dev/null
fi
curetc=$(df /etc | sed -n '/^\//p')
curetc=${curetc%% *}
list=()
nbpart=0
# Search for partitions containing /etc
for i in $(ls /dev/[hs]d[a-z][1-9]*)
do
[ $i = "$curetc" ] && continue
mount $i $mountpoint 2>/dev/null
if [ $? -eq 0 ]; then
if [ -d $mountpoint/etc ]; then
list[$nbpart]=$i
((nbpart++))
fi
fi
# -l below necesary, don't know why !?!?!?
umount -l $mountpoint 2>/dev/null
done
# Exit if no other linux system available
if [ $nbpart -eq 0 ]; then
echo -e "\nNo linux system found !\n"
sleep 5
exit 1
fi
if [ $nbpart != 1 ]; then
echo -e "\nList of found systems"
echo -e "====================="
for((i=0; i < $nbpart; i++))
do
v=${list[$i]}
l=$(e2label $v)
[ ! -z $l ] && l='('$l')'
echo "$i) $v $l"
done
# Choice of the system to chroot
echo -en "\nPlease enter your choice [0-$((nbpart-1))] : "
while read n
do
if [[ $n = +([0-9]) ]]; then
[ $n -lt $nbpart ] && break
fi
echo -en "\nPlease enter your choice [0-$((nbpart-1))] : "
done
else
n=0
fi
echo ${list[n]}
# mount /
mount ${list[n]} $mountpoint
# mount /boot (if exists)
#cat $mountpoint/etc/fstab
indboot=false
boot=$(grep -s '^[^#].*[ ]/boot[ ]' /$mountpoint/etc/fstab)
if [ $? -eq 0 ]; then
indboot=true
comm=$(echo $boot | awk '{print "mount -t " $3 " " $1}')
comm=${comm}" $mountpoint/boot"
$comm
fi
# mount /home (if exists)
indhome=false
home=$(grep -s '^[^#].*[ ]/home[ ]' /$mountpoint/etc/fstab)
if [ $? -eq 0 ]; then
indhome=true
comm=$(echo $home | awk '{print "mount -t " $3 " " $1}')
comm=${comm}" $mountpoint/home"
$comm
fi
# activate swap (if exists and not already activated)
indswap=$(swapon -s)
if [ -z "$indswap" ]; then
swap=$(grep -s '^[^#].*[ ]swap[ ]' /$mountpoint/etc/fstab)
if [ $? -eq 0 ]; then
comm=$(echo $swap | awk '{print "swapon " $1}')
echo $comm
$comm
fi
fi
chroot_api_mount "$mountpoint"
chroot_mount /etc/resolv.conf "$mountpoint/etc/resolv.conf" --bind
# mount proc, sys, dev and chroot
# mount -B /proc $mountpoint/proc
# mount -B /dev $mountpoint/dev
# mount -B /sys $mountpoint/sys
# mount -B /dev/pts $mountpoint/dev/pts
# mount -B /tmp $mountpoint/tmp
# # mount /run if it exists
# [ -d $mountpoint/run ] && mount -B /run $mountpoint/run
# cp /etc/resolv.conf $mountpoint/etc/resolv.conf
# read the architecture of the target
elf=$(file $mountpoint/usr/bin/file)
elf=${elf#*ELF *}
elf=${elf%%-*}
if [ "$elf" == 32 ]; then
arch=i686
else
arch=x86_64
if [ $(uname -m) == i686 ]; then
echo "Error : impossible to chroot from a 32 to a 64 system"
sleep 5
exit 1
fi
fi
setarch $arch chroot $mountpoint /bin/bash
#[ -d $mountpoint/run ] && umount -f $mountpoint/run
#umount -f $mountpoint/{tmp,dev/pts,sys,dev,proc}
[ $indhome = true ] && umount $mountpoint/home
[ $indboot = true ] && umount $mountpoint/boot
umount $mountpoint
rmdir $mountpoint
exit 0
......@@ -284,7 +284,7 @@ configure_displaymanager(){
}
# $1: chroot
configure_xorg_drivers(){
configure_mhwd_drivers(){
# Disable Catalyst if not present
if [ -z "$(ls $1/opt/livecd/pkgs/ | grep catalyst-utils 2> /dev/null)" ]; then
msg2 "Disabling Catalyst driver"
......@@ -391,7 +391,7 @@ download_to_cache(){
-w "${mountargs_rw}" \
-B "${build_mirror}/${branch}" \
"$1" \
pacman -v -Syw $2 --noconfirm
pacman -v -Syw $2 --noconfirm || return 1
chroot-run \
-r "${mountargs_ro}" \
-w "${mountargs_rw}" \
......
......@@ -109,8 +109,8 @@ copy_livecd_helpers(){
write_profile_conf_entries $1
}
copy_cache_xorg(){
msg2 "Copying xorg package cache ..."
copy_cache_mhwd(){
msg2 "Copying mhwd package cache ..."
rsync -v --files-from="${work_dir}/pkgs-image/cache-packages.txt" /var/cache/pacman/pkg "${work_dir}/pkgs-image/opt/livecd/pkgs"
}
......@@ -294,7 +294,7 @@ make_image_livecd() {
fi
}
make_image_xorg() {
make_image_mhwd() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
msg "Prepare [pkgs-image]"
local path="${work_dir}/pkgs-image"
......@@ -313,15 +313,16 @@ make_image_xorg() {
die "Exit ${FUNCNAME}"
fi
copy_cache_xorg
copy_cache_mhwd
if [[ -n "${packages_cleanup}" ]]; then
for xorg_clean in ${packages_cleanup}; do
rm ${path}/opt/livecd/pkgs/${xorg_clean}
for mhwd_clean in ${packages_cleanup}; do
rm ${path}/opt/livecd/pkgs/${mhwd_clean}
done
fi
cp ${PKGDATADIR}/pacman-gfx.conf ${path}/opt/livecd
make_repo "${path}/opt/livecd/pkgs/gfx-pkgs" "${path}/opt/livecd/pkgs"
configure_xorg_drivers "${path}"
configure_mhwd_drivers "${path}"
umount_image "${path}"
......@@ -510,28 +511,16 @@ load_pkgs(){
_purge="s|>cleanup.*||g" \
_purge_rm="s|>cleanup||g"
local list
if [[ $1 == "${packages_custom}" ]];then
local temp=/tmp/buildiso
prepare_dir ${temp}
sort -u ../shared/Packages-Custom ${packages_custom} > ${temp}/${packages_custom}
packages=$(sed "$_com_rm" "${temp}/${packages_custom}" \
| sed "$_space" \
| sed "$_blacklist" \
| sed "$_purge" \
| sed "$_init" \
| sed "$_init_rm" \
| sed "$_arch" \
| sed "$_arch_rm" \
| sed "$_nonfree_default" \
| sed "$_multi" \
| sed "$_nonfree_i686" \
| sed "$_nonfree_x86_64" \
| sed "$_nonfree_multi" \
| sed "$_kernel" \
| sed "$_clean")
#rm ${temp}/${packages_custom}
sort -u ../shared/Packages-Desktop ${packages_custom} > ${work_dir}/${packages_custom}
list=${work_dir}/${packages_custom}
else
packages=$(sed "$_com_rm" "$1" \
list=$1
fi
packages=$(sed "$_com_rm" "$list" \
| sed "$_space" \
| sed "$_blacklist" \
| sed "$_purge" \
......@@ -546,9 +535,8 @@ load_pkgs(){
| sed "$_nonfree_multi" \
| sed "$_kernel" \
| sed "$_clean")
fi
if [[ $1 == 'Packages-Xorg' ]]; then
if [[ $1 == 'Packages-Mhwd' ]]; then
packages_cleanup=$(sed "$_com_rm" "$1" \
| grep cleanup \
| sed "$_purge_rm" \
......@@ -596,7 +584,7 @@ load_profile(){
local files=$(ls Packages*)
for f in ${files[@]};do
case $f in
Packages|Packages-Livecd|Packages-Xorg) continue ;;
Packages|Packages-Livecd|Packages-Mhwd) continue ;;
*) packages_custom="$f" ;;
esac
done
......@@ -631,9 +619,9 @@ build_images(){
load_pkgs "Packages-Livecd"
make_image_livecd
fi
if [[ -f Packages-Xorg ]] ; then
load_pkgs 'Packages-Xorg'
make_image_xorg
if [[ -f Packages-Mhwd ]] ; then
load_pkgs 'Packages-Mhwd'
make_image_mhwd
fi
make_image_boot
if [[ "${arch}" == "x86_64" ]]; then
......
......@@ -13,8 +13,124 @@ ignore_error() {
return 0
}
parse_fstab(){
echo $(perl -ane 'printf("%s:%s\n", @F[0,1]) if $F[0] =~ m#^UUID=#;' $1/etc/fstab)
# perl -ane 'printf("%s:%s\n", @F[0,1]) if $F[0] =~ m#^/dev#;' $1/etc/fstab
# perl -ane 'printf("%s:%s\n", @F[0,1]) if $F[0] =~ m#^LABEL=#;' $1/etc/fstab
}
detect(){
local detected=( "$(os-prober | tr ' ' '_' | paste -s -d ' ')" )
echo ${detected[@]}
}
set_os(){
local count=${#os_list[@]}
if [[ ${count} -gt 1 ]];then
msg "List of found systems"
for((i=0; i < ${count}; i++)); do
msg3 "$i) $(get_os_name ${os_list[$i]})"
done
msg "Please enter your choice [0-$((count-1))] : "
while read selection; do
if [[ -n ${os_list[$selection]} ]];then
echo ${selection}
break
else
msg "Please enter your choice [0-$((count-1))] : "
fi
done
else
echo 0
fi
}
# $1: os-prober array
get_os_name(){
local str=$1
str="${str#*:}"
str="${str#*:}"
str="${str//:/}"
echo "$str"
}
get_chroot_arch(){
local elf=$(file $1/usr/bin/file)
elf=${elf//*executable,}
echo ${elf%%,*}
}
chroot_part_mount() {
mount "$@" && CHROOT_ACTIVE_PART_MOUNTS=("$2" "${CHROOT_ACTIVE_PART_MOUNTS[@]}")
msg2 "mounted: ${CHROOT_ACTIVE_PART_MOUNTS[@]}"
}
# $1: os-prober string
get_root(){
local os_string=$1
echo ${os_string%%:*}
}
select_os(){
for system in ${os_list[@]};do
case "${system##*:}" in
'linux') chroot_mount_partitions "${chrootdir}" "${system}" ;;
*) die "Detected: ${system##*:} is not a Linux" ;;
esac
done
}
chroot_mount_partitions(){
CHROOT_ACTIVE_PART_MOUNTS=()
CHROOT_ACTIVE_MOUNTS=()
[[ $(trap -p EXIT) ]] && die 'Error! Attempting to overwrite existing EXIT trap'
trap 'trap_handler' EXIT
local index=$(set_os)
msg "Selected OS: $(get_os_name ${os_list[$index]})"
local root=$(get_root "${os_list[$index]}")
chroot_part_mount ${root} $1