@@ -15,9 +15,10 @@ import (
1515const epochPattern = `epoch: %d`
1616
1717type bumpOptions struct {
18- repoDir string
19- epoch bool
20- dryRun bool
18+ repoDir string
19+ epoch bool
20+ dryRun bool
21+ increment bool
2122}
2223
2324// this feels very hacky but the Makefile is going away with help from Dag so plan to delete this func soon
@@ -72,6 +73,14 @@ the version in each matching configuration file:
7273 wolfictl bump openssl
7374 wolfictl bump lib*.yaml
7475
76+ wolfictl bump can take a filename, a package or a file glob,
77+ and extra flag increment set to false , decreasing the version in each
78+ matching configuration file:
79+
80+ wolfictl bump --increment=false zlib.yaml
81+ wolfictl bump --increment=false openssl
82+ wolfictl bump --increment=false lib*.yaml
83+
7584The command assumes it is being run from the top of the wolfi/os
7685repository. To look for files in another location use the --repo flag.
7786You can use --dry-run to see which versions will be bumped without
@@ -120,6 +129,7 @@ modifying anything in the filesystem.
120129 cmd .Flags ().BoolVar (& opts .epoch , "epoch" , true , "bump the package epoch" )
121130 cmd .Flags ().BoolVar (& opts .dryRun , "dry-run" , false , "don't change anything, just print what would be done" )
122131 cmd .Flags ().StringVar (& opts .repoDir , "repo" , "." , "path to the wolfi/os repository" )
132+ cmd .Flags ().BoolVar (& opts .increment , "increment" , true , "increments/decrements the package epoch" )
123133
124134 return cmd
125135}
@@ -130,9 +140,14 @@ func bumpEpoch(ctx context.Context, opts bumpOptions, path string) error {
130140 return fmt .Errorf ("unable to parse configuration at %q: %w" , path , err )
131141 }
132142
143+ newEpoch := cfg .Package .Epoch + 1
144+ if ! opts .increment {
145+ newEpoch = cfg .Package .Epoch - 1
146+ }
147+
133148 fmt .Fprintf (
134149 os .Stderr , "bumping %s-%s-%d in %s to epoch %d\n " , cfg .Package .Name ,
135- cfg .Package .Version , cfg .Package .Epoch , path , cfg . Package . Epoch + 1 ,
150+ cfg .Package .Version , cfg .Package .Epoch , path , newEpoch ,
136151 )
137152
138153 if opts .dryRun {
@@ -154,7 +169,7 @@ func bumpEpoch(ctx context.Context, opts bumpOptions, path string) error {
154169 found = true
155170 newFile = append (
156171 newFile , strings .ReplaceAll (
157- scanner .Text (), old , fmt .Sprintf (epochPattern , cfg . Package . Epoch + 1 ),
172+ scanner .Text (), old , fmt .Sprintf (epochPattern , newEpoch ),
158173 ),
159174 )
160175 } else {
@@ -173,7 +188,7 @@ func bumpEpoch(ctx context.Context, opts bumpOptions, path string) error {
173188 return fmt .Errorf ("writing %s: %w" , path , err )
174189 }
175190
176- if err := updateMakefile (opts .repoDir , cfg .Package .Name , cfg .Package .Version , cfg . Package . Epoch + 1 ); err != nil {
191+ if err := updateMakefile (opts .repoDir , cfg .Package .Name , cfg .Package .Version , newEpoch ); err != nil {
177192 return fmt .Errorf ("updating makefile: %w" , err )
178193 }
179194
0 commit comments