User Tools

Site Tools


developer_documentation

This is an old revision of the document!


Developer Documentation

Implementation Overview

The basic idea behind the implementation of Gargoyle is to do as much of the computation on the client side as possible. The router typically has a 200mhz processor, 32MB or less of RAM and 8MB or less of disk (flash drive) space. The clients connecting will typically have multi-GHz processors and over 512 MB of RAM. Even without considering delay introduced by the network connection, which do you think is going to be faster? Therefore, the majority of Gargoyle is implemented as Javascript. This results in a much faster, more flexible “feel” to Gargoyle. Source files for the javascript can be found in the /www/js directory.

The server-side scripting that is necessary is done using haserl, a very lightweight utility that enables the embedding of shell script into html files. The html/haserl scripts are the *.sh files in the /www directory. This is the same mechanism that X-wrt uses to run server-side scripts, although X-wrt tends to rely much more heavily on these scripts and much less on javascript.

The /www/utility directory contains shell scripts that are never displayed directly by the browser. In particular note the /www/utility/run_commands.sh script. This script is passed a single variable (computed by javascript) which contains a list of shell script commands to execute, which it then does. Yes, this IS a giant, gaping security hole – or would be if access to the router web interface didn't already mean that you could gain complete access to the system. Why bother creating a correctly formatted http request to run your commands when you could just go to the system/access page, change the root password, and then give yourself remote ssh access? If you have access to the gargoyle interface, by definition you already have complete control of the router.

The /www/utility/ directory also contains several scripts for restarting things. It's generally better to use these scripts to restart things because when you restart one module several others that depend on it may need to be restarted as well. In particular, the firewall, QoS and Bandwidth modules depend heavily on each other. Restarting everything could be accomplished by rebooting the router, but merely using these scripts is a more elegant solution.

The header/footer code is generated from the /etc/config/gargoyle config file by a utility written in C. This is necessary, as shell scripts execute slow enough to make loading the page take forever. You can use the /etc/config/gargoyle config file to disable/enable display of pages in the menu. This is how the qos_distributions page is enabled whenever qos is active and disabbled whenever qos is no longer active. The script section associates a shell script file name with an id for each section. The id must be of the form [SECTION-ID]_[PAGE-ID]. Similarly the display section associates a name to display with each page, as well as each section. There is also a section in the config for each menu section. The section is associated with a number as is each sub-section, defined as the options within the config section. These numbers indicate the order that the subsections will appear in the menu. To prevent a page from being displayed just remove it from the menu subsection it is in. A whole section can be removed by deleting the entire config section. It is not necessary to delete the page information in the scripts and/or display section.

To genenerate the menu from the config file the gargoyle_header_footer utility is then run with options that specify the section and page:

 -m Generate Minimal Header (for popup boxes used for editing table rows)  
 -h Generate Standard Header 
 -f Generate Footer 
 -s [SECTION-ID] Section/Main Menu Id 
 -p [PAGE-ID] Page Id 
 -c [CSS FILES] List of additional css files necessary for page 
 -j [JS FILES] List of additional javascript files necessary for page 
 -t [TITLE] Title of page 
 -i Include output of javascript variables that specify network interface ips and MAC addresses  

The utility is run once at the beginning of the page with the -h option to generate a header and once at the end with the -f option to generate the footer. The source for the gargoyle_header_footer utility is included in the /src subdirectory of the gargoyle package.

For more information about writing/compiling C/C++ programs for OpenWrt you may find this tutorial helpful.

This documentation is incomplete and there are probably many subtle points that should be addressed here and are not. However, this should be enough information to get started working with Gargoyle. If you have questions post to the forum or contact the author directly. This page will be updated as issues and points of interest are raised in the forum and via email.

Building from source

The best way to obtain the latest Gargoyle source code is to clone the public Git repository.

You can browse the repository online here, or clone from one of the URLs below. There is both a local copy of the repository and a Github mirror: <shell> apt-get install git git clone git:gargoyle-router.com/gargoyle.git </shell> <shell> git clone http://gargoyle-router.com/git/gargoyle.git git clone git:gargoyle-router.com/gargoyle.git git clone http://github.com/ericpaulbishop/gargoyle.git git clone git:github.com/ericpaulbishop/gargoyle.git </shell> If you want to build an older branch or tag, use the “git checkout” to switch to it after cloning the repository. e.g. to switch to the 1.2 branch: <shell> git checkout 1.2 </shell> Anyone who still prefers working with subversion can make use of the subversion support provided by the github mirror: <shell> svn checkout http://svn.github.com/ericpaulbishop/gargoyle.git </shell> <shell> cd gargoyle </shell> <shell> make </shell> You'll notice there are two scripts in the build directory: full-build.sh and rebuild.sh If you run make without the FULL_BUILD=true flag, and you've previously done a build, it will only rebuild the packages and not the underlying version of OpenWrt. This speeds up testing small changes in the packages dramatically. However, to do a complete build from scratch you really need to run the make command with “FULL_BUILD=true” set: <shell> make FULL_BUILD=true </shell> Or to build (for example) just the ar71xx architecture: <shell> make FULL_BUILD=true ar71xx </shell> Allow building of only one profile for a given architecture by running e.g. “make ar71xx.usb_large” to build usb_large profile instead of all ar71xx profiles <shell> make ar71xx.usb_large </shell> ar71xx profiles * default * routerstation * usb * usb_large * usb_large_nand You can see which routers are included in each profile by opening the file “profile_images” inside the profiles directory (targets/ar71xx/profiles). ===== Building ===== Building Gargoyle for the first time for even one supported platform can take several hours of churning on your computer. In addition you can expect each platform to require about 1.6GB of disk space so keep this in mind when deciding how many platforms you will build on your first attempt. Finally, be aware that only the components unique to Gargoyle are stored in the Gargoyle svn. Therefore, in order to build gargoyle, the build process must first download many additional components. If you do not have an internet connection, the build will fail. If it is a slow connection, the build will take a very,very long time. Before you can build Gargoyle, you will require the appropriate tools to build OpenWRT. To install these (list edited to add the additional things missing on Ubuntu Server 10.10), use the following on a 32 bit system: <shell> sudo apt-get install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev subversion flex uglifyjs texinfo </shell> Or for a 64 bit system: <shell> sudo apt-get install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo </shell> NOTE: To save build time, consider also installing npm, which will also install nodejs as a dependency. It is recommended that you install nodejs v6.13.1 (or equivalent) and npm v3.10.10 (or equivalent). See below For more details on building OpenWRT, you can see their wiki page here. Simply entering: <shell> make </shell> will result in all targets being built. If you prefer to build a single target (in this example ar71xx, though you could substitute brcm47xx or another valid target), enter: <shell> make ar71xx </shell> The makefile calls the full-build-backfire.sh script found in the same directory. This script controls the overall build process. In addition to the makefile and the build script you will find these subdirectories in the Gargoyle root build directory: dev-utils/ This directory contains a few scripts that can be useful to developers. They are not used during the normal build process. fon-flash/ This directory contains code for the fon-flash utility, for flashing redboot based routers. Technically, this is not part of Gargoyle, but it is closely associated with the project, so it's here. This does not automatically get built – to build fon-flash you need to cd into this directory and explicitly build it. netfilter-match-modules/ This directory contains Gargoyle specific extensions to netfilter. These are used in Gargoyle to implement bandwidth monitoring,quotas,time range matching and web url matching. This code is separate from the package directory because they need to be applied as kernel patches before the kernel is built. Because Gargoyle/OpenWrt supports multiple kernels, the necessary patch files are computed from source files at build time. This makes it a lot easier to make changes to the netfilter modules since a new patch doesn't have to be pieced together by hand every time a change is made. package/ This directory contains the majority of Gargoyle sources. Each subdirectory is an OpenWrt package. For the most part these are specific to Gargoyle. These packages are installed in the target directories after the OpenWrt kernel for that target is built. patches-generic/ This directory contains Gargoyle specific kernel patches. These are applied to OpenWrt sources in each target directory before the kernel is built. Unlike the netfilter-match-module situation these patches are manually created so changes to them are more tedious. sched-modules/ This directory, for now, is just a placeholder. It contains a script that, in the future, may be used to incorporate custom packet scheduling modules (for QoS) into the kernel, much as the netfilter-match-modules folder contains custom netfilter modules. targets/ This directory contains the configuration files needed to properly build Gargoyle on each of the platforms it supports. There is a profiles subdirectory for each target, and there may also be a patches subdirectory for target-specific patches. Within the profiles subdirectory there will be one or more directories, each containing a config file (the openwrt .config file for this profile), and a profile_images file which specifies which target images this configuration profile applies to. Only images matching the patterns listed in this file will be copied to the images/[arch]/ directory. The .config file for each target drives the entire build process. You can examine these .config files to see which options are enabled for each target. There are some differences due to the different RAM and FLASH availability in various models. A target may have a patches subdirectory. If it does then this directory contains patches specific to the target. These patches are applied only during the build of the indicated target and only after the generic patches are applied. The above directories are the ones in the Gargoyle Git. After running make additional directories are created on your box as follows: downloaded/ The process of building Gargoyle and OpenWRT requires downloading packages from the internet. These packages can be rather large so rather than download them each time you build, Gargoyle creates this local “cache” of packages it downloads. Each time you build the script will compare the cache with the latest available and only downloads them when required. This speeds subsequent builds especially on slow internet connections. This directory also contains the OpenWrt sources downloaded from svn.openwrt.org/openwrt/branches/backfire. <target>-src/ When a target is built the backfire-src directory (which is never modified) is copied to this directory, where an openwrt build environment for the desired target is configured. The contents of this directory can be treated exactly as you would any other OpenWrt build environment – this is just specifically setup/configured to build Gargoyle. built/<target> This directroy contains all of the OpenWrt package files (*.ipk) built for Gargoyle. If everything goes well all the packages which are a standard part of Gargoyle end up here. A complete set of packages is built for each target. images/<target> The image output directory. Once all the output packages are built we can make images. These are the .bin and .trx files often used to flash routers. There will be a complete set of images for each target you build. It is also possible to build Gargoyle using a custom build configuration. The process of building OpenWRT involves a configuration step in which packages are either included or excluded from the build image. Due to a lack of memory space on most routers it is not possible to included every package. The architecture of OpenWRT allows most packages not included in the original build image to be installed later if they are needed and space is available. So the general philosophy is to build with the least code practical in order to support routers with the least available memory. If you wish to create your own image with a different set of packages in the base image you should run make custom. <shell> make custom </shell> or a different profile <shell> make custom x86 </shell> You will then be given access to the OpenWrt menuconfig screen and can select the packages you want to include in your base image. ==== Installing Nodejs 6.13.1 and NPM 3.10.10 on Ubuntu ==== For compatibility reasons, it is recommended to use these versions of NodeJS and NPM. To do so: <code bash> curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh sudo bash nodesource_setup.sh sudo apt-get install nodejs nodejs -v npm -v </code> The contents of nodesource_setup.sh are preserved below for posterity: <code bash> #!/bin/bash # Discussion, issues and change requests at: # https://github.com/nodesource/distributions # # Script to install the NodeSource Node.js v6.x LTS Boron repo onto a # Debian or Ubuntu system. # # Run as root or insert `sudo -E` before `bash`: # # curl -sL https://deb.nodesource.com/setup_6.x | bash - # or # wget -qO- https://deb.nodesource.com/setup_6.x | bash - # export DEBIAN_FRONTEND=noninteractive SCRSUFFIX=“_6.x” NODENAME=“Node.js v6.x LTS Boron” NODEREPO=“node_6.x” NODEPKG=“nodejs” print_status() { echo echo “## $1” echo } if test -t 1; then # if terminal ncolors=$(which tput > /dev/null && tput colors) # supports color if test -n “$ncolors” && test $ncolors -ge 8; then termcols=$(tput cols) bold=“$(tput bold)” underline=“$(tput smul)” standout=“$(tput smso)” normal=“$(tput sgr0)” black=“$(tput setaf 0)” red=“$(tput setaf 1)” green=“$(tput setaf 2)” yellow=“$(tput setaf 3)” blue=“$(tput setaf 4)” magenta=“$(tput setaf 5)” cyan=“$(tput setaf 6)” white=“$(tput setaf 7)” fi fi print_bold() { title=“$1” text=“$2” echo echo “${red}================================================================================${normal}” echo “${red}================================================================================${normal}” echo echo -e “ ${bold}${yellow}${title}${normal}” echo echo -en “ ${text}” echo echo “${red}================================================================================${normal}” echo “${red}================================================================================${normal}” } bail() { echo 'Error executing command, exiting' exit 1 } exec_cmd_nobail() { echo “+ $1” bash -c “$1” } exec_cmd() { exec_cmd_nobail “$1” || bail } node_deprecation_warning() { if | "X${NODENAME}" == "Xio.js v2.x" || "X${NODENAME}" == "Xio.js v3.x" || "X${NODENAME}" == "XNode.js v5.x" ; then print_bold \ “ DEPRECATION WARNING ” “\ ${bold}${NODENAME} is no longer actively supported!${normal} ${bold}You will not receive security or critical stability updates${normal} for this version. You should migrate to a supported version of Node.js as soon as possible. Use the installation script that corresponds to the version of Node.js you wish to install. e.g. * ${green}https://deb.nodesource.com/setup_4.x — Node.js v4 LTS \”Argon\“${normal} (recommended) * ${green}https://deb.nodesource.com/setup_6.x — Node.js v6 Current${normal} Please see ${bold}https://github.com/nodejs/LTS/${normal} for details about which version may be appropriate for you. The ${bold}NodeSource${normal} Node.js Linux distributions GitHub repository contains information about which versions of Node.js and which Linux distributions are supported and how to use the install scripts. ${bold}https://github.com/nodesource/distributions${normal} ” echo echo “Continuing in 10 seconds …” echo sleep 10 elif [ “X${NODENAME}” == “XNode.js v0.10” ]; then print_bold \ “ NODE.JS v0.10 DEPRECATION WARNING ” “\ Node.js v0.10 will cease to be actively supported in ${bold}October 2016${normal}. This means you will not continue to receive security or critical stability updates for this version of Node.js beyond that time. You should begin migration to a newer version of Node.js as soon as possible. Use the installation script that corresponds to the version of Node.js you wish to install. e.g. * ${green}https://deb.nodesource.com/setup_4.x — Node.js v4 LTS \”Argon\“${normal} (recommended) * ${green}https://deb.nodesource.com/setup_6.x — Node.js v6 Current${normal} Please see ${bold}https://github.com/nodejs/LTS/${normal} for details about which version may be appropriate for you. The ${bold}NodeSource${normal} Node.js Linux distributions GitHub repository contains information about which versions of Node.js and which Linux distributions are supported and how to use the install scripts. ${bold}https://github.com/nodesource/distributions${normal} ” echo echo “Continuing in 5 seconds …” echo sleep 5 elif [ “X${NODENAME}” == “XNode.js v0.12” ]; then print_bold \ “ NODE.JS v0.12 DEPRECATION WARNING ” “\ Node.js v0.12 will cease to be actively supported ${bold}at the end of 2016${normal}. This means you will not continue to receive security or critical stability updates for this version of Node.js beyond that time. You should begin migration to a newer version of Node.js as soon as possible. Use the installation script that corresponds to the version of Node.js you wish to install. e.g. * ${green}https://deb.nodesource.com/setup_4.x — Node.js v4 LTS \”Argon\“${normal} (recommended) * ${green}https://deb.nodesource.com/setup_6.x — Node.js v6 Current${normal} Please see ${bold}https://github.com/nodejs/LTS/${normal} for details about which version may be appropriate for you. The ${bold}NodeSource${normal} Node.js Linux distributions GitHub repository contains information about which versions of Node.js and which Linux distributions are supported and how to use the install scripts. ${bold}https://github.com/nodesource/distributions${normal} ” echo echo “Continuing in 3 seconds …” echo sleep 3 fi } script_deprecation_warning() { if [ “X${SCRSUFFIX}” == “X” ]; then print_bold \ “ SCRIPT DEPRECATION WARNING ” “\ This script, located at ${bold}https://deb.nodesource.com/setup${normal}, used to install Node.js v0.10, is being deprecated and will eventually be made inactive. You should use the script that corresponds to the version of Node.js you wish to install. e.g. * ${green}https://deb.nodesource.com/setup_4.x — Node.js v4 LTS \”Argon\“${normal} (recommended) * ${green}https://deb.nodesource.com/setup_6.x — Node.js v6 Current${normal} Please see ${bold}https://github.com/nodejs/LTS/${normal} for details about which version may be appropriate for you. The ${bold}NodeSource${normal} Node.js Linux distributions GitHub repository contains information about which versions of Node.js and which Linux distributions are supported and how to use the install scripts. ${bold}https://github.com/nodesource/distributions${normal} ” echo echo “Continuing in 10 seconds (press Ctrl-C to abort) …” echo sleep 10 fi } setup() { script_deprecation_warning print_status “Installing the NodeSource ${NODENAME} repo…” if $(uname -m | grep -Eq ^armv6); then print_status “You appear to be running on ARMv6 hardware. Unfortunately this is not currently supported by the NodeSource Linux distributions. Please use the 'linux-armv6l' binary tarballs available directly from nodejs.org for Node.js v4 and later.” exit 1 fi PRE_INSTALL_PKGS=“” # Check that HTTPS transport is available to APT # (Check snaked from: https://get.docker.io/ubuntu/) if [ ! -e /usr/lib/apt/methods/https ]; then PRE_INSTALL_PKGS=“${PRE_INSTALL_PKGS} apt-transport-https” fi if [ ! -x /usr/bin/lsb_release ]; then PRE_INSTALL_PKGS=“${PRE_INSTALL_PKGS} lsb-release” fi if [ ! -x /usr/bin/curl ] && [ ! -x /usr/bin/wget ]; then PRE_INSTALL_PKGS=“${PRE_INSTALL_PKGS} curl” fi # Populating Cache print_status “Populating apt-get cache…” exec_cmd 'apt-get update' if [ “X${PRE_INSTALL_PKGS}” != “X” ]; then print_status “Installing packages required for setup:${PRE_INSTALL_PKGS}…” # This next command needs to be redirected to /dev/null or the script will bork # in some environments exec_cmd “apt-get install -y${PRE_INSTALL_PKGS} > /dev/null 2>&1” fi IS_PRERELEASE=$(lsb_release -d | grep 'Ubuntu .*development' >& /dev/null; echo $?) if $IS_PRERELEASE -eq 0; then print_status “Your distribution, identified as \”$(lsb_release -d -s)\“, is a pre-release version of Ubuntu. NodeSource does not maintain official support for Ubuntu versions until they are formally released. You can try using the manual installation instructions available at https://github.com/nodesource/distributions and use the latest supported Ubuntu version name as the distribution identifier, although this is not guaranteed to work.” exit 1 fi DISTRO=$(lsb_release -c -s) check_alt() { if [ “X${DISTRO}” == “X${2}” ]; then echo echo “## You seem to be using ${1} version ${DISTRO}.” echo “## This maps to ${3} \”${4}\“… Adjusting for you…” DISTRO=“${4}” fi } check_alt “Kali” “sana” “Debian” “jessie” check_alt “Kali” “kali-rolling” “Debian” “jessie” check_alt “Sparky Linux” “Nibiru” “Debian” “buster” check_alt “Linux Mint” “maya” “Ubuntu” “precise” check_alt “Linux Mint” “qiana” “Ubuntu” “trusty” check_alt “Linux Mint” “rafaela” “Ubuntu” “trusty” check_alt “Linux Mint” “rebecca” “Ubuntu” “trusty” check_alt “Linux Mint” “rosa” “Ubuntu” “trusty” check_alt “Linux Mint” “sarah” “Ubuntu” “xenial” check_alt “Linux Mint” “serena” “Ubuntu” “xenial” check_alt “Linux Mint” “sonya” “Ubuntu” “xenial” check_alt “Linux Mint” “sylvia” “Ubuntu” “xenial” check_alt “LMDE” “betsy” “Debian” “jessie” check_alt “elementaryOS” “luna” “Ubuntu” “precise” check_alt “elementaryOS” “freya” “Ubuntu” “trusty” check_alt “elementaryOS” “loki” “Ubuntu” “xenial” check_alt “Trisquel” “toutatis” “Ubuntu” “precise” check_alt “Trisquel” “belenos” “Ubuntu” “trusty” check_alt “Trisquel” “flidas” “Ubuntu” “xenial” check_alt “BOSS” “anokha” “Debian” “wheezy” check_alt “bunsenlabs” “bunsen-hydrogen” “Debian” “jessie” check_alt “Tanglu” “chromodoris” “Debian” “jessie” check_alt “Devuan” “ceres” “Debian” “sid” check_alt “PureOS” “green” “Debian” “sid” if [ “X${DISTRO}” == “Xdebian” ]; then print_status “Unknown Debian-based distribution, checking /etc/debian_version…” NEWDISTRO=$([ -e /etc/debian_version ] && cut -d/ -f1 < /etc/debian_version) if [ “X${NEWDISTRO}” == “X” ]; then print_status “Could not determine distribution from /etc/debian_version…” else DISTRO=$NEWDISTRO print_status “Found \”${DISTRO}\“ in /etc/debian_version…” fi fi print_status “Confirming \”${DISTRO}\“ is supported…” if [ -x /usr/bin/curl ]; then exec_cmd_nobail “curl -sLf -o /dev/null 'https://deb.nodesource.com/${NODEREPO}/dists/${DISTRO}/Release'” RC=$? else exec_cmd_nobail “wget -qO /dev/null -o /dev/null 'https://deb.nodesource.com/${NODEREPO}/dists/${DISTRO}/Release'” RC=$? fi if $RC != 0; then print_status “Your distribution, identified as \”${DISTRO}\“, is not currently supported, please contact NodeSource at https://github.com/nodesource/distributions/issues if you think this is incorrect or would like your distribution to be considered for support” exit 1 fi if [ -f “/etc/apt/sources.list.d/chris-lea-node_js-$DISTRO.list” ]; then print_status 'Removing Launchpad PPA Repository for NodeJS…' exec_cmd_nobail 'add-apt-repository -y -r ppa:chris-lea/node.js' exec_cmd “rm -f /etc/apt/sources.list.d/chris-lea-node_js-${DISTRO}.list” fi print_status 'Adding the NodeSource signing key to your keyring…' if [ -x /usr/bin/curl ]; then exec_cmd 'curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -' else exec_cmd 'wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -' fi print_status “Creating apt sources list file for the NodeSource ${NODENAME} repo…” exec_cmd “echo 'deb https://deb.nodesource.com/${NODEREPO} ${DISTRO} main' > /etc/apt/sources.list.d/nodesource.list” exec_cmd “echo 'deb-src https://deb.nodesource.com/${NODEREPO} ${DISTRO} main' » /etc/apt/sources.list.d/nodesource.list” print_status 'Running `apt-get update` for you…' exec_cmd 'apt-get update' node_deprecation_warning print_status “Run \`apt-get install ${NODEPKG}\` (as root) to install ${NODENAME} and npm” } ## Defer setup until we have the complete script setup </code> The same steps may work on other OSes ===== Building Older Versions of Gargoyle ===== Due to changes in upstream infrastructure, some of the older Gargoyle revisions no longer build out of the box. The following is a patch to restore 1.8.1 (or any Barrier Breaker 14.07 based version of Gargoyle) builds to build correctly: <code diff> — a/build.sh +++ b/build.sh @@ -21,15 +21,17 @@ set_version_variables() #openwrt branch branch_name=“Barrier Breaker” - branch_id=“barrier_breaker” + branch_id=“14.07” branch_is_trunk=“0” - branch_packages_path=“branches/packages_14.07” + branch_packages_path=“packages” - # set svn revision number to use - # you can set this to an alternate revision + # set precise commit in repo to use + # you can set this to an alternate commit # or empty to checkout latest - rnum=46817 + openwrt_commit=“a0847febf3afac0997b821f62be8c91e00e25fa0” + openwrt_abbrev_commit=$( echo “$openwrt_commit” | cut -b 1-7 ) + #set date here, so it's guaranteed the same for all images #even though build can take several hours @@ -82,7 +84,7 @@ create_gargoyle_banner() local gargoyle_version=“$4” local gargoyle_commit=“$5” local openwrt_branch=“$6” - local openwrt_revision=“$7” + local openwrt_cmt=“$7” local banner_file_path=“$8” local revision_save_dir=“$9” @@ -92,7 +94,7 @@ create_gargoyle_banner() fi local top_line=$(printf “| %-26s| %-35s|” “Gargoyle version $gargoyle_version” “$openwrt_branch_str”) - local middle_line=$(printf “| %-26s| %-35s|” “Gargoyle revision $gargoyle_commit” “OpenWrt revision r$openwrt_revision”) + local middle_line=$(printf “| %-26s| %-35s|” “Gargoyle revision $gargoyle_commit” “OpenWrt commit $openwrt_cmt”) local bottom_line=$(printf “| %-26s| %-35s|” “Built $date” “Target $target/$profile”) cat « 'EOF' >“$banner_file_path” @@ -198,7 +200,6 @@ distrib_init () fi #git log –since=5/16/2013 $(git log -1 –pretty=format:%h) –pretty=format:“%h%x09%ad%x09%s” –date=short > “$top_dir/Distribution/changelog.txt” git log $(git describe –abbrev=0 –tags)..$(git log -1 –pretty=format:%h) –no-merges –pretty=format:“%h%x09%ad%x09%s” –date=short > “$top_dir/Distribution/Gargoyle changelog.txt” - svn log -r “$rnum”:36425 svn:svn.openwrt.org/openwrt/branches/attitude_adjustment/ > “$top_dir/Distribution/OpenWrt changelog.txt” cp -fR “$top_dir/LICENSES” “$top_dir/Distribution/” }

@@ -334,9 +335,9 @@ fi

openwrt_src_dir=“$top_dir/downloaded/$branch_id” openwrt_package_dir=“$top_dir/downloaded/$branch_id-packages” -if [ -n “$rnum” ] ; then - openwrt_src_dir=“$top_dir/downloaded/$branch_id-$rnum” - openwrt_package_dir=“$top_dir/downloaded/$branch_id-packages-$rnum” +if [ -n “$openwrt_commit” ] ; then + openwrt_src_dir=“$top_dir/downloaded/$branch_id-${openwrt_abbrev_commit}” + openwrt_package_dir=“$top_dir/downloaded/$branch_id-packages-${openwrt_abbrev_commit}” else rm -rf “$openwrt_src_dir” rm -rf “$openwrt_package_dir” @@ -345,23 +346,22 @@ fi

#download openwrt source if we haven't already if [ ! -d “$openwrt_src_dir” ] ; then - revision=“” - if [ -n “$rnum” ] ; then - revision=“ -r $rnum ” - fi echo “fetching openwrt source” rm -rf “$branch_name” “$branch_id” if [ “$branch_is_trunk” = “1” ] ; then - svn checkout $revision svn:svn.openwrt.org/openwrt/trunk “$branch_id” + git clone git:git.openwrt.org/openwrt.git “$openwrt_src_dir” else - svn checkout $revision svn:svn.openwrt.org/openwrt/branches/$branch_id/ + git clone git:git.archive.openwrt.org/$branch_id/openwrt.git “$openwrt_src_dir” fi - if [ ! -d “$branch_id” ] ; then + if [ ! -d “$openwrt_src_dir” ] ; then echo “ERROR: could not download source, exiting” exit fi - cd “$branch_id” - find . -name “.svn” | xargs -r rm -rf + if [ -n “$openwrt_commit” ] ; then + cd “$openwrt_src_dir” + git checkout “$openwrt_commit” + fi + cd “$top_dir” mv “$branch_id” “$openwrt_src_dir” fi @@ -475,14 +475,10 @@ for target in $targets ; do if [ “$target” = “custom” ] ; then if [ ! -d “$openwrt_package_dir” ] ; then

- if [ “$branch_is_trunk” = “1” ] ; then - svn checkout $revision svn:svn.openwrt.org/openwrt/packages “$openwrt_package_dir” - else - svn checkout $revision “svn:svn.openwrt.org/openwrt/$branch_packages_path” “$openwrt_package_dir” - fi + git clone git:git.openwrt.org/packages.git “$openwrt_package_dir” cd “$openwrt_package_dir” - find . -name “.svn” | xargs rm -rf + for gp in $gargoyle_packages ; do IFS_ORIG=“$IFS” IFS_LINEBREAK=“$(printf '\n\r')” @@ -507,10 +503,9 @@ for target in $targets ; do - #enter build directory and make sure we get rid of all those pesky .svn files, - #and any crap left over from editing + #enter build directory and make sure we get rid of + #any crap left over from editing cd “$top_dir/$target-src” - find . -name “.svn” | xargs rm -rf find . -name “*~” | xargs rm -rf find . -name “.*sw*” | xargs rm -rf @@ -534,7 +529,7 @@ for target in $targets ; do openwrt_target=$(get_target_from_config “./.config”) - create_gargoyle_banner “$openwrt_target” “$profile_name” “$build_date” “$short_gargoyle_version” “$gargoyle_git_revision” “$branch_name” “$rnum” “package/base-files/files/etc/banner” “.” + create_gargoyle_banner “$openwrt_target” “$profile_name” “$build_date” “$short_gargoyle_version” “$gargoyle_git_revision” “$branch_name” “$openwrt_abbrev_commit” “package/base-files/files/etc/banner” “.” make $num_build_thread_str GARGOYLE_VERSION=“$numeric_gargoyle_version” GARGOYLE_VERSION_NAME=“$lower_short_gargoyle_version” GARGOYLE_PROFILE=“$default_profile” @@ -551,7 +546,7 @@ for target in $targets ; do openwrt_target=$(get_target_from_config “./.config”) - create_gargoyle_banner “$openwrt_target” “$profile_name” “$build_date” “$short_gargoyle_version” “$gargoyle_git_revision” “$branch_name” “$rnum” “package/base-files/files/etc/banner” “.” + create_gargoyle_banner “$openwrt_target” “$profile_name” “$build_date” “$short_gargoyle_version” “$gargoyle_git_revision” “$branch_name” “$openwrt_abbrev_commit” “package/base-files/files/etc/banner” “.” make $num_build_thread_str V=99 GARGOYLE_VERSION=“$numeric_gargoyle_version” GARGOYLE_VERSION_NAME=“$lower_short_gargoyle_version” GARGOYLE_PROFILE=“$default_profile” @@ -565,8 +560,9 @@ for target in $targets ; do #copy packages to built/target directory mkdir -p “$top_dir/built/$target/$default_profile” - package_files=$(find bin -name “*.ipk”) - index_files=$(find bin -name “Packa*”) + package_base_dir=$(find bin -name “base”) + package_files=$(find “$package_base_dir” -name “*.ipk”) + index_files=$(find “$package_base_dir” -name “Packa*”) if [ -n “$package_files” ] && [ -n “$index_files” ] ; then for pf in $package_files ; do @@ -643,7 +639,7 @@ for target in $targets ; do openwrt_target=$(get_target_from_config “./.config”) - create_gargoyle_banner “$openwrt_target” “$profile_name” “$build_date” “$short_gargoyle_version” “$gargoyle_git_revision” “$branch_name” “$rnum” “package/base-files/files/etc/banner” “.” + create_gargoyle_banner “$openwrt_target” “$profile_name” “$build_date” “$short_gargoyle_version” “$gargoyle_git_revision” “$branch_name” “$openwrt_abbrev_commit” “package/base-files/files/etc/banner” “.” echo “” @@ -674,8 +670,9 @@ for target in $targets ; do #copy packages to build/target directory mkdir -p “$top_dir/built/$target/$profile_name” arch=$(ls bin) - package_files=$(find bin -name “*.ipk”) - index_files=$(find bin -name “Packa*”) + package_base_dir=$(find bin -name “base”) + package_files=$(find “$package_base_dir” -name “*.ipk”) + index_files=$(find “$package_base_dir” -name “Packa*”) if [ -n “$package_files” ] && [ -n “$index_files” ] ; then for pf in $package_files ; do cp “$pf” “$top_dir/built/$target/$profile_name/” @@ -684,7 +681,10 @@ for target in $targets ; do cp “$inf” “$top_dir/built/$target/$profile_name/” done fi - + + + + if [ “$distribution” = “true” ] ; then mkdir -p “$top_dir/Distribution/Images/$target-$profile_name” fi @@ -719,3 +719,4 @@ for target in $targets ; do cd “$top_dir” done + — /dev/null +++ b/patches-generic/66-Fix-Kernel-Download.patch @@ -0,0 +1,13 @@ +— a/scripts/download.pl ++++ b/scripts/download.pl +@@ -165,8 +165,8 @@ foreach my $mirror (@ARGV) { + push @extra, “$extra[0]/longterm/v$1”; + } + foreach my $dir (@extra) { +- push @mirrors, “ftp://ftp.all.kernel.org/pub/$dir”; +- push @mirrors, “http://ftp.all.kernel.org/pub/$dir”; ++ push @mirrors, “https://cdn.kernel.org/pub/$dir”; ++ push @mirrors, “https://www.kernel.org/pub/$dir”; + } + } elsif ($mirror =~ /^\@GNOME\/(.+)$/) { + push @mirrors, “http://ftp.gnome.org/pub/GNOME/sources/$1”; </code> The same patch should work for earlier versions including 1.6.2 with some modifications

developer_documentation.1540449158.txt.gz · Last modified: 2018/10/25 06:32 by ispyisail