prepare_makepkg.sh 2.65 KB
Newer Older
AlmAck's avatar
AlmAck committed
1 2 3 4 5 6
#!/usr/bin/env bash
SCRIPT_DIR=$( dirname $( readlink -e $0 ) )
source "$SCRIPT_DIR/lib/ci-library.sh"

# determine the the repository where we should build against (stable|testing|staging)
repo_name=$(get_repository)
7 8 9 10 11 12 13

# if the project name is lib32 handle differently
if [[ $CI_PROJECT_NAME = *lib32* ]]
then
    repo_name="lib32-$repo_name"
fi

AlmAck's avatar
AlmAck committed
14 15
_log command "Enabling [$repo_name] pacman.conf..."
_do wget "https://code.chakralinux.org/tools/chakrabuildsystem/raw/master/conf/$repo_name.conf"
16
_do cp $repo_name.conf /etc/pacman.conf
AlmAck's avatar
AlmAck committed
17

18
# configure main directories and create a local db
AlmAck's avatar
AlmAck committed
19 20
# we use 'sudo -u builder' because the files created must be accessible
# by the builder user and can not be created as sudo
21
_log command "Creating directories for fetched sources..."
AlmAck's avatar
AlmAck committed
22
_do sudo -u builder mkdir -p _sources
23

24 25 26
_log command "Creating directories for storing the logs..."
_do sudo -u builder mkdir -p _logs

27
_log command "Create local repository..."
28 29 30 31
local_repo_name="gitlab-ci"
_do sudo -u builder mkdir -p "_repo/$local_repo_name"
_do sudo -u builder touch "_repo/$local_repo_name/local-$local_repo_name.db.tar"
_do sudo -u builder ln -s "local-$local_repo_name.db.tar" "_repo/$local_repo_name/local-$local_repo_name.db"
32 33

_log command "Enable local repository..."
AlmAck's avatar
AlmAck committed
34
sed "/@CHROOT_NAME@/ s/^#\s*//" -i /etc/pacman.conf
35
sed "s/@CHROOT_NAME@/$local_repo_name/g" -i /etc/pacman.conf
36
sed s"|/chakra/_repo|$PWD/_repo|g" -i /etc/pacman.conf
37 38 39

# create a local makepkg settings
_log command "Setting up makepkg.conf..."
40
sudo -u builder echo "source /etc/makepkg.conf
41 42 43 44 45

#-- Make Flags: change this for DistCC/SMP systems
MAKEFLAGS=\"-j$(($(nproc)+1))\"

#-- Destination: specify a fixed directory where all packages will be placed
46
PKGDEST=$PWD/_repo/$local_repo_name
47
#-- Source cache: specify a fixed directory where source files will be cached
48
SRCDEST=$PWD/_sources
49 50
#-- Log cache: directory where the log files are stored
LOGDEST=$PWD/_logs
51
# variable required by makepkg (repo-add)
52
CHROOT=$local_repo_name
53 54

#-- Packager: name/email of the person or organization building packages
55
PACKAGER=\"$GITLAB_USER_LOGIN <$GITLAB_USER_EMAIL>\"" > /home/builder/.makepkg.conf
56

AlmAck's avatar
AlmAck committed
57

58
# resync with local database
59 60 61 62 63 64 65 66
_do pacman -Syyu --noconfirm

# patch current makepkg with chakra custom mods
# done at the end of the script to avoid
# troubles if pacman is being updated (makepkg overwritten)
_log command "Patching makepkg..."
_do wget https://code.chakralinux.org/tools/chakrabuildsystem/raw/master/chakra/bin/makepkg
_do cp makepkg /usr/bin/makepkg
67

68
# install additional packages required by the gitlab-ci-scripts
AlmAck's avatar
AlmAck committed
69
_do pacman -S --noconfirm python2
70 71

# Remove packages that are no longer installed from the cache
totte's avatar
totte committed
72
yes | pacman -Sccv --noconfirm