OSDN Git Service

Update info
[rebornos/cnchi-gnome-osdn.git] / build.sh
1 #!/usr/bin/bash
2
3 set -e -u
4
5
6 if [ -f config ]; then
7     source ./config
8 else
9     # No config file!
10     exit 1
11 fi
12
13 iso_name=RebornOS
14 iso_label="RebornOS_$(date +%Y%m)"
15 iso_version=$(date +%Y.%m.%d)
16 install_dir=arch
17 work_dir=work
18 out_dir=out
19 gpg_key=
20
21 arch=$(uname -m)
22 verbose=""
23 script_path=$(readlink -f ${0%/*})
24
25 if [ -d ${script_path}/work ]; then
26      echo "Removing build directory for you. Please be patient..."
27      rm -rf ${script_path}/work
28     echo "######################################################"
29     echo "######################## DONE ########################"
30     echo "######################################################"
31 fi
32
33
34 _usage ()
35 {
36     echo "usage ${0} [options]"
37     echo
38     echo " General options:"
39     echo "    -N <iso_name>      Set an iso filename (prefix)"
40     echo "                        Default: ${iso_name}"
41     echo "    -V <iso_version>   Set an iso version (in filename)"
42     echo "                        Default: ${iso_version}"
43     echo "    -L <iso_label>     Set an iso label (disk label)"
44     echo "                        Default: ${iso_label}"
45     echo "    -D <install_dir>   Set an install_dir (directory inside iso)"
46     echo "                        Default: ${install_dir}"
47     echo "    -w <work_dir>      Set the working directory"
48     echo "                        Default: ${work_dir}"
49     echo "    -o <out_dir>       Set the output directory"
50     echo "                        Default: ${out_dir}"
51     echo "    -v                 Enable verbose output"
52     echo "    -h                 This help message"
53     exit ${1}
54 }
55
56 # Helper function to run make_*() only one time per architecture.
57 run_once() {
58     if [[ ! -e ${work_dir}/build.${1}_${arch} ]]; then
59         $1
60         touch ${work_dir}/build.${1}_${arch}
61     fi
62 }
63
64 # Setup custom pacman.conf with current cache directories.
65 make_pacman_conf() {
66     local _cache_dirs
67     _cache_dirs=($(pacman -v 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g'))
68 sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${_cache_dirs[@]})|g" ${script_path}/pacman.conf > ${work_dir}/pacman.conf
69 }
70
71 # Base installation, plus needed packages (airootfs)
72 make_basefs() {
73     setarch ${arch} mkarchiso ${verbose} -w "${work_dir}/${arch}" -C "${work_dir}/pacman.conf" -D "${install_dir}" init
74     setarch ${arch} mkarchiso ${verbose} -w "${work_dir}/${arch}" -C "${work_dir}/pacman.conf" -D "${install_dir}" -p "haveged intel-ucode memtest86+ mkinitcpio-nfs-utils nbd" install
75 }
76
77 # Additional packages (airootfs)
78 make_packages() {
79      setarch ${arch} mkarchiso ${verbose} -w "${work_dir}/${arch}" -C "${work_dir}/pacman.conf" -D "${install_dir}" -p "$(grep -h -v ^# ${script_path}/packages.{both,${arch}})" install
80 }
81
82 # Needed packages for x86_64 EFI boot
83 make_packages_efi() {
84     setarch ${arch} mkarchiso ${verbose} -w "${work_dir}/${arch}" -C "${work_dir}/pacman.conf" -D "${install_dir}" -p "efitools efibootmgr" install
85 }
86 # Copy mkinitcpio archiso hooks and build initramfs (airootfs)
87 make_setup_mkinitcpio() {
88     local _hook
89     mkdir -p ${work_dir}/${arch}/airootfs/etc/initcpio/hooks
90     mkdir -p ${work_dir}/${arch}/airootfs/etc/initcpio/install
91     for _hook in archiso archiso_shutdown archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs archiso_loop_mnt; do
92         cp /usr/lib/initcpio/hooks/${_hook} ${work_dir}/${arch}/airootfs/etc/initcpio/hooks
93         cp /usr/lib/initcpio/install/${_hook} ${work_dir}/${arch}/airootfs/etc/initcpio/install
94     done
95     sed -i "s|/usr/lib/initcpio/|/etc/initcpio/|g" ${work_dir}/${arch}/airootfs/etc/initcpio/install/archiso_shutdown
96     cp /usr/lib/initcpio/install/archiso_kms ${work_dir}/${arch}/airootfs/etc/initcpio/install
97     cp /usr/lib/initcpio/archiso_shutdown ${work_dir}/${arch}/airootfs/etc/initcpio
98     cp ${script_path}/mkinitcpio.conf ${work_dir}/${arch}/airootfs/etc/mkinitcpio-archiso.conf
99     gnupg_fd=
100     if [[ ${gpg_key} ]]; then
101       gpg --export ${gpg_key} >${work_dir}/gpgkey
102       exec 17<>${work_dir}/gpgkey
103     fi
104     ARCHISO_GNUPG_FD=${gpg_key:+17} setarch ${arch} mkarchiso ${verbose} -w "${work_dir}/${arch}" -C "${work_dir}/pacman.conf" -D "${install_dir}" -r 'mkinitcpio -c /etc/mkinitcpio-archiso.conf -k /boot/vmlinuz-linux -g /boot/archiso.img' run
105     if [[ ${gpg_key} ]]; then
106       exec 17<&-
107     fi
108 }
109 # Customize installation (airootfs)
110 make_customize_airootfs() {
111    cp -af ${script_path}/airootfs ${work_dir}/${arch}
112     curl -o ${work_dir}/${arch}/airootfs/etc/pacman.d/mirrorlist 'https://www.archlinux.org/mirrorlist/?country=all&protocol=http&use_mirror_status=on'
113     lynx -dump -nolist 'https://wiki.archlinux.org/index.php/Installation_Guide?action=render' >> ${work_dir}/${arch}/airootfs/root/install.txt
114     setarch ${arch} mkarchiso ${verbose} -w "${work_dir}/${arch}" -C "${work_dir}/pacman.conf" -D "${install_dir}" -r '/root/customize_airootfs.sh' run
115     rm ${work_dir}/${arch}/airootfs/root/customize_airootfs.sh
116     rm -f ${work_dir}/${arch}airootfs/etc/xdg/autostart/vboxclient.desktop
117         if [ -f "${work_dir}/${arch}/airootfs/etc/xdg/autostart/pamac-tray.desktop" ]; then
118             rm ${work_dir}/${arch}/airootfs/etc/xdg/autostart/pamac-tray.desktop
119         fi
120         ln -sf /usr/share/zoneinfo/UTC ${work_dir}/${arch}/airootfs/etc/localtime
121         chmod 750 ${work_dir}/${arch}/airootfs/etc/sudoers.d
122         chmod 440 ${work_dir}/${arch}/airootfs/etc/sudoers.d/g_wheel
123 cp -L ${script_path}/set_password ${work_dir}/${arch}/airootfs/usr/bin
124 }
125 ####################################################################################
126 # Install cnchi installer from Git
127 make_cnchi() {
128 # Install iso_hotfix_utility files to root-image
129 #    echo
130 #    echo ">>> Installing iso-hotfix-utility..."
131 #    echo
132 #    wget "${ISO_HOTFIX_UTILITY_URL}" -O ${script_path}/iso-hotfix-utility.tar.gz
133 #    tar xfz ${script_path}/iso-hotfix-utility.tar.gz -C ${script_path}
134 #    rm -f ${script_path}/iso-hotfix-utility.tar.gz
135 #    mv "${script_path}/iso-hotfix-utility-${ISO_HOTFIX_UTILITY_VERSION}" ${script_path}/iso-hotfix-utility
136 #    cp "${script_path}/iso-hotfix-utility/iso-hotfix-utility" "${work_dir}/${arch}/airootfs/usr/bin/pacman-boot"
137 #    chmod 755 "${work_dir}/${arch}/airootfs/usr/bin/pacman-boot"
138 #    mkdir -p "${work_dir}/${arch}/airootfs/etc/iso-hotfix-utility.d"
139 #    for _file in ${script_path}/iso-hotfix-utility/dist/**
140 #    do
141 #        install -m755 -t "${work_dir}/${arch}/airootfs/etc/iso-hotfix-utility.d" "${_file}"
142 #    done
143 #    for fpath in ${script_path}/iso-hotfix-utility/po/*; do
144 #        if [[ -f "${fpath}" ]] && [[ "${fpath}" != 'po/CNCHI_UPDATER.po' ]]; then
145 #            STRING_PO=`echo ${fpath#*/}`
146 #            STRING=`echo ${STRING_PO%.po}`
147 #            mkdir -p "${work_dir}/${arch}/airootfs/usr/share/locale/${STRING}/LC_MESSAGES"
148 #            msgfmt "${fpath}" -o "${work_dir}/${arch}/airootfs/usr/share/locale/${STRING}/LC_MESSAGES/CNCHI_UPDATER.mo"
149 #            echo "${STRING} installed..."
150 #            echo "ISO-HOTFIX-UTILITY IS NOW BUILT"
151 #        fi
152 #    done
153 #    rm -rf ${script_path}/iso-hotfix-utility
154 #
155     echo
156 #   echo ">>> Warning! Installing Cnchi Installer from GIT (${CNCHI_GIT_BRANCH} branch)"
157 #   wget "${CNCHI_GIT_URL}" -O ${script_path}/cnchi-git.zip
158     # The two previous line (commented) performed the download from Antergos Github.
159     # Now it's downloaded from our server:
160     echo "Downloading cnchi from our server:"
161     wget "${CNCHI_REBORNOS_URL}" -O ${script_path}/cnchi-git.zip
162     unzip ${script_path}/cnchi-git.zip -d ${script_path}
163     rm -f ${script_path}/cnchi-git.zip
164     CNCHI_SRC="${script_path}/Cnchi-${CNCHI_GIT_BRANCH}"
165         install -d ${work_dir}/${arch}/airootfs/usr/share/{cnchi,locale}
166         install -Dm755 "${CNCHI_SRC}/bin/cnchi" "${work_dir}/${arch}/airootfs/usr/bin/cnchi"
167          echo
168          echo "COPIED STARTUP FILE OVER"
169          echo
170         install -Dm755 "${CNCHI_SRC}/cnchi.desktop" "${work_dir}/${arch}/airootfs/usr/share/applications/cnchi.desktop"
171          echo
172          echo "COPIED DESKTOP FILE OVER"
173          echo
174         install -Dm644 "${CNCHI_SRC}/data/images/antergos/antergos-icon.png" "${work_dir}/${arch}/airootfs/usr/share/pixmaps/cnchi.png"
175          echo
176          echo "COPIED CNCHI ICON OVER"
177          echo
178     # TODO: This should be included in Cnchi's src code as a separate file
179     # (as both files are needed to run cnchi)
180     sed -r -i 's|\/usr.+ -v|pkexec /usr/share/cnchi/bin/cnchi -s bugsnag|g' "${work_dir}/${arch}/airootfs/usr/bin/cnchi"
181     echo
182     echo "MODIFIED STARTUP COMMAND FOR CNCHI"
183     echo
184     for i in ${CNCHI_SRC}/src ${CNCHI_SRC}/bin ${CNCHI_SRC}/data ${CNCHI_SRC}/scripts ${CNCHI_SRC}/ui; do
185         cp -R ${i} "${work_dir}/${arch}/airootfs/usr/share/cnchi/"
186         echo
187         echo "COPIED CNCHI'S MAIN SUBDIRECTORIES OVER TO BUILD FOLDER"
188         echo
189     done
190     echo
191     echo "REMOVED UNNECESARY .PO FILE"
192     rm -f ${CNCHI_SRC}/po/update_po.sh
193     echo
194     for files in ${CNCHI_SRC}/po/*; do
195         if [[ -f "$files" ]] && [[ "$files" != 'po/cnchi.pot' ]]; then
196             STRING_PO=`echo ${files#*/}`
197             STRING=`echo ${STRING_PO%.po}`
198             mkdir -p ${work_dir}/${arch}/airootfs/usr/share/locale/${STRING}/LC_MESSAGES
199             msgfmt $files -o ${work_dir}/${arch}/airootfs/usr/share/locale/${STRING}/LC_MESSAGES/cnchi.mo
200             echo "${STRING} installed..."
201             echo "CNCHI IS NOW BUILT"
202         fi
203     done
204 rm -rf ${script_path}/Cnchi-${CNCHI_GIT_BRANCH}
205             echo
206             echo "##################################################################"
207             echo "WRAPPED UP LOOSE ENDS - WILL BE MOVING ON NOW TO CUSTOMIZATIONS..."
208             echo "##################################################################"
209             echo
210             echo
211 }
212 ########################################################################################
213
214 make_fixes() {
215         # Remove Antergos gsettings file
216 #       rm ${work_dir}/${arch}/airootfs/usr/share/glib-2.0/schemas/90_deepin-default-gsettings.gschema.override
217         echo "ANTERGOS GSETTINGS REMOVED"
218         # Setup gsettings if gsettings folder exists
219         if [ -d ${script_path}/gsettings ]; then
220             # Copying GSettings XML schema files
221             mkdir -p ${work_dir}/${arch}/airootfs/usr/share/glib-2.0/schemas
222             for _schema in ${script_path}/gsettings/*.gschema.override; do
223                 echo ">>> Will use ${_schema}"
224                 cp ${_schema} ${work_dir}/${arch}/airootfs/usr/share/glib-2.0/schemas
225             done
226             # Compile GSettings XML schema files
227             # rm ${work_dir}/${arch}/airootfs/usr/share/glib-2.0/schemas/98_gnome.gschema.override
228             # rm ${work_dir}/${arch}/airootfs/usr/share/glib-2.0/schemas/95_budgie.gschema.override
229             echo "REMOVED APRICITY GSETTINGS"
230             ${work_dir}/${arch}/airootfs/usr/bin/glib-compile-schemas ${work_dir}/${arch}/airootfs/usr/share/glib-2.0/schemas
231           echo
232           echo "GENERATED REBORNOS GSETTINGS"
233           echo
234         fi
235 #Use lightdm.conf from local direcectory instead of default one
236 echo "Removing unnecessary lightdm.conf"
237 rm ${work_dir}/${arch}/airootfs/etc/lightdm/lightdm.conf
238 echo "Copying correct lightdm.conf file over"
239 cp ${script_path}/airootfs/etc/lightdm/lightdm.conf ${work_dir}/${arch}/airootfs/etc/lightdm/
240 echo "DONE"
241 echo
242 #Use sddm.conf from local direcectory instead of default one
243 echo "Removing unnecessary sddm.conf"
244 rm ${work_dir}/${arch}/airootfs/etc/sddm.conf
245 echo "Copying correct sddm.conf file over"
246 cp ${script_path}/airootfs/etc/sddm.conf ${work_dir}/${arch}/airootfs/etc/
247 echo "DONE"
248 echo
249 #Copy RebornOS Mirrorlist
250 echo "Setting up RebornOS Mirrorlist"
251 mkdir -p ${work_dir}/${arch}/airootfs/etc/pacman.d
252 cp ${script_path}/airootfs/etc/reborn-mirrorlist ${work_dir}/${arch}/airootfs/etc/pacman.d/
253 echo "DONE"
254 echo
255 #Copy pacman-init.service over
256 #echo "Copying pacman-init.service"
257 #cp ${script_path}/pacman-init.service ${work_dir}/${arch}/airootfs/etc/systemd/system/
258 echo "DONE"
259 echo
260 #Replace pacman.conf with RebornOS's
261 echo "Replacing pacman.conf with RebornOS's"
262 rm ${work_dir}/${arch}/airootfs/etc/pacman.conf
263 cp ${script_path}/Cnchi/pacman.conf ${work_dir}/${arch}/airootfs/etc/
264 cp ${script_path}/Cnchi/pacman.conf ${work_dir}/${arch}/airootfs/usr/share/cnchi/
265 cp ${script_path}/Cnchi/pacman2.conf ${work_dir}/${arch}/airootfs/
266 mv ${work_dir}/${arch}/airootfs/pacman2.conf ${work_dir}/${arch}/airootfs/tmp/pacman.conf
267 echo "DONE"
268 echo
269 #Editting Cnchi
270 echo "Moving Cnchi files over..."
271 rm ${work_dir}/${arch}/airootfs/usr/share/applications/cnchi.desktop
272 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/features.py
273 cp ${script_path}/Cnchi/features.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/
274 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/desktop_info.py
275 cp ${script_path}/Cnchi/desktop_info.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/
276 #rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/encfs.py
277 #cp ${script_path}/Cnchi/encfs.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/
278 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/boot/grub2.py
279 cp ${script_path}/Cnchi/grub2.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/boot/
280 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/scripts/10_antergos
281 cp ${script_path}/Cnchi/10_antergos ${work_dir}/${arch}/airootfs/usr/share/cnchi/scripts/
282 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/boot/systemd_boot.py
283 cp ${script_path}/Cnchi/systemd_boot.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/boot/
284 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/scripts/postinstall.sh
285 cp ${script_path}/Cnchi/postinstall.sh ${work_dir}/${arch}/airootfs/usr/share/cnchi/scripts/
286 #rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/main_window.py
287 #cp ${script_path}/Cnchi/main_window.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/
288 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/show_message.py
289 cp ${script_path}/Cnchi/show_message.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/
290 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/slides.py
291 cp ${script_path}/Cnchi/slides.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/
292 #rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/ask.py
293 #cp ${script_path}/Cnchi/ask.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/
294 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/check.py
295 cp ${script_path}/Cnchi/check.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/
296 #rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/timezone.py
297 #cp ${script_path}/Cnchi/timezone.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/
298 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/welcome.py
299 cp ${script_path}/Cnchi/welcome.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/
300 #rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/desktop.py
301 #cp ${script_path}/Cnchi/desktop.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/
302 #rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/download/metalink.py
303 #cp ${script_path}/Cnchi/metalink.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/download/
304 #rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/pac.py
305 #cp ${script_path}/Cnchi/pac.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/
306 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/antergos/antergos-logo-mini2.png
307 cp ${script_path}/Cnchi/antergos-logo-mini2.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/antergos/
308 cp ${script_path}/Cnchi/20-intel.conf ${work_dir}/${arch}/airootfs/usr/share/cnchi/
309 cp ${script_path}/Cnchi/lightdm-webkit2-greeter.conf ${work_dir}/${arch}/airootfs/usr/share/cnchi/
310 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/slides/1.png
311 cp ${script_path}/Cnchi/1.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/slides/
312 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/slides/2.png
313 cp ${script_path}/Cnchi/2.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/slides/
314 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/slides/3.png
315 cp ${script_path}/Cnchi/3.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/slides/
316 # cp ${script_path}/Cnchi/4.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/slides/
317 cp ${script_path}/Cnchi/sddm.conf ${work_dir}/${arch}/airootfs/usr/share/cnchi/
318 rm ${work_dir}/${arch}/airootfs/usr/share/pixmaps/cnchi.png
319 cp ${script_path}/airootfs/usr/share/applications/cnchi.png ${work_dir}/${arch}/airootfs/usr/share/pixmaps/
320 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/antergos/antergos-icon.png
321 cp ${script_path}/Cnchi/antergos-icon.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/antergos/antergos-icon.png
322 cp ${script_path}/scripts/tint2-start.desktop ${work_dir}/${arch}/airootfs/usr/share/cnchi/
323 cp ${script_path}/scripts/conky-start.desktop ${work_dir}/${arch}/airootfs/usr/share/cnchi/
324 cp ${script_path}/scripts/obmenu-gen.desktop ${work_dir}/${arch}/airootfs/usr/share/cnchi/
325 cp ${script_path}/scripts/plymouth-reborn.desktop ${work_dir}/${arch}/airootfs/usr/share/cnchi/
326 cp ${script_path}/scripts/mate-panel.desktop ${work_dir}/${arch}/airootfs/usr/share/cnchi/
327 cp ${script_path}/scripts/plymouth.sh ${work_dir}/${arch}/airootfs/usr/share/cnchi/
328 cp ${script_path}/scripts/flatpak.sh ${work_dir}/${arch}/airootfs/usr/share/cnchi/
329 cp ${script_path}/scripts/pkcon.sh ${work_dir}/${arch}/airootfs/usr/share/cnchi/
330 cp ${script_path}/scripts/pkcon2.sh ${work_dir}/${arch}/airootfs/usr/share/cnchi/
331 cp ${script_path}/scripts/flatpak.desktop ${work_dir}/${arch}/airootfs/usr/share/cnchi/
332 #cp ${script_path}/Cnchi/pacman2.conf ${work_dir}/${arch}/airootfs/usr/share/cnchi/
333 cp ${script_path}/scripts/update.desktop ${work_dir}/${arch}/airootfs/usr/share/cnchi/
334 cp ${script_path}/scripts/openbox-config.sh ${work_dir}/${arch}/airootfs/usr/share/cnchi/
335 cp ${script_path}/scripts/deepin-fix.sh ${work_dir}/${arch}/airootfs/usr/share/cnchi/
336 cp ${script_path}/scripts/deepin-fix.service ${work_dir}/${arch}/airootfs/usr/share/cnchi/
337 cp ${script_path}/images/pantheon.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/
338 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/deepin.png
339 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/kde.png
340 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/lxqt.png
341 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/openbox.png
342 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/xfce.png
343 cp ${script_path}/images/apricity.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/
344 cp ${script_path}/images/deepin.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/
345 cp ${script_path}/images/cinnamon.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/
346 cp ${script_path}/images/windows.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/
347 cp ${script_path}/images/kde.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/
348 cp ${script_path}/images/i3.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/
349 cp ${script_path}/images/lxqt.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/
350 cp ${script_path}/images/openbox.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/
351 cp ${script_path}/images/enlightenment.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/
352 cp ${script_path}/images/xfce.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/images/desktops/
353 cp ${script_path}/images/desktop-environment-apricity.svg ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/icons/scalable/
354 cp ${script_path}/images/desktop-environment-pantheon.svg ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/icons/scalable/
355 cp ${script_path}/images/desktop-environment-windows.svg ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/icons/scalable/
356 cp ${script_path}/images/desktop-environment-budgie.svg ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/icons/scalable/
357 cp ${script_path}/images/desktop-environment-i3.svg ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/icons/scalable/
358 cp ${script_path}/Cnchi/reborn-mirrorlist ${work_dir}/${arch}/airootfs/etc/pacman.d/
359 #
360 # Replacement made by Rafael from RebornOS
361 #
362 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/pacman.conf
363 cp ${script_path}/Cnchi/pacman.conf ${work_dir}/${arch}/airootfs/usr/share/cnchi/
364 rm ${work_dir}/${arch}/airootfs/etc/pacman.conf
365 cp ${script_path}/Cnchi/pacman.conf ${work_dir}/${arch}/airootfs/etc/
366 chmod 644 /etc/pacman.conf
367 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/pacman.tmpl
368 cp ${script_path}/Cnchi/pacman.tmpl ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/
369 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/info.py
370 cp ${script_path}/Cnchi/info.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/
371 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/update_db.py
372 cp ${script_path}/Cnchi/update_db.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/
373 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/cnchi.py
374 cp ${script_path}/Cnchi/cnchi.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/
375 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/rank_mirrors.py
376 cp ${script_path}/Cnchi/rank_mirrors.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/
377 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/features_info.py
378 cp ${script_path}/Cnchi/features_info.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/
379 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/packages.xml
380 cp ${script_path}/Cnchi/packages.xml ${work_dir}/${arch}/airootfs/usr/share/cnchi/data/
381 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/mirrors.py
382 cp ${script_path}/Cnchi/mirrors.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/
383 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/post_install.py
384 cp ${script_path}/Cnchi/post_install.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/
385 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/install.py
386 cp ${script_path}/Cnchi/install.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/
387 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/select_packages.py
388 cp ${script_path}/Cnchi/select_packages.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/
389 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/download/metalink.py
390 cp ${script_path}/Cnchi/metalink.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/download/
391 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/logging_utils.py
392 cp ${script_path}/Cnchi/logging_utils.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/
393 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/slides.py
394 cp ${script_path}/Cnchi/slides.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/
395 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pacman/pac.py
396 cp ${script_path}/Cnchi/pac.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pacman/
397 # Use neofetch to show in terminal RebornOS logo and info
398 rm ${work_dir}/${arch}/airootfs/home/rebornos/.bashrc
399 cp ${script_path}/Cnchi/bashrc ${work_dir}/${arch}/airootfs/home/rebornos/.bashrc
400 # Correct GeoIP timeout
401 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/geoip.py
402 cp ${script_path}/Cnchi/geoip.py ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/
403 # cnchi-start.sh is modified in its original location
404 # rm ${work_dir}/${arch}/airootfs/usr/bin/cnchi-start.sh
405 # cp ${script_path}/Cnchi/cnchi-start.sh ${work_dir}/${arch}/airootfs/usr/bin/
406 # Replace access to the RebornOS installer with another one with "sudo"
407 rm ${work_dir}/${arch}/airootfs/usr/share/applications/antergos-install.desktop
408 cp ${script_path}/Cnchi/antergos-install.desktop ${work_dir}/${arch}/airootfs/usr/share/applications/
409 # Add new cnchi icon for RebornOS Installer
410 rm ${work_dir}/${arch}/airootfs/usr/share/pixmaps/cnchi.png
411 cp ${script_path}/Cnchi/cnchi.png ${work_dir}/${arch}/airootfs/usr/share/pixmaps/
412 cp ${script_path}/Cnchi/reborn-icon-new.png ${work_dir}/${arch}/airootfs/usr/share/pixmaps/
413 cp ${script_path}/Cnchi/cnchi.png ${work_dir}/${arch}/airootfs/usr/share/applications/
414 # Add new wallpaper for RebornOS Live
415 rm ${work_dir}/${arch}/airootfs/usr/share/backgrounds/gnome/adwaita-day.jpg
416 cp ${script_path}/Cnchi/adwaita-day.jpg ${work_dir}/${arch}/airootfs/usr/share/backgrounds/gnome/
417 rm ${work_dir}/${arch}/airootfs/usr/share/backgrounds/gnome/adwaita-morning.jpg
418 cp ${script_path}/Cnchi/adwaita-day.jpg ${work_dir}/${arch}/airootfs/usr/share/backgrounds/gnome/adwaita-morning.jpg
419 rm ${work_dir}/${arch}/airootfs/usr/share/backgrounds/gnome/adwaita-night.jpg
420 cp ${script_path}/Cnchi/adwaita-day.jpg ${work_dir}/${arch}/airootfs/usr/share/backgrounds/gnome/adwaita-night.jpg
421 # Delete refresh.desktop in ~/.config/autostart and add new refresh-keys.desktop
422 # to refresh keys and run cnchi-start.sh when Live start
423 rm ${work_dir}/${arch}/airootfs/home/rebornos/.config/autostart/refresh.desktop
424 cp ${script_path}/Cnchi/refresh-keys.desktop ${work_dir}/${arch}/airootfs/home/rebornos/.config/autostart/
425 # Add refresh-keys.sh to /usr/bin (called by install.desktop)
426 # In the end, call cnchi-start.sh
427 cp ${script_path}/Cnchi/refresh-keys.sh ${work_dir}/${arch}/airootfs/usr/bin/
428 rm ${work_dir}/${arch}/airootfs/usr/share/cnchi/scripts/10_antergos
429 cp ${script_path}/Cnchi/10_antergos ${work_dir}/${arch}/airootfs/usr/share/cnchi/scripts/
430 # Uncomplicated Firewall Workaround
431 cp ${script_path}/Cnchi/gufw.png ${work_dir}/${arch}/airootfs/usr/share/cnchi/
432 cp ${script_path}/Cnchi/gufw.svg ${work_dir}/${arch}/airootfs/usr/share/cnchi/
433 cp ${script_path}/Cnchi/gufw.desktop ${work_dir}/${arch}/airootfs/usr/share/cnchi/
434 echo "DONE"
435 echo
436 echo "Replacing Antergos mentions with RebornOS"
437 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/advanced.py
438 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/alongside.py
439 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/ask.py
440 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/automatic.py
441 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/check.py
442 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/gtkbasebox.py
443 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/keymap.py
444 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/language.py
445 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/location.py
446 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/installation/process.py
447 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/slides.py
448 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/summary.py
449 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/timezone.py
450 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/user_info.py
451 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/wireless.py
452 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/zfs.py
453 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/desktop.py
454 sed -i "s/gnome/deepin/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/pages/desktop.py
455 #sed -i "s/Antergos/Reborn/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/encfs.py
456 sed -i "s/Antergos/RebornOS/g" ${work_dir}/${arch}/airootfs/usr/share/cnchi/src/main_window.py
457 echo "DONE"
458 echo
459 echo "Removing Mycroft-RebornOS's startup file from the ISO..."
460 rm -f ${work_dir}/${arch}/airootfs/etc/xdg/autostart/mycroft1.desktop
461 echo "DONE"
462 }
463 # Prepare kernel/initramfs ${install_dir}/boot/
464 make_boot() {
465     mkdir -p ${work_dir}/iso/${install_dir}/boot/${arch}
466     echo "Executed 'mkdir -p' Command Successfully"
467     cp ${work_dir}/${arch}/airootfs/boot/archiso.img ${work_dir}/iso/${install_dir}/boot/${arch}/archiso.img
468     echo "Built 'archiso.img' Successfully"
469     cp ${work_dir}/${arch}/airootfs/boot/vmlinuz-linux ${work_dir}/iso/${install_dir}/boot/${arch}/vmlinuz
470     echo "Built 'vmlinuz-linux' Successfully"
471     echo "DONE"
472     echo
473 }
474 # Add other aditional/extra files to ${install_dir}/boot/
475 make_boot_extra() {
476     cp ${work_dir}/${arch}/airootfs/boot/memtest86+/memtest.bin ${work_dir}/iso/${install_dir}/boot/memtest
477     cp ${work_dir}/${arch}/airootfs/usr/share/licenses/common/GPL2/license.txt ${work_dir}/iso/${install_dir}/boot/memtest.COPYING
478     cp ${work_dir}/${arch}/airootfs/boot/intel-ucode.img ${work_dir}/iso/${install_dir}/boot/intel_ucode.img
479     cp ${work_dir}/${arch}/airootfs/usr/share/licenses/intel-ucode/LICENSE ${work_dir}/iso/${install_dir}/boot/intel_ucode.LICENSE
480 }
481 # Prepare /${install_dir}/boot/syslinux
482 make_syslinux() {
483     mkdir -p ${work_dir}/iso/${install_dir}/boot/syslinux
484     for _cfg in ${script_path}/syslinux/*.cfg; do
485         sed "s|%ARCHISO_LABEL%|${iso_label}|g;
486              s|%INSTALL_DIR%|${install_dir}|g" ${_cfg} > ${work_dir}/iso/${install_dir}/boot/syslinux/${_cfg##*/}
487     done
488     cp ${script_path}/syslinux/splash.png ${work_dir}/iso/${install_dir}/boot/syslinux
489     cp ${work_dir}/${arch}/airootfs/usr/lib/syslinux/bios/*.c32 ${work_dir}/iso/${install_dir}/boot/syslinux
490     cp ${work_dir}/${arch}/airootfs/usr/lib/syslinux/bios/lpxelinux.0 ${work_dir}/iso/${install_dir}/boot/syslinux
491     cp ${work_dir}/${arch}/airootfs/usr/lib/syslinux/bios/memdisk ${work_dir}/iso/${install_dir}/boot/syslinux
492     mkdir -p ${work_dir}/iso/${install_dir}/boot/syslinux/hdt
493     gzip -c -9 ${work_dir}/${arch}/airootfs/usr/share/hwdata/pci.ids > ${work_dir}/iso/${install_dir}/boot/syslinux/hdt/pciids.gz
494 #    gzip -c -9 ${work_dir}/${arch}/airootfs/usr/lib/modules/*-ARCH/modules.alias > ${work_dir}/iso/${install_dir}/boot/syslinux/hdt/modalias.gz
495 }
496 # Prepare /isolinux
497 make_isolinux() {
498     mkdir -p ${work_dir}/iso/isolinux
499     sed "s|%INSTALL_DIR%|${install_dir}|g" ${script_path}/isolinux/isolinux.cfg > ${work_dir}/iso/isolinux/isolinux.cfg
500     cp ${work_dir}/${arch}/airootfs/usr/lib/syslinux/bios/isolinux.bin ${work_dir}/iso/isolinux/
501     cp ${work_dir}/${arch}/airootfs/usr/lib/syslinux/bios/isohdpfx.bin ${work_dir}/iso/isolinux/
502     cp ${work_dir}/${arch}/airootfs/usr/lib/syslinux/bios/ldlinux.c32 ${work_dir}/iso/isolinux/
503 }
504 # Prepare /EFI
505 make_efi() {
506     mkdir -p ${work_dir}/iso/EFI/boot
507     cp ${work_dir}/x86_64/airootfs/usr/share/efitools/efi/PreLoader.efi ${work_dir}/iso/EFI/boot/bootx64.efi
508     cp ${work_dir}/x86_64/airootfs/usr/share/efitools/efi/HashTool.efi ${work_dir}/iso/EFI/boot/
509     cp ${work_dir}/x86_64/airootfs/usr/lib/systemd/boot/efi/systemd-bootx64.efi ${work_dir}/iso/EFI/boot/loader.efi
510     mkdir -p ${work_dir}/iso/loader/entries
511     cp ${script_path}/efiboot/loader/loader.conf ${work_dir}/iso/loader/
512     cp ${script_path}/efiboot/loader/entries/uefi-shell-v2-x86_64.conf ${work_dir}/iso/loader/entries/
513     cp ${script_path}/efiboot/loader/entries/uefi-shell-v1-x86_64.conf ${work_dir}/iso/loader/entries/
514     sed "s|%ARCHISO_LABEL%|${iso_label}|g;
515          s|%INSTALL_DIR%|${install_dir}|g" \
516         ${script_path}/efiboot/loader/entries/archiso-x86_64-usb.conf > ${work_dir}/iso/loader/entries/archiso-x86_64.conf
517     # EFI Shell 2.0 for UEFI 2.3+
518     curl -o ${work_dir}/iso/EFI/shellx64_v2.efi https://raw.githubusercontent.com/tianocore/edk2/master/ShellBinPkg/UefiShell/X64/Shell.efi
519     # EFI Shell 1.0 for non UEFI 2.3+
520     curl -o ${work_dir}/iso/EFI/shellx64_v1.efi https://raw.githubusercontent.com/tianocore/edk2/master/EdkShellBinPkg/FullShell/X64/Shell_Full.efi
521 }
522 # Prepare efiboot.img::/EFI for "El Torito" EFI boot mode
523 make_efiboot() {
524     mkdir -p ${work_dir}/iso/EFI/archiso
525     truncate -s 40M ${work_dir}/iso/EFI/archiso/efiboot.img
526     mkfs.vfat -n ARCHISO_EFI ${work_dir}/iso/EFI/archiso/efiboot.img
527     mkdir -p ${work_dir}/efiboot
528     mount ${work_dir}/iso/EFI/archiso/efiboot.img ${work_dir}/efiboot
529     mkdir -p ${work_dir}/efiboot/EFI/archiso
530     cp ${work_dir}/iso/${install_dir}/boot/x86_64/vmlinuz ${work_dir}/efiboot/EFI/archiso/vmlinuz.efi
531     cp ${work_dir}/iso/${install_dir}/boot/x86_64/archiso.img ${work_dir}/efiboot/EFI/archiso/archiso.img
532     cp ${work_dir}/iso/${install_dir}/boot/intel_ucode.img ${work_dir}/efiboot/EFI/archiso/intel_ucode.img
533     mkdir -p ${work_dir}/efiboot/EFI/boot
534     cp ${work_dir}/x86_64/airootfs/usr/share/efitools/efi/PreLoader.efi ${work_dir}/efiboot/EFI/boot/bootx64.efi
535     cp ${work_dir}/x86_64/airootfs/usr/share/efitools/efi/HashTool.efi ${work_dir}/efiboot/EFI/boot/
536     cp ${work_dir}/x86_64/airootfs/usr/lib/systemd/boot/efi/systemd-bootx64.efi ${work_dir}/efiboot/EFI/boot/loader.efi
537     mkdir -p ${work_dir}/efiboot/loader/entries
538     cp ${script_path}/efiboot/loader/loader.conf ${work_dir}/efiboot/loader/
539     cp ${script_path}/efiboot/loader/entries/uefi-shell-v2-x86_64.conf ${work_dir}/efiboot/loader/entries/
540     cp ${script_path}/efiboot/loader/entries/uefi-shell-v1-x86_64.conf ${work_dir}/efiboot/loader/entries/
541     sed "s|%ARCHISO_LABEL%|${iso_label}|g;
542          s|%INSTALL_DIR%|${install_dir}|g" \
543         ${script_path}/efiboot/loader/entries/archiso-x86_64-cd.conf > ${work_dir}/efiboot/loader/entries/archiso-x86_64.conf
544     cp ${work_dir}/iso/EFI/shellx64_v2.efi ${work_dir}/efiboot/EFI/
545     cp ${work_dir}/iso/EFI/shellx64_v1.efi ${work_dir}/efiboot/EFI/
546     umount -d ${work_dir}/efiboot
547 }
548
549 # Build airootfs filesystem image
550 make_prepare() {
551     cp -a -l -f ${work_dir}/${arch}/airootfs ${work_dir}
552     setarch ${arch} mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" pkglist
553     setarch ${arch} mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" ${gpg_key:+-g ${gpg_key}} prepare
554     rm -rf ${work_dir}/airootfs
555     # rm -rf ${work_dir}/${arch}/airootfs (if low space, this helps)
556 }
557 # Build ISO
558 make_iso() {
559     mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" -L "${iso_label}" -o "${out_dir}" iso "${iso_name}-${iso_version}-x86_64.iso"
560 }
561 if [[ ${EUID} -ne 0 ]]; then
562     echo "This script must be run as root."
563     _usage 1
564 fi
565 if [[ ${arch} != x86_64 ]]; then
566     echo "This script needs to be run on x86_64"
567     _usage 1
568 fi
569 while getopts 'N:V:L:D:w:o:g:vh' arg; do
570     case "${arg}" in
571         N) iso_name="${OPTARG}" ;;
572         V) iso_version="${OPTARG}" ;;
573         L) iso_label="${OPTARG}" ;;
574         D) install_dir="${OPTARG}" ;;
575         w) work_dir="${OPTARG}" ;;
576         o) out_dir="${OPTARG}" ;;
577         g) gpg_key="${OPTARG}" ;;
578         v) verbose="-v" ;;
579         h) _usage 0 ;;
580         *)
581            echo "Invalid argument '${arg}'"
582            _usage 1
583            ;;
584     esac
585 done
586 mkdir -p ${work_dir}
587 run_once make_pacman_conf
588
589 for arch in x86_64; do
590     run_once make_basefs
591     run_once make_packages
592 done
593 run_once make_packages_efi
594 for arch in x86_64; do
595     run_once make_setup_mkinitcpio
596     run_once make_customize_airootfs
597 done
598 for arch in x86_64; do
599     run_once make_boot
600 done
601 # Do all stuff for iso
602 run_once make_boot_extra
603 run_once make_syslinux
604 run_once make_isolinux
605 run_once make_efi
606 run_once make_efiboot
607 run_once make_cnchi
608 run_once make_fixes
609
610 for arch in x86_64; do
611 run_once make_prepare
612 done
613 run_once make_iso