|
| 1 | +# sysgit - git based debian provisioning toolkit |
| 2 | + |
| 3 | +Let's manage and deploy debian systems with the help of a system-wide |
| 4 | +git repository. |
| 5 | + |
| 6 | +sysgit provides some helpfull commands and git hooks for this task. |
| 7 | + |
| 8 | +## Initialize |
| 9 | + |
| 10 | +### System variants: |
| 11 | + |
| 12 | +We provide some basic system variants: |
| 13 | + |
| 14 | +* **base** - Just the init script and the git hooks |
| 15 | +* **minimal** - Base system with sysgit repository as submodule |
| 16 | +* **full** - Anything helpfull |
| 17 | + |
| 18 | +### Initialize from an empty repository |
| 19 | + |
| 20 | +First, init the system-wide git repo: |
| 21 | +``` |
| 22 | +git init / |
| 23 | +``` |
| 24 | + |
| 25 | +Merge our system variant into it. Choose a variant, see above. |
| 26 | +``` |
| 27 | +cd / |
| 28 | +git remote add upstream https://github.com/simonwalz/sysgit-variants.git |
| 29 | +git fetch upstream |
| 30 | +# git merge upstream/<VARIANT> |
| 31 | +# i.e. |
| 32 | +git merge upstream/minimal |
| 33 | +``` |
| 34 | + |
| 35 | +And run the init script. This installs the git hooks and initialize the submodules: |
| 36 | +```sh |
| 37 | +/.sysgit/init.sh |
| 38 | +``` |
| 39 | + |
| 40 | + |
| 41 | +(optional) Add your remote: |
| 42 | +``` |
| 43 | +git remote add origin GIT_URL |
| 44 | +git checkout -b master --track origin/master |
| 45 | +git push |
| 46 | +``` |
| 47 | + |
| 48 | + |
| 49 | +### Initialize from existing repository |
| 50 | + |
| 51 | +First, init the system-wide git repo: |
| 52 | +```sh |
| 53 | +git init . |
| 54 | +``` |
| 55 | + |
| 56 | +Add your remote: |
| 57 | +```sh |
| 58 | +git remote add origin GIT_URL |
| 59 | +git checkout -b master --track origin/master |
| 60 | +``` |
| 61 | + |
| 62 | +Use either: |
| 63 | +```sh |
| 64 | +git reset --mixed origin/master |
| 65 | +# or |
| 66 | +git reset --hard origin/master |
| 67 | +``` |
| 68 | +to restore your files. `--mixed` only write non-existing files. `--hard` overwrites all files. |
| 69 | + |
| 70 | + |
| 71 | +And run the init script: |
| 72 | +```sh |
| 73 | +/.sysgit/init.sh |
| 74 | +``` |
| 75 | + |
| 76 | +### Port an other system-wide git not managed via sysgit: |
| 77 | + |
| 78 | +The git merge command fails if we try to merge an other repo. |
| 79 | + |
| 80 | +Thus use the commands in "Initialize from an empty repository" and |
| 81 | + use the following commands to rebase your existing commits: |
| 82 | + |
| 83 | +```sh |
| 84 | +git remote add old GIT_URL |
| 85 | +git fetch old |
| 86 | +# git rebase --onto upstream/<VARIANT> --root old/master |
| 87 | +# i.e. |
| 88 | +git rebase --onto upstream/minimal --root old/master |
| 89 | + |
| 90 | +# force push: |
| 91 | +git push -f |
| 92 | +``` |
| 93 | + |
| 94 | +Or cherry-pick the commits you what. |
| 95 | + |
| 96 | +## Working |
| 97 | + |
| 98 | +The following tools are automatically installed in **minimal** and **full** variants via a submodule and linked into path (by `/.sysgit/init.sh`). You can use these tools without the system variants; you only need to add all executables to the path. |
| 99 | + |
| 100 | +### Use git |
| 101 | + |
| 102 | +See [git documentation](https://git-scm.com/docs/). Use `git add FILE`, `git commit -m "Message"` and `git push`. |
| 103 | + |
| 104 | +### Command: `git sys-status` |
| 105 | + |
| 106 | +Show git status WITHOUT unchanged debian system-files. |
| 107 | + |
| 108 | +Usage: See [git status](https://git-scm.com/docs/git-status). |
| 109 | + |
| 110 | +This tool runs `git sys-ignore --update` before showing the status. |
| 111 | + |
| 112 | +### Command: `git sys-ignore-gen` (internal use) |
| 113 | + |
| 114 | +Update the git exclude file (`/.git/info/exclude`). |
| 115 | +This is automatically executed before showing `git sys-status`. |
| 116 | + |
| 117 | +### Command: `git sys-ignore` |
| 118 | + |
| 119 | +Configure which files shall be ignored. |
| 120 | + |
| 121 | +#### Usage: List pattern: |
| 122 | + |
| 123 | +```sh |
| 124 | +git sys-ignore |
| 125 | +``` |
| 126 | + |
| 127 | +#### Usage: Add pattern: |
| 128 | +```sh |
| 129 | +git sys-ignore PATTERN |
| 130 | +``` |
| 131 | + |
| 132 | +#### Example: |
| 133 | +```sh |
| 134 | +git sys-ignore 110 120 130 |
| 135 | +``` |
| 136 | + |
| 137 | +To remove a pattern, edit /etc/sysgit/ignore-config |
| 138 | + |
| 139 | + |
| 140 | +### Command: `git sys-ignore-untracked` |
| 141 | + |
| 142 | +Index all untracked files. If you change one of these files, it will |
| 143 | +show up in `git sys-status`. |
| 144 | + |
| 145 | +The index is saved to `/etc/sysgit/local-config.ignore-chk` |
| 146 | + |
| 147 | +### Command: `git sys-diff` |
| 148 | + |
| 149 | +Show differences of a file to version of the debian package: |
| 150 | + |
| 151 | +#### Usage: |
| 152 | +```sh |
| 153 | +git sys-diff debian-system-file |
| 154 | +``` |
| 155 | + |
| 156 | + |
| 157 | +### Command: `git sys-update`: update variant |
| 158 | + |
| 159 | +Get commits from one (or multiple) foreign repository (of remote `upstream`): |
| 160 | + |
| 161 | +```sh |
| 162 | +git sys-update [<VARIANT> [<VARIANT2> ...]] |
| 163 | +``` |
| 164 | +
|
| 165 | +Example |
| 166 | +```sh |
| 167 | +git sys-update minimal ansible |
| 168 | +``` |
| 169 | +
|
| 170 | +You can obmit the variant parameters if you saved it in the past with |
| 171 | +```sh |
| 172 | +git sys-update --save <VARIANT> [<VARIANT2> ...] |
| 173 | +``` |
| 174 | +
|
| 175 | +
|
| 176 | +Background: The command executes the following git commands: |
| 177 | +```sh |
| 178 | +cd / |
| 179 | +git fetch upstream |
| 180 | +git merge upstream/<VARIANT> |
| 181 | +``` |
| 182 | +
|
0 commit comments