aboutsummaryrefslogblamecommitdiff
path: root/xbps-mini-builder
blob: 72cd8505a3373fa50cebb267fe026d2d24b26b74 (plain) (tree)
1
2
3
4
5
6
7
8
9

         
                                             
                      
 
                               
                         
                            
                                                    

  


                  
                                                       
                      
                          



                                   
                                                           


                                              

                                           
                         
                             

  



                                                        
                                                   
                                                        

      
                                               
                                                        

                                                                                                          


      


                                             
                               


                                          
  

                                         

                                    
  
 










                                             




                                                                                     
                                                    
                                                       
                                                
                                                                     
                                                                                                          
                                                                    
                                                                                   

      
#!/bin/sh

# Jump to the directory that owns this script
cd "${0%/*}" || exit 1

# Do we have keys to sign with?
if [ ! -f id_rsa ] ; then
    rm -rf id_rsa id_rsa.pub
    ssh-keygen -b 4096 -t rsa -m PEM -N "" -f id_rsa
fi

# Remove old state
rm -f changed

# Create the void-packages directory if it doesn't exit
mkdir -p void-packages
cd void-packages || exit 2

# Do we actually have the repo yet?
if [ ! -d srcpkgs ] ; then
    # No, clone a fresh copy
    git clone https://github.com/void-linux/void-packages .

    # On bootstrap we need to build everything
    cp ../packages.list ../changed
else
    # Yes, pull in the changes for this run
    git reset --hard HEAD
    git pull | tee ../changed
fi

# Does this system use another set of repos
if [ -d /etc/xbps.d ] ; then
    cat /etc/xbps.d/* > etc/repos-remote.conf
    # If this platform is 64 bit, override those as well
    if [ "$(xbps-uhelper arch)" = "x86_64" ] ; then
        cat /etc/xbps.d/* > etc/repos-remote-x86_64.conf
    fi

    # The bootstrap config is loaded seperately
    if [ -f /etc/xbps.d/00-repository-main.conf ] ; then
        repo="$(sed 's/^.*=//' < /etc/xbps.d/00-repository-main.conf)"
        printf 'XBPS_INSTALL_ARGS="--repository=%s --repository=%s/musl"\n' "${repo}" "${repo}" > etc/conf
    fi
fi

# Do we have a live build environment
if [ ! -d masterdir ] ; then
    # No masterdir, go ahead and bootstrap it
    ./xbps-src binary-bootstrap
else
    # Have a masterdir, keep it up to date
    ./xbps-src bootstrap-update
fi

# Apply provided config file if it exists
if [ -f ../xbps-src.conf ] ; then
    cat ../xbps-src.conf >> etc/conf
fi

if [ -z "$@" ] ; then
    while read -r package ; do
        if grep "${package}" ../changed; then
            ./xbps-src pkg "${package}"
        fi
    done < ../packages.list
else
	for pkg in "$@"; do
		./xbps-src pkg "${pkg}"
	done
fi

# Sign built packages
xbps-rindex --sign --signedby "XBPS-mini-builder" --privkey ../id_rsa hostdir/binpkgs
xbps-rindex --sign-pkg --privkey ../id_rsa hostdir/binpkgs/*.xbps

for folder in multilib multilib/nonfree nonfree ; do
    printf "Trying to sign packages in %s\\n" ${folder}
    if [ -d "hostdir/binpkgs/${folder}" ] ; then
        printf "Updating repodata in hostdir/binpkgs/%s\\n" ${folder}
        xbps-rindex --sign --signedby "XBPS-mini-builder" --privkey ../id_rsa "hostdir/binpkgs/${folder}/"
        printf "Signing packages in hostdir/binpkgs/%s\\n" ${folder}
        xbps-rindex --sign-pkg --privkey ../id_rsa hostdir/binpkgs/${folder}/*.xbps
    fi
done