...
 
Commits (85)
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 = \
......
manjaro-tools
=============
Manjaro-tools-0.14
User manual
###1. manjaro-tools.conf
### 1. manjaro-tools.conf
manjaro-tools.conf is the central configuration file for manjaro-tools.
By default, the config is installed in
......@@ -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
......@@ -124,34 +119,37 @@ overriding
# iso_mirrors=('heanet' 'jaist' 'netcologne' 'iweb' 'kent')
~~~
###2. buildpkg
### 2. buildpkg
buildpkg is the chroot build script of manjaro-tools.
It it run in a abs/pkgbuilds directory which contains directories with PKGBUILD.
######manjaro-tools.conf supports the makepkg.conf variables
###### manjaro-tools.conf supports the makepkg.conf variables
####Arguments
#### Arguments
~~~
$ 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
~~~
######* build sysvinit package for both arches and branch testing:
###### * build sysvinit package for both arches and branch testing:
* i686(buildsystem is x86_64)
......@@ -168,32 +166,32 @@ buildpkg -p sysvinit -b testing -cswn
You can drop the branch arg if you set the branch in manjaro-tools.conf
The arch can also be set in manjaro-tools.conf, but under normal conditions, it is better to specify the non native arch by -a parameter.
######* -c
###### * -c
* Removes the chroot dir
* If the -c parameter is not used, buildpkg will update the existing chroot or create a new one if none is present.
######* -w
###### * -w
* Cleans pkgcache, and logfiles
######* -s
###### * -s
* Signs the package when built
######* -n
###### * -n
* Installs the built package in the chroot and runs a namcap check
######* -u
###### * -u
* Create udev build root (for eudev builds)
###3. buildiso
### 3. buildiso
buildiso is used to build manjaro-iso-profiles. It is run insde the profiles folder.
#####Packages for livecd only:
##### Packages for livecd only:
* manjaro-livecd-openrc
* manjaro-livecd-systemd
####Arguments
#### Arguments
~~~
$ buildiso -h
......@@ -221,7 +219,7 @@ Usage: buildiso [options]
-h This help
~~~
######* build xfce iso profile for both arches and branch testing on x86_64 build system
###### * build xfce iso profile for both arches and branch testing on x86_64 build system
* i686 (buildsystem is x86_64)
......@@ -237,16 +235,16 @@ buildiso -p xfce -b testing
The branch can be defined also in manjaro-tools.conf, but a manual parameter will always override conf settings.
####Special parameters
#### Special parameters
######* -x
###### * -x
* Build images only
* will stop after all packages have been installed. No iso sqfs compression will be executed
######* -z
###### * -z
* Use this to sqfs compress the chroots if you previously used -x.
###4. check-yaml
### 4. check-yaml
check-yaml can be used to write profile package lists to yaml.
It is also possible to generate calamares conf file as buildiso would do.
......@@ -265,7 +263,7 @@ Usage: check-yaml [options]
-q Query settings
-h This help
~~~
######* build xfce iso profile for both arches and branch testing on x86_64 build system
###### * build xfce iso profile for both arches and branch testing on x86_64 build system
* i686 (buildsystem is x86_64)
......@@ -285,19 +283,19 @@ check-yaml -p xfce -c
check-yaml -p kdebase -gv
~~~
####Special parameters
#### Special parameters
######* -c
###### * -c
* generate calamares module and settings conf files per profile
######* -g
###### * -g
* generate a netgroup for specified pacman group
###5. buildtree
### 5. buildtree
buildtree is a little tools to sync arch abs and manjaro PKGBUILD git repos.
####Arguments
#### Arguments
~~~
$ buildtree -h
......@@ -309,19 +307,19 @@ Usage: buildtree [options]
-h This help
~~~
######* sync arch and manjaro trees
###### * sync arch and manjaro trees
~~~
buildtree -as
~~~
###6. manjaro-chroot
### 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.
####Arguments
#### Arguments
~~~
$ manjaro-chroot -h
......@@ -336,26 +334,26 @@ usage: manjaro-chroot -a [or] manjaro-chroot chroot-dir [command]
and /build/manjaro-tools/manjaro-chroot.
~~~
######* automount
###### * automount
~~~
manjaro-chroot -a
~~~
######* mount manually
###### * mount manually
~~~
manjaro-chroot /mnt /bin/bash
~~~
###7. deployiso
### 7. deployiso
deployiso is a script to upload a specific iso or a buiildset to SF.
It needs to be run inside the iso-profiles directory.
Ideally, you have a running ssh agent on the host, and your key added, and your public key provided to your SF account. You can then upload without being asked for ssh password.
####Arguments
#### Arguments
~~~
$ deployiso -h
......@@ -370,13 +368,13 @@ Usage: deployiso [options]
-h This help
~~~
######* upload official build list, ie all built iso defined in a build list
###### * upload official build list, ie all built iso defined in a build list
~~~
deployiso -p official -c
~~~
######* upload xfce
###### * upload xfce
~~~
deployiso -p xfce -c
......
......@@ -19,6 +19,7 @@ LIBDIR='@libdir@'
import ${LIBDIR}/util.sh
import ${LIBDIR}/util-mount.sh
import ${LIBDIR}/util-chroot.sh
newroot=/mnt
......@@ -44,12 +45,11 @@ usage() {
}
# if [[ -z $1 || $1 = @(-h|--help) ]]; then
# usage
# exit $(( $# ? 0 : 1 ))
# 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
......@@ -82,7 +82,7 @@ ${interactive} && pacman_args+=(--noconfirm)
[[ -d $newroot ]] || die "%s is not a directory" "$newroot"
if ! mountpoint -q "$newroot" && ! ${directory}; then
die '%s is not a mountpoint!' "$newroot"
die '%s is not a mountpoint!' "$newroot"
fi
# create obligatory directories
......@@ -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}"
......@@ -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[@]}"
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}"
check_root
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
chroot_mount "${m%%:*}" "$1${m##*:}" -Br
done
unset IFS
fi
for m in ${bindmounts_ro[@]}; do
chroot_mount "${m%%:*}" "$1${m##*:}" -Br
done
if [[ -n ${mountargs_rw[@]} ]];then
local IFS=','
for m in ${mountargs_rw[@]}; do
chroot_mount "${m%%:*}" "$1${m##*:}" -B
done
unset IFS
fi
for m in ${bindmounts_rw[@]}; do
chroot_mount "${m%%:*}" "$1${m##*:}" -B
done
}
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}
......
This diff is collapsed.
......@@ -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
......@@ -82,13 +90,18 @@ umask 0022
lock 9 "${working_dir}.lock" "Locking chroot"
if is_btrfs "$working_dir"; then
rmdir "$working_dir"
if ! btrfs subvolume create "$working_dir"; then
die "Couldn't create subvolume for '%s'" "$working_dir"
fi
chmod 0755 "$working_dir"
rmdir "$working_dir"
if ! btrfs subvolume create "$working_dir"; then
die "Couldn't create subvolume for '%s'" "$working_dir"
fi
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[*]} \
......
This diff is collapsed.
......@@ -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
......@@ -26,4 +28,5 @@ if [ ! -e "$1" ]; then
fi
msg2 "Signing [%s] with key %s" "${1##*/}" "${GPGKEY}..."
[[ -e "$1".sig ]] && rm "$1".sig
gpg --detach-sign --use-agent -u "${GPGKEY}" "$1"
......@@ -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>
......
......@@ -55,10 +55,11 @@ _mnt_sfs() {
local mnt="${2}"
local img_fullname="${img##*/}"
local sfs_dev
local oper=$( [[ -n "${ip}" && -n "${miso_http_srv}" ]] && echo "mv" || echo "cp" )
if [[ "${copytoram}" == "y" ]]; then
msg -n ":: Copying squashfs image to RAM..."
if ! cp "${img}" "/run/miso/copytoram/${img_fullname}" ; then
if ! "${oper}" "${img}" "/run/miso/copytoram/${img_fullname}" ; then
echo "ERROR: while copy '${img}' to '/run/miso/copytoram/${img_fullname}'"
launch_interactive_shell
fi
......@@ -237,6 +238,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 -L -s --head "${_src}/${sfs}.sfs" | grep "OK" )" ]]; then
_curl_get "${_src}/${sfs}.sfs" "/${arch}"
if [[ "${checksum}" == "y" ]]; then
......
#!/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
# }
#!/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}"
}
......@@ -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=()