summaryrefslogtreecommitdiff
path: root/.script/bootstrapxbps
blob: 310327cc867c30b46a545f6e51a982cd0810c5b0 (plain)
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
#!/bin/sh
#
# bootstrapxbps
#
# This script takes a comma separated .csv file with the following format:
# A,B,C,...
# where:
# A = an xbps package name.
# all other columns will be ignored.
#
# First, "xbps-install -Suvy" will be called 3 times to ensure up to date repositories and existing packages.
# Then, all A values will be put into a call to "xbps-install".

Help()
{
	echo "bootstrapxbps [-h] [-e] file.csv"
	echo "file.csv is a comma separated value file. Separate with ,"
	echo "Package names will be gathered from the 0th column."
	echo "-h	Help"
	echo "-e	Install nonfree and multilib repositories before bootstrap"
}

Usage()
{
	echo "Usage:"
	echo "bootstrapxbps -h"
	echo "bootstrapxbps [-e] file.csv"
}

ExtraRepos()
{
	# Install multilib repository separately.
	xbps-install -Sy void-repo-multilib
	xbps-install -Sy void-repo-multilib-nonfree
	xbps-install -Sy void-repo-nonfree
}

Upgrade()
{
	# Update repositories and existing packages.
	xbps-install -Suy
	xbps-install -Suy
	xbps-install -Suy

	# Gather packages in .csv argument.
	IFS=","
	CMD="xbps-install"

	while read package comment; do
		CMD="${CMD} ${package}"
	done < "${1}"

	IFS=$OLDIFS

	# Install specified packages.
	eval $CMD

	exit 0
}

while getopts 'he' c; do
	case ${c} in
		h)	Help
			exit 0
			;;
		e)	ExtraRepos
			;;
		\?)	Usage
			exit 1
			;;
	esac
done
shift $((OPTIND -1))

Upgrade $1