-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting-actions-1.sh
191 lines (153 loc) · 5.86 KB
/
testing-actions-1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#! /usr/bin/env bash
workdir="$(pwd)"
echo "$workdir"
ls "$workdir"
if [[ $EUID -gt 0 ]]; then
echo "Not root, exiting..."
exit
fi
apt update && apt install -y gcc g++ gperf bison flex texinfo help2man make libncurses5-dev \
python3-dev autoconf automake libtool libtool-bin gawk curl bzip2 xz-utils unzip \
patch libstdc++6 rsync gh git meson ninja-build autopoint
### Getting Variables from files
UNY_AUTO_PAT="$(cat UNY_AUTO_PAT)"
export UNY_AUTO_PAT
# shellcheck disable=SC2034
GH_TOKEN="$(cat GH_TOKEN)"
export GH_TOKEN
### Setup the Shell
ln -fs /bin/bash /bin/sh
export UNY=/uny
### Setup Git and GitHub
# Setup Git User -
git config --global user.name "uny-auto"
git config --global user.email "uny-auto@unyqly.com"
git config --global credential.helper store
git config --global advice.detachedHead false
git credential approve <<EOF
protocol=https
url=https://github.com
username=uny-auto
password="$UNY_AUTO_PAT"
EOF
echo "Testing for /usr/bin/env"
type env
ls -lh /usr/bin/env
set -xv
### Add uny user
groupadd uny
useradd -s /bin/bash -g uny -m -k /dev/null uny
### Create uny chroot skeleton
mkdir -pv "$UNY"/home
mkdir -pv "$UNY"/sources/unygit
chmod -v a+wt "$UNY"/sources
mkdir -pv "$UNY"/{etc,var} "$UNY"/usr/{bin,lib,sbin}
mkdir -pv "$UNY"/uny/build/logs
for i in bin lib sbin; do
ln -sv usr/$i "$UNY"/$i
done
case $(uname -m) in
x86_64) mkdir -pv "$UNY"/lib64 ;;
esac
mkdir -pv "$UNY"/tools
chown -R uny:uny "$UNY"/* #{usr{,/*},lib,var,etc,bin,sbin,tools}
case $(uname -m) in
x86_64) chown -v uny "$UNY"/lib64 ;;
esac
[ ! -e /etc/bash.bashrc ] || mv -v /etc/bash.bashrc /etc/bash.bashrc.NOUSE
# new vdet date information
uny_build_date_seconds_now="$(date +%s)"
uny_build_date_now="$(date -d @"$uny_build_date_seconds_now" +"%Y-%m-%dT%H.%M.%SZ")"
######################################################################################################################
######################################################################################################################
### functions
function check_for_repo_and_create {
# Create repo if it doesn't exist
if [[ $(curl -s -o /dev/null -w "%{http_code}" https://github.com/unypkg/"$pkgname") != "200" ]]; then
gh repo create unypkg/"$pkgname" --public
[[ ! -d unygit ]] && mkdir -v unygit
git -C unygit clone https://github.com/unypkg/"$pkgname".git
touch unygit/"$pkgname"/emptyfile
git -C unygit/"$pkgname" add .
git -C unygit/"$pkgname" commit -m "Make repo non-empty"
git -C unygit/"$pkgname" push origin
fi
}
function git_clone_source_repo {
# shellcheck disable=SC2001
pkg_head="$(echo "$latest_head" | sed "s|.*refs/[^/]*/||")"
pkg_git_repo="$(echo "$pkggit" | cut --fields=1 --delimiter=" ")"
pkg_git_repo_dir="$(basename "$pkg_git_repo" | cut -d. -f1)"
[[ -d "$pkg_git_repo_dir" ]] && rm -rf "$pkg_git_repo_dir"
# shellcheck disable=SC2086
git clone $gitdepth --single-branch -b "$pkg_head" "$pkg_git_repo"
}
function version_details {
# Download last vdet file
curl -LO https://github.com/unypkg/"$pkgname"/releases/latest/download/vdet
old_commit_id="$(sed '2q;d' vdet)"
uny_build_date_seconds_old="$(sed '4q;d' vdet)"
[[ $latest_commit_id == "" ]] && latest_commit_id="$latest_ver"
# pkg will be built, if commit id is different and newer.
# Before a pkg is built the existence of a vdet-"$pkgname"-new file is checked
if [[ "$latest_commit_id" != "$old_commit_id" && "$uny_build_date_seconds_now" -gt "$uny_build_date_seconds_old" ]]; then
{
echo "$latest_ver"
echo "$latest_commit_id"
echo "$uny_build_date_now"
echo "$uny_build_date_seconds_now"
} >vdet-"$pkgname"-new
fi
}
function archiving_source {
rm -rf "$pkg_git_repo_dir"/.git "$pkg_git_repo_dir"/.git*
[[ -d "$pkgname-$latest_ver" ]] && rm -rf "$pkgname-$latest_ver"
mv -v "$pkg_git_repo_dir" "$pkgname-$latest_ver"
XZ_OPT="--threads=0" tar -cJpf "$pkgname-$latest_ver".tar.xz "$pkgname-$latest_ver"
}
function repo_clone_version_archive {
check_for_repo_and_create
git_clone_source_repo
version_details
archiving_source
}
######################################################################################################################
######################################################################################################################
cd "$UNY"/sources || exit
######################################################################################################################
### Util-Linux
pkgname="util-linux"
pkggit="https://github.com/util-linux/util-linux.git refs/tags/v[0-9.]*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9]([.0-9]+)+$" | tail -n 1)"
latest_ver="$(echo "$latest_head" | cut --delimiter='/' --fields=3 | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
# shellcheck disable=SC2001
latest_ver_front="$(echo "$latest_ver" | sed "s|[.][0-9]*$||")"
check_for_repo_and_create
wget https://www.kernel.org/pub/linux/utils/util-linux/v"$latest_ver_front"/util-linux-"$latest_ver".tar.xz
version_details
#gh -R unypkg/demo release create "$pkgname"-"$latest_ver"-"$uny_build_date_now" --generate-notes \
# "$pkgname-$latest_ver".tar.xz
tar xf "$pkgname-$latest_ver".tar.xz
cd "$pkgname-$latest_ver" || exit
#./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \
# --libdir=/usr/lib \
# --docdir=/usr/share/doc/util-linux \
# --disable-chfn-chsh \
# --disable-login \
# --disable-nologin \
# --disable-su \
# --disable-setpriv \
# --disable-runuser \
# --disable-pylibmount \
# --disable-static \
# --without-python \
# runstatedir=/run
#
#make -j"$(nproc)"
#make install
cd $UNY/sources || exit
echo "blabla from script 1" >blabla