-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibepkg
executable file
·818 lines (678 loc) · 27.7 KB
/
libepkg
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
#!/usr/bin/env bash
source /etc/portage/make.conf
# generic Argent variables
export ADD_OPTS="${ADD_OPTS:-}"
# export function for other gentoo distributions to use
export EPKG_DISTRO_SET="${GENTOO_DISTRO}"
export local ENABLE_COLOR="\e[1;49;34m"
export local DISABLE_COLOR="\e[0m"
export local PORTAGE_DIR="${PORTDIR}"
export local ARGENT_OVERLAY="/var/lib/layman/argent-ws"
# import gentoo functions, this has not been ported to lib64 yet
source /lib/gentoo/functions.sh
# generic gentoo variables
export PORTAGE_GROUP="${PORTAGE_GROUP:-portage}"
checkroot() {
if [[ "$(whoami)" != root ]] ; then
eerror "You're not root?...No cookies for you, go away !!!"
exit 1
fi
}
checksystemmode() {
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-srcmode" ]] ; then
eerror "The system is set to SRCMODE (full Gentoo mode), cowardly refusing to run!"
exit 1
fi
}
checkportageconfig() {
# running update on argent specific gentoo settings
pushd /opt/argentws-build > /dev/null 2>&1
git remote update > /dev/null 2>&1
export local CONFHASH=$(git rev-parse @)
export local RCONFHASH=$(git rev-parse @{u})
if [[ ! -e .git ]] ; then
echo -e ""
eerror "You do not have any connection with the Argent main server"
eerror "Establish a .git connection to the main Argent EPKG server"
eerror "Or use "$ENABLE_COLOR"avasile"$DISABLE_COLOR" to switch stance"
eerror "Ignoring local changes."
echo -e ""
elif [ "${CONFHASH}" != "${RCONFHASH}" ] ; then
eerror "portage config is out of date, run "epkg update" first"
fi
popd > /dev/null 2>&1
}
checkportagetree() {
# running update on gentoo snapshotted overlay
pushd "${PORTAGE_DIR}" > /dev/null 2>&1
git remote update > /dev/null 2>&1
export local TREEHASH=$(git rev-parse @)
export local RTREEHASH=$(git rev-parse @{u})
if [ "${TREEHASH}" != "${RTREEHASH}" ] ; then
eerror "Argent portage tree is out of date, run "epkg update" first"
fi
popd > /dev/null 2>&1
}
checkargentoverlay() {
# running update on argent gentoo overlay
pushd /var/lib/layman/argent-ws > /dev/null 2>&1
git remote update > /dev/null 2>&1
export local OVERLAYHASH=$(git rev-parse @)
export local ROVERLAYHASH=$(git rev-parse @{u})
if [ "${OVERLAYHASH}" != "${ROVERLAYHASH}" ] ; then
eerror "Overlay argent-ws is out of date, run "epkg update" first"
fi
}
checkmakeconf() {
# function checking the existence and validity of make.conf
# in accordance wih gentoo and argentws-build standard
if [ -e "/etc/portage/make.conf" ] ; then
. /etc/portage/make.conf
unset PKGDIR
export PKGDIR="${PKGDIR:-$(cat /etc/portage/make.conf | grep 'PKGDIR=' | cut -d '"' -f2)}"
else
eerror "The file does not match the pattern of environment script"
echo "Please consider using avasile to change to one of the modes"
echo "avasile --help"
fi
}
checkportdir() {
# function to check the existence of portage and argent/portage.git independent dirs:
# distfiles and packages
# the unconventional way here: we import /etc/portage/make.conf into current local function
checkmakeconf
# check if ${PORTDIR} exists
if [ ! -d "${PORTDIR}" ] ; then
eerror "No such directory: ${PORTDIR}"
echo "Consider running: epkg update"
exit 1
fi
# check if distfiles exist. Again, we might never know what Gentoo users are up to
if [ ! -d "${DISTDIR}" ] ; then
eerror "No such directory: ${DISTDIR}"
echo "Consider creating the directory with the right ownership:"
echo "i.e.: chgrp portage ${DISTDIR}"
exit 1
fi
# check if ${PKGDIR} exists
if [ ! -d "${PKGDIR}" ] ; then
eerror "No such directory: ${PKGDIR}/"
echo "Consider creating the directory with the right ownership:"
echo "i.e.: chgrp portage ${PKGDIR}/"
exit 1
fi
}
checksync() {
if [[ "${EPKG_DISTRO_SET}" == "argent" ]]; then
if [ -d "/opt/argentws-build/.git" ]; then
checkportagetree
else
ewarn "No portage tree found, you should fetch minimal portage tree via epkg update"
fi
if [ -d "$ARGENT_OVERLAY/.git" ]; then
checkargentoverlay
else
ewarn "No argent overlay found, you must eselect enable argent-ws or git clone it in:"
ewarn "either /var/lib/layman/ or /var/db/repos/"
ewarn "You also have the alternative to use the distro-reset command avasile --help"
fi
checkportageconfig
fi
}
syncrepos() {
if [[ -e "/etc/portage/repos.conf/layman.conf" ]] && [[ "$(cat /etc/portage/repos.conf/layman.conf | grep argent-ws )" ]] ; then
sed -i 's|auto-sync = No|auto-sync = yes|g' /etc/portage/repos.conf/layman.conf
fi
emerge --sync
}
set_var_cache_dir() {
export local COLOR_ON="\e[1;49;34m"
export local COLOR_OFF="\e[0m"
if [ -e "/etc/portage/make.conf" ] ; then
. /etc/portage/make.conf
unset PKGDIR
export PKGDIR="${PKGDIR:-$(cat /etc/portage/make.conf | grep 'PKGDIR=' | cut -d '"' -f2)}"
unset DISTDIR
export DISTDIR="${DISTDIR:-$(cat /etc/portage/make.conf | grep 'DISTDIR=' | cut -d '"' -f2)}"
unset PORTAGE_GROUP
export PORTAGE_GROUP="${PORTAGE_GROUP:-$(cat /etc/portage/make.conf | grep 'PORTAGE_GROUP=' | cut -d '"' -f2)}"
else
eerror "The file does not match the pattern of environment script"
echo "Please consider using avasile to change to one of the modes"
echo "avasile --help"
fi
echo " "
if [ ! -e "${PKGDIR}" ] ; then
mkdir -p "${PKGDIR}"
if [ $( stat -c "%G" "${PKGDIR}" ) != "${PORTAGE_GROUP}" ] ; then
eerror "Please make sure you set $PKGDIR ownership to $PORTAGE_GROUP"
echo " "
eerror "Run command: "$COLOR_ON"chgrp $PORTAGE_GROUP {${PKGDIR},${DISTDIR}} "$COLOR_OFF""
echo " "
eerror "You can safely cancel now, and run the blue command from above"
echo " "
fi
fi
if [ ! -e "${DISTDIR}" ] ; then
mkdir -p "${DISTDIR}"
if [ $( stat -c "%G" "${DISTDIR}" ) != "${PORTAGE_GROUP}" ] ; then
eerror "Please make sure you set $DISTDIR ownership to $PORTAGE_GROUP"
echo " "
eerror "Run command: "$COLOR_ON"chgrp $PORTAGE_GROUP {${PKGDIR},${DISTDIR}} "$COLOR_OFF""
echo " "
fi
fi
}
forcesync() {
# Full update, everything caught in history
pushd "${PORTAGE_DIR}" > /dev/null 2>&1
git pull --unshallow
popd
pushd /var/lib/layman/argent-ws/ > /dev/null 2>&1
git pull --unshallow
popd
pushd /opt/argentws-build > /dev/null 2>&1
git pull --unshallow
popd
}
fetchminimalsync() {
# fetch minimal portage tree
# in usermode we don't want the whole tree of gentoo ebuilds
# but we need portage profiles portage metadata && portage eclasses
# so make a sparse-checkout, to fetch only what we need
if [[ ! -d "${PORTAGE_DIR}"/.git ]] ; then
einfo "Injecting usermode (minimal) gentoo portage tree"
cd "${PORTAGE_DIR}" && git init > /dev/null 2>&1
git remote add origin https://gitlab.com/argent/portage.git
git config core.sparsecheckout true
echo "profiles/*" >> .git/info/sparse-checkout
echo "metadata/*" >> .git/info/sparse-checkout
echo "eclass/*" >> .git/info/sparse-checkout
echo ".gitignore" >> .git/info/sparse-checkout
git pull --depth=1 origin master
git branch -u origin/master master
rm -rf ""${PORTAGE_DIR}"/profiles/updates"
else
# We need minimal git pull if the folder really exists
pushd "${PORTAGE_DIR}" > /dev/null 2>&1
git pull --update-shallow
git pull --depth=1
git gc --prune=now
popd
fi
if [[ ! -d "/var/lib/layman/argent-ws/.git" ]] ; then
einfo "Injecting usermode argent-ws overlay"
cd "/var/lib/layman/argent-ws/" && git init > /dev/null 2>&1
git remote add origin https://gitlab.com/argent/argent-ws.git
git config core.sparsecheckout true
echo "profiles/*" >> .git/info/sparse-checkout
echo "metadata/*" >> .git/info/sparse-checkout
echo "eclass/*" >> .git/info/sparse-checkout
echo ".gitignore" >> .git/info/sparse-checkout
git pull --depth=1 origin master
git branch -u origin/master master
rm -rf ""${PORTAGE_DIR}"/profiles/updates"
else
pushd /var/lib/layman/argent-ws/ > /dev/null 2>&1
git pull --update-shallow
git pull --depth=1
git gc --prune=now
popd
fi
pushd /opt/argentws-build/ > /dev/null 2>&1
git pull --update-shallow
git pull --depth=1
git gc --prune=now
popd
}
backuppkg() {
# function to provide backup packages with own configurations
# a forenote: although if you run usermode or devmode, the installing packages will already be saved
# but if you run epkg cleanlocalpkg, you can start all over and save what packages you already configured
# like saving apache with own configs for example, for future use
# the unconventional way here: we import /etc/portage/make.conf into current local function
checkmakeconf
if [[ -z "$@" ]] ; then
eerror "You have not specified any package to backup"
echo " "
exit 1
fi
# checking if ${PKGDIR} exists
# usually it's /usr/portage/ if you're on avasile --usermode or --devmode
if [ -d "${PKGDIR}" ] ; then
quickpkg --include-config y --include-unmodified-config y "$@"
echo ""
echo "All packages were saved in ${PKGDIR} by category"
echo "Please make sure these files will not be overwritten!"
echo "If you consider further backup on the same package"
echo "consider copying packages from ${PKGDIR} into customized directories"
echo "Although, not recommended, you can epkg install them by path (from customized directories)"
echo "To customize directory, you can use variable PKGDIR as: PKGDIR='/location/' epkg backuppkg"
echo " "
else
echo " "
eerror "No such directory: ${PKGDIR}"
echo "Please consider creating the $PKGDIR directory"
echo "And set $PKGDIR GID to portage!"
echo " "
exit 1
fi
# regenerating environment here is a must!
env-update && source /etc/profile
}
backupallpkg() {
# function to *backup all packages in the system* for future use
# the unconventional way here: we import /etc/portage/make.conf into current local function
if [[ -z "$@" ]] ; then
eerror "You have not specified any package to backup"
echo " "
exit 1
fi
checkportdir
eerror "Warning: If you backup everything, make sure you keep the packages safe :)"
eerror "We cannot take responsibility of safe-guarding the newly backed-up system"
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You are on --usermode, we propose using: avasile --devmode or --srcmode for this"
eerror "If you continue, you continue at your own risk!"
eerror "Make sure you keep the backup safe!"
sleep 3
if [[ ! -e "/tmp/temporary_list_backup" ]] ; then
for i in $( qlist -IvC ) ; do echo =$i >> /tmp/temporary_list_backup ; done
quickpkg --include-config y --include-unmodified-config y $( cat /tmp/temporary_list_backup ) "$@"
else
rm -f /tmp/temporary_list_backup
for i in $( qlist -IvC ) ; do echo =$i >> /tmp/temporary_list_backup ; done
quickpkg --include-config y --include-unmodified-config y $( cat /tmp/temporary_list_backup ) "$@"
fi
else
if [[ ! -e "/tmp/temporary_list_backup" ]] ; then
for i in $( qlist -IvC ) ; do echo =$i >> /tmp/temporary_list_backup ; done
quickpkg --include-config y --include-unmodified-config y $( cat /tmp/temporary_list_backup ) "$@"
else
rm -f /tmp/temporary_list_backup
for i in $( qlist -IvC ) ; do echo =$i >> /tmp/temporary_list_backup ; done
quickpkg --include-config y --include-unmodified-config y $( cat /tmp/temporary_list_backup ) "$@"
fi
fi
# regenerating environment here is a must!
env-update && source /etc/profile
}
cleanoutdated() {
# function designed to clearout any outdated package using gentoolkit
# the unconventional way here: we import /etc/portage/make.conf into current local function
# we have 2 checks here: if usr/portage and usr/portage/packages really exist
# we may never know what users do to their portage dirs in Gentoo system
checkmakeconf
if [ -d "${PKGDIR}" ] ; then
/usr/bin/eclean-pkg
else
eerror "No such directory ${PKGDIR}"
echo "Please consider: mkdir ${PKGDIR}/"
echo "chgrp portage ${PKGDIR}"
exit 1
fi
# regenerating environment here is a must!
env-update && source /etc/profile
}
cleanlocalpkg() {
# function to cleanup all local packages in /usr/portage/packages
# it also includes deletion of /usr/portage/Packages
# if we do not have any /usr/portage, there is no reason we should continue
checkmakeconf
if [ -d "${PKGDIR}" ] ; then
rm -rf "${PKGDIR}"/* || exit 1
else
eerror "No such directory ${PKGDIR}"
echo "Make sure you have this directory"
echo "Also make sure you have the right GID:"
echo "i.e.: chgrp portage ${PKGDIR}"
exit 1
fi
# regenerating environment here is a must!
env-update && source /etc/profile
}
src-newuse() {
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You are on --usermode, we propose using: avasile --devmode or --srcmode for this"
eerror "If you continue, you continue at your own risk!"
sleep 3
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge -va --newuse --changed-use "$@"
else
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge -va --newuse --changed-use "$@"
fi
}
recompilepkg() {
# function to call a recompile of a package and save it to ${PKGDIR}"
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You are on --usermode, we propose using: avasile --devmode or --srcmode for this"
eerror "If you continue, you continue at your own risk!"
sleep 3
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge --oneshot -va "$@"
else
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge --oneshot -va "$@"
fi
}
recompileallpkg() {
# function to recompile everything on the system and also save all the recompiled packages.
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You are not allowed to run in --usermode, we propose using: avasile --devmode or --srcmode for this"
exit 1
else
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge -va $(qlist -IC)
eerror "Warning: if there are packages that are not found, you must run: epkg update"
eerror "If the error persists, force remove the package causing the corruption:"
eerror "in --devmode: epkg remove <package-name>"
eerror "in --srcmode: emerge --unmerge <package-name>"
eerror "Then re-run the same command: epkg recompileallpkg"
fi
}
autorecompilepkg() {
# function to call a recompile of a package and save it to ${PKGDIR}"
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You are on --usermode, we propose using: avasile --devmode or --srcmode for this"
eerror "If you continue, you continue at your own risk!"
sleep 3
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge --oneshot -v "$@"
else
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge --oneshot -v "$@"
fi
}
autorecompileallpkg() {
# function to recompile everything on the system and also save all the recompiled packages.
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You are not allowed to run in --usermode, we propose using: avasile --devmode or --srcmode for this"
exit 1
else
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge -v $(qlist -IC)
fi
}
recompile-depend() {
# function to recompile all the packages that directly depend on this package
local exclude_packages=()
local args=("$@")
local new_args=()
for ((i = 0; i < ${#args[@]}; i++)); do
if [[ "${args[i]}" == "--exclude" ]]; then
if [[ $((i + 1)) -lt ${#args[@]} ]]; then
exclude_packages+=("${args[i + 1]}")
i=$((i + 1))
fi
else
new_args+=("${args[i]}")
fi
done
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]]; then
eerror "You are on --usermode, we propose using: avasile --devmode or --srcmode for this"
eerror "If you continue, you continue at your own risk!"
sleep 3
fi
# function to create a lock file in order to not be possibly overwritten by another epkg (auto) recompile-depend
local temp_list="/tmp/epkg_temporary_list"
exec 200>"$temp_list"
flock -n 200 || { echo "Failed to acquire lock on $temp_list"; exit 1; }
cat /dev/null > "$temp_list"
equery d "${new_args[@]}" | awk '{print $1}' | sed -e 's/^/=/' >> "$temp_list"
if [[ -s "$temp_list" ]]; then
local exclude_str=""
if [[ ${#exclude_packages[@]} -gt 0 ]]; then
for pkg in "${exclude_packages[@]}"; do
exclude_str+="--exclude ${pkg} "
done
fi
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge --oneshot -va --keep-going $(cat "$temp_list") $exclude_str
else
echo "There are no packages that depend on given package(s)"
fi
rm -f "$temp_list" || exit 1
flock -u 200
exec 200>&-
}
recompile-depend-new() {
# function to recompile all the new packages that directly depend on this package
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You are on --usermode, we propose using: avasile --devmode or --srcmode for this"
eerror "If you continue, you continue at your own risk!"
sleep 3
fi
# function to create a lock file in order to not be possibly overwritten by another epkg (auto) recompile-depend
local temp_list="/tmp/epkg_temporary_list"
exec 200>"$temp_list"
flock -n 200 || { echo "Failed to acquire lock on $temp_list"; exit 1; }
cat /dev/null > "$temp_list"
for i in $(equery d "$@" | awk '{print $1}') ; do echo =${i} >> "$temp_list" ; done
if [[ -s "$temp_list" ]] ; then
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge --oneshot -va --keep-going $(cat "$temp_list")
else
echo "There are no packages that depend on given package(s)"
fi
rm -f "$temp_list" || exit 1
flock -u 200
exec 200>&-
}
autorecompile-depend() {
# function to recompile all the packages that directly depend on this package with no confirmation
local exclude_packages=()
local args=("$@")
local new_args=()
for ((i = 0; i < ${#args[@]}; i++)); do
if [[ "${args[i]}" == "--exclude" ]]; then
if [[ $((i + 1)) -lt ${#args[@]} ]]; then
exclude_packages+=("${args[i + 1]}")
i=$((i + 1))
fi
else
new_args+=("${args[i]}")
fi
done
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]]; then
eerror "You are on --usermode, we propose using: avasile --devmode or --srcmode for this"
eerror "If you continue, you continue at your own risk!"
sleep 3
fi
# function to create a lock file in order to not be possibly overwritten by another epkg (auto) recompile-depend
local temp_list="/tmp/epkg_temporary_list"
exec 200>"$temp_list"
flock -n 200 || { echo "Failed to acquire lock on $temp_list"; exit 1; }
cat /dev/null > "$temp_list"
equery d "${new_args[@]}" | awk '{print $1}' | sed -e 's/^/=/' >> "$temp_list"
if [[ -s "$temp_list" ]]; then
local exclude_str=""
if [[ ${#exclude_packages[@]} -gt 0 ]]; then
for pkg in "${exclude_packages[@]}"; do
exclude_str+="--exclude ${pkg} "
done
fi
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge -v --oneshot --keep-going $(cat "$temp_list") $exclude_str
else
echo "There are no packages that depend on given package(s)"
fi
rm -f "$temp_list" || exit 1
flock -u 200
exec 200>&-
}
autorecompile-depend-new() {
# function to recompile all the new packages that directly depend on this package with no confirmation
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You are on --usermode, we propose using: avasile --devmode or --srcmode for this"
eerror "If you continue, you continue at your own risk!"
sleep 3
fi
# function to create a lock file in order to not be possibly overwritten by another epkg (auto) recompile-depend
local temp_list="/tmp/epkg_temporary_list"
exec 200>"$temp_list"
flock -n 200 || { echo "Failed to acquire lock on $temp_list"; exit 1; }
cat /dev/null > "$temp_list"
for i in $(equery d "$@" | awk '{print $1}') ; do echo =${i} >> "$temp_list" ; done
if [[ -s "$temp_list" ]] ; then
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge -v $(cat "$temp_list")
else
echo "There are no packages that depend on given package(s)"
fi
rm -f "$temp_list" || exit 1
flock -u 200
exec 200>&-
}
# soon to be rewritten / deprecated
reinstall-depend() {
# function to reinstall (?) all new packages that directly depend on this package
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You are on --usermode, we propose using: avasile --devmode or --srcmode for this"
eerror "If you continue, you continue at your own risk!"
sleep 3
cat /dev/null > /tmp/epkg_temporary_list
for i in $(equery d "$@" | awk '{print $1}') ; do echo =${i} >> /tmp/epkg_temporary_list ; done
emerge -va $( cat /tmp/epkg_temporary_list )
rm -f /tmp/epkg_temporary_list || exit 1
else
cat /dev/null > /tmp/epkg_temporary_list
for i in $(equery d "$@" | awk '{print $1}') ; do echo =${i} >> /tmp/epkg_temporary_list ; done
emerge -va $( cat /tmp/epkg_temporary_list )
rm -f /tmp/epkg_temporary_list || exit 1
fi
}
autoreinstall-depend() {
# function to recompile all new packages that directly depend on this package
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You are on --usermode, we propose using: avasile --devmode or --srcmode for this"
eerror "If you continue, you continue at your own risk!"
sleep 3
cat /dev/null > /tmp/epkg_temporary_list
for i in $(equery d "$@" | awk '{print $1}') ; do echo =${i} >> /tmp/epkg_temporary_list ; done
emerge -v $( cat /tmp/epkg_temporary_list )
rm -f /tmp/epkg_temporary_list || exit 1
else
cat /dev/null > /tmp/epkg_temporary_list
for i in $(equery d "$@" | awk '{print $1}') ; do echo =${i} >> /tmp/epkg_temporary_list ; done
emerge -v $( cat /tmp/epkg_temporary_list )
rm -f /tmp/epkg_temporary_list || exit 1
fi
}
fetchsourcepkg() {
# function to download the source of the program for development / patching purposes
# the unconventional way here: we import /etc/portage/make.conf into current local function
checkportdir
# function to warn the regular user that he's doing something wrong
# but still do it anyway.
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You are on --usermode, we propose using: avasile --devmode or --srcmode for this"
sleep 3
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge --fetchonly "$@"
else
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge --fetchonly "$@"
fi
# regenerating environment here is a must!
env-update && source /etc/profile
}
fetchbinpkg() {
# function to download the source of the program for development / patching purposes
# the unconventional way here: we import /etc/portage/make.conf into current local function
checkportdir
# function to warn the regular user that he's doing something wrong
# but still do it anyway.
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "Fetching binary package(s) from remote"
sleep 2
EMERGE_DEFAULT_OPTS="--getbinpkgonly --rebuilt-binaries" emerge --fetchonly "$@"
else
EMERGE_DEFAULT_OPTS="--getbinpkgonly --rebuilt-binaries" emerge --fetchonly "$@"
fi
# regenerating environment here is a must!
env-update && source /etc/profile
}
remove-orphans() {
# The function calls 'emerge --depclean -a' which removes orphaned packages
# Probably the most successful emerge algorythm ever made
checkmakeconf
emerge --depclean -a
}
buildinstall() {
# Stands for build (-Bv) and install (-va with --getbinpkg)
# Also regenerates the binhost Packages file
if [[ -z "$@" ]] ; then
eerror "You have not specified any package to build & install"
echo " "
exit 1
fi
checkportdir
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You cannot run buildpkgonly from the user profile!"
exit 1
else
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge --with-bdeps=y -Bva "$@"
EMERGE_DEFAULT_OPTS="--getbinpkg --rebuilt-binaries" emerge -av "$@"
emaint -f binhost
fi
# regenerating environment here is a must!
env-update && source /etc/profile
}
autobuildinstall() {
# Stands for build (-Bv) and install (-va with --getbinpkg) automatically
# Also regenerates the binhost Packages file
if [[ -z "$@" ]] ; then
eerror "You have not specified any package to build & install"
echo " "
exit 1
fi
checkportdir
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You cannot run buildpkgonly from the user profile!"
exit 1
else
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge --with-bdeps=y -Bv "$@"
EMERGE_DEFAULT_OPTS="--getbinpkg --rebuilt-binaries" emerge -v "$@"
emaint -f binhost
fi
# regenerating environment here is a must!
env-update && source /etc/profile
}
buildpkgonly() {
# function to only build 1 or more packages based on input
# works as: epkg buildpkg-only <something>
checkportdir
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You cannot run buildpkgonly from the user profile!"
exit 1
else
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge --with-bdeps=y -Bva "$@"
fi
# regenerating environment here is a must!
env-update && source /etc/profile
}
autobuildpkgonly() {
# function to only build 1 or more packages based on input
# works as: epkg autobuildpkg-only <something>
checkportdir
if [[ "$(readlink -f "/etc/portage/make.conf")" = "/opt/argentws-build/conf/intel/portage/make.conf.amd64-user" ]] ; then
eerror "You cannot run buildpkgonly from the user profile!"
exit 1
else
EMERGE_DEFAULT_OPTS="--rebuilt-binaries" emerge --with-bdeps=y -Bv "$@"
fi
# regenerating environment here is a must!
env-update && source /etc/profile
}
syncportageconfig() {
# syncing with the latest updates on our argent gentoo configs
pushd /opt/argentws-build > /dev/null 2>&1
echo ">>> Syncing 'portage config' into '/etc/portage' "
echo "Git pulling latest modifications. Please, stand by..."
if [[ ! -e .git ]] ; then
echo -e ""
eerror "You do not have any connection with the Argent main server"
eerror "Establish a .git connection to the main Argent EPKG server"
eerror "Or use "$ENABLE_COLOR"avasile --help"$DISABLE_COLOR" to switch stance"
eerror "Ignoring local changes"
echo -e ""
else
git pull
fi
echo "=== Sync completed for 'portage config'"
popd > /dev/null 2>&1
}
argentsync() {
if [[ "${EPKG_DISTRO_SET}" == "argent" ]]; then
syncrepos
syncportageconfig
fi
echo ""
}