├── ChangeLog ├── README.md ├── bin └── eclasses.usage ├── repo.postsync.d ├── 10-chperm ├── 20-git-repack ├── 20-git-repack-repo ├── 40-fetch-cache ├── 50-egencache ├── 60-glsa ├── 60-news ├── 70-dtd ├── 70-projects-xml ├── 70-xml-schema ├── 90-chperm ├── README └── portage-postsyncd-mv.sh └── zsh └── _eclasses.usage /ChangeLog: -------------------------------------------------------------------------------- 1 | # ChangeLog for portage-postsyncd-mv 2 | 3 | *portage-postsyncd-mv-8.4: 4 | Martin Väth : 5 | - Add SPDX-License-Identifier 6 | 7 | *portage-postsyncd-mv-8.3: 8 | Martin Väth : 9 | - Remove support for portage-utils (q-reinit) 10 | 11 | *portage-postsyncd-mv-8.2: 12 | Martin Väth : 13 | - Work with >=portage-utils-0.80_pre20190605 14 | 15 | *portage-postsyncd-mv-8.1: 16 | Martin Väth : 17 | - Avoid git gc --agressive. Use instead: 18 | - git repack -f -a -d --window=250 --depth=250 19 | https://metalinguist.wordpress.com/2007/12/06/the-woes-of-git-gc-aggressive-and-how-git-deltas-work 20 | 21 | *portage-postsyncd-mv-8.0: 22 | Martin Väth : 23 | - Support different permissions for */.git/hooks/* (default to 0755) 24 | 25 | *portage-postsyncd-mv-7.1: 26 | Martin Väth : 27 | - Assume existing .git indicates git syncing 28 | 29 | *portage-postsyncd-mv-7.0: 30 | Martin Väth : 31 | - Support gentoo-mirror via variable POSTSYNC_MIRROR 32 | - Change default: POSTSYNC_EGENCACHE="" 33 | 34 | *portage-postsyncd-mv-6.0.1: 35 | Martin Väth : 36 | - Treat 0 and - as false only if no symbol follows 37 | 38 | *portage-postsyncd-mv-6.0.0: 39 | Martin Väth : 40 | - Re-enumerate services 41 | - Set permissions also at the end 42 | - No default write permissions. Change default file permissions 43 | 44 | *portage-postsyncd-mv-5.3.0: 45 | Martin Väth : 46 | - Fix simultaneous setting of several permissions 47 | - More secure default dir permissions (sticky bit and group suid) 48 | 49 | *portage-postsyncd-mv-5.2.0: 50 | Martin Väth : 51 | - Introduce POSTSYNC_RSYNC_TIMEOUT and let it default to 20 52 | - Use modify-window=2 to deal with FAT filesystems 53 | 54 | *portage-postsyncd-mv-5.1.1: 55 | Martin Väth : 56 | - Introduce POSTSYNC_RSYNC_EXTRA_OPTS and let it default to -c 57 | 58 | *portage-postsyncd-mv-5.1.0: 59 | Martin Väth : 60 | - Skip cache fetching with rsync based on checksum 61 | 62 | *portage-postsyncd-mv-5.0.2: 63 | Martin Väth : 64 | - Replace "git status" by "git udpate-index --refresh -q --unmerged" 65 | which is the for us important part which "git status" does internally 66 | https://bugs.gentoo.org/show_bug.cgi?id=552814#c43 67 | 68 | *portage-postsyncd-mv-5.0.1: 69 | Martin Väth : 70 | - Use git reset --merge again, but preceed by git status: 71 | See https://bugs.gentoo.org/show_bug.cgi?id=552814#c38 72 | 73 | *portage-postsyncd-mv-5.0.0: 74 | Martin Väth : 75 | - Never attempt git merging; use always git reset --hard 76 | - Introduce *_RETRY_* and *_KEEP_* for git error handling and 77 | support for automatic directory removal 78 | 79 | *portage-postsyncd-mv-4.4.0: 80 | Martin Väth : 81 | - Flatten repository's directory structure 82 | - eclasses.usage: Handle VERSION workaround correctly 83 | 84 | *portage-postsyncd-mv-4.3.5: 85 | Martin Väth : 86 | - Fix git update failure (regression from 4.3.3) 87 | 88 | *portage-postsyncd-mv-4.3.4: 89 | Martin Väth : 90 | - Handle export Bourne shell compatible 91 | 92 | *portage-postsyncd-mv-4.3.3: 93 | Martin Väth : 94 | - Avoid git pull breakage with limited depth 95 | 96 | *portage-postsyncd-mv-4.3.2: 97 | Martin Väth : 98 | - Avoid LC_COLLATE problems 99 | 100 | *portage-postsyncd-mv-4.3.1: 101 | Martin Väth : 102 | - eclasses.usage: fix catdir->catfile 103 | 104 | *portage-postsyncd-mv-4.3.0: 105 | Martin Väth : 106 | - eclasses.usage: use File::Which if available 107 | 108 | *portage-postsyncd-mv-4.2.3: 109 | Martin Väth : 110 | - eclasses.usage: support "man" arg, force utf8 encoding 111 | - eclasses.usage: internal: Check require at compile time. Fix use 112 | 113 | *portage-postsyncd-mv-4.2.2: 114 | Martin Väth : 115 | - internal: Avoid unnecessary subshell 116 | 117 | *portage-postsyncd-mv-4.2.1: 118 | Martin Väth : 119 | - Output newline when fetching with rsync or wget 120 | 121 | *portage-postsyncd-mv-4.2.0: 122 | Martin Väth : 123 | - Change version scheme to match eclasses.usage perl versioning 124 | - Add zsh completion file for eclasses.usage 125 | - Add eclasses.usage --version -V 126 | - Add eclasses.usage --print-dir -D 127 | 128 | *portage-postsyncd-mv-4.01: 129 | Martin Väth : 130 | - IMPORTANT: When you upgrade from a previous version, remove 131 | $PORTDIR/local/timestamp/git-gc.date 132 | (where $PORTDIR is the path to your main repository) and all 133 | $REPO/.git/git-gc.date 134 | (where $REPO is the path to your local overlays/repositories) 135 | - IMPORTANT: There are renames of configuration variables: 136 | POSTSYNC_DAYS_GIT_GC_REPO -> POSTSYNC_DAYS_GIT_REPACK_REPO 137 | POSTSYNC_DAYS_GIT_GC -> POSTSYNC_DAYS_GIT_REPACK 138 | - IMPORTANT: It might be necessary to remove your previous repositories 139 | and to refetch them: Pruning did remove from some repositories way 140 | too much history. In particular, this was the case for the main 141 | gentoo repository 142 | - Rename 20-git-gc -> 20-git-repack 143 | - Rename 20-git-gc-repo -> 20-git-repack-repo 144 | - Add ChangeLog 145 | 146 | *portage-postsyncd-mv-3.06: 147 | Martin Väth : 148 | - Introduce init_vars 149 | 150 | *portage-postsyncd-mv-3.05: 151 | Martin Väth : 152 | - Remove POSTSYNC_CHPERM_QUIET; use EINFO_VERBOSE instead 153 | - Minor output changes 154 | 155 | *portage-postsyncd-mv-3.04: 156 | Martin Väth : 157 | - Do not suppress error message of eclasses.usage 158 | 159 | *portage-postsyncd-mv-3.03: 160 | Martin Väth : 161 | - Provide eclasses.usage and support POSTSYNC_ECLASSES_MIN 162 | 163 | *portage-postsyncd-mv-3.02: 164 | Martin Väth : 165 | - No newline at beginning of chperm 166 | 167 | *portage-postsyncd-mv-3.01: 168 | Martin Väth : 169 | - IMPORTANT: Change meaning of POSTSYNC_REPO_USER 170 | This is now a list 171 | - Support POSTSYNC_CHPERM 172 | 173 | *portage-postsyncd-mv-2.12: 174 | Martin Väth : 175 | - Support POSTSYNC_DAYS_FETCH_CACHE 176 | 177 | *portage-postsyncd-mv-2.11: 178 | Martin Väth : 179 | - Be verbose in reasons for fetching metadata 180 | 181 | *portage-postsyncd-mv-2.10: 182 | Martin Väth : 183 | - Add POSTSYNC_COMPARE_LIST 184 | 185 | *portage-postsyncd-mv-2.09: 186 | Martin Väth : 187 | - Fix typo in --update-changelogs 188 | 189 | *portage-postsyncd-mv-2.08: 190 | Martin Väth : 191 | - Improve POSTSYNC_EGENCACHE* defaults 192 | - Cosmetics in hack file 193 | 194 | *portage-postsyncd-mv-2.07: 195 | Martin Väth : 196 | - Replace EPREFIX by PORTAGE_CONFIGROOT 197 | 198 | *portage-postsyncd-mv-2.06: 199 | Martin Väth : 200 | - Improve yesno() 201 | - Add hack for app-portage/portage-utils 202 | 203 | *portage-postsyncd-mv-2.05: 204 | Martin Väth : 205 | - Improve POSTSYNC_EGENCACHE documentation 206 | 207 | *portage-postsyncd-mv-2.04: 208 | Martin Väth : 209 | - Treat empty POSTSYNC_DAYS_GIT_GC_REPO match correctly 210 | 211 | *portage-postsyncd-mv-2.03: 212 | Martin Väth : 213 | - Fix POSTSYNC_FUNCTIONS default 214 | 215 | *portage-postsyncd-mv-2.02: 216 | Martin Väth : 217 | - Support POSTSYNC_DAYS_GIT_GC_REPO 218 | - Move function file to repo.postsync.d 219 | 220 | *portage-postsyncd-mv-2.01: 221 | Martin Väth : 222 | - Introduce git-gc-other 223 | - Improve output 224 | - Fix HOME 225 | - New ** defaults 226 | 227 | *portage-postsyncd-mv-2.00: 228 | Martin Väth : 229 | - IMPORTANT: When you upgrade from a previous version, remove 230 | $PORTDIR/{metadata/{dtd,glsa,news,xml-schema},/local/timestamps} 231 | (where $PORTDIR is the path to your main repository) 232 | - Fix timestamp handling 233 | - Fix downloads 234 | 235 | *portage-postsyncd-mv-1.02: 236 | Martin Väth : 237 | - Check for git, not for parent directory 238 | 239 | *portage-postsyncd-mv-1.01: 240 | Martin Väth : 241 | - Sync xml-schema 242 | - improve order 243 | 244 | *portage-postsyncd-mv-1.00: 245 | Martin Väth : 246 | - Remove POSTSYNC_FUNCTIONS_SH interface 247 | - Improve output 248 | 249 | *portage-postsyncd-mv-0.02: 250 | Martin Väth : 251 | - Some Bourne Shell compatibility 252 | 253 | *portage-postsyncd-mv-0.01: 254 | Martin Väth : 255 | - Initial version 256 | 257 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # portage-postsyncd-mv 2 | 3 | postsync hooks for portage to sync from git 4 | 5 | (C) Martin Väth (martin at mvath.de). 6 | 7 | This project is under the GPL-2 license 8 | SPDX-License-Identifier: GPL-2.0-only 9 | 10 | This project provides several files which can be used for syncing with 11 | portage via git or github. 12 | 13 | The problem when syncing via git is that several files like the metadata cache, 14 | the news announcements, the GLSAs, dtd, xml-schema, and project.xml files 15 | are not modified and must be updated/fetched independently. 16 | 17 | This project is loosely inspired by 18 | - https://github.com/hasufell/portage-gentoo-git-config 19 | 20 | but it aims to be much more flexible and configurable. 21 | 22 | Moreover, it aims to be more secure, since root permissions are dropped 23 | as soon as possible. 24 | 25 | These scripts will work no matter whether you use git syncing or not: 26 | When you do not sync from git, a lot of tasks will be skipped, automatically. 27 | 28 | 29 | ## Installation 30 | 31 | Emerge the `app-portage/portage-postsyncd-mv` ebuild from the mv overlay. 32 | Alternatively, copy the content of `repo.postsync.d/` to 33 | `/etc/portage/repo.postsync.d/`, the content of `bin/` to your `$PATH` 34 | (perhaps `/usr/bin`). For __zsh completion__ support, copy the content of 35 | `zsh/` to your zsh's `$fpath` (perhaps `/usr/share/zsh/site-functions`). 36 | 37 | ## Configuration 38 | 39 | There are sane defaults, but if you need a nonstandard setting, 40 | you can configure a lot of details through `POSTSYNC_*` variables 41 | in your `/etc/portage/make.conf`. Read `repo.postsync.d/README` 42 | for the available variables and their default values. 43 | 44 | Of course, it is also possible to remove the executable bits of some 45 | files of this project in `/etc/portage/repo.postsync.d/*`. 46 | Then, of course, the corresponding functionality will be switched off. 47 | The project is written in such a way that this is not harmful. 48 | 49 | Except for setting permissions of your repositories and 50 | calling egencache for your non-main repositories, the scripts do nothing 51 | unless you configure your main repository to be fetched via git. 52 | The scripts recognize the latter by checking that the sync-uri 53 | of your `$POSTSYNC_MAIN_REPOSITORY` ends with `.git`. 54 | 55 | This project does intentionally not include some configuration file 56 | to force the latter, because it is up to the user whether he wants this. 57 | If you want it, you must set up `/etc/portage/repos.conf` correspondingly. 58 | For instance, you might have files with the content 59 | 60 | `/etc/portage/repos.conf/00-defaults.conf`: 61 | ``` 62 | [DEFAULT] 63 | main-repo = gentoo 64 | ``` 65 | `/etc/portage/repos.conf/50-defaults.conf`: 66 | ``` 67 | [gentoo] 68 | location = /usr/portage 69 | priority = 5000 70 | auto-sync = yes 71 | sync-type = git 72 | sync-depth = 0 73 | sync-uri = https://github.com/gentoo/gentoo.git 74 | ``` 75 | In this example, 76 | - `location` is the path to the main (gentoo) repository 77 | - `priority` determines the order of the main repository relative to the others 78 | - `auto-sync` means that `emerge --sync` will actually sync it 79 | - `sync-type` means that git will be used for syncing 80 | - `sync-depth` determines how long will be the history which you can see 81 | with git; the value 0 means full history. 82 | 83 | Specify `sync-depth = 1` if you are not interested in any `ChangeLogs`: 84 | This will need half of the disk space (or even less in some future). 85 | 86 | However, the scripts in this project will also regularly recompress your 87 | git history (with git repack) so that it needs less disk space. 88 | The latter takes some time, of course. As mentioned above, read 89 | `repo.postsync.d/README` to learn how to configure such details. 90 | 91 | These scripts make use of some timestamps. 92 | These are stored locally in the `$location/local/timestamps` directory 93 | (which is created if it does not exist). Here, `$location` is the path to 94 | the (main) repository. 95 | -------------------------------------------------------------------------------- /bin/eclasses.usage: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # SPDX-License-Identifier: GPL-2.0-only 3 | BEGIN { require 5.006_001 } 4 | package Eclasses; 5 | our $VERSION = 'v5.0.0'; 6 | eval { $VERSION = version->declare($VERSION) }; 7 | eval 'use version 0.77; $VERSION = version->declare($VERSION)' if($@); 8 | 9 | use warnings; 10 | use strict; 11 | use integer; 12 | use File::Find (); 13 | use File::Spec (); 14 | use Getopt::Long 2.24 (); 15 | #use Pod::Usage (); # needed for --man, --help, some errors 16 | #use String::ShellQuote (); # not mandatory but recommended: poor fallback 17 | #use File::Which (); # not mandatory but recommended; there are fallbacks 18 | 19 | my $name = 'eclasses.usage'; 20 | 21 | =encoding UTF-8 22 | 23 | =head1 NAME 24 | 25 | eclasses.usage - Print how often eclasses are used in a certain repository 26 | 27 | The output is in decreasing order of usage (alphabetically for same usage) 28 | 29 | =head1 SYNOPSIS 30 | 31 | B [options] [man|help] 32 | 33 | For an extended help type B 34 | 35 | =head1 OPTIONS AND ARGUMENTS 36 | 37 | =over 8 38 | 39 | =item B<--help> or B<-h> or B 40 | 41 | Display brief help 42 | 43 | =item B<--man> or B<-?> or B 44 | 45 | Display extended help as a manpage 46 | 47 | =item B<--version> or B<-V> 48 | 49 | Print version number 50 | 51 | =item B<--minimal=>I or B<-m> I 52 | 53 | Print only eclasses which are used at least I times 54 | 55 | =item B<--dir=>I or B<-d> I 56 | 57 | Specify the root of the repository. 58 | If not specified or empty, I is guessed by heuristics, using B 59 | (if available) B (if set), B and 60 | B (if set) 61 | 62 | =item B<--print-dir> or B<-D> 63 | 64 | Print the directory used for B<--dir> to stdout (without a newline) and exit 65 | 66 | =item B<--only-names> or B<-o> 67 | 68 | Output only the names of the used eclasses, not their usage number 69 | 70 | =item B<--first> or B<-1> 71 | 72 | Output only the first match 73 | 74 | =item B<--time=>I