Skip to content

Commit 458ecc8

Browse files
Merge pull request #13 from RandomCoderOrg/build-template-fix
Build template fix [ stage 1 ]
2 parents f479e09 + 5fe197a commit 458ecc8

File tree

7 files changed

+28
-86
lines changed

7 files changed

+28
-86
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ contains functions that can be used for cmd line building and integrating in scr
3939
do_mount "/path/to/fs"
4040
```
4141

42-
<kbd>do_debootstrap()</kbd> bootstraps linux to a directories of specified arch
42+
<kbd>do_build()</kbd> bootstraps linux to a directories of specified arch
4343
```bash
44-
do_debootstrap "out/udroid-test" "arm64"
44+
do_build "out/udroid-test" "arm64"
4545
```
4646
###### TODO ( need to write more )
4747

@@ -51,7 +51,7 @@ do_debootstrap "out/udroid-test" "arm64"
5151
```bash
5252
source plugins/envsetup
5353
SUITE=impish
54-
do_debootstrap "out/fs" "arm64"
54+
do_build "out/fs" "arm64"
5555
```
5656
### Quick build scripts
5757
- `build-impish-raw.sh`: to build raw ubuntu 21.10 tarballs
@@ -70,7 +70,7 @@ do_debootstrap "out/fs" "arm64"
7070
- `no_to_directory()`: exits if directory given is present
7171
- `foreign_arch()`: checks does target arch matches with host architecture
7272
- `includes_packages()`: takes care of extrapackges when a variable `INCLUDE_PACKAGES` is set with packages
73-
- `do_debootstrap()`: bootstraps linux to with target arch to target directorie
73+
- `do_build()`: bootstraps linux to with target arch to target directorie
7474
- `do_second_stage()`: if foreign arch triggers second stage
7575
- - `do_qemu_user_emulation()` sets up qemu binaries in chroot
7676
- `do_chroot_ae()`: to run command in chroot

build-impish-raw.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ additional_setup() {
3232
install_pkg "lz4 bzip2 gzip bc pv"
3333
}
3434

35-
do_debootstrap "${frn}-arm64" arm64
35+
do_build "${frn}-arm64" arm64
3636
do_compress "${frn}-arm64"
37-
do_debootstrap "${frn}-armhf" armhf
37+
do_build "${frn}-armhf" armhf
3838
do_compress "${frn}-armhf"
39-
do_debootstrap "${frn}-amd64" amd64
39+
do_build "${frn}-amd64" amd64
4040
do_compress "${frn}-amd64"
4141

4242
do_unmount "${frn}-arm64"

build-kali-raw.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ ENABLE_USER_SETUP=false
3535

3636
warn "for best results use kali-linux host for building"
3737

38-
do_debootstrap "${frn}-arm64" arm64
38+
do_build "${frn}-arm64" arm64
3939
do_compress "${frn}-arm64"
40-
do_debootstrap "${frn}-armhf" armhf
40+
do_build "${frn}-armhf" armhf
4141
do_compress "${frn}-armhf"
42-
do_debootstrap "${frn}-amd64" amd64
42+
do_build "${frn}-amd64" amd64
4343
do_compress "${frn}-amd64"
4444

4545
do_unmount "${frn}-arm64"

build/mate/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function stage_one() {
4848
for _arch in ${BUILD_ARCH}; do
4949
export _arch
5050
msg "+ building ${_arch}"
51-
do_debootstrap "${OUT_DIR}-${_arch}" "$_arch" || exit 1
51+
do_build "${OUT_DIR}-${_arch}" "$_arch" || exit 1
5252
second_stage
5353
done
5454
}

build/raw/build-hirsute-raw.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ frn="out/hirsute-raw"
1616
OVERRIDER_COMPRESSION_TYPE="gzip"
1717
ENABLE_EXIT=true
1818

19-
do_debootstrap "${frn}-arm64" arm64
19+
do_build "${frn}-arm64" arm64
2020
do_compress "${frn}-arm64"
21-
do_debootstrap "${frn}-armhf" armhf
21+
do_build "${frn}-armhf" armhf
2222
do_compress "${frn}-armhf"
23-
do_debootstrap "${frn}-amd64" amd64
23+
do_build "${frn}-amd64" amd64
2424
do_compress "${frn}-amd64"

cook.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ OVERRIDER_COMPRESSION_TYPE="gzip"
1818
ENABLE_EXIT=true
1919
ENABLE_USER_SETUP=false
2020

21-
do_debootstrap "${frn}-arm64" arm64
21+
do_build "${frn}-arm64" arm64
2222
do_compress "${frn}-arm64"
23-
do_debootstrap "${frn}-armhf" armhf
23+
do_build "${frn}-armhf" armhf
2424
do_compress "${frn}-armhf"
25-
do_debootstrap "${frn}-amd64" amd64
25+
do_build "${frn}-amd64" amd64
2626
do_compress "${frn}-amd64"
2727

2828
do_unmount "${frn}-arm64"

plugins/envsetup

Lines changed: 11 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
################################
44
# MIT License
5-
#
5+
#
66
# Copyright (c) 2021 RandomCoderOrg,Saicharankandkuri <[email protected]>
7-
#
7+
#
88
# Permission is hereby granted, free of charge, to any person obtaining a copy
99
# of this software and associated documentation files (the "Software"), to deal
1010
# in the Software without restriction, including without limitation the rights
@@ -14,7 +14,7 @@
1414
#
1515
# The above copyright notice and this permission notice shall be included in all
1616
# copies or substantial portions of the Software.
17-
#
17+
#
1818
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1919
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2020
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -61,6 +61,12 @@ msg() {
6161
}
6262
# lshout () { echo -e "${*}";:; }
6363

64+
trim_quotes() {
65+
# Usage: trim_quotes "string"
66+
: "${1//\'}"
67+
printf '%s\n' "${_//\"}"
68+
}
69+
6470
do_mount() {
6571
local chroot_dir=$1
6672
points="$chroot_dir/dev $chroot_dir/sys $chroot_dir/proc"
@@ -220,7 +226,7 @@ includes_packages() {
220226
shout "$x includes processed "
221227
}
222228

223-
do_debootstrap() {
229+
do_build() {
224230
export target_dir="$1"
225231
export arch="$2"
226232

@@ -298,70 +304,6 @@ do_debootstrap() {
298304
fi
299305
}
300306

301-
setup_user()
302-
{
303-
default_uid=1001
304-
default_gid=1001
305-
306-
if [ -n "$FS_USER" ]; then
307-
_user=$FS_USER
308-
else
309-
warn "username not set in \$\"FS_USER\""
310-
msg "defaulting to ${USER}01"
311-
_user="${USER}01"
312-
fi
313-
314-
if [ -n "$FS_PASSWD" ]; then
315-
_passwd=$FS_PASSWD
316-
else
317-
_passwd="fs-cook-${RANDOM}"
318-
warn "password not set in \$\"FS_PASSWD\""
319-
msg "defaulting to $_passwd"
320-
fi
321-
322-
# SUDO setup
323-
if ! $ENABLE_PASSWD; then
324-
pass_set_cmd="echo $_user ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$_user;chmod 0440 /etc/sudoers.d/$_user"
325-
else
326-
pass_set_cmd="echo $_user ALL=\(root\) ALL > /etc/sudoers.d/$_user;chmod 0440 /etc/sudoers.d/$_user"
327-
fi
328-
329-
# UID setup
330-
if [ -n "$FS_UID" ]; then
331-
uid_val="$FS_UID"
332-
else
333-
uid_val="$default_uid"
334-
fi
335-
336-
# GID setup
337-
if [ -n "$FS_GID" ]; then
338-
gid_val="$FS_GID"
339-
else
340-
gid_val="$default_gid"
341-
fi
342-
343-
shout "setting up $_user..."
344-
345-
# create user group
346-
run_cmd "groupadd --gid 1001 $_user"
347-
348-
# create user
349-
CMD="useradd -m \
350-
-p \$\(openssl passwd -1 $_passwd\) \
351-
-G sudo \
352-
-d /home/$_user \
353-
-g $gid_val \
354-
-u $uid_val \
355-
-k /etc/skel \
356-
-s /bin/bash \
357-
$_user"
358-
359-
run_cmd "apt update"
360-
install_pkg "openssl"
361-
run_cmd "$CMD"
362-
run_cmd "$pass_set_cmd"
363-
364-
}
365307
arch_translate() {
366308
arch=$1
367309
export t_arch
@@ -406,7 +348,7 @@ do_qemu_user_emulation() {
406348
}
407349

408350
do_chroot_ae() {
409-
local chroot_dir="$1"
351+
local chroot_dir=$1
410352
shift
411353
local command=$*
412354
do_mount "$chroot_dir"

0 commit comments

Comments
 (0)