-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdnf-host
140 lines (129 loc) · 5.45 KB
/
dnf-host
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
#!/bin/sh
#DEFAULT_TARGET_ ROOTFS=""
WORKDIR=`pwd`
DEFAULT_REPO_DIR=$WORKDIR/oe_repo
DEFAULT_ROOTFS_DIR=$WORKDIR/rootfs
DEFAULT_SPDX_REPO_DIR=file://$WORKDIR/oe_repo/spdx_repo
DEFAULT_SPDX_DESTINATION_DIR=$WORKDIR/spdx_download
DEFAULT_SRPM_REPO_DIR=file://$WORKDIR/oe_repo/srpm_repo
DEFAULT_SRPM_DESTINATION_DIR=$WORKDIR/srpm_download
if [ $1 = "init" -a $# = 1 ]; then
#get repo directory
echo "The repo directory: (default:$WORKDIR/oe_repo)."
echo "Is this ok?[y/N]:"
read DEFINE_REPO_DIR_ANSWER
if [ $DEFINE_REPO_DIR_ANSWER = "N" ]; then
echo "Please input repo directory =>"
read DEFINE_REPO_DIR
else
DEFINE_REPO_DIR=$DEFAULT_REPO_DIR
echo "repo directory: $DEFINE_REPO_DIR"
fi
#get rootfs destination directory
echo "The rootfs destination directory: (default: $DEFAULT_ROOTFS_DIR)."
echo "Is this ok?[y/N]:"
read DEFINE_ROOTFS_DIR_ANSWER
if [ $DEFINE_ROOTFS_DIR_ANSWER = "N" ]; then
echo "Please input rootfs destination directory =>"
read DEFINE_ROOTFS_DIR
else
DEFINE_ROOTFS_DIR=$DEFAULT_ROOTFS_DIR
echo "rootfs destination directory: $DEFINE_ROOTFS_DIR"
fi
#get SPDX repo directory
echo "The SPDX repo directory: (default: $DEFAULT_SPDX_REPO_DIR)."
echo "Is this ok?[y/N]:"
read DEFINE_SPDX_REPO_DIR_ANSWER
if [ $DEFINE_SPDX_REPO_DIR_ANSWER = "N" ]; then
echo "Please input SPDX repo directory =>"
read DEFINE_SPDX_REPO_DIR
else
DEFINE_SPDX_REPO_DIR=$DEFAULT_SPDX_REPO_DIR
echo "SPDX repo directory: $DEFINE_SPDX_REPO_DIR"
fi
#get SPDX file destination directory
echo "The SPDX file destination directory: (default: $DEFAULT_SPDX_DESTINATION_DIR)."
echo "Is this ok?[y/N]:"
read DEFINE_SPDX_DESTINATION_DIR_ANSWER
if [ $DEFINE_SPDX_DESTINATION_DIR_ANSWER = "N" ]; then
echo "Please input SPDX file destination directory =>"
read DEFINE_SPDX_DESTINATION_DIR
else
DEFINE_SPDX_DESTINATION_DIR=$DEFAULT_SPDX_DESTINATION_DIR
echo "SPDX file destination directory: $DEFINE_SPDX_DESTINATION_DIR"
fi
if [ ! -d $DEFINE_SPDX_DESTINATION_DIR ];then
echo "Create the SPDX file destination directory automatically"
mkdir -p $DEFINE_SPDX_DESTINATION_DIR
fi
#get SRPM repo directory
echo "The SRPM repo directory: (default: $DEFAULT_SRPM_REPO_DIR)."
echo "Is this ok?[y/N]:"
read DEFINE_SRPM_REPO_DIR_ANSWER
if [ $DEFINE_SRPM_REPO_DIR_ANSWER = "N" ]; then
echo "Please input SRPM repo directory =>"
read DEFINE_SRPM_REPO_DIR
else
DEFINE_SRPM_REPO_DIR=$DEFAULT_SRPM_REPO_DIR
echo "SRPM repo directory: $DEFINE_SRPM_REPO_DIR"
fi
#get SRPM file destination directory
echo "The SRPM file destination directory: (default: $DEFAULT_SRPM_DESTINATION_DIR)."
echo "Is this ok?[y/N]:"
read DEFINE_SRPM_DESTINATION_DIR_ANSWER
if [ $DEFINE_SRPM_DESTINATION_DIR_ANSWER = "N" ]; then
echo "Please input SRPM destination directory =>"
read DEFINE_SRPM_DESTINATION_DIR
else
DEFINE_SRPM_DESTINATION_DIR=$DEFAULT_SRPM_DESTINATION_DIR
echo "SRPM file destination directory: $DEFINE_SRPM_DESTINATION_DIR"
fi
if [ ! -d $DEFINE_SRPM_DESTINATION_DIR ];then
echo "Create the SRPM file destination directory automatically"
mkdir -p $DEFINE_SRPM_DESTINATION_DIR
fi
environment-dnf.sh $DEFINE_ROOTFS_DIR $DEFINE_REPO_DIR $DEFINE_SPDX_REPO_DIR $DEFINE_SPDX_DESTINATION_DIR $DEFINE_SRPM_REPO_DIR $DEFINE_SRPM_DESTINATION_DIR
#elif [ $1 = "init" -a $# != 3 ]; then
# echo "Error! The usage of dnf-host init is :"
# echo "dnf-host init \${rootfs-dir} \${repo-dir} "
elif [ $1 = "help" -o $1 = "--help" -o $1 = "-h" -o $1 = "-H" ]; then
if [ ! -f $WORKDIR/.env-dnf ]; then
echo "Init the environment failed, please init again"
exit 0
else
source $WORKDIR/.env-dnf
echo "usage: "
echo ""
echo "dnf-host is only used on host to manage packages for target."
echo ""
echo "1. If you want to create a new rootfs."
echo " \$ source dnf-host init \${rootfs-dir} \${repo-dir}"
echo ""
echo "2. If you want to manage your rootfs that has already create by dnf-host."
echo " \$ dnf-host [options] COMMAND "
echo " In this case, the usage is as same as dnf:"
echo ""
dnf -y -c ${TARGET_ROOTFS}/etc/dnf/dnf.conf --setopt=reposdir=${TARGET_ROOTFS}/etc/yum.repos.d --installroot=${TARGET_ROOTFS} --setopt=logdir=$WORKDIR/ help
fi
elif [ $1 = "show" ]; then
if [ ! -f $WORKDIR/.env-dnf ]; then
echo "Init the environment failed, please init again"
exit 0
else
source $WORKDIR/.env-dnf
echo "repo directory : ${REPO_DIR}"
echo "rootfs destination directory : ${TARGET_ROOTFS}"
echo "SPDX repo directory : ${SPDX_REPO_DIR}"
echo "SPDX destination directory : ${SPDX_DESTINATION_DIR}"
echo "SRPM repo directory : ${SRPM_REPO_DIR}"
echo "SRPM destination directory : ${SRPM_DESTINATION_DIR}"
fi
else
if [ ! -f $WORKDIR/.env-dnf ]; then
echo "Init the environment failed, please init again"
exit 0
else
source $WORKDIR/.env-dnf
dnf -c ${TARGET_ROOTFS}/etc/dnf/dnf.conf --setopt=reposdir=${TARGET_ROOTFS}/etc/yum.repos.d --repofrompath=oe-repo,${REPO_DIR} --installroot=${TARGET_ROOTFS} --setopt=logdir=$WORKDIR/ --nogpgcheck $*
fi
fi