173 lines
3.8 KiB
Bash
Executable File
173 lines
3.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
CONFIG_DIR="/voidpkg/vur"
|
|
CONFIG_FILE="vur.conf"
|
|
KEY_FILE="privkey.pem"
|
|
KEY_PATH="${CONFIG_DIR}/${KEY_FILE}"
|
|
|
|
help_file(){
|
|
echo """
|
|
|
|
usage: ${0} [-a]
|
|
|
|
-a add packages to repository and sign them
|
|
"""
|
|
}
|
|
|
|
get_void_pkgs(){
|
|
echo -n "Location to place void-packages?: "
|
|
read vpkgs_location
|
|
|
|
if [ -z "${vpkgs_location}" ];then
|
|
vpkgs_location="/voidpkg/void-packages"
|
|
echo "Creating directory: ${vpkgs_location}"
|
|
mkdir -p "${vpkgs_location}"
|
|
git clone https://github.com/void-linux/void-packages.git "${vpkgs_location}"
|
|
|
|
elif [ -n "${vpkgs_location}" ];then
|
|
while true;do
|
|
echo -n "Use ssh? [y/N]: "
|
|
read use_ssh
|
|
|
|
if [ -z "${use_ssh}" ] || [ "${use_ssh}" = "n" ] || [ "${use_ssh}" = "N" ] ;then
|
|
echo "Creating directory: ${vpkgs_location}"
|
|
|
|
git clone https://github.com/void-linux/void-packages.git "${vpkgs_location}" || exit 1
|
|
break
|
|
|
|
|
|
elif [ "${use_ssh}" = "y" ] || [ "${use_ssh}" = "Y" ];then
|
|
|
|
echo -n "Remote git username? (i.e github username): "
|
|
read git_user
|
|
|
|
git clone github.com:"${git_user}"/void-packages.git "${vpkgs_location}" || exit 1
|
|
break
|
|
|
|
else
|
|
|
|
echo "please enter y, n, or leave blank"
|
|
fi
|
|
done
|
|
fi
|
|
}
|
|
|
|
gen_conf(){
|
|
|
|
if [ ! -d "${CONFIG_DIR}" ];then
|
|
mkdir -p "${CONFIG_DIR}" || exit 1
|
|
fi
|
|
|
|
if [ ! -f "${CONFIG_DIR}/${CONFIG_FILE}" ];then
|
|
echo "No config file exists yet"
|
|
echo -e "Please answer a few questions to set up the config\n\n"
|
|
|
|
echo -n "Where do you want your custom repository? (mind permissions): "
|
|
read repo_location
|
|
|
|
echo "REPO_PATH=${repo_location}" > "${CONFIG_DIR}/${CONFIG_FILE}"
|
|
|
|
echo -n "Where is your 'void-packages' location (no trailing /):"
|
|
read void_packages_location
|
|
|
|
echo "void_packages=${void_packages_location}/hostdir/binpkgs" >> "${CONFIG_DIR}/${CONFIG_FILE}"
|
|
|
|
source "${CONFIG_DIR}/${CONFIG_FILE}"
|
|
fi
|
|
}
|
|
|
|
load_conf(){
|
|
|
|
if [ -f "${HOME}"/.config/vrepo.conf ];then
|
|
source "${CONFIG_DIR}"/"${CONFIG_FILE}"
|
|
else
|
|
gen_conf
|
|
source "${CONFIG_DIR}"/"${CONFIG_FILE}"
|
|
fi
|
|
}
|
|
|
|
check_deps(){
|
|
if [ ! -f "/usr/bin/xbps-install" ];then
|
|
echo "A Void Linux based system is required!"
|
|
echo "Unable to locate xbps-install"
|
|
return 1
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
create_repo(){
|
|
|
|
if [ ! -d "${REPO_PATH}" ];then
|
|
|
|
mkdir "${REPO_PATH}"
|
|
#cd "${BASE_DIR}"/"${REPO_PATH}" || return
|
|
|
|
|
|
if [ -d "${REPO_PATH}" ];then
|
|
|
|
return 0
|
|
fi
|
|
|
|
elif [ -d "${REPO_PATH}" ];then
|
|
echo "Using custom repository: ${REPO_PATH}"
|
|
return 0
|
|
fi
|
|
}
|
|
|
|
gen_key(){
|
|
ssh-keygen -t rsa -b 4096 -m PEM -f "${KEY_PATH}"
|
|
}
|
|
|
|
sign_pkgs(){
|
|
|
|
if [ ! -f "${KEY_PATH}" ];then
|
|
echo "Key file does not exist"
|
|
echo "Generating a new key..."
|
|
gen_key
|
|
|
|
echo "Signing xbps files in ${REPO_PATH}"
|
|
xbps-rindex --sign --signedby "${USER}" --privkey "${KEY_PATH}" "$REPO_PATH"
|
|
else
|
|
echo "Signing xbps files in ${REPO_PATH}"
|
|
xbps-rindex --sign --signedby "${USER}" --privkey "${KEY_PATH}" "$REPO_PATH"
|
|
fi
|
|
}
|
|
|
|
add_pkg(){
|
|
load_conf
|
|
create_repo
|
|
cp -r "${void_packages}"/*.xbps "${REPO_PATH}" || exit 1
|
|
xbps-rindex -a "${REPO_PATH}"/*.xbps
|
|
}
|
|
|
|
case "${1}" in
|
|
|
|
-c | --create)
|
|
load_conf
|
|
create_repo
|
|
;;
|
|
|
|
-gk | --gen-key)
|
|
load_conf
|
|
gen_key
|
|
;;
|
|
|
|
-sp | --sign-pkgs)
|
|
load_conf
|
|
sign_pkgs
|
|
;;
|
|
|
|
-a | --add-pkg)
|
|
load_conf
|
|
add_pkg
|
|
sign_pkgs
|
|
;;
|
|
|
|
-vp | --void-packages)
|
|
get_void_pkgs
|
|
;;
|
|
|
|
*)
|
|
help_file
|
|
;;
|
|
esac |