Commit 81bdafcf authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

*) update scripts/kicad-install.sh to use Github plugin for system footprints.

*) Add scripts/library-repos-install.sh for downloading *.pretty libraries and possibly using them.
*) Remove template/fp-* files, they are now at https://github.com/KiCad/kicad-library/template/*
   so they can be maintained by the library team.  However note that it is possible to break
   kicad-install.sh with uncoordinated changes to that github repo.

It is best to delete your ~/kicad_sources/kicad-lib.bzr directory before running kicad-install.sh
at this or any newer version relative to an older library repo.
parent 0e514e93
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -459,11 +459,6 @@ add_custom_target( uninstall
# Installation
#================================================

add_custom_target( install_user_configuration_files
    "${CMAKE_COMMAND}" -E copy "${PROJECT_SOURCE_DIR}/template/fp-lib-table" ${KICAD_USER_CONFIG_DIR}/
    COMMENT "Install template fp-lib-table into your home directory."
    )

install( FILES INSTALL.txt
    DESTINATION ${KICAD_DOCS}
    COMPONENT resources )
@@ -534,10 +529,6 @@ if( UNIX AND NOT APPLE )
    #set( CPACK_PACKAGE_CONTACT Firstname Lastname <email@company.com> )
    set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "KiCad built by CMake build system." )

    # Tell debian CPack about all files which are configuration files
    add_conffiles()         # clear file
    add_conffiles( ${KICAD_USER_CONFIG_DIR}/fp-lib-table )  # append to it

    include( CPack )

endif()
+49 −20
Original line number Diff line number Diff line
@@ -4,8 +4,25 @@
#  -> a Red Hat
# compatible linux system.
#
# The "install_prerequisites" step is the only "distro dependent" one.  Could modify
# that step for other linux distros.
# The "install_prerequisites" step is the only "distro dependent" one.  That step could be modified
# for other linux distros.
#
# There are 3 package groups in a KiCad install:
# 1) Compiled source code in the form of executable programs.
# 2) User manuals and other documentation typically as *.pdf files.
# 3) a) Schematic parts, b) layout footprints, and c) 3D models for footprints.
#
# To achieve 1) source is checked out from its repo and compiled by this script then executables
#  are installed using CMake.
# To achieve 2) documentation is checked out from its repo and installed using CMake.
# TO achieve 3a) and 3c) they are checked out from their repos and installed using CMake.
# To achieve 3b) a global fp-lib-table is put into your home directory which points to
#  http://github.com/KiCad.  No actual footprints are installed locally, internet access is used
#  during program operation to fetch footprints from github as if it was a remote drive in the cloud.
#  If you want to install those same KiCad footprints locally, you may run a separate script
#  named library-repos-install.sh found in this same directory.  That script requires that "git" be on
#  your system whereas this script does not.  The footprints require some means to download them and
#  bzr-git seems not up to the task.  wget or curl would also work.


# Set where the 3 source trees will go, use a full path
@@ -19,6 +36,8 @@ OPTS="$OPTS -DBUILD_GITHUB_PLUGIN=ON"
# Python scripting, uncomment to enable
#OPTS="$OPTS -DKICAD_SCRIPTING=ON -DKICAD_SCRIPTING_MODULES=ON -DKICAD_SCRIPTING_WXPYTHON=ON"

LIB_REPO=~kicad-testing-committers/kicad/library


usage()
{
@@ -30,6 +49,7 @@ usage()
    echo "      --install-or-update     (does full installation or update.)"
    echo "      --remove-sources        (removes source trees for another attempt.)"
    echo "      --uninstall-libraries   (removes KiCad supplied libraries.)"
    echo "      --uninstall-kicad       (uninstalls all of KiCad but leaves source trees.)"
    echo ""
    echo "example:"
    echo '    $ ./kicad-install.sh --install-or-update'
@@ -109,8 +129,6 @@ cmake_uninstall()
    elif [ ! -e install_manifest.txt  ]; then
        echo
        echo "Missing file $dir/install_manifest.txt."
        echo "Libraries may have already been uinstalled, or were not"
        echo 'originally installed with an "uninstall" knowledgable CMakeLists.txt file.'
    else
        echo "uninstalling from $dir"
        sudo make uninstall
@@ -145,15 +163,11 @@ install_or_update()
        cd ../
    fi


    echo "step 4) checking out the libraries from launchpad repo..."
    if [ ! -d "$WORKING_TREES/kicad-lib.bzr" ]; then
        bzr checkout lp:~dickelbeck/kicad/library-read-only kicad-lib.bzr
        bzr checkout "lp:$LIB_REPO" kicad-lib.bzr
        echo ' kicad-lib checked out.'
    else
        cd kicad-lib.bzr
        # change the name of the repo this checkout is bound to
        bzr bind lp:~dickelbeck/kicad/library-read-only
        bzr up
        echo ' kicad-lib repo updated.'
        cd ../
@@ -178,7 +192,6 @@ install_or_update()
        cmake $OPTS ../
    else
        cd build

        # Although a "make clean" is sometimes needed, more often than not it slows down the update
        # more than it is worth.  Do it manually if you need to in this directory.
        # make clean
@@ -192,13 +205,7 @@ install_or_update()
    echo " kicad program files installed."


    echo "step 8) as non-root, install user configuration files..."
    # install ~/fp-lib-table [and friends]
    make install_user_configuration_files
    echo " kicad user-configuration files installed."


    echo "step 9) installing libraries..."
    echo "step 8) installing libraries..."
    cd ../../kicad-lib.bzr
    rm_build_dir build
    mkdir build && cd build
@@ -207,6 +214,12 @@ install_or_update()
    echo " kicad-lib installed."


    echo "step 9) as non-root, install user configuration files..."
    # install ~/fp-lib-table
    make  install_github_fp-lib-table
    echo " kicad user-configuration files installed."


    echo "step 10) installing documentation..."
    cd ../../kicad-doc.bzr
    rm_build_dir build
@@ -242,4 +255,20 @@ if [ $# -eq 1 -a "$1" == "--uninstall-libraries" ]; then
    exit
fi


if [ $# -eq 1 -a "$1" == "--uninstall-kicad" ]; then
    cd "$WORKING_TREES/kicad.bzr/build"
    cmake_uninstall "$WORKING_TREES/kicad.bzr/build"

    cd "$WORKING_TREES/kicad-lib.bzr/build"
    cmake_uninstall "$WORKING_TREES/kicad-lib.bzr/build"

    # this may fail since "uninstall" support is a recent feature of this repo:
    cd "$WORKING_TREES/kicad-doc.bzr/build"
    cmake_uninstall "$WORKING_TREES/kicad-doc.bzr/build"

    exit
fi


usage
+168 −0
Original line number Diff line number Diff line
#!/bin/bash
# Git KiCad library repos:
#
# The "install_prerequisites" step is the only "distro dependent" one.  Could modify
# that step for other linux distros.
# This script requires "git".  The package bzr-git is not up to the task.
# The first time you run with option --install-or-update that is the slowest, because
# git clone from github.com is slow.
# After that updates should run faster.

# There are two reasons why you might want to run this script:
#
# 1) You want to contribute to the KiCad library team maintained libraries and have yet to
#    discover or have chosen not to use the COW feature in the Github "Plugin Type".
#
# 2) You want to run with local pretty footprint libraries and not those remotely located
#    on https://github.com using Github plugin.  After running this script you should be able to
#      a)  $ cp ~/kicad_sources/library-repos/kicad-library/template/fp-lib-table.for-pretty ~/fp-lib-table
#    and then
#      b) set your environment variable KISYSMOD to "~/kicad_sources/library-repos/kicad-library"
#    before starting pcbnew.  This will use the KiCad plugin against the *.pretty dirs in that base dir.



# Set where the library repos will go, use a full path
WORKING_TREES=~/kicad_sources


usage()
{
    echo ""
    echo " usage:"
    echo ""
    echo "./library-sources-install.sh <cmd>"
    echo "    where <cmd> is one of:"
    echo "      --install-or-update         (of the library sources.)"
    echo "      --remove-all-sources        (remove all source trees.)"
    echo "      --install-prerequisites     (install command tools needed here, run once first.)"
#    echo "      --uninstall-libraries       (remove KiCad supplied libraries which have been installed.)"
    echo ""
    echo "example:"
    echo '    $ ./library-sources-install.sh --install-or-update'
}


install_prerequisites()
{
    # Find a package manager, PM
    PM=$( command -v yum || command -v apt-get )

    # assume all these Debian, Mint, Ubuntu systems have same prerequisites
    if [ "$(expr match "$PM" '.*\(apt-get\)')" == "apt-get" ]; then
        #echo "debian compatible system"
        sudo apt-get install \
            git \
            curl \
            sed

    # assume all yum systems have same prerequisites
    elif [ "$(expr match "$PM" '.*\(yum\)')" == "yum" ]; then
        #echo "red hat compatible system"
        # Note: if you find this list not to be accurate, please submit a patch:
        sudo yum install \
            git \
            curl \
            sed
    else
        echo
        echo "Incompatible System. Neither 'yum' nor 'apt-get' found. Not possible to continue."
        echo
        exit 1
    fi
}


rm_build_dir()
{
    local dir="$1"
    # this file is often created as root, so remove as root
    sudo rm "$dir/install_manifest.txt" 2> /dev/null
    rm -rf "$dir"
}


cmake_uninstall()
{
    # assume caller set the CWD, and is only telling us about it in $1
    local dir="$1"

    cwd=`pwd`
    if [ "$cwd" != "$dir" ]; then
        echo "missing dir $dir"
    elif [ ! -e install_manifest.txt  ]; then
        echo
        echo "Missing file $dir/install_manifest.txt."
    else
        echo "uninstalling from $dir"
        sudo make uninstall
        sudo rm install_manifest.txt
    fi
}


detect_pretty_repos()
{
    # Use github API to list repos for org KiCad, then subset the JSON reply for only
    # *.pretty repos
    PRETTY_REPOS=`curl https://api.github.com/orgs/KiCad/repos?per_page=2000 2> /dev/null \
        | grep full_name | grep pretty \
        | sed -r  's:.+ "KiCad/(.+)",:\1:'`

    #echo "PRETTY_REPOS:$PRETTY_REPOS"
}


checkout_or_update_libraries()
{
    if [ ! -d "$WORKING_TREES" ]; then
        sudo mkdir -p "$WORKING_TREES"
        echo " mark $WORKING_TREES as owned by me"
        sudo chown -R `whoami` "$WORKING_TREES"
    fi
    cd $WORKING_TREES

    detect_pretty_repos

    if [ ! -e "$WORKING_TREES/library-repos" ]; then
        mkdir -p "$WORKING_TREES/library-repos"
    fi

    for repo in kicad-library $PRETTY_REPOS; do
        # echo "repo:$repo"

        if [ ! -e "$WORKING_TREES/library-repos/$repo" ]; then

            # Be _sure_ and preserve the directory name, we want extension .pretty not .pretty.git.
            # That way those repos can serve as pretty libraries directly if need be.

            echo "installing $WORKING_TREES/library-repos/$repo"
            git clone "https://github.com/KiCad/$repo" "$WORKING_TREES/library-repos/$repo"
        else
            echo "updating $WORKING_TREES/library-repos/$repo"
            cd "$WORKING_TREES/library-repos/$repo"
            git pull
        fi
    done
}


if [ $# -eq 1 -a "$1" == "--install-or-update" ]; then
    checkout_or_update_libraries
    exit
fi


if [ $# -eq 1 -a "$1" == "--remove-all-sources" ]; then
    rm -rf "$WORKING_TREES/library-repos"
    exit
fi


if [ $# -eq 1 -a "$1" == "--install-prerequisites" ]; then
    install_prerequisites
    exit
fi


usage

scripts/make_global_table.sh

deleted100755 → 0
+0 −68
Original line number Diff line number Diff line
#!/bin/sh
# Generate a footprint library table which can serve as a sensible initial
# personal/global table assuming you have all the footprint libraries installed
# from the bazaar library repo.
# Copyright (C) 2007-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
# License GPLv2

# This program makes the table either in s-expression or CSV format.
# The CSV format can be loaded into a spreadsheet and then from there rows
# can be copied into either of the fp_table_dialog's table editors:
# a) personal/global or b) project


# Usage:
# $ make_global_table.sh [--csv] > outputfile

# Library Type:  Legacy for now, Kicad in future
libtype="Legacy"


# Get a list of modules currently in the launchpad repo:
mods=`bzr ls -d lp:~kicad-lib-committers/kicad/library modules 2>/dev/null`
#echo "$mods"

mods=`echo "$mods" | egrep '\.mod$' | sort`
#echo "$mods"

csv=0

if [ $# -gt 0  -a "$1" == "--csv" ]; then
    csv=1
fi

today=`date --rfc-3339=date`

if [ $csv -eq 1 ]; then
    echo "NICKNAME,TYPE,URI,OPTIONS,DESCR,,FP LIB TABLE: made from KiCad's Bazaar 'library' repository on $today"
    echo

    echo "$mods" | while read mod;
    do
        # base filename w/o extension
        bfn=`basename $mod .mod`

        printf '%s,%s,${KISYSMOD}/%s,"",""\n' \
            "$bfn" \
            "$libtype" \
            "$bfn.mod"
    done

else

    echo "# FP LIB TABLE: made from KiCad's Bazaar 'library' repository on $today"
    echo "(fp_lib_table"

    echo "$mods" | while read mod;
    do
        # base filename w/o extension
        bfn=`basename $mod .mod`

        printf ' (lib (name %s)(type %s)(uri ${KISYSMOD}/%s)(options "")(descr ""))\n' \
            "$bfn" \
            "$libtype" \
            "$bfn.mod"
    done

    echo ")"
fi
+0 −4
Original line number Diff line number Diff line
install( FILES
    kicad.pro
    fp-lib-table
    fp-lib-table.csv
    fp-lib-table.for-github
    fp-lib-table.for-eagle-6.4.0
    gost_landscape.kicad_wks
    gost_portrait.kicad_wks
    pagelayout_default.kicad_wks
Loading