PkgBuild - um gerenciador de construção de pacotes
Publicado por Natsu Dragneel (última atualização em 27/11/2018)
[ Hits: 1.088 ]
Homepage: https://notabug.org/infinityuser01
Esse é um gerenciador de construção de pacotes. Por favor, ainda está em estágio ALPHA, ou seja, falta muita coisa!
No futuro, será integrado com o spawn. Idéias e bugs serão ouvidos.
Funções para serem usadas no buildpkg:
prepare_pkg ()
install_pkg ()
remove_pkg ()
triggers_pkg ()
clean_pkg ()
InfinityUser01
#!/bin/bash # this is a pkgbuild, a simple buildsystem to spawn. # so, the pkgbuild is criated to use on InfinityOS. But can easy # be used on others distros. Making the work, more easy. # Based on the makepkg of archlinux. # This is a project open source and free, is under the license MIT # 2018, by InfinityUser01 # Variables for control de color. RED_COLOR="\033[1;31m" GENERIC_C="\033[0m" YELLOW_CL="\033[1;34m" LOG_PATH="/tmp/buildpkg.$RANDOM" IS_CLEAN_END="true" # Function: trigger # Use: to check some command used on the buildpkg # Return: Nothing trigger () { TRIGGER_ID="$RANDOM" echo "Trigger [$TRIGGER_ID]: $1" echo "Trigger [$TRIGGER_ID]: $1 is checking" >> $LOG_PATH if [ ! "$(which $1)" ]; then die "io.trigger.id.$TRIGGER_ID" "Unable to process trigger: $1" fi } # Function: check_arch # Use: To get the arch by the system # Return: Arch (i386), (x86_64) check_arch () { ARCH_MATCH=`uname -m` if [ "$ARCH_MATCH" == 'x86_64' ]; then printf "x86_64" else printf "i386" fi } arch_use=$(check_arch) # Function get_date # Use: Get date from the system # Return: Nothing. get_date () { DATE_NOW=`date '+%Y-%m-%d %H:%M:%S'` printf "$DATE_NOW" } # Function: warn $1, $2 # Use: Print a warn internal error # Return: Nothing. warn () { echo "*** System Warning: $1, Reason $2 ***" >> $LOG_PATH echo -e "$YELLOW_CL*** WARN: $1, Reason: $2 *** $GENERIC_C" } # Function: die $1, $2 # Use: Kill by some internal error # Return: Nothing. die () { echo "*** System Error; $1, Reason: $2" >> $LOG_PATH echo -e "$RED_COLOR*** System Error / $1 *** $GENERIC_C" echo -e " -> Reason: $2" exit 1 } # Function: do_checkup # Use: Checkup by the building env # Return: Nothing. do_checkup () { # check if the buildpkg file is on the folder. if [ ! -e './buildpkg' ]; then die "io.do_checkup.internal.buildpkg" "Missing the buildpkg file to build the program." fi # check the source library... source ./buildpkg # check the package version if [ "$pkg_ver" == "" ]; then die "io.do_checkup.internal.buildpkg" "Missing the pkg_ver= on the ./buildpkg" fi # check the package name if [ "$pkg_name" == "" ]; then die "io.do_checkup.internal.buildpkg" "Missing the pkg_name= on the ./buildpkg" fi # Check the architure compatible with the system if [ "$pkg_arch" == "" ]; then die "io.do_checkup.internal.buildpkg" "Missing the pkg_arch=() on the ./buildpkg" fi # check arch by arch if is compatible Arch="" for i in "${pkg_arch[@]}"; do if [ "$i" == "$arch_use" ] || [ "$i" == "any" ]; then Arch="$i" break fi done if [ "$Arch" == "" ]; then die "io.do_checkup.internal.buildpkg" "Arch is incompatible to build" fi # Check the description of package "not required" if [ "$pkg_desc" == "" ]; then warn "io.do_checkup.internal.buildpkg" "Unable to handle the pkg_desc. Is null or not exist." fi # # /// New log info /// # # echo "- Package Name: $pkg_name" >> $LOG_PATH echo "- Package Vers: $pkg_ver" >> $LOG_PATH echo "- Package Description: $pkg_desc" >> $LOG_PATH echo "- Arch: $Arch" >> $LOG_PATH } do_checkup # Ok, if the build reach this point, is time for build the package, but, needs to be checked # the args... The buildpkg has support to: # 1: Install -> "Install package, compiling from source" # 2: Remove -> "Remove the package, compiling from source" # 3: Clean -> "Clean the package, clean the source, of clean building." # The pkgbuild can support then, 4 functions: # prepare_pkg () -> Prepare a new package 'download and descompress package' # install_pkg () -> Install a package './configure and make phase' -> Require ROOT # remove_pkg () -> Remove a package './configure; make remove' -> Require ROOT # clean_pkg () -> Delete all files. ROOT_MODE="false" if [ $EUID -eq 0 ]; then ROOT_MODE="true" else warn "io.rootcheck.function" "Install or other required functions aren't work" fi # Queue Mode. QUEUE=() MODE_LOCK="false" for i in "$@"; do case $i in install) if [ "$ROOT_MODE" == "false" ]; then die "io.queue.check" "unable to run install mode." else if [ "$MODE_LOCK" == "false" ]; then QUEUE+=("install.mode") MODE_LOCK="true" else warn "io.queue.check" "mode is locked." fi fi ;; remove) if [ "$ROOT_MODE" == "false" ]; then die "io.queue.check" "unable to run remove mode." else if [ "$MODE_LOCK" == "false" ]; then QUEUE+=("remove.mode") MODE_LOCK="true" else warn "io.queue.check" "mode is locked" fi fi ;; clean) QUEUE+=("clean.mode") ;; -no-clean) IS_CLEAN_END="false" echo "Clean on end: {false}" >> $LOG_PATH ;; *) warn "io.queue.check" "No instruction found: $i" ;; esac done # Write queue on the log echo "Queue :: ${QUEUE[@]}" >> $LOG_PATH # User input ask if wants install. while : do read -p "Put your editor or (y,Y) or (n,N) for actions: " edopt if [ "$edopt" == "N" ] || [ "$edopt" == "n" ]; then exit 1 elif [ "$edopt" == "y" ] || [ "$edopt" == "Y" ]; then break else if [ ! "$(which $edopt)" ]; then echo "editor or command not found." else echo "Called editor: $edopt" >> $LOG_PATH $edopt ./buildpkg echo "You want start build?" fi fi done # Start to build. echo "Is building the package: $pkg_name, Version: $pkg_ver" echo "Checking some triggers: " triggers_pkg # Start the building, by the prepare. echo "Prepare Pkg: $(get_date)" >> $LOG_PATH prepare_pkg if [ $? -ne 0 ]; then die "io.prepare_pkg.run" "Failed to run prepare_pkg" fi # start to process the queue for i in "${QUEUE[@]}" ; do if [ "$i" == "install.mode" ]; then echo "Install mode as initialized on $(get_date)" >> $LOG_PATH install_pkg if [ $? -ne 0 ]; then die "io.queue.install" "Unable to install package" fi elif [ "$i" == "remove.mode" ]; then echo "Remove mode as initialized on $(get_date)" >> $LOG_PATH remove_pkg if [ $? -ne 0 ]; then die "io.queue.remove" "Unable to remove package" fi elif [ "$i" == "clean.mode" ]; then echo "Cleanup performed: $(get_date)" >> $LOG_PATH clean_pkg else warn "io.queue.reading" "invalid operation: $i" fi done # Do cleanup, if you want to remove this, is just put: # -not-clean if [ "$IS_CLEAN_END" == "true" ]; then clean_pkg; fi
Dicas e explicações de comandos do Linux - rápidos e reeditáveis
Verificar status de carga da bateria do notebook
Nenhum comentário foi encontrado.
Compartilhando a tela do Computador no Celular via Deskreen
Como Configurar um Túnel SSH Reverso para Acessar Sua Máquina Local a Partir de uma Máquina Remota
Configuração para desligamento automatizado de Computadores em um Ambiente Comercial
Como renomear arquivos de letras maiúsculas para minúsculas
Imprimindo no formato livreto no Linux
Vim - incrementando números em substituição
Efeito "livro" em arquivos PDF
Como resolver o erro no CUPS: Unable to get list of printer drivers
Não to conseguindo resolver este problemas ao instalar o playonelinux (1)
Excluir banco de dados no xampp (1)
[Python] Automação de scan de vulnerabilidades
[Python] Script para analise de superficie de ataque
[Shell Script] Novo script para redimensionar, rotacionar, converter e espelhar arquivos de imagem
[Shell Script] Iniciador de DOOM (DSDA-DOOM, Doom Retro ou Woof!)
[Shell Script] Script para adicionar bordas às imagens de uma pasta